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

Rtcp sender packet event #393

Merged
merged 16 commits into from
May 24, 2024
Merged

Rtcp sender packet event #393

merged 16 commits into from
May 24, 2024

Conversation

Karolk99
Copy link
Contributor

No description provided.

Copy link

codecov bot commented May 17, 2024

Codecov Report

Attention: Patch coverage is 72.13115% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 55.22%. Comparing base (2708790) to head (84121c5).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #393      +/-   ##
==========================================
+ Coverage   54.95%   55.22%   +0.27%     
==========================================
  Files          75       75              
  Lines        3259     3299      +40     
==========================================
+ Hits         1791     1822      +31     
- Misses       1468     1477       +9     
Files Coverage Δ
recording/lib/edge_timestamp_saver.ex 100.00% <100.00%> (ø)
recording/test/support/mock_track.ex 100.00% <100.00%> (ø)
rtsp/lib/rtsp/connection_manager.ex 82.65% <100.00%> (+2.04%) ⬆️
webrtc/lib/endpoint_bin/endpoint_bin.ex 37.19% <100.00%> (ø)
webrtc/lib/endpoint_bin/extension/mid.ex 83.33% <100.00%> (ø)
webrtc/lib/endpoint_bin/extension/rid.ex 83.33% <100.00%> (ø)
webrtc/lib/endpoint_bin/track.ex 77.10% <100.00%> (ø)
webrtc/lib/endpoint_bin/extension/repaired_rid.ex 16.66% <0.00%> (ø)
webrtc/lib/endpoint_bin/extension/twcc.ex 0.00% <0.00%> (ø)
webrtc/lib/endpoint_bin/extension/vad.ex 0.00% <0.00%> (ø)
... and 7 more

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 2708790...84121c5. Read the comment docs.


defp add_wallclock_start_time(track, rtcp) do
delta_t_ns =
(rtcp.sender_info.rtp_timestamp - track.start_timestamp) / track.clock_rate * 10 ** 9
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move this number to constant?

Comment on lines 155 to 211
defp recalculate_offsets(tracks) do
{tracks, _acc} =
tracks
|> Enum.sort_by(fn {_filename, track} -> track.offset end)
|> Enum.map_reduce(nil, fn {filename, track}, acc ->
cond do
not Map.has_key?(track, :start_timestamp_wallclock) ->
{{filename, track}, acc}

is_nil(acc) ->
{{filename, track}, track}

true ->
offset = acc.offset + track.start_timestamp_wallclock - acc.start_timestamp_wallclock
{{filename, %{track | offset: offset}}, acc}
end
end)

tracks
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Some comments are needed about how this synchronization works and why we do it that way.

@Karolk99 Karolk99 marked this pull request as ready for review May 20, 2024 13:35
@Karolk99 Karolk99 requested a review from Rados13 May 20, 2024 13:38
Copy link
Contributor

@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.

Looks cool! Just a one comment regarding docs in Report that I believe is important. We also need to add at least unit tests for reporter that will check rtcp sync

recording/lib/reporter.ex Show resolved Hide resolved
@sgfn sgfn self-requested a review May 22, 2024 09:01
@Karolk99 Karolk99 requested review from mickel8 and Rados13 May 24, 2024 10:15
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could add another test where only two tracks have RTCP reports but they are not in order e.g: second and fourth will have RTCP reports.


events =
for _idx <- 0..events do
{:event, {:output, %RTCPEvent{rtcp: rtcp}}}
Copy link
Contributor

Choose a reason for hiding this comment

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

This way, we don't know if the last RTCPEvent is saved or the last one, as we generate five of the same events.

@@ -166,4 +171,150 @@ defmodule Membrane.RTC.Engine.Endpoint.Recording.ReporterTest do
}
} = Reporter.get_report(reporter)
end

describe "RTCP synchronization" do
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add some comments about how this test should work for future contributors, as it is not obvious how each of these tests works.

@Karolk99 Karolk99 merged commit acc80de into master May 24, 2024
39 checks passed
@Karolk99 Karolk99 deleted the rtcp-sender-packet-event branch May 24, 2024 13:07
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

4 participants