| 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 // RtpStreamsSynchronizer is responsible for synchronization audio and video for | 11 // RtpStreamsSynchronizer is responsible for synchronization audio and video for |
| 12 // a given voice engine channel and video receive stream. | 12 // a given voice engine channel and video receive stream. |
| 13 | 13 |
| 14 #ifndef WEBRTC_VIDEO_RTP_STREAMS_SYNCHRONIZER_H_ | 14 #ifndef WEBRTC_VIDEO_RTP_STREAMS_SYNCHRONIZER_H_ |
| 15 #define WEBRTC_VIDEO_RTP_STREAMS_SYNCHRONIZER_H_ | 15 #define WEBRTC_VIDEO_RTP_STREAMS_SYNCHRONIZER_H_ |
| 16 | 16 |
| 17 #include <memory> | 17 #include <memory> |
| 18 | 18 |
| 19 #include "webrtc/base/criticalsection.h" | 19 #include "webrtc/base/criticalsection.h" |
| 20 #include "webrtc/base/thread_checker.h" | 20 #include "webrtc/base/thread_checker.h" |
| 21 #include "webrtc/modules/include/module.h" | 21 #include "webrtc/modules/include/module.h" |
| 22 #include "webrtc/video/rtp_stream_receiver.h" | 22 #include "webrtc/video/rtp_stream_receiver.h" |
| 23 #include "webrtc/video/stream_synchronization.h" | 23 #include "webrtc/video/stream_synchronization.h" |
| 24 | 24 |
| 25 namespace webrtc { | 25 namespace webrtc { |
| 26 | 26 |
| 27 class Clock; | 27 class Clock; |
| 28 class Syncable; |
| 28 class VideoFrame; | 29 class VideoFrame; |
| 29 class VoEVideoSync; | |
| 30 | 30 |
| 31 namespace vcm { | 31 namespace vcm { |
| 32 class VideoReceiver; | 32 class VideoReceiver; |
| 33 } // namespace vcm | 33 } // namespace vcm |
| 34 | 34 |
| 35 class RtpStreamsSynchronizer : public Module { | 35 class RtpStreamsSynchronizer : public Module { |
| 36 public: | 36 public: |
| 37 RtpStreamsSynchronizer(vcm::VideoReceiver* vcm, | 37 RtpStreamsSynchronizer(vcm::VideoReceiver* vcm, |
| 38 RtpStreamReceiver* rtp_stream_receiver); | 38 RtpStreamReceiver* rtp_stream_receiver); |
| 39 | 39 |
| 40 void ConfigureSync(int voe_channel_id, | 40 void ConfigureSync(Syncable* syncable); |
| 41 VoEVideoSync* voe_sync_interface); | |
| 42 | 41 |
| 43 // Implements Module. | 42 // Implements Module. |
| 44 int64_t TimeUntilNextProcess() override; | 43 int64_t TimeUntilNextProcess() override; |
| 45 void Process() override; | 44 void Process() override; |
| 46 | 45 |
| 47 // Gets the sync offset between the current played out audio frame and the | 46 // Gets the sync offset between the current played out audio frame and the |
| 48 // video |frame|. Returns true on success, false otherwise. | 47 // video |frame|. Returns true on success, false otherwise. |
| 49 // The estimated frequency is the frequency used in the RTP to NTP timestamp | 48 // The estimated frequency is the frequency used in the RTP to NTP timestamp |
| 50 // conversion. | 49 // conversion. |
| 51 bool GetStreamSyncOffsetInMs(const VideoFrame& frame, | 50 bool GetStreamSyncOffsetInMs(const VideoFrame& frame, |
| 52 int64_t* stream_offset_ms, | 51 int64_t* stream_offset_ms, |
| 53 double* estimated_freq_khz) const; | 52 double* estimated_freq_khz) const; |
| 54 | 53 |
| 55 private: | 54 private: |
| 56 Clock* const clock_; | 55 Clock* const clock_; |
| 57 vcm::VideoReceiver* const video_receiver_; | 56 vcm::VideoReceiver* const video_receiver_; |
| 58 RtpReceiver* const video_rtp_receiver_; | 57 RtpReceiver* const video_rtp_receiver_; |
| 59 RtpRtcp* const video_rtp_rtcp_; | 58 RtpRtcp* const video_rtp_rtcp_; |
| 60 | 59 |
| 61 rtc::CriticalSection crit_; | 60 rtc::CriticalSection crit_; |
| 62 int voe_channel_id_ GUARDED_BY(crit_); | 61 Syncable* syncable_ GUARDED_BY(crit_); |
| 63 VoEVideoSync* voe_sync_interface_ GUARDED_BY(crit_); | |
| 64 RtpReceiver* audio_rtp_receiver_ GUARDED_BY(crit_); | |
| 65 RtpRtcp* audio_rtp_rtcp_ GUARDED_BY(crit_); | |
| 66 std::unique_ptr<StreamSynchronization> sync_ GUARDED_BY(crit_); | 62 std::unique_ptr<StreamSynchronization> sync_ GUARDED_BY(crit_); |
| 67 StreamSynchronization::Measurements audio_measurement_ GUARDED_BY(crit_); | 63 StreamSynchronization::Measurements audio_measurement_ GUARDED_BY(crit_); |
| 68 StreamSynchronization::Measurements video_measurement_ GUARDED_BY(crit_); | 64 StreamSynchronization::Measurements video_measurement_ GUARDED_BY(crit_); |
| 69 | 65 |
| 70 rtc::ThreadChecker process_thread_checker_; | 66 rtc::ThreadChecker process_thread_checker_; |
| 71 int64_t last_sync_time_ ACCESS_ON(&process_thread_checker_); | 67 int64_t last_sync_time_ ACCESS_ON(&process_thread_checker_); |
| 72 }; | 68 }; |
| 73 | 69 |
| 74 } // namespace webrtc | 70 } // namespace webrtc |
| 75 | 71 |
| 76 #endif // WEBRTC_VIDEO_RTP_STREAMS_SYNCHRONIZER_H_ | 72 #endif // WEBRTC_VIDEO_RTP_STREAMS_SYNCHRONIZER_H_ |
| OLD | NEW |