niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 0975d21 | 2012-03-06 20:59:13 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | // - 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.org | c1a40a7 | 2014-05-28 09:52:06 +0000 | [diff] [blame] | 18 | // - Redundant Coding (RED) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | // - Writing RTP and RTCP packets to binary files for off-line analysis of |
| 20 | // the call quality. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | // |
| 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 | // |
| 39 | #ifndef WEBRTC_VOICE_ENGINE_VOE_RTP_RTCP_H |
| 40 | #define WEBRTC_VOICE_ENGINE_VOE_RTP_RTCP_H |
| 41 | |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 42 | #include <vector> |
pbos@webrtc.org | 956aa7e | 2013-05-21 13:52:32 +0000 | [diff] [blame] | 43 | #include "webrtc/common_types.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
| 45 | namespace webrtc { |
| 46 | |
| 47 | class VoiceEngine; |
| 48 | |
| 49 | // VoERTPObserver |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 50 | class WEBRTC_DLLEXPORT VoERTPObserver { |
| 51 | public: |
| 52 | virtual void OnIncomingCSRCChanged(int channel, |
| 53 | unsigned int CSRC, |
| 54 | bool added) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 55 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 56 | virtual void OnIncomingSSRCChanged(int channel, unsigned int SSRC) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 58 | protected: |
| 59 | virtual ~VoERTPObserver() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | // CallStatistics |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 63 | struct 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 78 | // See section 6.4.1 in http://www.ietf.org/rfc/rfc3550.txt for details. |
| 79 | struct 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. |
| 88 | struct ReportBlock { |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 89 | uint32_t sender_SSRC; // SSRC of sender |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 90 | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 99 | // VoERTP_RTCP |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 100 | class 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 106 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 107 | // 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 112 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 113 | // Sets the local RTP synchronization source identifier (SSRC) explicitly. |
| 114 | virtual int SetLocalSSRC(int channel, unsigned int ssrc) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 115 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 116 | // Gets the local RTP SSRC of a specified |channel|. |
| 117 | virtual int GetLocalSSRC(int channel, unsigned int& ssrc) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 119 | // Gets the SSRC of the incoming RTP packets. |
| 120 | virtual int GetRemoteSSRC(int channel, unsigned int& ssrc) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 121 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 122 | // Sets the status of rtp-audio-level-indication on a specific |channel|. |
| 123 | virtual int SetSendAudioLevelIndicationStatus(int channel, |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 124 | bool enable, |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 125 | unsigned char id = 1) = 0; |
wu@webrtc.org | ebdb0e3 | 2014-03-06 23:49:08 +0000 | [diff] [blame] | 126 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 127 | // Sets the RTCP status on a specific |channel|. |
| 128 | virtual int SetRTCPStatus(int channel, bool enable) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 129 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 130 | // Gets the RTCP status on a specific |channel|. |
| 131 | virtual int GetRTCPStatus(int channel, bool& enabled) = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 132 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 133 | // 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 136 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 137 | // 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 140 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 141 | // Gets RTCP statistics for a specific |channel|. |
| 142 | virtual int GetRTCPStatistics(int channel, CallStatistics& stats) = 0; |
minyue@webrtc.org | c1a40a7 | 2014-05-28 09:52:06 +0000 | [diff] [blame] | 143 | |
Jelena Marusic | 0d26605 | 2015-05-04 14:15:32 +0200 | [diff] [blame] | 144 | protected: |
| 145 | VoERTP_RTCP() {} |
| 146 | virtual ~VoERTP_RTCP() {} |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | } // namespace webrtc |
| 150 | |
| 151 | #endif // #ifndef WEBRTC_VOICE_ENGINE_VOE_RTP_RTCP_H |