Skip to content
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

Sending RTCP Reports #81

Merged
merged 10 commits into from
Mar 11, 2024
Merged

Sending RTCP Reports #81

merged 10 commits into from
Mar 11, 2024

Conversation

LVala
Copy link
Member

@LVala LVala commented Mar 4, 2024

This PR utilises previously added RTPSender.ReportRecorder and RTPReceiver.ReportRecorder modules to actually track incoming packets and send corresponding RTCP Sender and Receiver Reports.

@LVala LVala self-assigned this Mar 4, 2024
@LVala LVala mentioned this pull request Mar 4, 2024
46 tasks
Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Merging #81 (218767b) into master (e4d664e) will decrease coverage by 0.74%.
Report is 1 commits behind head on master.
The diff coverage is 78.72%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
- Coverage   88.80%   88.06%   -0.74%     
==========================================
  Files          31       31              
  Lines        1411     1492      +81     
==========================================
+ Hits         1253     1314      +61     
- Misses        158      178      +20     
Files Coverage Δ
lib/ex_webrtc/rtp_sender.ex 100.00% <100.00%> (ø)
lib/ex_webrtc/rtp_receiver/report_recorder.ex 96.66% <87.50%> (-1.45%) ⬇️
lib/ex_webrtc/rtp_sender/report_recorder.ex 96.96% <87.50%> (+0.54%) ⬆️
lib/ex_webrtc/rtp_receiver.ex 92.30% <88.23%> (-7.70%) ⬇️
lib/ex_webrtc/rtp_transceiver.ex 92.30% <86.66%> (-1.76%) ⬇️
lib/ex_webrtc/peer_connection.ex 85.39% <50.00%> (-1.75%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e4d664e...218767b. Read the comment docs.

@LVala LVala marked this pull request as ready for review March 7, 2024 18:09
@LVala LVala requested a review from mickel8 March 7, 2024 18:09
Copy link
Member

@mickel8 mickel8 left a comment

Choose a reason for hiding this comment

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

Awesome! No blocking changes except this comment: #81 (comment)

lib/ex_webrtc/peer_connection.ex Outdated Show resolved Hide resolved
lib/ex_webrtc/rtp_receiver/report_recorder.ex Outdated Show resolved Hide resolved
lib/ex_webrtc/peer_connection.ex Show resolved Hide resolved
@spec new(MediaStreamTrack.t(), RTPCodecParameters.t() | nil) :: t()
def new(track, codec) do
report_recorder = %ReportRecorder{
clock_rate: codec && codec.clock_rate
Copy link
Member

Choose a reason for hiding this comment

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

Smart! Looks like optional 🤯

lib/ex_webrtc/rtp_receiver/report_recorder.ex Show resolved Hide resolved
lib/ex_webrtc/rtp_receiver/report_recorder.ex Outdated Show resolved Hide resolved
@@ -1,5 +1,5 @@
defmodule ExWebRTC.RTPReceiver.ReportRecorder do
@moduledoc false
@moduledoc nil
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
@moduledoc nil
@moduledoc false

Copy link
Member Author

Choose a reason for hiding this comment

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

I wish, ReportRecorder is a part of a RTPReceiver.t() and RTPSender.t() typespecs, we can either make it public (like here) or remove the fields from sender's and receiver's typespecs.

lib/ex_webrtc/rtp_transceiver.ex Outdated Show resolved Hide resolved
lib/ex_webrtc/rtp_transceiver.ex Show resolved Hide resolved
@@ -132,14 +146,18 @@ defmodule ExWebRTC.RTPTransceiver do

codecs = get_codecs(mline, config)
rtp_hdr_exts = get_rtp_hdr_extensions(mline, config)
sender = RTPSender.update(transceiver.sender, mid, List.first(codecs), rtp_hdr_exts)
codec = List.first(codecs)
Copy link
Member

Choose a reason for hiding this comment

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

In theory, the other side may send data using any payload format negotiated in SDP offer/answer. IIRC, they can even switch between codecs during the session without renegotiation. I don't want to handle that behaviour but maybe we should somewhere ensure that a packet we receive has expected payload type?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was considering this, but we only really care about the clock rate here (if codec changes, but the clock rate remains the same, it's all good).

AFAIR if clock rate changes, the source should generate a new RTP stream (and SSRC) for that, so we don't really have to care (I cannot find the RFC that specified that atm).

Even if it did, we only risk one invalid report, so it's not very critical I'd say.

Copy link
Member Author

Choose a reason for hiding this comment

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

@mickel8 mickel8 self-requested a review March 11, 2024 12:14
@LVala LVala merged commit 1d63ba8 into master Mar 11, 2024
4 checks passed
@LVala LVala deleted the rtcp-reports branch March 11, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants