Class: ONVIF::MediaAction::GetVideoEncoderConfigurationOptions

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

Instance Method Summary collapse

Methods inherited from Action

#attribute, #callback, #initialize, #send_message, #value

Constructor Details

This class inherits a constructor from ONVIF::Action

Instance Method Details

#_get_each_val(xml_doc, parent_name) ⇒ Object



64
65
66
67
68
69
70
# File 'lib/ruby_onvif_client/media/get_video_encoder_configuration_options.rb', line 64

def _get_each_val xml_doc, parent_name
    result_val = []
    xml_doc.each do |node|
        result_val << _get_width_height(node, parent_name)
    end
    return result_val
end

#_get_min_max(xml_doc, parent_name) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'lib/ruby_onvif_client/media/get_video_encoder_configuration_options.rb', line 72

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_node(parent_node, node_name) ⇒ Object



60
61
62
# File 'lib/ruby_onvif_client/media/get_video_encoder_configuration_options.rb', line 60

def _get_node parent_node, node_name
    parent_node.at_xpath(node_name)
end

#_get_profiles_supported(xml_doc, parent_name) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/ruby_onvif_client/media/get_video_encoder_configuration_options.rb', line 52

def _get_profiles_supported xml_doc, parent_name
    this_node = xml_doc.at_xpath(parent_name)
    result_val = []
    this_node.each do |node|
        result_val << node.content
    end
    return result_val
end

#_get_width_height(xml_doc, parent_name) ⇒ Object



83
84
85
86
87
88
89
90
91
92
# File 'lib/ruby_onvif_client/media/get_video_encoder_configuration_options.rb', line 83

def _get_width_height xml_doc, parent_name
    this_node = xml_doc
    unless parent_name.nil?
        this_node = xml_doc.at_xpath(parent_name)
    end
    return {
        width: value(this_node, "tt:Width"),
        height: value(this_node, "tt:Height")
    }
end

#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
# File 'lib/ruby_onvif_client/media/get_video_encoder_configuration_options.rb', line 11

def run options, cb
    message = Message.new
    message.body =  ->(xml) do
        xml.wsdl(:GetVideoEncoderConfigurationOptions) 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])
            options = {
                quality_range: _get_min_max(_get_node(xml_doc, "//tt:QualityRange")),
                jpeg: {
                    resolutions_available: _get_each_val(_get_node(xml_doc, "//tt:JPEG"), "//tt:ResolutionsAvailable"),
                    frame_rate_range: _get_min_max(_get_node(xml_doc, "//tt:JPEG"), "//tt:FrameRateRange"),
                    rncoding_interval_range: _get_min_max(_get_node(xml_doc, "//tt:JPEG"), "//tt:FrameRateRange")
                },
                mpeg4: {
                    resolutions_available: _get_each_val(_get_node(xml_doc, "//tt:MPEG4"), "//tt:ResolutionsAvailable"),
                    gov_length_range: _get_min_max(_get_node(xml_doc, "//tt:MPEG4"), "//tt:GovLengthRange"),
                    frame_rate_range: _get_min_max(_get_node(xml_doc, "//tt:MPEG4"), "//tt:FrameRateRange"),
                    rncoding_interval_range: _get_min_max(_get_node(xml_doc, "//tt:MPEG4"), "//tt:EncodingIntervalRange"),
                    mpeg4_profiles_supported: _get_profiles_supported(_get_node(xml_doc, "//tt:MPEG4"), "//tt:Mpeg4ProfilesSupported")
                },
                h264: {
                    resolutions_available: _get_each_val(_get_node(xml_doc, "//tt:h264"), "//tt:ResolutionsAvailable"),
                    gov_length_range: _get_min_max(_get_node(xml_doc, "//tt:h264"), "//tt:GovLengthRange"),
                    frame_rate_range: _get_min_max(_get_node(xml_doc, "//tt:h264"), "//tt:FrameRateRange"),
                    rncoding_interval_range: _get_min_max(_get_node(xml_doc, "//tt:h264"), "//tt:EncodingIntervalRange"),
                    h264_profiles_supported: _get_profiles_supported(_get_node(xml_doc, "//tt:h264"), "//tt:H264ProfilesSupported")
                },
                extension: ""
            }
            
            callback cb, success, options
        else
            callback cb, success, result
        end
    end
end