Class: ONVIF::MediaAction::GetProfiles
- Defined in:
- lib/ruby_onvif_client/media/get_profiles.rb
Instance Method Summary collapse
- #_get_audio_encoder_configuration(parent_node) ⇒ Object
- #_get_audio_source_configuration(parent_node) ⇒ Object
- #_get_metadata_configuration(parent_node) ⇒ Object
- #_get_min_max(xml_doc, parent_name) ⇒ Object
- #_get_multicast(parent_node) ⇒ Object
- #_get_name(parent_node) ⇒ Object
- #_get_node(parent_node, node_name) ⇒ Object
- #_get_parameters(parent_node) ⇒ Object
- #_get_ptz_configuration(parent_node) ⇒ Object
- #_get_public_sector(parent_node) ⇒ Object
- #_get_token(parent_node) ⇒ Object
- #_get_use_count(parent_node) ⇒ Object
- #_get_video_analytics_configuration(parent_node) ⇒ Object
- #_get_video_encoder_configuration(parent_node) ⇒ Object
- #_get_video_source_configuration(parent_node) ⇒ Object
- #run(cb) ⇒ Object
Methods inherited from Action
#attribute, #callback, #create_event_onvif_message, #create_media_onvif_message, #create_ptz_onvif_message, #initialize, #send_message, #value
Constructor Details
This class inherits a constructor from ONVIF::Action
Instance Method Details
#_get_audio_encoder_configuration(parent_node) ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 124 def _get_audio_encoder_configuration parent_node configuration = _get_public_sector(parent_node) configuration[:encoding] = value(parent_node, "tt:Encoding") configuration[:bitrate] = value(parent_node, "tt:Bitrate") configuration[:sample_rate] = value(parent_node, "tt:SampleRate") configuration[:multicast] = _get_multicast(parent_node) configuration[:session_timeout] = value(parent_node, "tt:SessionTimeout") return configuration end |
#_get_audio_source_configuration(parent_node) ⇒ Object
88 89 90 91 92 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 88 def _get_audio_source_configuration parent_node configuration = _get_public_sector(parent_node) configuration[:source_token] = value(parent_node, "tt:SourceToken") return configuration end |
#_get_metadata_configuration(parent_node) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 202 def parent_node configuration = _get_public_sector(parent_node) configuration[:ptz_status] = { status: value(_get_node(parent_node, "tt:PTZStatus"), "tt:Status"), sosition: value(_get_node(parent_node, "tt:PTZStatus"), "tt:Position") } configuration[:events] = { filter: value(_get_node(parent_node, "tt:Events"), "tt:Filter"), subscription_policy: value(_get_node(parent_node, "tt:Events"), "tt:SubscriptionPolicy") } configuration[:analytics] = value(parent_node, "tt:Analytics") configuration[:multicast] = _get_multicast(parent_node) configuration[:session_timeout] = value(parent_node, "tt:SessionTimeout") unless parent_node.at_xpath("tt:AnalyticsEngineConfiguration//tt:AnalyticsModule").nil? analytics_module = [] parent_node.at_xpath("tt:AnalyticsEngineConfiguration//tt:AnalyticsModule").each do |node| analytics_module << { name: attribute(node, "Name"), type: attribute(node, "Type"), parameters: _get_parameters(node) } end configuration[:analytics_engine_configuration] = { analytics_module: analytics_module, extension: "" } end configuration[:extension] = "" return configuration end |
#_get_min_max(xml_doc, parent_name) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 57 def _get_min_max xml_doc, parent_name this_node = xml_doc unless parent_name.nil? this_node = xml_doc.at_xpath(parent_name) end return { min: value(this_node, "tt:Min"), max: value(this_node, "tt:Max") } end |
#_get_multicast(parent_node) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 233 def _get_multicast parent_node { address: { type: value(_get_node(parent_node, "//tt:Multicast//tt:Address"), '//tt:Type'), ipv4_address: value(_get_node(parent_node, "//tt:Multicast//tt:Address"), '//tt:IPv4Address'), ipv6_address: value(_get_node(parent_node, "//tt:Multicast//tt:Address"), '//tt:IPv6Address') }, port: value(_get_node(parent_node, "//tt:Multicast"), "tt:Port"), ttl: value(_get_node(parent_node, "//tt:Multicast"), "tt:TTL"), auto_start: value(_get_node(parent_node, "//tt:Multicast"), "tt:AutoStart") } end |
#_get_name(parent_node) ⇒ Object
48 49 50 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 48 def _get_name parent_node value(parent_node, "tt:Name") end |
#_get_node(parent_node, node_name) ⇒ Object
45 46 47 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 45 def _get_node parent_node, node_name parent_node.at_xpath(node_name) end |
#_get_parameters(parent_node) ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 246 def _get_parameters parent_node simple_item = [] element_item = [] parent_node.at_xpath("tt:SimpleItem").each do |node| simple_item << { name: attribute(node, "Name"), value: attribute(node, "Value") } end parent_node.at_xpath("tt:ElementItem").each do |node| element_item << { xsd_any: value(node, "tt:xsd:any"), name: attribute(node, "Name") } end return { simple_item: simple_item, element_item: element_item, extension: "" } end |
#_get_ptz_configuration(parent_node) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 162 def _get_ptz_configuration parent_node configuration = _get_public_sector(parent_node) configuration[:node_token] = value(parent_node, "tt:NodeToken") configuration[:default_absolute_pant_tilt_position_space] = value(parent_node, "tt:DefaultAbsolutePantTiltPositionSpace") configuration[:default_absolute_zoom_position_space] = value(parent_node, "tt:DefaultAbsoluteZoomPositionSpace") configuration[:default_relative_pan_tilt_translation_space] = value(parent_node, "tt:DefaultRelativePanTiltTranslationSpace") configuration[:default_relative_zoom_translation_space] = value(parent_node, "tt:DefaultRelativeZoomTranslationSpace") configuration[:default_continuous_pan_tilt_velocity_space] = value(parent_node, "tt:DefaultContinuousPanTiltVelocitySpace") configuration[:default_continuous_zoom_velocity_space] = value(parent_node, "tt:DefaultContinuousZoomVelocitySpace") pan_tilt = _get_node(parent_node,"//tt:DefaultPTZSpeed//tt:PanTilt") zoom = _get_node(parent_node,"//tt:DefaultPTZSpeed//tt:Zoom") configuration[:default_ptz_speed] = { pan_tilt:{ x: attribute(pan_tilt, "x"), y: attribute(pan_tilt, "y"), space: attribute(pan_tilt, "space") }, zoom: { x: attribute(zoom, "x"), space: attribute(zoom, "space") } } configuration[:fefault_ptz_timeout] = value(parent_node, "tt:DefaultPTZTimeout") configuration[:pan_tilt_limits] = { range: { uri: value(_get_node(parent_node, "tt:PanTiltLimits//tt:Range"), "tt:URI"), x_range: _get_min_max(_get_node(parent_node,"tt:PanTiltLimits//tt:Range"), "tt:XRange"), y_range: _get_min_max(_get_node(parent_node,"tt:PanTiltLimits//tt:Range"), "tt:YRange") } } configuration[:zoom_limits] = { range: { uri: value(_get_node(parent_node, "tt:PanTiltLimits//tt:Range"), "tt:URI"), x_range: _get_min_max(_get_node(parent_node,"tt:PanTiltLimits//tt:Range"), "tt:XRange"), } } configuration[:extension] = "" return configuration end |
#_get_public_sector(parent_node) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 67 def _get_public_sector parent_node { name: _get_name(parent_node), token: _get_token(parent_node), use_count: _get_use_count(parent_node) } end |
#_get_token(parent_node) ⇒ Object
54 55 56 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 54 def _get_token parent_node attribute(parent_node, "token") end |
#_get_use_count(parent_node) ⇒ Object
51 52 53 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 51 def _get_use_count parent_node value(parent_node, "tt:UseCount") end |
#_get_video_analytics_configuration(parent_node) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 134 def _get_video_analytics_configuration parent_node configuration = _get_public_sector(parent_node) analytics_module = []; rule = [] parent_node.at_xpath("tt:AnalyticsEngineConfiguration//tt:AnalyticsModule").each do |node| analytics_module << { name: attribute(node, "Name"), type: attribute(node, "Type"), parameters: _get_parameters(node) } end parent_node.at_xpath("tt:AnalyticsEngineConfiguration//tt:RuleEngineConfiguration").each do |node| rule << { name: attribute(node, "Name"), type: attribute(node, "Type"), parameters: _get_parameters(node) } end configuration[:analytics_engine_configuration] = { analytics_module: analytics_module, extension: "" } configuration[:rule_engine_configuration] = { rule: rule, extension: "" } return configuration end |
#_get_video_encoder_configuration(parent_node) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 94 def _get_video_encoder_configuration parent_node configuration = _get_public_sector(parent_node) configuration[:encoding] = value(parent_node, "tt:Encoding") configuration[:resolution] = { width: value(_get_node(parent_node, "tt:Resolution"), "tt:Width"), height: value(_get_node(parent_node, "tt:Resolution"), "tt:Height") } configuration[:quality] = value(parent_node, "tt:Quality") configuration[:rate_control] = { frame_rate_limit: value(_get_node(parent_node, "tt:RateControl"), "tt:FrameRateLimit"), encoding_interval: value(_get_node(parent_node, "tt:RateControl"), "tt:EncodingInterval"), bitrate_limit: value(_get_node(parent_node, "tt:RateControl"), "tt:BitrateLimit") } unless parent_node.at_xpath('//tt:MPEG4').nil? configuration[:MPEG4] = { gov_length: value(_get_node(parent_node, "tt:MPEG4"), "tt:GovLength"), mpeg4_profile: value(_get_node(parent_node, "tt:MPEG4"), "tt:Mpeg4Profile") } end unless parent_node.at_xpath('//tt:H264').nil? configuration[:H264] = { gov_length: value(_get_node(parent_node, "tt:H264"), "tt:GovLength"), h264_profile: value(_get_node(parent_node, "tt:H264"), "tt:H264Profile") } end configuration[:multicast] = _get_multicast(parent_node) configuration[:session_timeout] = value(parent_node, "tt:SessionTimeout") return configuration end |
#_get_video_source_configuration(parent_node) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 75 def _get_video_source_configuration parent_node configuration = _get_public_sector(parent_node) configuration[:source_token] = value(parent_node, "tt:SourceToken") bounds = parent_node.at_xpath("tt:Bounds") configuration[:bounds] = { x: attribute(bounds, "x"), y: attribute(bounds, "y"), width: attribute(bounds, "width"), height: attribute(bounds, "height") } return configuration end |
#run(cb) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_onvif_client/media/get_profiles.rb', line 6 def run cb = .body = ->(xml) do xml.wsdl(:GetProfiles) end do |success, result| if success xml_doc = Nokogiri::XML(result[:content]) profiles = [] xml_doc.xpath('//trt:Profiles').each do |root_node| video_source = root_node.at_xpath("tt:VideoSourceConfiguration") audio_source = root_node.at_xpath("tt:AudioSourceConfiguration") video_encoder = root_node.at_xpath("tt:VideoEncoderConfiguration") audio_encoder = root_node.at_xpath("tt:AudioEncoderConfiguration") video_analytics = root_node.at_xpath("tt:VideoAnalyticsConfiguration") ptz = root_node.at_xpath("tt:PTZConfiguration") = root_node.at_xpath("tt:MetadataConfiguration") success_result = { name: _get_name(root_node), token: _get_token(root_node), fixed: attribute(root_node, "fixed"), extension: "" } success_result[:video_source_configuration] = _get_video_source_configuration(video_source) unless video_source.nil? success_result[:audio_source_configuration] = _get_audio_source_configuration(audio_source) unless audio_source.nil? success_result[:video_encoder_configuration] = _get_video_encoder_configuration(video_encoder) unless video_encoder.nil? success_result[:audio_encoder_configuration] = _get_audio_encoder_configuration(audio_encoder) unless audio_encoder.nil? #success_result[:video_analytics_configuration] = _get_video_analytics_configuration(video_analytics) unless video_analytics.nil? #success_result[:ptz_configuration] = _get_ptz_configuration(ptz) unless ptz.nil? success_result[:metadata_configuration] = () unless .nil? profiles << success_result end callback cb, success, profiles else callback cb, success, result end end end |