blob: e863a28666c05bbf2f8933086cfcc9a73124d7a5 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org0975d212012-03-06 20:59:13 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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// - Callbacks for RTP and RTCP events such as modified SSRC or CSRC.
14// - SSRC handling.
15// - Transmission of RTCP sender reports.
16// - Obtaining RTCP data from incoming RTCP sender reports.
17// - RTP and RTCP statistics (jitter, packet loss, RTT etc.).
minyue@webrtc.orgc1a40a72014-05-28 09:52:06 +000018// - Redundant Coding (RED)
niklase@google.com470e71d2011-07-07 08:21:25 +000019// - Writing RTP and RTCP packets to binary files for off-line analysis of
20// the call quality.
niklase@google.com470e71d2011-07-07 08:21:25 +000021//
22// Usage example, omitting error checking:
23//
24// using namespace webrtc;
25// VoiceEngine* voe = VoiceEngine::Create();
26// VoEBase* base = VoEBase::GetInterface(voe);
27// VoERTP_RTCP* rtp_rtcp = VoERTP_RTCP::GetInterface(voe);
28// base->Init();
29// int ch = base->CreateChannel();
30// ...
31// rtp_rtcp->SetLocalSSRC(ch, 12345);
32// ...
33// base->DeleteChannel(ch);
34// base->Terminate();
35// base->Release();
36// rtp_rtcp->Release();
37// VoiceEngine::Delete(voe);
38//
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020039#ifndef VOICE_ENGINE_VOE_RTP_RTCP_H_
40#define VOICE_ENGINE_VOE_RTP_RTCP_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000041
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +000042#include <vector>
Mirko Bonadei71207422017-09-15 13:58:09 +020043#include "common_types.h" // NOLINT(build/include)
niklase@google.com470e71d2011-07-07 08:21:25 +000044
45namespace webrtc {
46
47class VoiceEngine;
48
49// VoERTPObserver
Jelena Marusic0d266052015-05-04 14:15:32 +020050class WEBRTC_DLLEXPORT VoERTPObserver {
51 public:
52 virtual void OnIncomingCSRCChanged(int channel,
53 unsigned int CSRC,
54 bool added) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000055
Jelena Marusic0d266052015-05-04 14:15:32 +020056 virtual void OnIncomingSSRCChanged(int channel, unsigned int SSRC) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +000057
Jelena Marusic0d266052015-05-04 14:15:32 +020058 protected:
59 virtual ~VoERTPObserver() {}
niklase@google.com470e71d2011-07-07 08:21:25 +000060};
61
niklase@google.com470e71d2011-07-07 08:21:25 +000062// CallStatistics
Jelena Marusic0d266052015-05-04 14:15:32 +020063struct CallStatistics {
64 unsigned short fractionLost;
65 unsigned int cumulativeLost;
66 unsigned int extendedMax;
67 unsigned int jitterSamples;
68 int64_t rttMs;
69 size_t bytesSent;
70 int packetsSent;
71 size_t bytesReceived;
72 int packetsReceived;
73 // The capture ntp time (in local timebase) of the first played out audio
74 // frame.
75 int64_t capture_start_ntp_time_ms_;
niklase@google.com470e71d2011-07-07 08:21:25 +000076};
77
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +000078// See section 6.4.1 in http://www.ietf.org/rfc/rfc3550.txt for details.
79struct SenderInfo {
80 uint32_t NTP_timestamp_high;
81 uint32_t NTP_timestamp_low;
82 uint32_t RTP_timestamp;
83 uint32_t sender_packet_count;
84 uint32_t sender_octet_count;
85};
86
87// See section 6.4.2 in http://www.ietf.org/rfc/rfc3550.txt for details.
88struct ReportBlock {
Jelena Marusic0d266052015-05-04 14:15:32 +020089 uint32_t sender_SSRC; // SSRC of sender
henrika@webrtc.org8a2fc882012-08-22 08:53:55 +000090 uint32_t source_SSRC;
91 uint8_t fraction_lost;
92 uint32_t cumulative_num_packets_lost;
93 uint32_t extended_highest_sequence_number;
94 uint32_t interarrival_jitter;
95 uint32_t last_SR_timestamp;
96 uint32_t delay_since_last_SR;
97};
98
niklase@google.com470e71d2011-07-07 08:21:25 +000099// VoERTP_RTCP
Jelena Marusic0d266052015-05-04 14:15:32 +0200100class WEBRTC_DLLEXPORT VoERTP_RTCP {
101 public:
102 // Factory for the VoERTP_RTCP sub-API. Increases an internal
103 // reference counter if successful. Returns NULL if the API is not
104 // supported or if construction fails.
105 static VoERTP_RTCP* GetInterface(VoiceEngine* voiceEngine);
niklase@google.com470e71d2011-07-07 08:21:25 +0000106
Jelena Marusic0d266052015-05-04 14:15:32 +0200107 // Releases the VoERTP_RTCP sub-API and decreases an internal
108 // reference counter. Returns the new reference count. This value should
109 // be zero for all sub-API:s before the VoiceEngine object can be safely
110 // deleted.
111 virtual int Release() = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000112
Jelena Marusic0d266052015-05-04 14:15:32 +0200113 // Sets the local RTP synchronization source identifier (SSRC) explicitly.
114 virtual int SetLocalSSRC(int channel, unsigned int ssrc) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000115
Jelena Marusic0d266052015-05-04 14:15:32 +0200116 // Gets the local RTP SSRC of a specified |channel|.
117 virtual int GetLocalSSRC(int channel, unsigned int& ssrc) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000118
Jelena Marusic0d266052015-05-04 14:15:32 +0200119 // Gets the SSRC of the incoming RTP packets.
120 virtual int GetRemoteSSRC(int channel, unsigned int& ssrc) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000121
Jelena Marusic0d266052015-05-04 14:15:32 +0200122 // Sets the status of rtp-audio-level-indication on a specific |channel|.
123 virtual int SetSendAudioLevelIndicationStatus(int channel,
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000124 bool enable,
Jelena Marusic0d266052015-05-04 14:15:32 +0200125 unsigned char id = 1) = 0;
wu@webrtc.orgebdb0e32014-03-06 23:49:08 +0000126
Jelena Marusic0d266052015-05-04 14:15:32 +0200127 // Sets the RTCP status on a specific |channel|.
128 virtual int SetRTCPStatus(int channel, bool enable) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000129
Jelena Marusic0d266052015-05-04 14:15:32 +0200130 // Gets the RTCP status on a specific |channel|.
131 virtual int GetRTCPStatus(int channel, bool& enabled) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000132
Jelena Marusic0d266052015-05-04 14:15:32 +0200133 // Sets the canonical name (CNAME) parameter for RTCP reports on a
134 // specific |channel|.
135 virtual int SetRTCP_CNAME(int channel, const char cName[256]) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000136
Jelena Marusic0d266052015-05-04 14:15:32 +0200137 // Gets the canonical name (CNAME) parameter for incoming RTCP reports
138 // on a specific channel.
139 virtual int GetRemoteRTCP_CNAME(int channel, char cName[256]) = 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000140
Jelena Marusic0d266052015-05-04 14:15:32 +0200141 // Gets RTCP statistics for a specific |channel|.
142 virtual int GetRTCPStatistics(int channel, CallStatistics& stats) = 0;
minyue@webrtc.orgc1a40a72014-05-28 09:52:06 +0000143
Jelena Marusic0d266052015-05-04 14:15:32 +0200144 protected:
145 VoERTP_RTCP() {}
146 virtual ~VoERTP_RTCP() {}
niklase@google.com470e71d2011-07-07 08:21:25 +0000147};
148
149} // namespace webrtc
150
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200151#endif // #ifndef VOICE_ENGINE_VOE_RTP_RTCP_H_