diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml new file mode 100644 index 0000000..dd5946c --- /dev/null +++ b/.github/workflows/ci_tests.yml @@ -0,0 +1,47 @@ +name: CI Tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + + name: Build and test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Read .tool-versions + uses: marocchino/tool-versions-action@v1 + id: versions + + - name: Set up Elixir + uses: erlef/setup-beam@v1 + with: + otp-version: ${{ steps.versions.outputs.erlang }} + elixir-version: ${{ steps.versions.outputs.elixir }} + version-type: "strict" + + - name: Restore dependencies cache + uses: actions/cache@v4 + with: + path: deps + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: ${{ runner.os }}-mix- + + - name: Install dependencies + run: mix deps.get + + - name: Run tests + run: mix test diff --git a/lib/factory.ex b/lib/factory.ex new file mode 100644 index 0000000..50545b8 --- /dev/null +++ b/lib/factory.ex @@ -0,0 +1,88 @@ +defmodule Onvif.Factory do + def device do + %Onvif.Device{ + address: "http://192.168.254.89", + auth_type: :digest_auth, + device_service_path: "/onvif/device_service", + firmware_version: nil, + hardware_id: "V1.0", + manufacturer: "General", + media_ver10_service_path: "/onvif/media_service", + media_ver20_service_path: "/onvif/media2_service", + model: "N864A6", + ntp: "NTP", + password: "admin", + port: 80, + scopes: [ + "onvif://www.onvif.org/location/country/China", + "onvif://www.onvif.org/name/General", + "onvif://www.onvif.org/hardware/N864A6", + "onvif://www.onvif.org/Profile/Streaming", + "onvif://www.onvif.org/type/Network_Video_Transmitter", + "onvif://www.onvif.org/extension/unique_identifier/1", + "onvif://www.onvif.org/Profile/G", + "onvif://www.onvif.org/Profile/T" + ], + serial_number: "NV012306000836", + services: [ + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver10/replay/wsdl", + version: "17.06", + xaddr: "http://192.168.254.89/onvif/replay_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver10/search/wsdl", + version: "18.12", + xaddr: "http://192.168.254.89/onvif/search_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver10/recording/wsdl", + version: "18.06", + xaddr: "http://192.168.254.89/onvif/recording_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver10/deviceIO/wsdl", + version: "18.12", + xaddr: "http://192.168.254.89/onvif/deviceIO_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver10/events/wsdl", + version: "2.60", + xaddr: "http://192.168.254.89/onvif/event_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver20/ptz/wsdl", + version: "18.12", + xaddr: "http://192.168.254.89/onvif/ptz_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver20/media/wsdl", + version: "18.12", + xaddr: "http://192.168.254.89/onvif/media2_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver10/media/wsdl", + version: "18.06", + xaddr: "http://192.168.254.89/onvif/media_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver20/imaging/wsdl", + version: "18.12", + xaddr: "http://192.168.254.89/onvif/imaging_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver20/analytics/wsdl", + version: "18.12", + xaddr: "http://192.168.254.89/onvif/analytics_service" + }, + %Onvif.Device.Service{ + namespace: "http://www.onvif.org/ver10/device/wsdl", + version: "18.12", + xaddr: "http://192.168.254.89/onvif/device_service" + } + ], + time_diff_from_system_secs: 3597, + username: "admin" + } + end +end diff --git a/lib/media/ver10/profile/video_encoder_configuration.ex b/lib/media/ver10/profile/video_encoder_configuration.ex index ecc526e..79f2dbc 100644 --- a/lib/media/ver10/profile/video_encoder_configuration.ex +++ b/lib/media/ver10/profile/video_encoder_configuration.ex @@ -11,6 +11,8 @@ defmodule Onvif.Media.Ver10.Profile.VideoEncoderConfiguration do @primary_key false @derive Jason.Encoder + @required [:reference_token, :name, :encoding] + @optional [:use_count, :guaranteed_frame_rate, :quality, :session_timeout] embedded_schema do field(:reference_token, :string) field(:name, :string) @@ -57,23 +59,24 @@ defmodule Onvif.Media.Ver10.Profile.VideoEncoderConfiguration do def parse(doc) do xmap( doc, - reference_token: ~x"./@token"s, - name: ~x"./tt:Name/text()"s, - use_count: ~x"./tt:UseCount/text()"i, - guaranteed_frame_rate: ~x"./tt:GuaranteedFrameRate/text()"s, - encoding: ~x"./tt:Encoding/text()"s, - session_timeout: ~x"./tt:SessionTimeout/text()"s, - quality: ~x"./tt:Quality/text()"f, - resolution: ~x"./tt:Resolution"e |> transform_by(&parse_resolution/1), - rate_control: ~x"./tt:RateControl"e |> transform_by(&parse_rate_control/1), - mpeg4_configuration: ~x"./tt:Mpeg4"e |> transform_by(&parse_mpeg4_configuration/1), - h264_configuration: ~x"./tt:H264"e |> transform_by(&parse_h264_configuration/1), + reference_token: ~x"./@token"so, + name: ~x"./tt:Name/text()"so, + use_count: ~x"./tt:UseCount/text()"io, + guaranteed_frame_rate: ~x"./tt:GuaranteedFrameRate/text()"so, + encoding: ~x"./tt:Encoding/text()"so, + session_timeout: ~x"./tt:SessionTimeout/text()"so, + quality: ~x"./tt:Quality/text()"fo, + resolution: ~x"./tt:Resolution"eo |> transform_by(&parse_resolution/1), + rate_control: ~x"./tt:RateControl"eo |> transform_by(&parse_rate_control/1), + mpeg4_configuration: ~x"./tt:Mpeg4"eo |> transform_by(&parse_mpeg4_configuration/1), + h264_configuration: ~x"./tt:H264"eo |> transform_by(&parse_h264_configuration/1), multicast_configuration: - ~x"./tt:Multicast"e |> transform_by(&MulticastConfiguration.parse/1) + ~x"./tt:Multicast"eo |> transform_by(&MulticastConfiguration.parse/1) ) end defp parse_resolution([]), do: nil + defp parse_resolution(nil), do: nil defp parse_resolution(doc) do xmap( @@ -84,6 +87,7 @@ defmodule Onvif.Media.Ver10.Profile.VideoEncoderConfiguration do end defp parse_rate_control([]), do: nil + defp parse_rate_control(nil), do: nil defp parse_rate_control(doc) do xmap( @@ -136,15 +140,8 @@ defmodule Onvif.Media.Ver10.Profile.VideoEncoderConfiguration do def changeset(module, attrs) do module - |> cast(attrs, [ - :reference_token, - :name, - :use_count, - :guaranteed_frame_rate, - :encoding, - :quality, - :session_timeout - ]) + |> cast(attrs, @required ++ @optional) + |> validate_required(@required) |> cast_embed(:resolution, with: &resolution_changeset/2) |> cast_embed(:rate_control, with: &rate_control_changeset/2) |> cast_embed(:mpeg4_configuration, with: &mpeg4_configuration_changeset/2) diff --git a/mix.exs b/mix.exs index fb647eb..5a4f2cd 100644 --- a/mix.exs +++ b/mix.exs @@ -42,7 +42,8 @@ defmodule Onvif.MixProject do {:sweet_xml, "~> 0.7"}, {:tesla, "~> 1.7"}, {:xml_builder, "~> 2.1"}, - {:jason, "~> 1.4"} + {:jason, "~> 1.4"}, + {:mimic, "~> 1.7", only: :test} ] end end diff --git a/mix.lock b/mix.lock index 3e8fb09..d56e85f 100644 --- a/mix.lock +++ b/mix.lock @@ -11,6 +11,7 @@ "makeup_elixir": {:hex, :makeup_elixir, "0.16.0", "f8c570a0d33f8039513fbccaf7108c5d750f47d8defd44088371191b76492b0b", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "28b2cbdc13960a46ae9a8858c4bebdec3c9a6d7b4b9e7f4ed1502f8159f338e7"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, "mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"}, + "mimic": {:hex, :mimic, "1.7.4", "cd2772ffbc9edefe964bc668bfd4059487fa639a5b7f1cbdf4fd22946505aa4f", [:mix], [], "hexpm", "437c61041ecf8a7fae35763ce89859e4973bb0666e6ce76d75efc789204447c3"}, "mint": {:hex, :mint, "1.5.1", "8db5239e56738552d85af398798c80648db0e90f343c8469f6c6d8898944fb6f", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "4a63e1e76a7c3956abd2c72f370a0d0aecddc3976dea5c27eccbecfa5e7d5b1e"}, "nimble_options": {:hex, :nimble_options, "1.0.2", "92098a74df0072ff37d0c12ace58574d26880e522c22801437151a159392270e", [:mix], [], "hexpm", "fd12a8db2021036ce12a309f26f564ec367373265b53e25403f0ee697380f1b8"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, diff --git a/test/media/ver10/fixtures/get_profiles_response_with_invalid_video_encoder.xml b/test/media/ver10/fixtures/get_profiles_response_with_invalid_video_encoder.xml new file mode 100644 index 0000000..b86c64c --- /dev/null +++ b/test/media/ver10/fixtures/get_profiles_response_with_invalid_video_encoder.xml @@ -0,0 +1,3572 @@ + + + + + + + MediaProfile_Channel1_MainStream + + VideoSourceConfig_Channel1 + 3 + 00000 + + + + AudioSourceConfig_Channel1 + 3 + 00000 + + + VideoEncoderConfig_Channel1_MainStream + 1 + + + AudioEncoderConfig_Channel1_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.0.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel1 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel1 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.0.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel1 + 3 + 00000 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel1_MainStream + 1 + + + + + MediaProfile_Channel1_SubStream1 + + VideoSourceConfig_Channel1 + 3 + 00000 + + + + AudioSourceConfig_Channel1 + 3 + 00000 + + + + AudioEncoderConfig_Channel1_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.0.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel1 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel1 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.0.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel1 + 3 + 00000 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel1_SubStream1 + 1 + + + + + MediaProfile_Channel1_SubStream2 + + VideoSourceConfig_Channel1 + 3 + 00000 + + + + AudioSourceConfig_Channel1 + 3 + 00000 + + + + AudioEncoderConfig_Channel1_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.0.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel1 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel1 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.0.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel1 + 3 + 00000 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel1_SubStream2 + 1 + + + + + MediaProfile_Channel2_MainStream + + VideoSourceConfig_Channel2 + 3 + 00100 + + + + AudioSourceConfig_Channel2 + 3 + 00100 + + + VideoEncoderConfig_Channel2_MainStream + 1 + + + AudioEncoderConfig_Channel2_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.1.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel2 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel2 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.1.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel2 + 3 + 00100 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel2_MainStream + 1 + + + + + MediaProfile_Channel2_SubStream1 + + VideoSourceConfig_Channel2 + 3 + 00100 + + + + AudioSourceConfig_Channel2 + 3 + 00100 + + + + AudioEncoderConfig_Channel2_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.1.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel2 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel2 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.1.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel2 + 3 + 00100 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel2_SubStream1 + 1 + + + + + MediaProfile_Channel2_SubStream2 + + VideoSourceConfig_Channel2 + 3 + 00100 + + + + AudioSourceConfig_Channel2 + 3 + 00100 + + + + AudioEncoderConfig_Channel2_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.1.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel2 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel2 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.1.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel2 + 3 + 00100 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel2_SubStream2 + 1 + + + + + MediaProfile_Channel3_MainStream + + VideoSourceConfig_Channel3 + 3 + 00200 + + + + AudioSourceConfig_Channel3 + 3 + 00200 + + + VideoEncoderConfig_Channel3_MainStream + 1 + + + AudioEncoderConfig_Channel3_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.2.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel3 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel3 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.2.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel3 + 3 + 00200 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel3_MainStream + 1 + + + + + MediaProfile_Channel3_SubStream1 + + VideoSourceConfig_Channel3 + 3 + 00200 + + + + AudioSourceConfig_Channel3 + 3 + 00200 + + + + AudioEncoderConfig_Channel3_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.2.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel3 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel3 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.2.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel3 + 3 + 00200 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel3_SubStream1 + 1 + + + + + MediaProfile_Channel3_SubStream2 + + VideoSourceConfig_Channel3 + 3 + 00200 + + + + AudioSourceConfig_Channel3 + 3 + 00200 + + + + AudioEncoderConfig_Channel3_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.2.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel3 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel3 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.2.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel3 + 3 + 00200 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel3_SubStream2 + 1 + + + + + MediaProfile_Channel4_MainStream + + VideoSourceConfig_Channel4 + 3 + 00300 + + + + AudioSourceConfig_Channel4 + 3 + 00300 + + + VideoEncoderConfig_Channel4_MainStream + 1 + + + AudioEncoderConfig_Channel4_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.3.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel4 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel4 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.3.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel4 + 3 + 00300 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel4_MainStream + 1 + + + + + MediaProfile_Channel4_SubStream1 + + VideoSourceConfig_Channel4 + 3 + 00300 + + + + AudioSourceConfig_Channel4 + 3 + 00300 + + + + AudioEncoderConfig_Channel4_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.3.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel4 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel4 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.3.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel4 + 3 + 00300 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel4_SubStream1 + 1 + + + + + MediaProfile_Channel4_SubStream2 + + VideoSourceConfig_Channel4 + 3 + 00300 + + + + AudioSourceConfig_Channel4 + 3 + 00300 + + + + AudioEncoderConfig_Channel4_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.3.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel4 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel4 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.3.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel4 + 3 + 00300 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel4_SubStream2 + 1 + + + + + MediaProfile_Channel5_MainStream + + VideoSourceConfig_Channel5 + 3 + 00400 + + + + AudioSourceConfig_Channel5 + 3 + 00400 + + + VideoEncoderConfig_Channel5_MainStream + 1 + + + AudioEncoderConfig_Channel5_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.4.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel5 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel5 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.4.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel5 + 3 + 00400 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel5_MainStream + 1 + + + + + MediaProfile_Channel5_SubStream1 + + VideoSourceConfig_Channel5 + 3 + 00400 + + + + AudioSourceConfig_Channel5 + 3 + 00400 + + + + AudioEncoderConfig_Channel5_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.4.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel5 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel5 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.4.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel5 + 3 + 00400 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel5_SubStream1 + 1 + + + + + MediaProfile_Channel5_SubStream2 + + VideoSourceConfig_Channel5 + 3 + 00400 + + + + AudioSourceConfig_Channel5 + 3 + 00400 + + + + AudioEncoderConfig_Channel5_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.4.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel5 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel5 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.4.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel5 + 3 + 00400 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel5_SubStream2 + 1 + + + + + MediaProfile_Channel6_MainStream + + VideoSourceConfig_Channel6 + 3 + 00500 + + + + AudioSourceConfig_Channel6 + 3 + 00500 + + + VideoEncoderConfig_Channel6_MainStream + 1 + + + AudioEncoderConfig_Channel6_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.5.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel6 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel6 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.5.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel6 + 3 + 00500 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel6_MainStream + 1 + + + + + MediaProfile_Channel6_SubStream1 + + VideoSourceConfig_Channel6 + 3 + 00500 + + + + AudioSourceConfig_Channel6 + 3 + 00500 + + + + AudioEncoderConfig_Channel6_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.5.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel6 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel6 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.5.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel6 + 3 + 00500 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel6_SubStream1 + 1 + + + + + MediaProfile_Channel6_SubStream2 + + VideoSourceConfig_Channel6 + 3 + 00500 + + + + AudioSourceConfig_Channel6 + 3 + 00500 + + + + AudioEncoderConfig_Channel6_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.5.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel6 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel6 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.5.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel6 + 3 + 00500 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel6_SubStream2 + 1 + + + + + MediaProfile_Channel7_MainStream + + VideoSourceConfig_Channel7 + 3 + 00600 + + + + AudioSourceConfig_Channel7 + 3 + 00600 + + + VideoEncoderConfig_Channel7_MainStream + 1 + + + AudioEncoderConfig_Channel7_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.6.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel7 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel7 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.6.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel7 + 3 + 00600 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel7_MainStream + 1 + + + + + MediaProfile_Channel7_SubStream1 + + VideoSourceConfig_Channel7 + 3 + 00600 + + + + AudioSourceConfig_Channel7 + 3 + 00600 + + + + AudioEncoderConfig_Channel7_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.6.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel7 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel7 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.6.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel7 + 3 + 00600 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel7_SubStream1 + 1 + + + + + MediaProfile_Channel7_SubStream2 + + VideoSourceConfig_Channel7 + 3 + 00600 + + + + AudioSourceConfig_Channel7 + 3 + 00600 + + + + AudioEncoderConfig_Channel7_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.6.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel7 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel7 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.6.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel7 + 3 + 00600 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel7_SubStream2 + 1 + + + + + MediaProfile_Channel8_MainStream + + VideoSourceConfig_Channel8 + 3 + 00700 + + + + AudioSourceConfig_Channel8 + 3 + 00700 + + + VideoEncoderConfig_Channel8_MainStream + 1 + + + AudioEncoderConfig_Channel8_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.7.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel8 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel8 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.7.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel8 + 3 + 00700 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel8_MainStream + 1 + + + + + MediaProfile_Channel8_SubStream1 + + VideoSourceConfig_Channel8 + 3 + 00700 + + + + AudioSourceConfig_Channel8 + 3 + 00700 + + + + AudioEncoderConfig_Channel8_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.7.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel8 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel8 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.7.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel8 + 3 + 00700 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel8_SubStream1 + 1 + + + + + MediaProfile_Channel8_SubStream2 + + VideoSourceConfig_Channel8 + 3 + 00700 + + + + AudioSourceConfig_Channel8 + 3 + 00700 + + + + AudioEncoderConfig_Channel8_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.7.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel8 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel8 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.7.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel8 + 3 + 00700 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel8_SubStream2 + 1 + + + + + MediaProfile_Channel9_MainStream + + VideoSourceConfig_Channel9 + 3 + 00800 + + + + AudioSourceConfig_Channel9 + 3 + 00800 + + + VideoEncoderConfig_Channel9_MainStream + 1 + + + AudioEncoderConfig_Channel9_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.8.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel9 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel9 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.8.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel9 + 3 + 00800 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel9_MainStream + 1 + + + + + MediaProfile_Channel9_SubStream1 + + VideoSourceConfig_Channel9 + 3 + 00800 + + + + AudioSourceConfig_Channel9 + 3 + 00800 + + + + AudioEncoderConfig_Channel9_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.8.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel9 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel9 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.8.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel9 + 3 + 00800 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel9_SubStream1 + 1 + + + + + MediaProfile_Channel9_SubStream2 + + VideoSourceConfig_Channel9 + 3 + 00800 + + + + AudioSourceConfig_Channel9 + 3 + 00800 + + + + AudioEncoderConfig_Channel9_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.8.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel9 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel9 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.8.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel9 + 3 + 00800 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel9_SubStream2 + 1 + + + + + MediaProfile_Channel10_MainStream + + VideoSourceConfig_Channel10 + 3 + 00900 + + + + AudioSourceConfig_Channel10 + 3 + 00900 + + + VideoEncoderConfig_Channel10_MainStream + 1 + + + AudioEncoderConfig_Channel10_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.9.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel10 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel10 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.9.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel10 + 3 + 00900 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel10_MainStream + 1 + + + + + MediaProfile_Channel10_SubStream1 + + VideoSourceConfig_Channel10 + 3 + 00900 + + + + AudioSourceConfig_Channel10 + 3 + 00900 + + + + AudioEncoderConfig_Channel10_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.9.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel10 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel10 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.9.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel10 + 3 + 00900 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel10_SubStream1 + 1 + + + + + MediaProfile_Channel10_SubStream2 + + VideoSourceConfig_Channel10 + 3 + 00900 + + + + AudioSourceConfig_Channel10 + 3 + 00900 + + + + AudioEncoderConfig_Channel10_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.9.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel10 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel10 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.9.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel10 + 3 + 00900 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel10_SubStream2 + 1 + + + + + MediaProfile_Channel11_MainStream + + VideoSourceConfig_Channel11 + 3 + 01000 + + + + AudioSourceConfig_Channel11 + 3 + 01000 + + + VideoEncoderConfig_Channel11_MainStream + 1 + + + AudioEncoderConfig_Channel11_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.10.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel11 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel11 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.10.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel11 + 3 + 01000 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel11_MainStream + 1 + + + + + MediaProfile_Channel11_SubStream1 + + VideoSourceConfig_Channel11 + 3 + 01000 + + + + AudioSourceConfig_Channel11 + 3 + 01000 + + + + AudioEncoderConfig_Channel11_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.10.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel11 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel11 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.10.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel11 + 3 + 01000 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel11_SubStream1 + 1 + + + + + MediaProfile_Channel11_SubStream2 + + VideoSourceConfig_Channel11 + 3 + 01000 + + + + AudioSourceConfig_Channel11 + 3 + 01000 + + + + AudioEncoderConfig_Channel11_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.10.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel11 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel11 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.10.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel11 + 3 + 01000 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel11_SubStream2 + 1 + + + + + MediaProfile_Channel12_MainStream + + VideoSourceConfig_Channel12 + 3 + 01100 + + + + AudioSourceConfig_Channel12 + 3 + 01100 + + + VideoEncoderConfig_Channel12_MainStream + 1 + + + AudioEncoderConfig_Channel12_MainStream + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.11.0 + + 40002 + 64 + false + + PT60S + + + AnalyticsConfig_Channel12 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel12 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.11.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel12 + 3 + 01100 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel12_MainStream + 1 + + + + + MediaProfile_Channel12_SubStream1 + + VideoSourceConfig_Channel12 + 3 + 01100 + + + + AudioSourceConfig_Channel12 + 3 + 01100 + + + + AudioEncoderConfig_Channel12_SubStream1 + 1 + G711 + 32 + 8 + + + IPv4 + 224.1.11.1 + + 40010 + 64 + false + + PT60S + + + AnalyticsConfig_Channel12 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel12 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.11.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel12 + 3 + 01100 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel12_SubStream1 + 1 + + + + + MediaProfile_Channel12_SubStream2 + + VideoSourceConfig_Channel12 + 3 + 01100 + + + + AudioSourceConfig_Channel12 + 3 + 01100 + + + + AudioEncoderConfig_Channel12_SubStream2 + 1 + G711 + 0 + 0 + + + IPv4 + 224.1.11.2 + + 40018 + 64 + false + + PT60S + + + AnalyticsConfig_Channel12 + 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + MetadataConfig_Channel12 + 3 + + false + false + + + + tns1:RuleEngine/CellMotionDetector/Motion + + + true + + + IPv4 + 224.2.11.0 + + 40020 + 64 + false + + PT60S + + + + AudioOutputConfig_Channel12 + 3 + 01100 + www.onvif.org/ver20/HalfDuplex/Auto + 50 + + + AudioDecoderConfig_Channel12_SubStream2 + 1 + + + + + + diff --git a/test/media/ver10/get_profiles_test.exs b/test/media/ver10/get_profiles_test.exs new file mode 100644 index 0000000..b308e29 --- /dev/null +++ b/test/media/ver10/get_profiles_test.exs @@ -0,0 +1,23 @@ +defmodule Onvif.Media.Ver10.GetProfilesTest do + use ExUnit.Case, async: true + + @moduletag capture_log: true + + describe "GetProfiles/1" do + test "should exclude invalid video encoder payloads" do + xml_response = + File.read!( + "test/media/ver10/fixtures/get_profiles_response_with_invalid_video_encoder.xml" + ) + + device = Onvif.Factory.device() + + Mimic.expect(Tesla, :request, fn _client, _opts -> + {:ok, %{status: 200, body: xml_response}} + end) + + {:ok, profiles} = Onvif.Media.Ver10.GetProfiles.request(device) + Enum.each(profiles, &assert(is_nil(&1.video_encoder_configuration))) + end + end +end diff --git a/test/test_helper.exs b/test/test_helper.exs index 869559e..54ba313 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1 +1,3 @@ ExUnit.start() + +Mimic.copy(Tesla)