From 7bfbf56c6c1adb853dc61f8090bc7c8a92daf16a Mon Sep 17 00:00:00 2001 From: FelonEkonom <38541925+FelonEkonom@users.noreply.github.com> Date: Tue, 31 May 2022 14:19:33 +0200 Subject: [PATCH] Add new function to utils module (#11) * Add new function to utils module * Add frame and keyframe detectors to PayloadFormat * Update deps * Add docs for added function * Update deps branches --- lib/plugin_app.ex | 4 +++- lib/utils.ex | 13 +++++++++++++ mix.exs | 4 ++-- mix.lock | 9 ++++----- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/plugin_app.ex b/lib/plugin_app.ex index 3f7ad65..f836144 100644 --- a/lib/plugin_app.ex +++ b/lib/plugin_app.ex @@ -9,7 +9,9 @@ defmodule Membrane.RTP.VP8.Plugin.App do encoding_name: :VP8, payload_type: 98, depayloader: VP8.Depayloader, - payloader: VP8.Payloader + payloader: VP8.Payloader, + keyframe_detector: &VP8.Utils.is_keyframe/1, + frame_detector: &VP8.Utils.is_new_frame/1 }) PayloadFormat.register_payload_type_mapping(98, :VP8, 90_000) diff --git a/lib/utils.ex b/lib/utils.ex index 0391acf..30ce932 100644 --- a/lib/utils.ex +++ b/lib/utils.ex @@ -21,4 +21,17 @@ defmodule Membrane.RTP.VP8.Utils do _err -> false end end + + @doc """ + Checks whether RTP payload contains new frame. + """ + @spec is_new_frame(binary()) :: boolean() + def is_new_frame(rtp_payload) do + with {:ok, {payload_descriptor, _payload}} <- + Membrane.RTP.VP8.PayloadDescriptor.parse_payload_descriptor(rtp_payload) do + payload_descriptor.s == 1 and payload_descriptor.partition_index == 0 + else + _err -> false + end + end end diff --git a/mix.exs b/mix.exs index 50d0f1c..68a6100 100644 --- a/mix.exs +++ b/mix.exs @@ -38,10 +38,10 @@ defmodule Membrane.RTP.VP8.Plugin.Mixfile do defp deps do [ {:membrane_core, "~> 0.10.0"}, - {:membrane_rtp_format, "~> 0.4.0"}, {:membrane_vp8_format, "~> 0.4.0"}, {:membrane_file_plugin, "~> 0.12.0"}, - {:membrane_rtp_plugin, "~> 0.13.0", only: :test}, + {:membrane_rtp_format, github: "membraneframework/membrane_rtp_format"}, + {:membrane_rtp_plugin, github: "membraneframework/membrane_rtp_plugin", only: :test}, {:ex_libsrtp, "~> 0.4.0", only: :test}, {:membrane_pcap_plugin, github: "membraneframework/membrane_pcap_plugin", tag: "v0.6.1", only: :test}, diff --git a/mix.lock b/mix.lock index 3444fff..bf98c4a 100644 --- a/mix.lock +++ b/mix.lock @@ -12,7 +12,6 @@ "ex_doc": {:hex, :ex_doc, "0.28.4", "001a0ea6beac2f810f1abc3dbf4b123e9593eaa5f00dd13ded024eae7c523298", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bf85d003dd34911d89c8ddb8bda1a958af3471a274a4c2150a9c01c78ac3f8ed"}, "ex_libsrtp": {:hex, :ex_libsrtp, "0.4.0", "c30898f11e3069826c813ae7dee293fa59dfb633251e203be77c4ca2c223ed2c", [:mix], [{:bunch, "~> 1.3", [hex: :bunch, repo: "hexpm", optional: false]}, {:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "a5d25860db0030cdbf0bd50d467180426f57d597a841bc03e6730e3c12107137"}, "ex_pcap": {:git, "https://github.com/membraneframework/expcap.git", "07c5bfa25280ea6a28d022d3a206ececf9b9913a", []}, - "expcap": {:git, "https://github.com/Hajto/expcap.git", "0608702b7e22c1f3206014dbe3e1d313cdc17f1c", []}, "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, "heap": {:hex, :heap, "2.0.2", "d98cb178286cfeb5edbcf17785e2d20af73ca57b5a2cf4af584118afbcf917eb", [:mix], [], "hexpm", "ba9ea2fe99eb4bcbd9a8a28eaf71cbcac449ca1d8e71731596aace9028c9d429"}, "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, @@ -20,14 +19,13 @@ "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"}, "membrane_core": {:hex, :membrane_core, "0.10.1", "b4fb68d9e541888b60ebbf4e22c4913a84f35c955846b7df26154cb7c5ce0f78", [:mix], [{:bunch, "~> 1.3", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 2.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d039f67d00cb1c1608b1e4f03cea8a9b5a88ff0fef3f61f54dc65e515b9dc286"}, - "membrane_element_pcap": {:git, "https://github.com/membraneframework/membrane-element-pcap.git", "e9d9c47bc1ed5897250e6463710b4adb0d76c4ed", []}, "membrane_file_plugin": {:hex, :membrane_file_plugin, "0.12.0", "eb940e7a2f2abf30e048bd0b7c2bef9c17c18aa58875b9a833c0bc7e7b1fd709", [:mix], [{:membrane_core, "~> 0.10.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "281b9bf9467beead3f973adce55b9844bc4206bb3f3f60f0db8320a4af4fc5ca"}, "membrane_ivf_plugin": {:hex, :membrane_ivf_plugin, "0.4.1", "0851e1016e54663d6cc4d5b848550003d4efef932943fae01477f704af832ba6", [:mix], [{:membrane_core, "~> 0.10.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "48ca06438957162365e869722bb9102b6d6f3904d9a9441494f496949ca3a937"}, "membrane_pcap_plugin": {:git, "https://github.com/membraneframework/membrane_pcap_plugin.git", "2bab35e62ac87e5a2c5d514dfb0b51de12a3ed96", [tag: "v0.6.1"]}, - "membrane_rtp_format": {:hex, :membrane_rtp_format, "0.4.0", "be84e88206c6a91363660eeb7cbf03330cd9a00486fb4bce4a7b86a4172d3a4b", [:mix], [{:membrane_core, "~> 0.10.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "44944956c1031f49269b7d447525b7c3d1026120b100b4f0dfaca5dc228c65e0"}, - "membrane_rtp_plugin": {:hex, :membrane_rtp_plugin, "0.13.0", "0cb0ba042fb9fe26d305b1c610d8cd2b67f5254469c51c580b7c4a62f53fc477", [:mix], [{:bimap, "~> 1.1.0", [hex: :bimap, repo: "hexpm", optional: false]}, {:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:ex_libsrtp, "~> 0.4.0", [hex: :ex_libsrtp, repo: "hexpm", optional: true]}, {:heap, "~> 2.0.2", [hex: :heap, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.10.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_rtp_format, "~> 0.4.0", [hex: :membrane_rtp_format, repo: "hexpm", optional: false]}, {:qex, "~> 0.5.1", [hex: :qex, repo: "hexpm", optional: false]}], "hexpm", "4194ab684e68ac6694d0abaad4835233d00dfc5008ac7c15bd3fba29c4dacb47"}, + "membrane_rtp_format": {:git, "https://github.com/membraneframework/membrane_rtp_format.git", "7f135ad0168324970d214d04c6a46b90a59e1c3c", []}, + "membrane_rtp_plugin": {:git, "https://github.com/membraneframework/membrane_rtp_plugin.git", "600bf5e9a12b4b3248e36fac40c0781bbb20fd21", []}, + "membrane_telemetry_metrics": {:git, "https://github.com/membraneframework/membrane_telemetry_metrics.git", "1ed21f9b75fac9d5520a26976ee252cf8953e8fa", []}, "membrane_vp8_format": {:hex, :membrane_vp8_format, "0.4.0", "6c29ec67479edfbab27b11266dc92f18f3baf4421262c5c31af348c33e5b92c7", [:mix], [], "hexpm", "8bb005ede61db8fcb3535a883f32168b251c2dfd1109197c8c3b39ce28ed08e2"}, - "mockery": {:hex, :mockery, "2.3.1", "a02fd60b10ac9ed37a7a2ecf6786c1f1dd5c75d2b079a60594b089fba32dc087", [:mix], [], "hexpm", "1d0971d88ebf084e962da3f2cfee16f0ea8e04ff73a7710428500d4500b947fa"}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, "numbers": {:hex, :numbers, "5.2.4", "f123d5bb7f6acc366f8f445e10a32bd403c8469bdbce8ce049e1f0972b607080", [:mix], [{:coerce, "~> 1.0", [hex: :coerce, repo: "hexpm", optional: false]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "eeccf5c61d5f4922198395bf87a465b6f980b8b862dd22d28198c5e6fab38582"}, "pkt": {:hex, :pkt, "0.5.0", "6dc345565dd7e8d80e56c1198e1ee07344f191782d9f1e66eca50b40c98b1720", [:rebar3], [], "hexpm", "c285cd1e5fb850d09f7fd98e1c9e291d1348ab41e4171c78fa99d04e04d84fb2"}, @@ -36,5 +34,6 @@ "secure_random": {:hex, :secure_random, "0.5.1", "c5532b37c89d175c328f5196a0c2a5680b15ebce3e654da37129a9fe40ebf51b", [:mix], [], "hexpm", "1b9754f15e3940a143baafd19da12293f100044df69ea12db5d72878312ae6ab"}, "shmex": {:hex, :shmex, "0.5.0", "7dc4fb1a8bd851085a652605d690bdd070628717864b442f53d3447326bcd3e8", [:mix], [{:bunch_native, "~> 0.5.0", [hex: :bunch_native, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "b67bb1e22734758397c84458dbb746519e28eac210423c267c7248e59fc97bdc"}, "telemetry": {:hex, :telemetry, "1.1.0", "a589817034a27eab11144ad24d5c0f9fab1f58173274b1e9bae7074af9cbee51", [:rebar3], [], "hexpm", "b727b2a1f75614774cff2d7565b64d0dfa5bd52ba517f16543e6fc7efcc0df48"}, + "telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"}, "unifex": {:hex, :unifex, "1.0.0", "a8a2ac6f6f437dd689db8c680df53e28e43c0548cd58ba2af36a1241f66fbc62", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}, {:shmex, "~> 0.5.0", [hex: :shmex, repo: "hexpm", optional: false]}], "hexpm", "23b30d5d9d65bb77c25397e476d86818df7b6519bcb0ea816429a70d0729c14d"}, }