blob: 655ba6354368f1a94e9821e7a47f74e3a0557249 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 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// This sub-API supports the following functionalities:
12//
13// - RTP header modification (time stamp and sequence number fields).
14// - Playout delay tuning to synchronize the voice with video.
15// - Playout delay monitoring.
16//
17// Usage example, omitting error checking:
18//
19// using namespace webrtc;
20// VoiceEngine* voe = VoiceEngine::Create();
21// VoEBase* base = VoEBase::GetInterface(voe);
22// VoEVideoSync* vsync = VoEVideoSync::GetInterface(voe);
23// base->Init();
24// ...
25// int buffer_ms(0);
26// vsync->GetPlayoutBufferSize(buffer_ms);
27// ...
28// base->Terminate();
29// base->Release();
30// vsync->Release();
31// VoiceEngine::Delete(voe);
32//
33#ifndef WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H
34#define WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H
35
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +000036#include "webrtc/common_types.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000037
38namespace webrtc {
39
wu@webrtc.org822fbd82013-08-15 23:38:54 +000040class RtpReceiver;
niklase@google.com470e71d2011-07-07 08:21:25 +000041class RtpRtcp;
42class VoiceEngine;
43
Jelena Marusic0d266052015-05-04 14:15:32 +020044class WEBRTC_DLLEXPORT VoEVideoSync {
45 public:
46 // Factory for the VoEVideoSync sub-API. Increases an internal
47 // reference counter if successful. Returns NULL if the API is not
48 // supported or if construction fails.
49 static VoEVideoSync* GetInterface(VoiceEngine* voiceEngine);
niklase@google.com470e71d2011-07-07 08:21:25 +000050
Jelena Marusic0d266052015-05-04 14:15:32 +020051 // Releases the VoEVideoSync sub-API and decreases an internal
52 // reference counter. Returns the new reference count. This value should
53 // be zero for all sub-API:s before the VoiceEngine object can be safely
54 // deleted.
55 virtual int Release() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000056
Jelena Marusic0d266052015-05-04 14:15:32 +020057 // Gets the current sound card buffer size (playout delay).
58 virtual int GetPlayoutBufferSize(int& buffer_ms) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000059
Jelena Marusic0d266052015-05-04 14:15:32 +020060 // Sets a minimum target delay for the jitter buffer. This delay is
61 // maintained by the jitter buffer, unless channel condition (jitter in
62 // inter-arrival times) dictates a higher required delay. The overall
63 // jitter buffer delay is max of |delay_ms| and the latency that NetEq
64 // computes based on inter-arrival times and its playout mode.
65 virtual int SetMinimumPlayoutDelay(int channel, int delay_ms) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000066
Jelena Marusic0d266052015-05-04 14:15:32 +020067 // Gets the |jitter_buffer_delay_ms| (including the algorithmic delay), and
68 // the |playout_buffer_delay_ms| for a specified |channel|.
69 virtual int GetDelayEstimate(int channel,
70 int* jitter_buffer_delay_ms,
71 int* playout_buffer_delay_ms) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000072
Jelena Marusic0d266052015-05-04 14:15:32 +020073 // Returns the least required jitter buffer delay. This is computed by the
74 // the jitter buffer based on the inter-arrival time of RTP packets and
75 // playout mode. NetEq maintains this latency unless a higher value is
76 // requested by calling SetMinimumPlayoutDelay().
77 virtual int GetLeastRequiredDelayMs(int channel) const = 0;
turaj@webrtc.orge46c8d32013-05-22 20:39:43 +000078
Jelena Marusic0d266052015-05-04 14:15:32 +020079 // Manual initialization of the RTP timestamp.
80 virtual int SetInitTimestamp(int channel, unsigned int timestamp) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000081
Jelena Marusic0d266052015-05-04 14:15:32 +020082 // Manual initialization of the RTP sequence number.
83 virtual int SetInitSequenceNumber(int channel, short sequenceNumber) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000084
Jelena Marusic0d266052015-05-04 14:15:32 +020085 // Get the received RTP timestamp
86 virtual int GetPlayoutTimestamp(int channel, unsigned int& timestamp) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000087
Jelena Marusic0d266052015-05-04 14:15:32 +020088 virtual int GetRtpRtcp(int channel,
89 RtpRtcp** rtpRtcpModule,
90 RtpReceiver** rtp_receiver) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000091
Jelena Marusic0d266052015-05-04 14:15:32 +020092 protected:
93 VoEVideoSync() {}
94 virtual ~VoEVideoSync() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000095};
96
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000097} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000098
99#endif // #ifndef WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H