-
Notifications
You must be signed in to change notification settings - Fork 826
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
Implement audio video synchronization #4325
base: master
Are you sure you want to change the base?
Conversation
An early comment since it's still a draft. Perhaps removing the |
Sure, actually early feedbacks is one of the goal of creating this draft.
Yes, the sync module is generic for any media, especially delivered via RTP/RTCP and using a shared/synchronized NTP source. IMO the 'av_sync' prefix will enhance intuitiveness, i.e: it sounds related to presentation time synchronization. While 'sync' prefix may be somewhat ambiguous, e.g: what to sync?. I recall how 'ssl_sock' term was chosen over |
The term should be inter-media synchronization, but yes, it's not quite as catchy, so I suppose it's okay if the 'av' stays. |
The jitter buffer is designed for audio, while in video it is just a normal/dummy buffer. Hence managing delay in audio stream is much easier than in video stream. As normally video presentation is later than audio, it should be fine to adjust the delay in audio stream only for the synchronization.
@@ -330,11 +326,15 @@ PJ_DEF(pj_int32_t) pjmedia_av_sync_update_pts( | |||
pj_sub_timestamp(&ntp_diff, &media->last_ntp); | |||
ms_diff = ntp_to_ms(&ntp_diff); | |||
|
|||
/* Smoothen and round down the delay */ | |||
ms_diff = ((ms_diff + 19 * media->smooth_diff) / 200) * 10; |
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.
Should an upper bound considered? Where does the magic numbers come from?
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.
Just added the upper bound 60s in the last commit, actually not really sure if it is needed.
The magic numbers are weighting for the smoothing, i.e: last delay uses weight of 19, newly received delay uses weight of 1, then divide the sum by 20 for the new delay. Instead of by 20, it is by 200 then multiplied to 10 for rounding down to nearest 10.
Thanks for the feedback.
Ready to review perhaps :) Currently the delay adjustment is implemented in audio stream only, because:
|
Sorry, quick question about that: Are there any specific plans to implement this (more specifically: RTT with T.140)? |
Yes, I'm currently implementing it. The basic functionality is already working (can send and receive text), but there's still a lot more to do, such as redundancy, docs, etc. |
If this work available publicly? From a quick glance I couldn't find a proper branch. |
How it works in general:
pjmedia_av_sync_create()
.pjmedia_av_sync_add_media()
.pjmedia_av_sync_update_ref()
.Logic in
pjmedia_av_sync_update_pts()
:max_ntp
. Otherwise, calculate the difference/delay of this pts to themax_ntp
, then request the media to speed up as much as the delay.Changes needed in stream: