blob: 25a370cf2db88031ff83f65daa7836e28d63c3bb [file] [log] [blame]
stefan@webrtc.org5f284982012-06-28 07:51:16 +00001/*
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
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000014#include <list>
15
stefan@webrtc.org64d9dec2012-09-26 16:47:40 +000016#include "modules/remote_bitrate_estimator/include/rtp_to_ntp.h"
mflodman@webrtc.orgab2610f2012-06-29 10:05:28 +000017#include "typedefs.h" // NOLINT
stefan@webrtc.org5f284982012-06-28 07:51:16 +000018
19namespace webrtc {
20
21struct ViESyncDelay;
22
23class StreamSynchronization {
24 public:
25 struct Measurements {
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000026 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;
stefan@webrtc.org5f284982012-06-28 07:51:16 +000030 };
31
32 StreamSynchronization(int audio_channel_id, int video_channel_id);
33 ~StreamSynchronization();
34
stefan@webrtc.org7c3523c2012-09-11 07:00:42 +000035 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);
stefan@webrtc.org5f284982012-06-28 07:51:16 +000046
47 private:
48 ViESyncDelay* channel_delay_;
49 int audio_channel_id_;
50 int video_channel_id_;
51};
stefan@webrtc.org5f284982012-06-28 07:51:16 +000052} // namespace webrtc
53
54#endif // WEBRTC_VIDEO_ENGINE_STREAM_SYNCHRONIZATION_H_