-
Notifications
You must be signed in to change notification settings - Fork 8
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
bump elixir webrtc to 0.3 #3
Changes from all commits
5c1abbe
f540024
b5dacca
4d68e17
186ab5a
01393f3
6c75273
7318d34
e2f10b6
553b0f6
b42ffff
c739655
bdfcf17
ca0fbaf
901f668
790aed7
8d4c2ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ defmodule Membrane.WebRTC.ExWebRTCSink do | |
SessionDescription | ||
} | ||
|
||
alias ExRTCP.Packet.PayloadFeedback.PLI | ||
|
||
alias Membrane.WebRTC.{ExWebRTCUtils, SignalingChannel, SimpleWebSocketServer} | ||
|
||
def_options signaling: [], tracks: [], video_codec: [], ice_servers: [] | ||
|
@@ -38,7 +40,8 @@ defmodule Membrane.WebRTC.ExWebRTCSink do | |
audio_params: ExWebRTCUtils.codec_params(:opus), | ||
video_params: ExWebRTCUtils.codec_params(opts.video_codec), | ||
video_codec: opts.video_codec, | ||
ice_servers: opts.ice_servers | ||
ice_servers: opts.ice_servers, | ||
last_keyframe_request_ts: nil | ||
}} | ||
end | ||
|
||
|
@@ -133,6 +136,42 @@ defmodule Membrane.WebRTC.ExWebRTCSink do | |
raise "Track #{inspect(track_id)} was rejected by the other peer" | ||
end | ||
|
||
@impl true | ||
def handle_info({:ex_webrtc, _from, {:rtcp, rtcp_packets}}, ctx, state) do | ||
pli? = | ||
rtcp_packets | ||
|> Enum.reduce(false, fn | ||
%PLI{} = packet, _pli? -> | ||
Membrane.Logger.debug("Keyframe request received: #{inspect(packet)}") | ||
true | ||
|
||
packet, pli? -> | ||
Membrane.Logger.debug_verbose("Ignoring RTCP packet: #{inspect(packet)}") | ||
pli? | ||
end) | ||
|
||
now = System.os_time(:millisecond) |> Membrane.Time.milliseconds() | ||
then = state.last_keyframe_request_ts | ||
|
||
request_keyframe? = pli? and (then == nil or now - then >= Membrane.Time.second()) | ||
state = if request_keyframe?, do: %{state | last_keyframe_request_ts: now}, else: state | ||
|
||
actions = | ||
if request_keyframe? do | ||
ctx.pads | ||
|> Enum.flat_map(fn {pad_ref, pad_data} -> | ||
case pad_data.options.kind do | ||
:video -> [event: {pad_ref, %Membrane.KeyframeRequestEvent{}}] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we somehow 'debounce' the keyframe requests? AFAIR the browser is going to spam us with PLIs when it's unable to decode the stream to make sure we receive a PLI ASAP. And we shouldn't generate as many keyframes as PLIs. cc @mickel8 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds resonable but how to distinct between PLI retransmission and real PLI 🤔 |
||
:audio -> [] | ||
end | ||
end) | ||
else | ||
[] | ||
end | ||
|
||
{actions, state} | ||
end | ||
|
||
@impl true | ||
def handle_info({:ex_webrtc, _from, message}, _ctx, state) do | ||
Membrane.Logger.debug("Ignoring ex_webrtc message: #{inspect(message)}") | ||
|
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.
Why sending keyframe on all video pads? Just send on a pad that refers to
track_id
from line 142There 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.
In fact, there is no
track_id
there