blob: cf16d3b3cf8e6772bd5d740a67955d9d48579109 [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
44class WEBRTC_DLLEXPORT VoEVideoSync
45{
46public:
47 // Factory for the VoEVideoSync sub-API. Increases an internal
48 // reference counter if successful. Returns NULL if the API is not
49 // supported or if construction fails.
50 static VoEVideoSync* GetInterface(VoiceEngine* voiceEngine);
51
52 // Releases the VoEVideoSync sub-API and decreases an internal
53 // reference counter. Returns the new reference count. This value should
54 // be zero for all sub-API:s before the VoiceEngine object can be safely
55 // deleted.
56 virtual int Release() = 0;
57
58 // Gets the current sound card buffer size (playout delay).
pwestin@webrtc.org1de01352013-04-11 20:23:35 +000059 virtual int GetPlayoutBufferSize(int& buffer_ms) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000060
turaj@webrtc.orge46c8d32013-05-22 20:39:43 +000061 // Sets a minimum target delay for the jitter buffer. This delay is
62 // maintained by the jitter buffer, unless channel condition (jitter in
63 // inter-arrival times) dictates a higher required delay. The overall
64 // jitter buffer delay is max of |delay_ms| and the latency that NetEq
65 // computes based on inter-arrival times and its playout mode.
pwestin@webrtc.org1de01352013-04-11 20:23:35 +000066 virtual int SetMinimumPlayoutDelay(int channel, int delay_ms) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000067
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +000068 // Sets an initial delay for the playout jitter buffer. The playout of the
turaj@webrtc.orge46c8d32013-05-22 20:39:43 +000069 // audio is delayed by |delay_ms| in milliseconds. Thereafter, the delay is
70 // maintained, unless NetEq's internal mechanism requires a higher latency.
71 // Such a latency is computed based on inter-arrival times and NetEq's
72 // playout mode.
turaj@webrtc.org6388c3e2013-02-12 21:42:18 +000073 virtual int SetInitialPlayoutDelay(int channel, int delay_ms) = 0;
74
pwestin@webrtc.org1de01352013-04-11 20:23:35 +000075 // Gets the |jitter_buffer_delay_ms| (including the algorithmic delay), and
76 // the |playout_buffer_delay_ms| for a specified |channel|.
77 virtual int GetDelayEstimate(int channel,
78 int* jitter_buffer_delay_ms,
79 int* playout_buffer_delay_ms) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000080
turaj@webrtc.orge46c8d32013-05-22 20:39:43 +000081 // Returns the least required jitter buffer delay. This is computed by the
82 // the jitter buffer based on the inter-arrival time of RTP packets and
83 // playout mode. NetEq maintains this latency unless a higher value is
84 // requested by calling SetMinimumPlayoutDelay().
85 virtual int GetLeastRequiredDelayMs(int channel) const = 0;
86
niklase@google.com470e71d2011-07-07 08:21:25 +000087 // Manual initialization of the RTP timestamp.
88 virtual int SetInitTimestamp(int channel, unsigned int timestamp) = 0;
89
90 // Manual initialization of the RTP sequence number.
91 virtual int SetInitSequenceNumber(int channel, short sequenceNumber) = 0;
92
93 // Get the received RTP timestamp
94 virtual int GetPlayoutTimestamp(int channel, unsigned int& timestamp) = 0;
95
wu@webrtc.org822fbd82013-08-15 23:38:54 +000096 virtual int GetRtpRtcp (int channel, RtpRtcp** rtpRtcpModule,
97 RtpReceiver** rtp_receiver) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000098
99protected:
100 VoEVideoSync() { }
101 virtual ~VoEVideoSync() { }
102};
103
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +0000104} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000105
106#endif // #ifndef WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H