aboutsummaryrefslogtreecommitdiff
path: root/webrtc/voice_engine/include/voe_video_sync.h
blob: 1143cefb0e163dffa8ef416e8003d1b604c633a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

// This sub-API supports the following functionalities:
//
//  - RTP header modification (time stamp and sequence number fields).
//  - Playout delay tuning to synchronize the voice with video.
//  - Playout delay monitoring.
//
// Usage example, omitting error checking:
//
//  using namespace webrtc;
//  VoiceEngine* voe = VoiceEngine::Create();
//  VoEBase* base = VoEBase::GetInterface(voe);
//  VoEVideoSync* vsync  = VoEVideoSync::GetInterface(voe);
//  base->Init();
//  ...
//  int buffer_ms(0);
//  vsync->GetPlayoutBufferSize(buffer_ms);
//  ...
//  base->Terminate();
//  base->Release();
//  vsync->Release();
//  VoiceEngine::Delete(voe);
//
#ifndef WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H
#define WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H

#include "webrtc/common_types.h"

namespace webrtc {

class RtpReceiver;
class RtpRtcp;
class VoiceEngine;

class WEBRTC_DLLEXPORT VoEVideoSync {
 public:
  // Factory for the VoEVideoSync sub-API. Increases an internal
  // reference counter if successful. Returns NULL if the API is not
  // supported or if construction fails.
  static VoEVideoSync* GetInterface(VoiceEngine* voiceEngine);

  // Releases the VoEVideoSync sub-API and decreases an internal
  // reference counter. Returns the new reference count. This value should
  // be zero for all sub-API:s before the VoiceEngine object can be safely
  // deleted.
  virtual int Release() = 0;

  // Gets the current sound card buffer size (playout delay).
  virtual int GetPlayoutBufferSize(int& buffer_ms) = 0;

  // Sets a minimum target delay for the jitter buffer. This delay is
  // maintained by the jitter buffer, unless channel condition (jitter in
  // inter-arrival times) dictates a higher required delay. The overall
  // jitter buffer delay is max of |delay_ms| and the latency that NetEq
  // computes based on inter-arrival times and its playout mode.
  virtual int SetMinimumPlayoutDelay(int channel, int delay_ms) = 0;

  // Sets an initial delay for the playout jitter buffer. The playout of the
  // audio is delayed by |delay_ms| in milliseconds. Thereafter, the delay is
  // maintained, unless NetEq's internal mechanism requires a higher latency.
  // Such a latency is computed based on inter-arrival times and NetEq's
  // playout mode.
  virtual int SetInitialPlayoutDelay(int channel, int delay_ms) = 0;

  // Gets the |jitter_buffer_delay_ms| (including the algorithmic delay), and
  // the |playout_buffer_delay_ms| for a specified |channel|.
  virtual int GetDelayEstimate(int channel,
                               int* jitter_buffer_delay_ms,
                               int* playout_buffer_delay_ms) = 0;

  // Returns the least required jitter buffer delay. This is computed by the
  // the jitter buffer based on the inter-arrival time of RTP packets and
  // playout mode. NetEq maintains this latency unless a higher value is
  // requested by calling SetMinimumPlayoutDelay().
  virtual int GetLeastRequiredDelayMs(int channel) const = 0;

  // Manual initialization of the RTP timestamp.
  virtual int SetInitTimestamp(int channel, unsigned int timestamp) = 0;

  // Manual initialization of the RTP sequence number.
  virtual int SetInitSequenceNumber(int channel, short sequenceNumber) = 0;

  // Get the received RTP timestamp
  virtual int GetPlayoutTimestamp(int channel, unsigned int& timestamp) = 0;

  virtual int GetRtpRtcp(int channel,
                         RtpRtcp** rtpRtcpModule,
                         RtpReceiver** rtp_receiver) = 0;

 protected:
  VoEVideoSync() {}
  virtual ~VoEVideoSync() {}
};

}  // namespace webrtc

#endif  // #ifndef WEBRTC_VOICE_ENGINE_VOE_VIDEO_SYNC_H