diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c456c93 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: Elixir CI + +on: + push: + branches: + - master + pull_request: + +env: + MIX_ENV: test + +jobs: + test: + strategy: + matrix: + include: + - otp_version: 25.3 + elixir_version: 1.16 + + - otp_version: 27.2 + elixir_version: 1.18 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: erlef/setup-beam@v1 + with: + elixir-version: ${{ matrix.elixir_version }} + otp-version: ${{ matrix.otp_version }} + + - name: Install dependencies + run: mix deps.get + - name: Compile dependencies + run: mix deps.compile + - name: Run tests + run: mix test --warnings-as-errors + - name: Run Credo + run: mix credo --strict + + format: + runs-on: ubuntu-latest + name: mix format + steps: + - uses: actions/checkout@v4 + - uses: erlef/setup-beam@v1 + with: + otp-version: 27.2 + elixir-version: 1.18 + - run: mix format --check-formatted diff --git a/examples/publish_mp4.exs b/examples/publish_mp4.exs index 9baf898..585dc67 100644 --- a/examples/publish_mp4.exs +++ b/examples/publish_mp4.exs @@ -91,7 +91,7 @@ defmodule Publisher do defp init_tag(%{media: :h264} = track) do <<_::binary-size(8), dcr::binary>> = ExMP4.Box.serialize(track.priv_data) - VideoData.AVC.new(dcr, :sequence_header, 0) |> VideoData.new(:avc, :keyframe) + VideoData.AVC.new(dcr, :sequence_header, 0) |> VideoData.new(:h264, :keyframe) end defp init_tag(%{media: :h265} = track) do @@ -116,7 +116,7 @@ defmodule Publisher do defp video_tag(:h264, sample, ct) do sample.payload |> VideoData.AVC.new(:nalu, ct) - |> VideoData.new(:avc, if(sample.sync?, do: :keyframe, else: :interframe)) + |> VideoData.new(:h264, if(sample.sync?, do: :keyframe, else: :interframe)) end defp video_tag(:h265, sample, ct) do diff --git a/examples/read_to_flv.exs b/examples/read_to_flv.exs index e05232c..d1b42b9 100644 --- a/examples/read_to_flv.exs +++ b/examples/read_to_flv.exs @@ -39,11 +39,11 @@ defmodule StreamWriter do end @impl true - def handle_info({:video, pid, _stream_id, {:codec, :avc, dcr}}, %{client: pid} = state) do + def handle_info({:video, pid, _stream_id, {:codec, :h264, dcr}}, %{client: pid} = state) do payload = dcr |> Tag.AVCVideoPacket.new(:sequence_header, 0) - |> Tag.VideoData.new(:avc, :keyframe) + |> Tag.VideoData.new(:h264, :keyframe) tag = Tag.serialize(%Tag{type: :video, data: payload, timestamp: 0}) IO.binwrite(state.writer, [tag, <>]) @@ -73,7 +73,7 @@ defmodule StreamWriter do payload |> Enum.map(&<>) |> Tag.AVCVideoPacket.new(:nalu, pts - dts) - |> Tag.VideoData.new(:avc, if(sync?, do: :keyframe, else: :interframe)) + |> Tag.VideoData.new(:h264, if(sync?, do: :keyframe, else: :interframe)) tag = Tag.serialize(%Tag{type: :video, data: payload, timestamp: dts}) IO.binwrite(state.writer, [tag, <>]) diff --git a/examples/send_mp4.exs b/examples/send_mp4.exs index 82db7c7..3108706 100644 --- a/examples/send_mp4.exs +++ b/examples/send_mp4.exs @@ -30,7 +30,7 @@ defmodule Publisher do video_reducer: video_reducer, audio_track: audio_track, audio_reducer: audio_reducer, - stream_id: opts[:stream_id], + stream_id: opts[:stream_id] }, {:continue, :send_init_data}} end @@ -55,7 +55,7 @@ defmodule Publisher do dcr |> AVCVideoPacket.new(:sequence_header, 0) - |> VideoData.new(:avc, :keyframe) + |> VideoData.new(:h264, :keyframe) |> ExFLV.Tag.Serializer.serialize() |> then(&ClientSession.send_video_data(state.rtmp_sender, state.stream_id, 0, &1)) @@ -83,7 +83,7 @@ defmodule Publisher do data = sample.payload |> AVCVideoPacket.new(:nalu, sample.pts - sample.dts) - |> VideoData.new(:avc, frame_type) + |> VideoData.new(:h264, frame_type) |> ExFLV.Tag.Serializer.serialize() ClientSession.send_video_data(state.rtmp_sender, state.stream_id, timestamp, data) diff --git a/lib/ex_rtmp/chunk.ex b/lib/ex_rtmp/chunk.ex index adee8d1..ff4a509 100644 --- a/lib/ex_rtmp/chunk.ex +++ b/lib/ex_rtmp/chunk.ex @@ -32,9 +32,8 @@ defmodule ExRTMP.Chunk do @spec parse_header(binary()) :: {:ok, t(), binary()} | :more def parse_header(data) do with {:ok, chunk, rest} <- parse_stream_id(data), - {:ok, chunk, rest} <- parse_message_header(chunk, rest), - {:ok, chunk, rest} <- parse_extended_timestamp(chunk, rest) do - {:ok, chunk, rest} + {:ok, chunk, rest} <- parse_message_header(chunk, rest) do + parse_extended_timestamp(chunk, rest) end end diff --git a/lib/ex_rtmp/chunk_parser.ex b/lib/ex_rtmp/chunk_parser.ex index 1aad03a..4d63a7e 100644 --- a/lib/ex_rtmp/chunk_parser.ex +++ b/lib/ex_rtmp/chunk_parser.ex @@ -12,8 +12,8 @@ defmodule ExRTMP.ChunkParser do defstruct [:unprocessed_data, :messages, :message_first_chunk, chunk_size: 128] - @spec new() :: t() - def new() do + @spec new :: t() + def new do %__MODULE__{ unprocessed_data: <<>>, messages: %{}, diff --git a/lib/ex_rtmp/client/media_processor.ex b/lib/ex_rtmp/client/media_processor.ex index aaaed82..dd5af0a 100644 --- a/lib/ex_rtmp/client/media_processor.ex +++ b/lib/ex_rtmp/client/media_processor.ex @@ -10,8 +10,8 @@ defmodule ExRTMP.Client.MediaProcessor do @type codec :: AudioData.source_format() | VideoData.codec_id() - | ExVideoData.fourcc() - | ExAudioData.fourcc() + | ExVideoData.codec_id() + | ExAudioData.codec_id() @type track :: {:codec, codec(), binary()} @type video_sample :: @@ -31,8 +31,8 @@ defmodule ExRTMP.Client.MediaProcessor do defstruct [:nalu_prefix_size, video?: false, audio?: false] - @spec new() :: t() - def new(), do: %__MODULE__{} + @spec new :: t() + def new, do: %__MODULE__{} @spec push_video(Message.t(), t()) :: {video_return(), t()} def push_video(message, processor) do @@ -56,7 +56,7 @@ defmodule ExRTMP.Client.MediaProcessor do defp parse_audio_tag(<<9::4, _::bitstring>> = data), do: ExAudioData.parse!(data) defp parse_audio_tag(data), do: AudioData.parse!(data) - defp handle_video_tag(%VideoData{codec_id: :avc} = tag, timestamp, processor) do + defp handle_video_tag(%VideoData{codec_id: :h264} = tag, timestamp, processor) do packet_type = tag.data.packet_type cond do @@ -67,11 +67,11 @@ defmodule ExRTMP.Client.MediaProcessor do packet_type == :sequence_header -> processor = %{ processor - | nalu_prefix_size: nalu_prefix_size(:avc, tag.data.data), + | nalu_prefix_size: nalu_prefix_size(:h264, tag.data.data), video?: true } - {{:codec, :avc, tag.data.data}, processor} + {{:codec, :h264, tag.data.data}, processor} packet_type == :end_of_sequence -> {nil, processor} @@ -101,11 +101,11 @@ defmodule ExRTMP.Client.MediaProcessor do packet_type == :sequence_start -> processor = %{ processor - | nalu_prefix_size: nalu_prefix_size(tag.fourcc, tag.data), + | nalu_prefix_size: nalu_prefix_size(tag.codec_id, tag.data), video?: true } - {{:codec, tag.fourcc, tag.data}, processor} + {{:codec, tag.codec_id, tag.data}, processor} packet_type in [:sequence_end, :metadata] -> {nil, processor} @@ -149,7 +149,7 @@ defmodule ExRTMP.Client.MediaProcessor do {{:sample, tag.data, timestamp}, processor} tag.packet_type == :sequence_start -> - {{:codec, tag.fourcc, tag.data}, %{processor | audio?: true}} + {{:codec, tag.codec_id, tag.data}, %{processor | audio?: true}} true -> {nil, processor} @@ -165,12 +165,12 @@ defmodule ExRTMP.Client.MediaProcessor do {{:sample, tag.data, timestamp}, processor} end - defp nalu_prefix_size(:hvc1, <<_::binary-size(21), _::6, nalu_prefix_size::2, _::binary>>) do + defp nalu_prefix_size(:h265, <<_::binary-size(21), _::6, nalu_prefix_size::2, _::binary>>) do nalu_prefix_size + 1 end defp nalu_prefix_size(codec, <<_::38, nalu_prefix_size::2, _::binary>>) - when codec == :avc or codec == :avc1 do + when codec == :h264 or codec == :h265 do nalu_prefix_size + 1 end diff --git a/lib/ex_rtmp/message.ex b/lib/ex_rtmp/message.ex index 2bdc29a..ddfd7ce 100644 --- a/lib/ex_rtmp/message.ex +++ b/lib/ex_rtmp/message.ex @@ -9,7 +9,7 @@ defmodule ExRTMP.Message do alias __MODULE__.Command.NetStream.{DeleteStream, FCPublish, OnStatus, Play, Publish} alias __MODULE__.Metadata alias __MODULE__.UserControl.Event - alias ExRTMP.Chunk + alias ExRTMP.{Chunk, Message} @type stream_id :: non_neg_integer() @@ -149,7 +149,7 @@ defmodule ExRTMP.Message do payload = if is_struct(message.payload), - do: ExRTMP.Message.Serializer.serialize(message.payload), + do: Message.Serializer.serialize(message.payload), else: message.payload payload = IO.iodata_to_binary(payload) @@ -221,51 +221,57 @@ defmodule ExRTMP.Message do @doc false defp parse_payload(%__MODULE__{type: 20, payload: payload} = msg) do payload = - case ExRTMP.AMF0.parse(IO.iodata_to_binary(payload)) do - ["connect", transaction_id, properties | _rest] -> - %Connect{transaction_id: transaction_id, properties: properties} - - ["createStream", transaction_id | _rest] -> - %CreateStream{transaction_id: transaction_id} - - [result, transaction_id, command_object, data] when result in ["_result", "_error"] -> - %Response{ - result: result, - transaction_id: trunc(transaction_id), - command_object: command_object, - data: data - } + payload + |> IO.iodata_to_binary() + |> ExRTMP.AMF0.parse() + |> handle_message_payload() - ["publish", _txid, nil, name, type] -> - Publish.new(name, type) + %{msg | payload: payload} + end - ["FCPublish", transaction_id, nil, name] -> - FCPublish.new(transaction_id, name) + defp parse_payload(msg), do: msg - ["deleteStream", _txid, nil, stream_id] -> - DeleteStream.new(stream_id) + defp handle_message_payload(["connect", transaction_id, properties | _rest]) do + %Connect{transaction_id: transaction_id, properties: properties} + end - ["play", _txid, nil, stream_name | opts] -> - play_opts = - case opts do - [] -> [] - [start] -> [start: start] - [start, duration] -> [start: start, duration: duration] - [start, duration, reset] -> [start: start, duration: duration, reset: reset] - end + defp handle_message_payload(["createStream", transaction_id | _rest]) do + %CreateStream{transaction_id: transaction_id} + end - Play.new(stream_name, play_opts) + defp handle_message_payload([result, transaction_id, command_object, data]) + when result in ["_result", "_error"] do + %Response{ + result: result, + transaction_id: trunc(transaction_id), + command_object: command_object, + data: data + } + end - ["onStatus", _ts_id, nil, info] -> - %OnStatus{info: info} + defp handle_message_payload(["publish", _txid, nil, name, type]), do: Publish.new(name, type) + defp handle_message_payload(["onStatus", _txid, nil, info]), do: %OnStatus{info: info} - other -> - Logger.warning("Unknown command: #{inspect(List.first(other))}") - payload + defp handle_message_payload(["play", _txid, nil, name | opts]) do + play_opts = + case opts do + [] -> [] + [start] -> [start: start] + [start, duration] -> [start: start, duration: duration] + [start, duration, reset] -> [start: start, duration: duration, reset: reset] end - %{msg | payload: payload} + Play.new(name, play_opts) end - defp parse_payload(msg), do: msg + defp handle_message_payload(["deleteStream", _txid, nil, stream_id]), + do: DeleteStream.new(stream_id) + + defp handle_message_payload(["FCPublish", transaction_id, nil, name]), + do: FCPublish.new(transaction_id, name) + + defp handle_message_payload(other) do + Logger.warning("Unknown command: #{inspect(other)}") + other + end end diff --git a/lib/ex_rtmp/message/command/net_stream/on_status.ex b/lib/ex_rtmp/message/command/net_stream/on_status.ex index 340579d..6ccd36a 100644 --- a/lib/ex_rtmp/message/command/net_stream/on_status.ex +++ b/lib/ex_rtmp/message/command/net_stream/on_status.ex @@ -18,11 +18,11 @@ defmodule ExRTMP.Message.Command.NetStream.OnStatus do %__MODULE__{info: info} end - @spec publish_ok() :: t() - def publish_ok(), do: new("NetStream.Publish.Start") + @spec publish_ok :: t() + def publish_ok, do: new("NetStream.Publish.Start") - @spec publish_bad_stream() :: t() - def publish_bad_stream() do + @spec publish_bad_stream :: t() + def publish_bad_stream do new("NetStream.Publish.BadStream", :error, "Unknown stream") end @@ -31,11 +31,11 @@ defmodule ExRTMP.Message.Command.NetStream.OnStatus do new("NetStream.Publish.Failed", :error, reason) end - @spec play_ok() :: t() - def play_ok(), do: new("NetStream.Play.Start") + @spec play_ok :: t() + def play_ok, do: new("NetStream.Play.Start") - @spec play_bad_stream() :: t() - def play_bad_stream() do + @spec play_bad_stream :: t() + def play_bad_stream do new("NetStream.Play.BadStream", :error, "Unknown stream") end diff --git a/lib/ex_rtmp/server/client_session.ex b/lib/ex_rtmp/server/client_session.ex index 5c4d2eb..df8621f 100644 --- a/lib/ex_rtmp/server/client_session.ex +++ b/lib/ex_rtmp/server/client_session.ex @@ -12,7 +12,7 @@ defmodule ExRTMP.Server.ClientSession do alias ExRTMP.Message alias ExRTMP.Message.Command.NetConnection alias ExRTMP.Message.Command.NetConnection.{CreateStream, Response} - alias ExRTMP.Message.Command.NetStream.{DeleteStream, FCPublish, Play, Publish, OnStatus} + alias ExRTMP.Message.Command.NetStream.{DeleteStream, FCPublish, OnStatus, Play, Publish} alias ExRTMP.Message.Metadata @default_acknowledgement_size 3_000_000 diff --git a/mix.exs b/mix.exs index 0d42fcc..88aa2ee 100644 --- a/mix.exs +++ b/mix.exs @@ -8,7 +8,7 @@ defmodule ExRTMP.MixProject do [ app: :ex_rtmp, version: @version, - elixir: "~> 1.15", + elixir: "~> 1.16", start_permanent: Mix.env() == :prod, deps: deps(), elixirc_paths: elixirc_paths(Mix.env()), @@ -32,8 +32,9 @@ defmodule ExRTMP.MixProject do defp deps do [ - {:ex_flv, "~> 0.3.0"}, + {:ex_flv, "~> 0.4.0"}, {:ex_doc, "~> 0.38", only: :dev, runtime: false}, + {:credo, "~> 1.7", only: [:dev, :test], runtime: false}, {:media_codecs, "~> 0.8.0", only: :test} ] end diff --git a/mix.lock b/mix.lock index 6ce4b76..a6250da 100644 --- a/mix.lock +++ b/mix.lock @@ -1,7 +1,11 @@ %{ + "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, + "credo": {:hex, :credo, "1.7.15", "283da72eeb2fd3ccf7248f4941a0527efb97afa224bcdef30b4b580bc8258e1c", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "291e8645ea3fea7481829f1e1eb0881b8395db212821338e577a90bf225c5607"}, "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, "ex_doc": {:hex, :ex_doc, "0.38.4", "ab48dff7a8af84226bf23baddcdda329f467255d924380a0cf0cee97bb9a9ede", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "f7b62346408a83911c2580154e35613eb314e0278aeea72ed7fedef9c1f165b2"}, - "ex_flv": {:hex, :ex_flv, "0.3.0", "3215b6209bdf4ff50ccbd744e5c5b7f7a3c30da0b474a53dd3aa6d77a62d15a8", [:mix], [], "hexpm", "751ce661f4e3fe5b4d916f6c1cf19cbab7f33aa8f5f20ad9172f268bf883a083"}, + "ex_flv": {:hex, :ex_flv, "0.4.0", "9e43c833b5cbe3c6e21bb2651ae7650f3ec939eac8079f34efed8f813bf9133d", [:mix], [], "hexpm", "484f6990791e0c8862a88e4150f004deb067c7342e40b779c82d5c9a9c057969"}, + "file_system": {:hex, :file_system, "1.1.1", "31864f4685b0148f25bd3fbef2b1228457c0c89024ad67f7a81a3ffbc0bbad3a", [:mix], [], "hexpm", "7a15ff97dfe526aeefb090a7a9d3d03aa907e100e262a0f8f7746b78f8f87a5d"}, + "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"}, diff --git a/test/ex_rtmp/chunk_parser_test.exs b/test/ex_rtmp/chunk_parser_test.exs index 1618c54..a67986c 100644 --- a/test/ex_rtmp/chunk_parser_test.exs +++ b/test/ex_rtmp/chunk_parser_test.exs @@ -3,9 +3,9 @@ defmodule ExRTMP.ChunkParserTest do alias ExRTMP.ChunkParser alias ExRTMP.Message - alias ExRTMP.Message.Command.NetStream.Publish - alias ExRTMP.Message.Command.NetConnection.CreateStream alias ExRTMP.Message.Command.NetConnection.Connect + alias ExRTMP.Message.Command.NetConnection.CreateStream + alias ExRTMP.Message.Command.NetStream.Publish test "Parse a stream of chunks into messages" do {messages, parser} = diff --git a/test/ex_rtmp/client_test.exs b/test/ex_rtmp/client_test.exs index 4e0d9c4..98c7706 100644 --- a/test/ex_rtmp/client_test.exs +++ b/test/ex_rtmp/client_test.exs @@ -62,15 +62,15 @@ defmodule ExRTMP.ClientTest do case unquote(codec) do :h264 -> assert media_type == :video - assert received_codec == :avc + assert received_codec == :h264 :hevc -> assert media_type == :video - assert received_codec == :hvc1 + assert received_codec == :h265 :pcma -> assert media_type == :audio - assert received_codec == :g711_alaw + assert received_codec == :pcma end collected_access_units = collect_received_data([]) @@ -104,7 +104,7 @@ defmodule ExRTMP.ClientTest do init_tag = ExRTMP.ServerHandler.dcr() |> VideoData.AVC.new(:sequence_header, 0) - |> VideoData.new(:avc, :keyframe) + |> VideoData.new(:h264, :keyframe) Client.send_tag(pid, 0, init_tag) @@ -114,7 +114,7 @@ defmodule ExRTMP.ClientTest do access_unit |> Enum.map(&[<>, &1]) |> VideoData.AVC.new(:nalu, 0) - |> VideoData.new(:avc, if(keyframe?, do: :keyframe, else: :interframe)) + |> VideoData.new(:h264, if(keyframe?, do: :keyframe, else: :interframe)) |> then(&Client.send_tag(pid, 0, &1)) end) diff --git a/test/support/server_handler.ex b/test/support/server_handler.ex index c60b04b..c2be191 100644 --- a/test/support/server_handler.ex +++ b/test/support/server_handler.ex @@ -3,13 +3,13 @@ defmodule ExRTMP.ServerHandler do use ExRTMP.Server.Handler - alias MediaCodecs.H264 alias ExFLV.Tag.{AudioData, ExVideoData, Serializer, VideoData, VideoData.AVC} alias ExRTMP.Server.ClientSession - alias MediaCodecs.H264.NaluSplitter + alias MediaCodecs.H264 alias MediaCodecs.H264.AccessUnitSplitter - alias MediaCodecs.H265.NaluSplitter, as: HevcNaluSplitter + alias MediaCodecs.H264.NaluSplitter alias MediaCodecs.H265.AccessUnitSplitter, as: HevcAccessUnitSplitter + alias MediaCodecs.H265.NaluSplitter, as: HevcNaluSplitter @dcr <<1, 66, 192, 13, 255, 225, 0, 25, 103, 66, 192, 13, 171, 32, 40, 51, 243, 224, 34, 0, 0, 3, 0, 2, 0, 0, 3, 0, 97, 30, 40, 84, 144, 1, 0, 4, 104, 206, 60, 128>> @@ -113,14 +113,14 @@ defmodule ExRTMP.ServerHandler do defp h264_dcr_tag(dcr) do dcr |> AVC.new(:sequence_header, 0) - |> VideoData.new(:avc, :keyframe) + |> VideoData.new(:h264, :keyframe) end defp hevc_dcr_tag(dcr) do %ExVideoData{ frame_type: :keyframe, packet_type: :sequence_start, - fourcc: :hvc1, + codec_id: :h265, data: dcr } end @@ -130,7 +130,7 @@ defmodule ExRTMP.ServerHandler do |> Enum.map(&[<>, &1]) |> AVC.new(:nalu, 0) |> VideoData.new( - :avc, + :h264, if(Enum.any?(access_unit, &H264.NALU.keyframe?/1), do: :keyframe, else: :interframe) ) end @@ -142,15 +142,14 @@ defmodule ExRTMP.ServerHandler do %ExVideoData{ frame_type: if(keyframe?, do: :keyframe, else: :interframe), packet_type: :coded_frames, - fourcc: :hvc1, - composition_time_offset: 0, + codec_id: :h265, data: payload } end defp create_tag(:pcma, data) do %AudioData{ - sound_format: :g711_alaw, + sound_format: :pcma, sound_size: 0, sound_rate: 1, sound_type: :mono,