Class: ONVIF::MediaAction::GetAudioEncoderConfigurationOptions

Inherits:
Action
  • Object
show all
Defined in:
lib/ruby_onvif_client/media/get_audio_encoder_configuration_options.rb

Instance Method Summary collapse

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 的结构

c_token: "xxxxxxx",  //[ReferenceToken] Optional audio encoder configuration token that specifies an existing configuration that the options are intended for.
p_token: "xxxxxxx"  //[ReferenceToken]  Optional ProfileToken that specifies an existing media profile that the options shall be compatible with.



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
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ruby_onvif_client/media/get_audio_encoder_configuration_options.rb', line 11

def run options, cb
    message = create_media_onvif_message
    message.body =  ->(xml) do
        xml.wsdl(:GetAudioEncoderConfigurationOptions) do
            xml.wsdl :ConfigurationToken, options[:c_token]
            xml.wsdl :ProfileToken, options[:p_token]
        end
    end
    send_message message do |success, result|
        if success
            xml_doc = Nokogiri::XML(result[:content])
            node_options = []
            xml_doc.xpath('//trt:Options//tt:Options').each do |node|
                this_options = {encoding: value(node, 'tt:Encoding')}
                bitrate = node.at_xpath("tt:BitrateList")
                unless bitrate.nil?
                    bitrate_list = []
                    node.xpath('tt:BitrateList//tt:Items').each do |item|
                        bitrate_list << {
                            items: item.content
                        }
                    end
                    this_options[:bitrate_list] = bitrate_list
                end
                sample_rate = node.at_xpath("tt:SampleRateList")
                unless sample_rate.nil?
                    sample_rate_list = []
                    node.xpath('tt:SampleRateList//tt:Items').each do |item|
                        sample_rate_list << {
                            items: item.content
                        }
                    end
                    this_options[:sample_rate_list] = sample_rate_list
                end


                node_options << this_options
            end
            callback cb, success, node_options
        else
            callback cb, success, result
        end
    end
end