andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #ifndef WEBRTC_VIDEO_ENGINE_STREAM_SYNCHRONIZATION_H_ |
| 12 | #define WEBRTC_VIDEO_ENGINE_STREAM_SYNCHRONIZATION_H_ |
| 13 | |
| 14 | #include <list> |
| 15 | |
pbos@webrtc.org | 281cff8 | 2013-05-17 13:44:48 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/remote_bitrate_estimator/include/rtp_to_ntp.h" |
| 17 | #include "webrtc/typedefs.h" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | struct ViESyncDelay; |
| 22 | |
| 23 | class StreamSynchronization { |
| 24 | public: |
| 25 | struct Measurements { |
| 26 | Measurements() : rtcp(), latest_receive_time_ms(0), latest_timestamp(0) {} |
| 27 | synchronization::RtcpList rtcp; |
| 28 | int64_t latest_receive_time_ms; |
| 29 | uint32_t latest_timestamp; |
| 30 | }; |
| 31 | |
| 32 | StreamSynchronization(int audio_channel_id, int video_channel_id); |
| 33 | ~StreamSynchronization(); |
| 34 | |
| 35 | bool ComputeDelays(int relative_delay_ms, |
| 36 | int current_audio_delay_ms, |
| 37 | int* extra_audio_delay_ms, |
| 38 | int* total_video_delay_target_ms); |
| 39 | |
| 40 | // On success |relative_delay| contains the number of milliseconds later video |
| 41 | // is rendered relative audio. If audio is played back later than video a |
| 42 | // |relative_delay| will be negative. |
| 43 | static bool ComputeRelativeDelay(const Measurements& audio_measurement, |
| 44 | const Measurements& video_measurement, |
| 45 | int* relative_delay_ms); |
mikhal@webrtc.org | 9d6fcb3 | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 46 | // Set target buffering delay - All audio and video will be delayed by at |
| 47 | // least target_delay_ms. |
| 48 | void SetTargetBufferingDelay(int target_delay_ms); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 49 | |
| 50 | private: |
| 51 | ViESyncDelay* channel_delay_; |
| 52 | int audio_channel_id_; |
| 53 | int video_channel_id_; |
mikhal@webrtc.org | 9d6fcb3 | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 54 | int base_target_delay_ms_; |
pwestin@webrtc.org | f13f1fc | 2013-04-22 18:57:14 +0000 | [diff] [blame] | 55 | int avg_diff_ms_; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 56 | }; |
| 57 | } // namespace webrtc |
| 58 | |
| 59 | #endif // WEBRTC_VIDEO_ENGINE_STREAM_SYNCHRONIZATION_H_ |