diff --git a/README.md b/README.md index 135180c..5362a8a 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The package can be installed by adding `membrane_rtp_h264_plugin` to your list o ```elixir def deps do [ - {:membrane_rtp_h264_plugin, "~> 0.19.3"} + {:membrane_rtp_h264_plugin, "~> 0.19.4"} ] end ``` diff --git a/lib/rtp_h264/utils.ex b/lib/rtp_h264/utils.ex index b48aabc..6239c0e 100644 --- a/lib/rtp_h264/utils.ex +++ b/lib/rtp_h264/utils.ex @@ -3,6 +3,30 @@ defmodule Membrane.RTP.H264.Utils do Utility functions for RTP packets containing H264 encoded frames. """ + @doc """ + Deprecated since `v0.19.4`. Use `keyframe?/2` instead. + + Checks whether RTP payload contains H264 keyframe. + + By default, with option `look_for` set to `:sps`, will in some cases check + whether the payload contains SPS (NALU payload type 7); + if `look_for` is set to `:idr`, will look exclusively for IDR frames + (NALU payload type 5). + """ + @deprecated "Use #{inspect(__MODULE__)}.keyframe?/2 instead" + @spec is_keyframe(binary(), :sps | :idr) :: boolean() + # credo:disable-for-next-line Credo.Check.Readability.PredicateFunctionNames + def is_keyframe(rtp_payload, look_for \\ :sps) + + # credo:disable-for-next-line Credo.Check.Readability.PredicateFunctionNames + def is_keyframe(rtp_payload, _look_for) when byte_size(rtp_payload) < 1, do: false + + # credo:disable-for-next-line Credo.Check.Readability.PredicateFunctionNames + def is_keyframe(rtp_payload, look_for) do + <<_f::1, _nri::2, nalu_type::5, rest::binary>> = rtp_payload + do_is_keyframe(nalu_type, rest, look_for) + end + @doc """ Checks whether RTP payload contains H264 keyframe. diff --git a/mix.exs b/mix.exs index a302c5a..cbdd3cd 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Membrane.RTP.H264.MixProject do use Mix.Project - @version "0.19.3" + @version "0.19.4" @github_url "https://github.com/membraneframework/membrane_rtp_h264_plugin" def project do