Skip to content

Conversation

@FelonEkonom
Copy link
Member

Continuation #9 but in source

@FelonEkonom FelonEkonom marked this pull request as ready for review October 25, 2024 14:36
@FelonEkonom FelonEkonom requested a review from mat-hek October 25, 2024 14:36
Copy link
Member

@mat-hek mat-hek left a 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

By default only `:vp8`.
"""
],
suggested_video_codec: [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
suggested_video_codec: [
preferred_video_codec: [

spec: :vp8 | :h264 | [:vp8 | :h264],
default: :vp8,
description: """
Specyfies, which video codecs can be accepted by source during the SDP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment on lines 65 to 66
Usage of this option makes sense only if option `:allowed_video_codecs`
is set to `[:vp8, :h264]` or `[:h264, :vp8]`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment on lines 204 to 227
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}}
Copy link
Member

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

@FelonEkonom FelonEkonom requested a review from mat-hek November 6, 2024 12:47
@FelonEkonom FelonEkonom force-pushed the support-various-video-codecs-in-source branch from 77d97ff to 90e7f31 Compare November 6, 2024 12:58
@FelonEkonom FelonEkonom self-assigned this Nov 7, 2024
use ExUnit.Case, async: true

use ExUnit.Case, async: true

Copy link
Member

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

@FelonEkonom FelonEkonom requested a review from mat-hek November 13, 2024 09:17
Comment on lines 213 to 214
def handle_child_notification(_notification, {ff, _ref}, _ctx, state)
when ff in [:first_ff, :second_ff] do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment on lines 181 to 183
if kind == :video and state.negotiated_video_codecs == nil,
do: state |> Map.update!(:awaiting_pads, &MapSet.put(&1, pad_ref)),
else: state
Copy link
Member

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

@FelonEkonom FelonEkonom requested a review from mat-hek November 20, 2024 18:15
@FelonEkonom FelonEkonom merged commit 71f23f6 into master Nov 22, 2024
2 of 3 checks passed
@FelonEkonom FelonEkonom deleted the support-various-video-codecs-in-source branch November 22, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants