I tried adding a single filter between the TCP socket and the RTP bin:
defmodule Disect do
use Membrane.Filter
alias Membrane.Buffer
def_input_pad :input, caps: :any, demand_unit: :buffers
def_output_pad :output, caps: :any
@impl true
def handle_init(state) do
state = Map.merge(state || %{}, %{
buffer: <<>>
})
{:ok, state}
end
@impl true
def handle_demand(:output, size, :buffers, _ctx, state) do
{{:ok, demand: {:input, size}}, state}
end
@impl true
def handle_process(:input, %{payload: payload}, _ctx, state) do
disect(state.buffer <> payload, [], state)
end
def disect(<<36, 0::integer-8, length::integer-16, chunk::binary-size(length), rest::binary>>, acc, state) do
# chunk is an RTP packet, forward to RTP parser
disect(rest, acc ++ [%Buffer{payload: chunk}], state)
end
def disect(<<36, channel::integer-8, length::integer-16, _chunk::binary-size(length), rest::binary>>, acc, state) do
IO.puts "ignoring channel: #{channel}"
disect(rest, acc, state)
end
# ignoring non video packets for simplicity
def disect(<<36, _::binary>> = incomplete, acc, state) do
# need to request more data
{{:ok, [buffer: {:output, acc}, redemand: :output]}, %{state | buffer: incomplete}}
end
def disect(<<>>, acc, state) do
{{:ok, [buffer: {:output, acc}, redemand: :output]}, %{state | buffer: <<>>}}
end
end
but i’m still getting a similar error to what i received before:
09:00:54.691 [error] GenServer #PID<0.403.0> terminating
** (Membrane.ActionError) Error while handling :split action:
Unknown error: :send_pkt
Callback: Membrane.Element.FFmpeg.H264.Decoder.handle_process_list
Action args: {:handle_process,
[
[
:input,
%Membrane.Buffer{
metadata: %{},
payload: <<0, 0, 0, 1, 101, 136, 128, 16, 0, 12, 255, 245, 154, 34, 103,
162, 245, 12, 56, 225, 60, 222, 189, 150, 153, 78, 16, 77, 254, 201,
165, 53, 240, 253, 3, 133, 170, 112, 0, 254, 178, 211, 19, ...>>
}
]
]}
The issue i have here is that in my wireshark dump, those bytes don’t exist in any of the packets. I have wireshark pcap if you are interested. Any ideas?
UPDATE:
i found this line that adds the first 4 bytes onto the head of that paylod, but i still can’t find even 101, 136, 128, 16
or any other portion of this paylod in the pcap.