-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement elements for packetizing and depacketzing RTP packets for TCP #163
Conversation
8117047
to
57d18f7
Compare
lib/membrane/rtp/tcp_depacketizer.ex
Outdated
case :binary.encode_unsigned(byte_size(payload), :big) do | ||
<<len::size(8)>> -> <<0, len>> | ||
<<len::binary-size(2)>> -> len | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be replaced with len_bytes = <<byte_size(payload)::size(16)>>
(Elixir uses big endian by default when creating binaries this way)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be further expanded to payload = <<byte_size(payload)::size(16), payload::binary>>
, which creates the prefixed payload that can be directly passed to outputed buffer
lib/membrane/rtp/tcp_depacketizer.ex
Outdated
@@ -0,0 +1,48 @@ | |||
defmodule Membrane.RTP.TCP.Depacketizer do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was kind of counterintuitive to me that Depacketizer is reponsible for encapsulation, even though it technically is correct. What do you think about Encapsulator and Decapsulator?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I would probably stay with Packetizer/Depacketizer or Payloader/Depayloader, but I don't mind changing that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, actually is it correct? I think of depacketizing as of getting out of packets, which in this case would be removing the two-byte header with packet length…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the RFC calls it framing: https://datatracker.ietf.org/doc/html/rfc4571 however as I read it, I understand that by framing they mean adding the 2 byte header, not the other way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packetizing = converting to packets from a continuous stream of data (TCP does not really have a concept of packets)
I already changed it either way so does not really matter
lib/membrane/rtp/tcp_packetizer.ex
Outdated
end | ||
|
||
defp get_complete_packets(packets_binary, complete_packets) do | ||
<<payload_length::size(16), rest::binary>> = packets_binary |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can change the function headers to the following:
defp get_complete_packets(
<<payload_length::16, payload::binary-size(payload_length), rest::binary>>,
complete_packets) do
# next chunk available
end
defp get_complete_packets(leftover, complete_packets) do
# next chunk unavailable
end
df8fd3a
to
8c507a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to bump version in mix.exs and readme
…connection-oriented transport
8c507a0
to
273e719
Compare
Membrane.RTP.TCP.Encapsulator
- reads packet and generates bytestream that can be send over connection-oriented transport (such as TCP)Membrane.RTP.TCP.Decapsulator
- create RTP packets from a bytestreamMostly based on
Membrane.RTP.TCP.Depayloader
(this element implements different mechanism used in RTSP)I'm open to the name suggestions:
Membrane.RTP.TCP.Depayloader
andMembrane.RTP.TCP.Payloader
, but in that case existingMembrane.RTP.TCP.Depayloader
would need to be renamed