Sorry, I don't want to mess in your PR but I have a couple of observations:
depayloaders does not take any options right now so we can get rid of them
all payloaders can take the same argument - max_payload_size
if the two above are true, we can hide everything except ExWebRTC.RTP.Payloader and ExWebRTC.RTP.Depayloader - user doesn't have to know about specific payloader/depayloader modules
we can extract payloader/depayloader behaviours into separate modules so they are private too. If we want to provide automatic dispatching, user won't be able to implement those behaviours as our dispatcher's new function has to be modified anyway
An alternative approach would be to use Protocols. The API would look like this:
defprotocol ExWebRTC.RTP.Payloader do
def payload(t(), data)
end
defprotocol ExWebRTC.RTP.Depayloader do
def depayload(t(), data)
end
defmodule ExWebRTC.RTP.Utils do
alias ExWebRTC.RTPCodecParameters
@spec new_payloader(RTPCodecParameters.t()) :: ExWebRTC.RTP.Payloader.t()
def new_payloader(codec_params) do
end
@spec new_depayloader(RTPCodecParameters.t()) :: ExWebRTC.RTP.Depayloader.t()
def new_depayloader(codec_params) do
end
end
This way, user can use RTP utils to automatically find payloader/depayloader or implement their own payloade/depayloader and still use our protocols.
This would be beneficial if we used those protocols internally, in PeerConnection but we don't right now.
Sorry, I don't want to mess in your PR but I have a couple of observations:
ExWebRTC.RTP.Payloader
andExWebRTC.RTP.Depayloader
- user doesn't have to know about specific payloader/depayloader modulesnew
function has to be modified anywayAn alternative approach would be to use Protocols. The API would look like this:
This way, user can use RTP utils to automatically find payloader/depayloader or implement their own payloade/depayloader and still use our protocols. This would be beneficial if we used those protocols internally, in PeerConnection but we don't right now.
Any thoughts?