blob: 0c047d7ad2fc0af485046db87eedabc5cfed5e15 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
stefan@webrtc.org07b45a52012-02-02 08:37:48 +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
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000011#include "video_engine/vie_rtp_rtcp_impl.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000012
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +000013#include "engine_configurations.h" // NOLINT
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000014#include "system_wrappers/interface/file_wrapper.h"
15#include "system_wrappers/interface/trace.h"
mflodman@webrtc.orga4863db2011-12-22 08:51:52 +000016#include "video_engine/include/vie_errors.h"
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000017#include "video_engine/vie_channel.h"
18#include "video_engine/vie_channel_manager.h"
19#include "video_engine/vie_defines.h"
20#include "video_engine/vie_encoder.h"
21#include "video_engine/vie_impl.h"
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000022#include "video_engine/vie_shared_data.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000023
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000024namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000025
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000026// Helper methods for converting between module format and ViE API format.
niklase@google.com470e71d2011-07-07 08:21:25 +000027
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000028static RTCPMethod ViERTCPModeToRTCPMethod(ViERTCPMode api_mode) {
29 switch (api_mode) {
30 case kRtcpNone:
31 return kRtcpOff;
niklase@google.com470e71d2011-07-07 08:21:25 +000032
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000033 case kRtcpCompound_RFC4585:
34 return kRtcpCompound;
35
36 case kRtcpNonCompound_RFC5506:
37 return kRtcpNonCompound;
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000038 }
mflodman@webrtc.org657b2a42012-02-06 11:06:01 +000039 assert(false);
40 return kRtcpOff;
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000041}
42
43static ViERTCPMode RTCPMethodToViERTCPMode(RTCPMethod module_method) {
44 switch (module_method) {
45 case kRtcpOff:
46 return kRtcpNone;
47
48 case kRtcpCompound:
49 return kRtcpCompound_RFC4585;
50
51 case kRtcpNonCompound:
52 return kRtcpNonCompound_RFC5506;
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000053 }
mflodman@webrtc.org657b2a42012-02-06 11:06:01 +000054 assert(false);
55 return kRtcpNone;
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000056}
57
58static KeyFrameRequestMethod APIRequestToModuleRequest(
59 ViEKeyFrameRequestMethod api_method) {
60 switch (api_method) {
61 case kViEKeyFrameRequestNone:
62 return kKeyFrameReqFirRtp;
63
64 case kViEKeyFrameRequestPliRtcp:
65 return kKeyFrameReqPliRtcp;
66
67 case kViEKeyFrameRequestFirRtp:
68 return kKeyFrameReqFirRtp;
69
70 case kViEKeyFrameRequestFirRtcp:
71 return kKeyFrameReqFirRtcp;
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000072 }
mflodman@webrtc.org657b2a42012-02-06 11:06:01 +000073 assert(false);
74 return kKeyFrameReqFirRtp;
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000075}
76
77ViERTP_RTCP* ViERTP_RTCP::GetInterface(VideoEngine* video_engine) {
niklase@google.com470e71d2011-07-07 08:21:25 +000078#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000079 if (!video_engine) {
niklase@google.com470e71d2011-07-07 08:21:25 +000080 return NULL;
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000081 }
82 VideoEngineImpl* vie_impl = reinterpret_cast<VideoEngineImpl*>(video_engine);
83 ViERTP_RTCPImpl* vie_rtpimpl = vie_impl;
84 // Increase ref count.
85 (*vie_rtpimpl)++;
86 return vie_rtpimpl;
87#else
88 return NULL;
niklase@google.com470e71d2011-07-07 08:21:25 +000089#endif
90}
91
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000092int ViERTP_RTCPImpl::Release() {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +000093 WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000094 "ViERTP_RTCP::Release()");
95 // Decrease ref count.
96 (*this)--;
niklase@google.com470e71d2011-07-07 08:21:25 +000097
mflodman@webrtc.org8da24172011-12-19 14:18:41 +000098 WebRtc_Word32 ref_count = GetCount();
99 if (ref_count < 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000100 WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000101 "ViERTP_RTCP release too many times");
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000102 shared_data_->SetLastError(kViEAPIDoesNotExist);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000103 return -1;
104 }
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000105 WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000106 "ViERTP_RTCP reference count: %d", ref_count);
107 return ref_count;
niklase@google.com470e71d2011-07-07 08:21:25 +0000108}
109
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000110ViERTP_RTCPImpl::ViERTP_RTCPImpl(ViESharedData* shared_data)
111 : shared_data_(shared_data) {
112 WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000113 "ViERTP_RTCPImpl::ViERTP_RTCPImpl() Ctor");
niklase@google.com470e71d2011-07-07 08:21:25 +0000114}
115
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000116ViERTP_RTCPImpl::~ViERTP_RTCPImpl() {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000117 WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000118 "ViERTP_RTCPImpl::~ViERTP_RTCPImpl() Dtor");
niklase@google.com470e71d2011-07-07 08:21:25 +0000119}
120
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000121int ViERTP_RTCPImpl::SetLocalSSRC(const int video_channel,
pwestin@webrtc.org1da1ce02011-10-13 15:19:55 +0000122 const unsigned int SSRC,
123 const StreamType usage,
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000124 const unsigned char simulcast_idx) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000125 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
126 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000127 "%s(channel: %d, SSRC: %d)", __FUNCTION__, video_channel, SSRC);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000128 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000129 ViEChannel* vie_channel = cs.Channel(video_channel);
130 if (!vie_channel) {
stefan@webrtc.orgd0bdab02011-10-14 14:24:54 +0000131 // The channel doesn't exists
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000132 WEBRTC_TRACE(kTraceError, kTraceVideo,
133 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000134 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000135 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000136 return -1;
137 }
138 if (vie_channel->SetSSRC(SSRC, usage, simulcast_idx) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000139 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000140 return -1;
141 }
142 return 0;
143}
144
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +0000145int ViERTP_RTCPImpl::SetRemoteSSRCType(const int videoChannel,
146 const StreamType usage,
147 const unsigned int SSRC) const {
148 WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo,
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000149 ViEId(shared_data_->instance_id(), videoChannel),
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +0000150 "%s(channel: %d, usage:%d SSRC: 0x%x)",
151 __FUNCTION__, usage, videoChannel, SSRC);
152
153 // Get the channel
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000154 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +0000155 ViEChannel* ptrViEChannel = cs.Channel(videoChannel);
156 if (ptrViEChannel == NULL) {
157 // The channel doesn't exists
158 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo,
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000159 ViEId(shared_data_->instance_id(), videoChannel),
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +0000160 "%s: Channel %d doesn't exist",
161 __FUNCTION__, videoChannel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000162 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +0000163 return -1;
164 }
165 if (ptrViEChannel->SetRemoteSSRCType(usage, SSRC) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000166 shared_data_->SetLastError(kViERtpRtcpUnknownError);
pwestin@webrtc.org8281e7d2012-01-10 14:09:18 +0000167 return -1;
168 }
169 return 0;
170}
171
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000172int ViERTP_RTCPImpl::GetLocalSSRC(const int video_channel,
173 unsigned int& SSRC) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000174 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
175 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000176 "%s(channel: %d, SSRC: %d)", __FUNCTION__, video_channel, SSRC);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000177 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000178 ViEChannel* vie_channel = cs.Channel(video_channel);
179 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000180 WEBRTC_TRACE(kTraceError, kTraceVideo,
181 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000182 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000183 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000184 return -1;
185 }
mflodman@webrtc.orgd6ec3862012-10-25 11:30:29 +0000186 uint8_t idx = 0;
187 if (vie_channel->GetLocalSSRC(idx, &SSRC) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000188 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000189 return -1;
190 }
191 return 0;
192}
193
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000194int ViERTP_RTCPImpl::GetRemoteSSRC(const int video_channel,
195 unsigned int& SSRC) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000196 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
197 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000198 "%s(channel: %d)", __FUNCTION__, video_channel, SSRC);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000199 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000200 ViEChannel* vie_channel = cs.Channel(video_channel);
201 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000202 WEBRTC_TRACE(kTraceError, kTraceVideo,
203 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000204 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000205 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000206 return -1;
207 }
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000208 if (vie_channel->GetRemoteSSRC(&SSRC) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000209 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000210 return -1;
211 }
212 return 0;
213}
214
215int ViERTP_RTCPImpl::GetRemoteCSRCs(const int video_channel,
216 unsigned int CSRCs[kRtpCsrcSize]) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000217 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
218 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000219 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000220 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000221 ViEChannel* vie_channel = cs.Channel(video_channel);
222 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000223 WEBRTC_TRACE(kTraceError, kTraceVideo,
224 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000225 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000226 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000227 return -1;
228 }
229 if (vie_channel->GetRemoteCSRC(CSRCs) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000230 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000231 return -1;
232 }
233 return 0;
234}
235
236int ViERTP_RTCPImpl::SetStartSequenceNumber(const int video_channel,
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000237 uint16_t sequence_number) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000238 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
239 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000240 "%s(channel: %d, sequence_number: %u)", __FUNCTION__,
241 video_channel, sequence_number);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000242 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000243 ViEChannel* vie_channel = cs.Channel(video_channel);
244 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000245 WEBRTC_TRACE(kTraceError, kTraceVideo,
246 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000247 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000248 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000249 return -1;
250 }
251 if (vie_channel->Sending()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000252 WEBRTC_TRACE(kTraceError, kTraceVideo,
253 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000254 "%s: Channel %d already sending.", __FUNCTION__,
255 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000256 shared_data_->SetLastError(kViERtpRtcpAlreadySending);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000257 return -1;
258 }
259 if (vie_channel->SetStartSequenceNumber(sequence_number) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000260 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000261 return -1;
262 }
263 return 0;
264}
265
266int ViERTP_RTCPImpl::SetRTCPStatus(const int video_channel,
267 const ViERTCPMode rtcp_mode) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000268 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
269 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000270 "%s(channel: %d, mode: %d)", __FUNCTION__, video_channel,
271 rtcp_mode);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000272 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000273 ViEChannel* vie_channel = cs.Channel(video_channel);
274 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000275 WEBRTC_TRACE(kTraceError, kTraceVideo,
276 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000277 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000278 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
stefan@webrtc.orgd0bdab02011-10-14 14:24:54 +0000279 return -1;
280 }
281
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000282 RTCPMethod module_mode = ViERTCPModeToRTCPMethod(rtcp_mode);
283 if (vie_channel->SetRTCPMode(module_mode) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000284 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000285 return -1;
286 }
287 return 0;
288}
289
290int ViERTP_RTCPImpl::GetRTCPStatus(const int video_channel,
291 ViERTCPMode& rtcp_mode) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000292 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
293 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000294 "%s(channel: %d)", __FUNCTION__, video_channel, rtcp_mode);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000295 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000296 ViEChannel* vie_channel = cs.Channel(video_channel);
297 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000298 WEBRTC_TRACE(kTraceError, kTraceVideo,
299 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000300 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000301 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000302 return -1;
303 }
304 RTCPMethod module_mode = kRtcpOff;
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000305 if (vie_channel->GetRTCPMode(&module_mode) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000306 WEBRTC_TRACE(kTraceError, kTraceVideo,
307 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000308 "%s: could not get current RTCP mode", __FUNCTION__);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000309 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000310 return -1;
311 }
312 rtcp_mode = RTCPMethodToViERTCPMode(module_mode);
313 return 0;
314}
315
316int ViERTP_RTCPImpl::SetRTCPCName(const int video_channel,
317 const char rtcp_cname[KMaxRTCPCNameLength]) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000318 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
319 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000320 "%s(channel: %d, name: %s)", __FUNCTION__, video_channel,
321 rtcp_cname);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000322 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000323 ViEChannel* vie_channel = cs.Channel(video_channel);
324 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000325 WEBRTC_TRACE(kTraceError, kTraceVideo,
326 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000327 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000328 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000329 return -1;
330 }
331 if (vie_channel->Sending()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000332 WEBRTC_TRACE(kTraceError, kTraceVideo,
333 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000334 "%s: Channel %d already sending.", __FUNCTION__,
335 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000336 shared_data_->SetLastError(kViERtpRtcpAlreadySending);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000337 return -1;
338 }
339 if (vie_channel->SetRTCPCName(rtcp_cname) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000340 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000341 return -1;
342 }
343 return 0;
344}
345
346int ViERTP_RTCPImpl::GetRTCPCName(const int video_channel,
347 char rtcp_cname[KMaxRTCPCNameLength]) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000348 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
349 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000350 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000351 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000352 ViEChannel* vie_channel = cs.Channel(video_channel);
353 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000354 WEBRTC_TRACE(kTraceError, kTraceVideo,
355 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000356 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000357 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000358 return -1;
359 }
360 if (vie_channel->GetRTCPCName(rtcp_cname) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000361 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000362 return -1;
363 }
364 return 0;
365}
366
367int ViERTP_RTCPImpl::GetRemoteRTCPCName(
368 const int video_channel,
369 char rtcp_cname[KMaxRTCPCNameLength]) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000370 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
371 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000372 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000373 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000374 ViEChannel* vie_channel = cs.Channel(video_channel);
375 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000376 WEBRTC_TRACE(kTraceError, kTraceVideo,
377 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000378 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000379 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000380 return -1;
381 }
382 if (vie_channel->GetRemoteRTCPCName(rtcp_cname) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000383 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000384 return -1;
385 }
386 return 0;
387}
388
389int ViERTP_RTCPImpl::SendApplicationDefinedRTCPPacket(
390 const int video_channel,
391 const unsigned char sub_type,
392 unsigned int name,
393 const char* data,
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000394 uint16_t data_length_in_bytes) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000395 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
396 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000397 "%s(channel: %d, sub_type: %c, name: %d, data: x, length: %u)",
398 __FUNCTION__, video_channel, sub_type, name,
399 data_length_in_bytes);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000400 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000401 ViEChannel* vie_channel = cs.Channel(video_channel);
402 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000403 WEBRTC_TRACE(kTraceError, kTraceVideo,
404 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000405 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000406 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000407 return -1;
408 }
409 if (!vie_channel->Sending()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000410 WEBRTC_TRACE(kTraceError, kTraceVideo,
411 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000412 "%s: Channel %d not sending", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000413 shared_data_->SetLastError(kViERtpRtcpNotSending);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000414 return -1;
415 }
416 RTCPMethod method;
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000417 if (vie_channel->GetRTCPMode(&method) != 0 || method == kRtcpOff) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000418 WEBRTC_TRACE(kTraceError, kTraceVideo,
419 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000420 "%s: RTCP disabled on channel %d.", __FUNCTION__,
421 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000422 shared_data_->SetLastError(kViERtpRtcpRtcpDisabled);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000423 return -1;
424 }
425 if (vie_channel->SendApplicationDefinedRTCPPacket(
426 sub_type, name, reinterpret_cast<const WebRtc_UWord8*>(data),
427 data_length_in_bytes) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000428 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000429 return -1;
430 }
431 return 0;
432}
433
434int ViERTP_RTCPImpl::SetNACKStatus(const int video_channel, const bool enable) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000435 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
436 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000437 "%s(channel: %d, enable: %d)", __FUNCTION__, video_channel,
438 enable);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000439 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000440 ViEChannel* vie_channel = cs.Channel(video_channel);
441 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000442 WEBRTC_TRACE(kTraceError, kTraceVideo,
443 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000444 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000445 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000446 return -1;
447 }
448 if (vie_channel->SetNACKStatus(enable) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000449 WEBRTC_TRACE(kTraceError, kTraceVideo,
450 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000451 "%s: failed for channel %d", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000452 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000453 return -1;
454 }
455
456 // Update the encoder
457 ViEEncoder* vie_encoder = cs.Encoder(video_channel);
458 if (!vie_encoder) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000459 WEBRTC_TRACE(kTraceError, kTraceVideo,
460 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000461 "%s: Could not get encoder for channel %d", __FUNCTION__,
462 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000463 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000464 return -1;
465 }
466 vie_encoder->UpdateProtectionMethod();
467 return 0;
468}
469
470int ViERTP_RTCPImpl::SetFECStatus(const int video_channel, const bool enable,
471 const unsigned char payload_typeRED,
472 const unsigned char payload_typeFEC) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000473 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
474 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000475 "%s(channel: %d, enable: %d, payload_typeRED: %u, "
476 "payloadTypeFEC: %u)",
477 __FUNCTION__, video_channel, enable, payload_typeRED,
478 payload_typeFEC);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000479 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000480 ViEChannel* vie_channel = cs.Channel(video_channel);
481 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000482 WEBRTC_TRACE(kTraceError, kTraceVideo,
483 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000484 "%s: Channel %d doesn't exist", __FUNCTION__,
485 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000486 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000487 return -1;
488 }
489 if (vie_channel->SetFECStatus(enable, payload_typeRED,
490 payload_typeFEC) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000491 WEBRTC_TRACE(kTraceError, kTraceVideo,
492 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000493 "%s: failed for channel %d", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000494 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000495 return -1;
496 }
497 // Update the encoder.
498 ViEEncoder* vie_encoder = cs.Encoder(video_channel);
499 if (!vie_encoder) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000500 WEBRTC_TRACE(kTraceError, kTraceVideo,
501 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000502 "%s: Could not get encoder for channel %d", __FUNCTION__,
503 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000504 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000505 return -1;
506 }
507 vie_encoder->UpdateProtectionMethod();
508 return 0;
509}
510
511int ViERTP_RTCPImpl::SetHybridNACKFECStatus(
512 const int video_channel,
513 const bool enable,
514 const unsigned char payload_typeRED,
515 const unsigned char payload_typeFEC) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000516 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
517 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000518 "%s(channel: %d, enable: %d, payload_typeRED: %u, "
519 "payloadTypeFEC: %u)",
520 __FUNCTION__, video_channel, enable, payload_typeRED,
521 payload_typeFEC);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000522 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000523 ViEChannel* vie_channel = cs.Channel(video_channel);
524 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000525 WEBRTC_TRACE(kTraceError, kTraceVideo,
526 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000527 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000528 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000529 return -1;
530 }
531
532 // Update the channel status with hybrid NACK FEC mode.
533 if (vie_channel->SetHybridNACKFECStatus(enable, payload_typeRED,
534 payload_typeFEC) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000535 WEBRTC_TRACE(kTraceError, kTraceVideo,
536 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000537 "%s: failed for channel %d", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000538 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000539 return -1;
540 }
541
542 // Update the encoder.
543 ViEEncoder* vie_encoder = cs.Encoder(video_channel);
544 if (!vie_encoder) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000545 WEBRTC_TRACE(kTraceError, kTraceVideo,
546 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000547 "%s: Could not get encoder for channel %d", __FUNCTION__,
548 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000549 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000550 return -1;
551 }
552 vie_encoder->UpdateProtectionMethod();
553 return 0;
554}
555
556int ViERTP_RTCPImpl::SetKeyFrameRequestMethod(
557 const int video_channel,
558 const ViEKeyFrameRequestMethod method) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000559 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
560 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000561 "%s(channel: %d, method: %d)", __FUNCTION__, video_channel,
562 method);
563
564 // Get the channel.
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000565 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000566 ViEChannel* vie_channel = cs.Channel(video_channel);
567 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000568 WEBRTC_TRACE(kTraceError, kTraceVideo,
569 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000570 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000571 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000572 return -1;
573 }
574 KeyFrameRequestMethod module_method = APIRequestToModuleRequest(method);
575 if (vie_channel->SetKeyFrameRequestMethod(module_method) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000576 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000577 return -1;
578 }
579 return 0;
580}
581
582int ViERTP_RTCPImpl::SetTMMBRStatus(const int video_channel,
583 const bool enable) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000584 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
585 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000586 "%s(channel: %d, enable: %d)", __FUNCTION__, video_channel,
587 enable);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000588 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000589 ViEChannel* vie_channel = cs.Channel(video_channel);
590 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000591 WEBRTC_TRACE(kTraceError, kTraceVideo,
592 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000593 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000594 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000595 return -1;
596 }
597 if (vie_channel->EnableTMMBR(enable) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000598 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000599 return -1;
600 }
601 return 0;
602}
603
mflodman@webrtc.org6cf529d2012-01-24 06:16:16 +0000604int ViERTP_RTCPImpl::SetRembStatus(int video_channel, bool sender,
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000605 bool receiver) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000606 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
607 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000608 "ViERTP_RTCPImpl::SetRembStatus(%d, %d, %d)", video_channel,
609 sender, receiver);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000610 if (!shared_data_->channel_manager()->SetRembStatus(video_channel, sender,
611 receiver)) {
mflodman@webrtc.org6cf529d2012-01-24 06:16:16 +0000612 return -1;
613 }
614 return 0;
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000615}
616
stefan@webrtc.org976a7e62012-09-21 13:20:21 +0000617int ViERTP_RTCPImpl::SetBandwidthEstimationMode(BandwidthEstimationMode mode) {
618 WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
619 "ViERTP_RTCPImpl::SetBandwidthEstimationMode(%d)", mode);
620 if (!shared_data_->channel_manager()->SetBandwidthEstimationMode(mode)) {
621 return -1;
622 }
623 return 0;
624}
625
mflodman@webrtc.org90071dd2012-08-13 17:13:27 +0000626int ViERTP_RTCPImpl::SetSendTimestampOffsetStatus(int video_channel,
627 bool enable,
628 int id) {
629 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
630 ViEId(shared_data_->instance_id(), video_channel),
631 "ViERTP_RTCPImpl::SetSendTimestampOffsetStatus(%d, %d, %d)",
632 video_channel, enable, id);
633
634 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
635 ViEChannel* vie_channel = cs.Channel(video_channel);
636 if (!vie_channel) {
637 WEBRTC_TRACE(kTraceError, kTraceVideo,
638 ViEId(shared_data_->instance_id(), video_channel),
639 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
640 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
641 return -1;
642 }
643 if (vie_channel->SetSendTimestampOffsetStatus(enable, id) != 0) {
644 shared_data_->SetLastError(kViERtpRtcpUnknownError);
645 return -1;
646 }
647 return 0;
648}
649
650int ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(int video_channel,
651 bool enable,
652 int id) {
653 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
654 ViEId(shared_data_->instance_id(), video_channel),
655 "ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(%d, %d, %d)",
656 video_channel, enable, id);
657 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
658 ViEChannel* vie_channel = cs.Channel(video_channel);
659 if (!vie_channel) {
660 WEBRTC_TRACE(kTraceError, kTraceVideo,
661 ViEId(shared_data_->instance_id(), video_channel),
662 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
663 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
664 return -1;
665 }
666 if (vie_channel->SetReceiveTimestampOffsetStatus(enable, id) != 0) {
667 shared_data_->SetLastError(kViERtpRtcpUnknownError);
668 return -1;
669 }
670 return 0;
671}
672
mflodman@webrtc.org5a7507f2012-09-12 13:47:06 +0000673int ViERTP_RTCPImpl::SetTransmissionSmoothingStatus(int video_channel,
674 bool enable) {
675 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
676 ViEId(shared_data_->instance_id(), video_channel),
677 "%s(channel: %d, enble: %d)", __FUNCTION__, video_channel,
678 enable);
679 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
680 ViEChannel* vie_channel = cs.Channel(video_channel);
681 if (!vie_channel) {
682 WEBRTC_TRACE(kTraceError, kTraceVideo,
683 ViEId(shared_data_->instance_id(), video_channel),
684 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
685 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
686 return -1;
687 }
688 vie_channel->SetTransmissionSmoothingStatus(enable);
689 return 0;
690}
691
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000692int ViERTP_RTCPImpl::GetReceivedRTCPStatistics(const int video_channel,
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000693 uint16_t& fraction_lost,
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000694 unsigned int& cumulative_lost,
695 unsigned int& extended_max,
696 unsigned int& jitter,
697 int& rtt_ms) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000698 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
699 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000700 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000701 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000702 ViEChannel* vie_channel = cs.Channel(video_channel);
703 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000704 WEBRTC_TRACE(kTraceError, kTraceVideo,
705 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000706 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000707 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000708 return -1;
709 }
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000710 if (vie_channel->GetReceivedRtcpStatistics(&fraction_lost,
711 &cumulative_lost,
712 &extended_max,
713 &jitter,
714 &rtt_ms) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000715 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000716 return -1;
717 }
718 return 0;
719}
720
721int ViERTP_RTCPImpl::GetSentRTCPStatistics(const int video_channel,
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000722 uint16_t& fraction_lost,
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000723 unsigned int& cumulative_lost,
724 unsigned int& extended_max,
725 unsigned int& jitter,
726 int& rtt_ms) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000727 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
728 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000729 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000730 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000731 ViEChannel* vie_channel = cs.Channel(video_channel);
732 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000733 WEBRTC_TRACE(kTraceError, kTraceVideo,
734 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000735 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000736 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000737 return -1;
738 }
739
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000740 if (vie_channel->GetSendRtcpStatistics(&fraction_lost, &cumulative_lost,
741 &extended_max, &jitter,
742 &rtt_ms) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000743 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000744 return -1;
745 }
746 return 0;
747}
748
749int ViERTP_RTCPImpl::GetRTPStatistics(const int video_channel,
750 unsigned int& bytes_sent,
751 unsigned int& packets_sent,
752 unsigned int& bytes_received,
753 unsigned int& packets_received) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000754 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
755 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000756 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000757 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000758 ViEChannel* vie_channel = cs.Channel(video_channel);
759 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000760 WEBRTC_TRACE(kTraceError, kTraceVideo,
761 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000762 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000763 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000764 return -1;
765 }
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000766 if (vie_channel->GetRtpStatistics(&bytes_sent,
767 &packets_sent,
768 &bytes_received,
769 &packets_received) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000770 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000771 return -1;
772 }
773 return 0;
774}
775
776int ViERTP_RTCPImpl::GetBandwidthUsage(const int video_channel,
777 unsigned int& total_bitrate_sent,
778 unsigned int& video_bitrate_sent,
779 unsigned int& fec_bitrate_sent,
780 unsigned int& nackBitrateSent) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000781 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
782 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000783 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000784 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000785 ViEChannel* vie_channel = cs.Channel(video_channel);
786 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000787 WEBRTC_TRACE(kTraceError, kTraceVideo,
788 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000789 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000790 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000791 return -1;
792 }
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000793 vie_channel->GetBandwidthUsage(&total_bitrate_sent,
794 &video_bitrate_sent,
795 &fec_bitrate_sent,
796 &nackBitrateSent);
stefan@webrtc.orgd0bdab02011-10-14 14:24:54 +0000797 return 0;
798}
799
stefan@webrtc.org439be292012-02-16 14:45:37 +0000800int ViERTP_RTCPImpl::GetEstimatedSendBandwidth(
stefan@webrtc.org07b45a52012-02-02 08:37:48 +0000801 const int video_channel,
802 unsigned int* estimated_bandwidth) const {
803 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
804 ViEId(shared_data_->instance_id(), video_channel),
805 "%s(channel: %d)", __FUNCTION__, video_channel);
806 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
807 ViEEncoder* vie_encoder = cs.Encoder(video_channel);
808 if (!vie_encoder) {
809 WEBRTC_TRACE(kTraceError, kTraceVideo,
810 ViEId(shared_data_->instance_id(), video_channel),
811 "%s: Could not get encoder for channel %d", __FUNCTION__,
812 video_channel);
813 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
814 return -1;
815 }
stefan@webrtc.org439be292012-02-16 14:45:37 +0000816 return vie_encoder->EstimatedSendBandwidth(
817 static_cast<WebRtc_UWord32*>(estimated_bandwidth));
818}
819
820int ViERTP_RTCPImpl::GetEstimatedReceiveBandwidth(
821 const int video_channel,
822 unsigned int* estimated_bandwidth) const {
823 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
824 ViEId(shared_data_->instance_id(), video_channel),
825 "%s(channel: %d)", __FUNCTION__, video_channel);
826 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
827 ViEChannel* vie_channel = cs.Channel(video_channel);
828 if (!vie_channel) {
829 WEBRTC_TRACE(kTraceError, kTraceVideo,
830 ViEId(shared_data_->instance_id(), video_channel),
831 "%s: Could not get channel %d", __FUNCTION__,
832 video_channel);
833 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
834 return -1;
835 }
836 return vie_channel->GetEstimatedReceiveBandwidth(
stefan@webrtc.org07b45a52012-02-02 08:37:48 +0000837 static_cast<WebRtc_UWord32*>(estimated_bandwidth));
838}
839
astor@webrtc.orgc0496e62012-08-10 10:14:43 +0000840int ViERTP_RTCPImpl::SetOverUseDetectorOptions(
841 const OverUseDetectorOptions& options) const {
842 if (!shared_data_->Initialized()) {
843 shared_data_->SetLastError(kViENotInitialized);
844 WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
845 "%s - ViE instance %d not initialized", __FUNCTION__,
846 shared_data_->instance_id());
847 return -1;
848 }
849 // Lock the channel manager to avoid creating a channel with
850 // "undefined" bwe settings (atomic copy).
851 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
852 shared_data_->SetOverUseDetectorOptions(options);
853 return 0;
854}
855
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000856int ViERTP_RTCPImpl::StartRTPDump(const int video_channel,
857 const char file_nameUTF8[1024],
858 RTPDirections direction) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000859 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
860 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000861 "%s(channel: %d, file_name: %s, direction: %d)", __FUNCTION__,
862 video_channel, file_nameUTF8, direction);
863 assert(FileWrapper::kMaxFileNameSize == 1024);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000864 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000865 ViEChannel* vie_channel = cs.Channel(video_channel);
866 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000867 WEBRTC_TRACE(kTraceError, kTraceVideo,
868 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000869 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000870 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000871 return -1;
872 }
873 if (vie_channel->StartRTPDump(file_nameUTF8, direction) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000874 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000875 return -1;
876 }
877 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000878}
879
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000880int ViERTP_RTCPImpl::StopRTPDump(const int video_channel,
881 RTPDirections direction) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000882 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
883 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000884 "%s(channel: %d, direction: %d)", __FUNCTION__, video_channel,
885 direction);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000886 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000887 ViEChannel* vie_channel = cs.Channel(video_channel);
888 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000889 WEBRTC_TRACE(kTraceError, kTraceVideo,
890 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000891 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000892 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000893 return -1;
894 }
895 if (vie_channel->StopRTPDump(direction) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000896 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000897 return -1;
898 }
899 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000900}
901
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000902int ViERTP_RTCPImpl::RegisterRTPObserver(const int video_channel,
903 ViERTPObserver& observer) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000904 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
905 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000906 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000907 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000908 ViEChannel* vie_channel = cs.Channel(video_channel);
909 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000910 WEBRTC_TRACE(kTraceError, kTraceVideo,
911 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000912 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000913 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000914 return -1;
915 }
916 if (vie_channel->RegisterRtpObserver(&observer) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000917 shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000918 return -1;
919 }
920 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000921}
922
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000923int ViERTP_RTCPImpl::DeregisterRTPObserver(const int video_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000924 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
925 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000926 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000927 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000928 ViEChannel* vie_channel = cs.Channel(video_channel);
929 if (!vie_channel) {
930 WEBRTC_TRACE(kTraceError, kTraceVideo,
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000931 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000932 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000933 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000934 return -1;
935 }
936 if (vie_channel->RegisterRtpObserver(NULL) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000937 shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000938 return -1;
939 }
940 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000941}
942
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000943int ViERTP_RTCPImpl::RegisterRTCPObserver(const int video_channel,
944 ViERTCPObserver& observer) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000945 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
946 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000947 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000948 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000949 ViEChannel* vie_channel = cs.Channel(video_channel);
950 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000951 WEBRTC_TRACE(kTraceError, kTraceVideo,
952 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000953 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000954 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000955 return -1;
956 }
957 if (vie_channel->RegisterRtcpObserver(&observer) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000958 shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000959 return -1;
960 }
961 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000962}
963
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000964int ViERTP_RTCPImpl::DeregisterRTCPObserver(const int video_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000965 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
966 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000967 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000968 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000969 ViEChannel* vie_channel = cs.Channel(video_channel);
970 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000971 WEBRTC_TRACE(kTraceError, kTraceVideo,
972 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000973 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000974 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000975 return -1;
976 }
977 if (vie_channel->RegisterRtcpObserver(NULL) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000978 shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000979 return -1;
980 }
981 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000982}
983
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000984} // namespace webrtc