1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #ifndef VIDEO_STREAM_SYNCHRONIZATION_H_
- #define VIDEO_STREAM_SYNCHRONIZATION_H_
- #include <stdint.h>
- #include "system_wrappers/include/rtp_to_ntp_estimator.h"
- namespace webrtc {
- class StreamSynchronization {
- public:
- struct Measurements {
- Measurements() : latest_receive_time_ms(0), latest_timestamp(0) {}
- RtpToNtpEstimator rtp_to_ntp;
- int64_t latest_receive_time_ms;
- uint32_t latest_timestamp;
- };
- StreamSynchronization(uint32_t video_stream_id, uint32_t audio_stream_id);
- bool ComputeDelays(int relative_delay_ms,
- int current_audio_delay_ms,
- int* total_audio_delay_target_ms,
- int* total_video_delay_target_ms);
-
-
-
- static bool ComputeRelativeDelay(const Measurements& audio_measurement,
- const Measurements& video_measurement,
- int* relative_delay_ms);
-
-
- void SetTargetBufferingDelay(int target_delay_ms);
-
- void ReduceAudioDelay();
-
- void ReduceVideoDelay();
- uint32_t audio_stream_id() const { return audio_stream_id_; }
- uint32_t video_stream_id() const { return video_stream_id_; }
- private:
- struct SynchronizationDelays {
- int extra_ms = 0;
- int last_ms = 0;
- };
- const uint32_t video_stream_id_;
- const uint32_t audio_stream_id_;
- SynchronizationDelays audio_delay_;
- SynchronizationDelays video_delay_;
- int base_target_delay_ms_;
- int avg_diff_ms_;
- };
- }
- #endif
|