Class: ONVIF::MediaAction::GetStreamUri
- Defined in:
- lib/ruby_onvif_client/media/get_stream_uri.rb
Instance Method Summary collapse
-
#run(options, cb) ⇒ Object
options 的结构 { stream_setup: { stream: ‘RTP-Unicast’, //‘RTP-Unicast’, ‘RTP-Multicast’ transport: { protocol: ‘UDP’, //‘UDP’, ‘TCP’, ‘RTSP’, ‘HTTP’ tunnel:{ protocol: ‘TCP’, //‘UDP’, ‘TCP’, ‘RTSP’, ‘HTTP’ } } } profile_token: “xxxxxxx” // [ReferenceToken] }.
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
#run(options, cb) ⇒ Object
options 的结构 {
stream_setup: {
stream: 'RTP-Unicast', //'RTP-Unicast', 'RTP-Multicast'
transport: {
protocol: 'UDP', //'UDP', 'TCP', 'RTSP', 'HTTP'
tunnel:{
protocol: 'TCP', //'UDP', 'TCP', 'RTSP', 'HTTP'
}
}
}
profile_token: "xxxxxxx" // [ReferenceToken]
}
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 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ruby_onvif_client/media/get_stream_uri.rb', line 19 def run , cb = namespaces: {:'xmlns:sch' => 'http://www.onvif.org/ver10/schema'} .body = ->(xml) do xml.wsdl(:GetStreamUri) do xml.wsdl(:StreamSetup) do xml.sch :Stream, [:stream_setup][:stream] xml.sch :Transport do xml.sch :Protocol, [:stream_setup][:transport][:protocol] xml.sch :Tunnel do tunnel = [:stream_setup][:transport][:tunnel] unless tunnel.nil? xml.sch :Protocol,[:stream_setup][:transport][:tunnel][:protocol] xml.sch :Tunnel,[:stream_setup][:transport][:tunnel][:tunnel] end end end end xml.wsdl :ProfileToken, [:profile_token] end end do |success, result| if success xml_doc = Nokogiri::XML(result[:content]) media_uri = { media_uri: { uri: value(xml_doc, '//tt:Uri'), invalid_after_connect: value(xml_doc, '//tt:InvalidAfterConnect'), invalid_after_reboot: value(xml_doc, '//tt:InvalidAfterReboot'), timeout: value(xml_doc, '//tt:Timeout') } } callback cb, success, media_uri else callback cb, success, result end end end |