| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 4  *  Use of this source code is governed by a BSD-style license | 
| 5  *  that can be found in the LICENSE file in the root of the source | 5  *  that can be found in the LICENSE file in the root of the source | 
| 6  *  tree. An additional intellectual property rights grant can be found | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| 11 #ifndef WEBRTC_VIDEO_STREAM_SYNCHRONIZATION_H_ | 11 #ifndef WEBRTC_VIDEO_STREAM_SYNCHRONIZATION_H_ | 
| 12 #define WEBRTC_VIDEO_STREAM_SYNCHRONIZATION_H_ | 12 #define WEBRTC_VIDEO_STREAM_SYNCHRONIZATION_H_ | 
| 13 | 13 | 
| 14 #include <list> | 14 #include <list> | 
| 15 | 15 | 
| 16 #include "webrtc/system_wrappers/include/rtp_to_ntp_estimator.h" | 16 #include "webrtc/system_wrappers/include/rtp_to_ntp_estimator.h" | 
| 17 #include "webrtc/typedefs.h" | 17 #include "webrtc/typedefs.h" | 
| 18 | 18 | 
| 19 namespace webrtc { | 19 namespace webrtc { | 
| 20 | 20 | 
| 21 class StreamSynchronization { | 21 class StreamSynchronization { | 
| 22  public: | 22  public: | 
| 23   struct Measurements { | 23   struct Measurements { | 
| 24     Measurements() : latest_receive_time_ms(0), latest_timestamp(0) {} | 24     Measurements() : latest_receive_time_ms(0), latest_timestamp(0) {} | 
| 25     RtpToNtpEstimator rtp_to_ntp; | 25     RtpToNtpEstimator rtp_to_ntp; | 
| 26     int64_t latest_receive_time_ms; | 26     int64_t latest_receive_time_ms; | 
| 27     uint32_t latest_timestamp; | 27     uint32_t latest_timestamp; | 
| 28   }; | 28   }; | 
| 29 | 29 | 
| 30   StreamSynchronization(uint32_t video_primary_ssrc, int audio_channel_id); | 30   StreamSynchronization(int video_stream_id, int audio_stream_id); | 
| 31 | 31 | 
| 32   bool ComputeDelays(int relative_delay_ms, | 32   bool ComputeDelays(int relative_delay_ms, | 
| 33                      int current_audio_delay_ms, | 33                      int current_audio_delay_ms, | 
| 34                      int* extra_audio_delay_ms, | 34                      int* extra_audio_delay_ms, | 
| 35                      int* total_video_delay_target_ms); | 35                      int* total_video_delay_target_ms); | 
| 36 | 36 | 
| 37   // On success |relative_delay| contains the number of milliseconds later video | 37   // On success |relative_delay| contains the number of milliseconds later video | 
| 38   // is rendered relative audio. If audio is played back later than video a | 38   // is rendered relative audio. If audio is played back later than video a | 
| 39   // |relative_delay| will be negative. | 39   // |relative_delay| will be negative. | 
| 40   static bool ComputeRelativeDelay(const Measurements& audio_measurement, | 40   static bool ComputeRelativeDelay(const Measurements& audio_measurement, | 
| 41                                    const Measurements& video_measurement, | 41                                    const Measurements& video_measurement, | 
| 42                                    int* relative_delay_ms); | 42                                    int* relative_delay_ms); | 
| 43   // Set target buffering delay - All audio and video will be delayed by at | 43   // Set target buffering delay - All audio and video will be delayed by at | 
| 44   // least target_delay_ms. | 44   // least target_delay_ms. | 
| 45   void SetTargetBufferingDelay(int target_delay_ms); | 45   void SetTargetBufferingDelay(int target_delay_ms); | 
| 46 | 46 | 
| 47  private: | 47  private: | 
| 48   struct SynchronizationDelays { | 48   struct SynchronizationDelays { | 
| 49     int extra_video_delay_ms = 0; | 49     int extra_video_delay_ms = 0; | 
| 50     int last_video_delay_ms = 0; | 50     int last_video_delay_ms = 0; | 
| 51     int extra_audio_delay_ms = 0; | 51     int extra_audio_delay_ms = 0; | 
| 52     int last_audio_delay_ms = 0; | 52     int last_audio_delay_ms = 0; | 
| 53   }; | 53   }; | 
| 54 | 54 | 
| 55   SynchronizationDelays channel_delay_; | 55   SynchronizationDelays channel_delay_; | 
| 56   const uint32_t video_primary_ssrc_; | 56   const int video_stream_id_; | 
| 57   const int audio_channel_id_; | 57   const int audio_stream_id_; | 
| 58   int base_target_delay_ms_; | 58   int base_target_delay_ms_; | 
| 59   int avg_diff_ms_; | 59   int avg_diff_ms_; | 
| 60 }; | 60 }; | 
| 61 }  // namespace webrtc | 61 }  // namespace webrtc | 
| 62 | 62 | 
| 63 #endif  // WEBRTC_VIDEO_STREAM_SYNCHRONIZATION_H_ | 63 #endif  // WEBRTC_VIDEO_STREAM_SYNCHRONIZATION_H_ | 
| OLD | NEW | 
|---|