-
Notifications
You must be signed in to change notification settings - Fork 10
Support various video codecs in source #11
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
Conversation
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.
Please add some tests receiving negotiated_video_codec and new_track notifications and checking if they're correct
lib/membrane_webrtc/source.ex
Outdated
| By default only `:vp8`. | ||
| """ | ||
| ], | ||
| suggested_video_codec: [ |
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.
| suggested_video_codec: [ | |
| preferred_video_codec: [ |
lib/membrane_webrtc/source.ex
Outdated
| spec: :vp8 | :h264 | [:vp8 | :h264], | ||
| default: :vp8, | ||
| description: """ | ||
| Specyfies, which video codecs can be accepted by source during the SDP |
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.
| Specyfies, which video codecs can be accepted by source during the SDP | |
| Specifies, which video codecs can be accepted by the source during the SDP |
lib/membrane_webrtc/source.ex
Outdated
| Usage of this option makes sense only if option `:allowed_video_codecs` | ||
| is set to `[:vp8, :h264]` or `[:h264, :vp8]`. |
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.
| Usage of this option makes sense only if option `:allowed_video_codecs` | |
| is set to `[:vp8, :h264]` or `[:h264, :vp8]`. | |
| Usage of this option makes sense only if there are at least 2 codecs | |
| specified in the `:allowed_video_codecs` option. |
| video_codecs_in_sdp = ExWebRTCUtils.get_video_codecs_from_sdp(sdp) | ||
|
|
||
| negotiated_video_codecs = | ||
| state.allowed_video_codecs | ||
| |> Enum.filter(&(&1 in video_codecs_in_sdp)) | ||
| |> case do | ||
| [] -> [] | ||
| [codec] -> [codec] | ||
| _both -> [state.suggested_video_codec] | ||
| end | ||
|
|
||
| video_params = ExWebRTCUtils.codec_params(negotiated_video_codecs) | ||
|
|
||
| {:ok, pc} = | ||
| PeerConnection.start( | ||
| ice_servers: state.ice_servers, | ||
| video_codecs: video_params, | ||
| audio_codecs: state.audio_params | ||
| ) | ||
|
|
||
| Process.monitor(pc) | ||
|
|
||
| notify_parent = [notify_parent: {:negotiated_video_codecs, negotiated_video_codecs}] | ||
| {notify_parent, %{state | pc: pc, video_params: video_params}} |
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 function is now quite long, let's extract this to a private one
…eo-codecs-in-source
77d97ff to
90e7f31
Compare
| use ExUnit.Case, async: true | ||
|
|
||
| use ExUnit.Case, async: true | ||
|
|
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.
All the added assertions only test one case, I don't think it helps much. I meant to add a separate test and check a few possibilities
lib/membrane_webrtc/source.ex
Outdated
| def handle_child_notification(_notification, {ff, _ref}, _ctx, state) | ||
| when ff in [:first_ff, :second_ff] 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.
| def handle_child_notification(_notification, {ff, _ref}, _ctx, state) | |
| when ff in [:first_ff, :second_ff] do | |
| def handle_child_notification(_notification, _child, _ctx, state) do |
lib/membrane_webrtc/source.ex
Outdated
| if kind == :video and state.negotiated_video_codecs == nil, | ||
| do: state |> Map.update!(:awaiting_pads, &MapSet.put(&1, pad_ref)), | ||
| else: state |
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.
let's move it into the cond and return {actions, state} from there
Continuation #9 but in source