blob: c716e778d4dac5b2a14483ca2f2d7204737d5eb2 [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 }
vikasmarwaha@webrtc.org8239ca52012-10-24 22:35:52 +0000186 if (vie_channel->GetLocalSSRC(&SSRC) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000187 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000188 return -1;
189 }
190 return 0;
191}
192
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000193int ViERTP_RTCPImpl::GetRemoteSSRC(const int video_channel,
194 unsigned int& SSRC) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000195 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
196 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000197 "%s(channel: %d)", __FUNCTION__, video_channel, SSRC);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000198 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000199 ViEChannel* vie_channel = cs.Channel(video_channel);
200 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000201 WEBRTC_TRACE(kTraceError, kTraceVideo,
202 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000203 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000204 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000205 return -1;
206 }
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000207 if (vie_channel->GetRemoteSSRC(&SSRC) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000208 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000209 return -1;
210 }
211 return 0;
212}
213
214int ViERTP_RTCPImpl::GetRemoteCSRCs(const int video_channel,
215 unsigned int CSRCs[kRtpCsrcSize]) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000216 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
217 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000218 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000219 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000220 ViEChannel* vie_channel = cs.Channel(video_channel);
221 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000222 WEBRTC_TRACE(kTraceError, kTraceVideo,
223 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000224 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000225 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000226 return -1;
227 }
228 if (vie_channel->GetRemoteCSRC(CSRCs) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000229 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000230 return -1;
231 }
232 return 0;
233}
234
235int ViERTP_RTCPImpl::SetStartSequenceNumber(const int video_channel,
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000236 uint16_t sequence_number) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000237 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
238 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000239 "%s(channel: %d, sequence_number: %u)", __FUNCTION__,
240 video_channel, sequence_number);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000241 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000242 ViEChannel* vie_channel = cs.Channel(video_channel);
243 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000244 WEBRTC_TRACE(kTraceError, kTraceVideo,
245 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000246 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000247 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000248 return -1;
249 }
250 if (vie_channel->Sending()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000251 WEBRTC_TRACE(kTraceError, kTraceVideo,
252 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000253 "%s: Channel %d already sending.", __FUNCTION__,
254 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000255 shared_data_->SetLastError(kViERtpRtcpAlreadySending);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000256 return -1;
257 }
258 if (vie_channel->SetStartSequenceNumber(sequence_number) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000259 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000260 return -1;
261 }
262 return 0;
263}
264
265int ViERTP_RTCPImpl::SetRTCPStatus(const int video_channel,
266 const ViERTCPMode rtcp_mode) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000267 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
268 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000269 "%s(channel: %d, mode: %d)", __FUNCTION__, video_channel,
270 rtcp_mode);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000271 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000272 ViEChannel* vie_channel = cs.Channel(video_channel);
273 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000274 WEBRTC_TRACE(kTraceError, kTraceVideo,
275 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000276 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000277 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
stefan@webrtc.orgd0bdab02011-10-14 14:24:54 +0000278 return -1;
279 }
280
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000281 RTCPMethod module_mode = ViERTCPModeToRTCPMethod(rtcp_mode);
282 if (vie_channel->SetRTCPMode(module_mode) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000283 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000284 return -1;
285 }
286 return 0;
287}
288
289int ViERTP_RTCPImpl::GetRTCPStatus(const int video_channel,
290 ViERTCPMode& rtcp_mode) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000291 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
292 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000293 "%s(channel: %d)", __FUNCTION__, video_channel, rtcp_mode);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000294 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000295 ViEChannel* vie_channel = cs.Channel(video_channel);
296 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000297 WEBRTC_TRACE(kTraceError, kTraceVideo,
298 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000299 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000300 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000301 return -1;
302 }
303 RTCPMethod module_mode = kRtcpOff;
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000304 if (vie_channel->GetRTCPMode(&module_mode) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000305 WEBRTC_TRACE(kTraceError, kTraceVideo,
306 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000307 "%s: could not get current RTCP mode", __FUNCTION__);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000308 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000309 return -1;
310 }
311 rtcp_mode = RTCPMethodToViERTCPMode(module_mode);
312 return 0;
313}
314
315int ViERTP_RTCPImpl::SetRTCPCName(const int video_channel,
316 const char rtcp_cname[KMaxRTCPCNameLength]) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000317 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
318 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000319 "%s(channel: %d, name: %s)", __FUNCTION__, video_channel,
320 rtcp_cname);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000321 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000322 ViEChannel* vie_channel = cs.Channel(video_channel);
323 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000324 WEBRTC_TRACE(kTraceError, kTraceVideo,
325 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000326 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000327 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000328 return -1;
329 }
330 if (vie_channel->Sending()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000331 WEBRTC_TRACE(kTraceError, kTraceVideo,
332 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000333 "%s: Channel %d already sending.", __FUNCTION__,
334 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000335 shared_data_->SetLastError(kViERtpRtcpAlreadySending);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000336 return -1;
337 }
338 if (vie_channel->SetRTCPCName(rtcp_cname) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000339 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000340 return -1;
341 }
342 return 0;
343}
344
345int ViERTP_RTCPImpl::GetRTCPCName(const int video_channel,
346 char rtcp_cname[KMaxRTCPCNameLength]) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000347 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
348 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000349 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000350 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000351 ViEChannel* vie_channel = cs.Channel(video_channel);
352 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000353 WEBRTC_TRACE(kTraceError, kTraceVideo,
354 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000355 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000356 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000357 return -1;
358 }
359 if (vie_channel->GetRTCPCName(rtcp_cname) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000360 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000361 return -1;
362 }
363 return 0;
364}
365
366int ViERTP_RTCPImpl::GetRemoteRTCPCName(
367 const int video_channel,
368 char rtcp_cname[KMaxRTCPCNameLength]) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000369 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
370 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000371 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000372 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000373 ViEChannel* vie_channel = cs.Channel(video_channel);
374 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000375 WEBRTC_TRACE(kTraceError, kTraceVideo,
376 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000377 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000378 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000379 return -1;
380 }
381 if (vie_channel->GetRemoteRTCPCName(rtcp_cname) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000382 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000383 return -1;
384 }
385 return 0;
386}
387
388int ViERTP_RTCPImpl::SendApplicationDefinedRTCPPacket(
389 const int video_channel,
390 const unsigned char sub_type,
391 unsigned int name,
392 const char* data,
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000393 uint16_t data_length_in_bytes) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000394 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
395 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000396 "%s(channel: %d, sub_type: %c, name: %d, data: x, length: %u)",
397 __FUNCTION__, video_channel, sub_type, name,
398 data_length_in_bytes);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000399 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000400 ViEChannel* vie_channel = cs.Channel(video_channel);
401 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000402 WEBRTC_TRACE(kTraceError, kTraceVideo,
403 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000404 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000405 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000406 return -1;
407 }
408 if (!vie_channel->Sending()) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000409 WEBRTC_TRACE(kTraceError, kTraceVideo,
410 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000411 "%s: Channel %d not sending", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000412 shared_data_->SetLastError(kViERtpRtcpNotSending);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000413 return -1;
414 }
415 RTCPMethod method;
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000416 if (vie_channel->GetRTCPMode(&method) != 0 || method == kRtcpOff) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000417 WEBRTC_TRACE(kTraceError, kTraceVideo,
418 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000419 "%s: RTCP disabled on channel %d.", __FUNCTION__,
420 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000421 shared_data_->SetLastError(kViERtpRtcpRtcpDisabled);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000422 return -1;
423 }
424 if (vie_channel->SendApplicationDefinedRTCPPacket(
425 sub_type, name, reinterpret_cast<const WebRtc_UWord8*>(data),
426 data_length_in_bytes) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000427 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000428 return -1;
429 }
430 return 0;
431}
432
433int ViERTP_RTCPImpl::SetNACKStatus(const int video_channel, const bool enable) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000434 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
435 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000436 "%s(channel: %d, enable: %d)", __FUNCTION__, video_channel,
437 enable);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000438 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000439 ViEChannel* vie_channel = cs.Channel(video_channel);
440 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000441 WEBRTC_TRACE(kTraceError, kTraceVideo,
442 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000443 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000444 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000445 return -1;
446 }
447 if (vie_channel->SetNACKStatus(enable) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000448 WEBRTC_TRACE(kTraceError, kTraceVideo,
449 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000450 "%s: failed for channel %d", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000451 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000452 return -1;
453 }
454
455 // Update the encoder
456 ViEEncoder* vie_encoder = cs.Encoder(video_channel);
457 if (!vie_encoder) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000458 WEBRTC_TRACE(kTraceError, kTraceVideo,
459 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000460 "%s: Could not get encoder for channel %d", __FUNCTION__,
461 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000462 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000463 return -1;
464 }
465 vie_encoder->UpdateProtectionMethod();
466 return 0;
467}
468
469int ViERTP_RTCPImpl::SetFECStatus(const int video_channel, const bool enable,
470 const unsigned char payload_typeRED,
471 const unsigned char payload_typeFEC) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000472 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
473 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000474 "%s(channel: %d, enable: %d, payload_typeRED: %u, "
475 "payloadTypeFEC: %u)",
476 __FUNCTION__, video_channel, enable, payload_typeRED,
477 payload_typeFEC);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000478 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000479 ViEChannel* vie_channel = cs.Channel(video_channel);
480 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000481 WEBRTC_TRACE(kTraceError, kTraceVideo,
482 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000483 "%s: Channel %d doesn't exist", __FUNCTION__,
484 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000485 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000486 return -1;
487 }
488 if (vie_channel->SetFECStatus(enable, payload_typeRED,
489 payload_typeFEC) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000490 WEBRTC_TRACE(kTraceError, kTraceVideo,
491 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000492 "%s: failed for channel %d", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000493 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000494 return -1;
495 }
496 // Update the encoder.
497 ViEEncoder* vie_encoder = cs.Encoder(video_channel);
498 if (!vie_encoder) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000499 WEBRTC_TRACE(kTraceError, kTraceVideo,
500 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000501 "%s: Could not get encoder for channel %d", __FUNCTION__,
502 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000503 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000504 return -1;
505 }
506 vie_encoder->UpdateProtectionMethod();
507 return 0;
508}
509
510int ViERTP_RTCPImpl::SetHybridNACKFECStatus(
511 const int video_channel,
512 const bool enable,
513 const unsigned char payload_typeRED,
514 const unsigned char payload_typeFEC) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000515 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
516 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000517 "%s(channel: %d, enable: %d, payload_typeRED: %u, "
518 "payloadTypeFEC: %u)",
519 __FUNCTION__, video_channel, enable, payload_typeRED,
520 payload_typeFEC);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000521 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000522 ViEChannel* vie_channel = cs.Channel(video_channel);
523 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000524 WEBRTC_TRACE(kTraceError, kTraceVideo,
525 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000526 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000527 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000528 return -1;
529 }
530
531 // Update the channel status with hybrid NACK FEC mode.
532 if (vie_channel->SetHybridNACKFECStatus(enable, payload_typeRED,
533 payload_typeFEC) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000534 WEBRTC_TRACE(kTraceError, kTraceVideo,
535 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000536 "%s: failed for channel %d", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000537 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000538 return -1;
539 }
540
541 // Update the encoder.
542 ViEEncoder* vie_encoder = cs.Encoder(video_channel);
543 if (!vie_encoder) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000544 WEBRTC_TRACE(kTraceError, kTraceVideo,
545 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000546 "%s: Could not get encoder for channel %d", __FUNCTION__,
547 video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000548 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000549 return -1;
550 }
551 vie_encoder->UpdateProtectionMethod();
552 return 0;
553}
554
555int ViERTP_RTCPImpl::SetKeyFrameRequestMethod(
556 const int video_channel,
557 const ViEKeyFrameRequestMethod method) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000558 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
559 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000560 "%s(channel: %d, method: %d)", __FUNCTION__, video_channel,
561 method);
562
563 // Get the channel.
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000564 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000565 ViEChannel* vie_channel = cs.Channel(video_channel);
566 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000567 WEBRTC_TRACE(kTraceError, kTraceVideo,
568 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000569 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000570 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000571 return -1;
572 }
573 KeyFrameRequestMethod module_method = APIRequestToModuleRequest(method);
574 if (vie_channel->SetKeyFrameRequestMethod(module_method) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000575 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000576 return -1;
577 }
578 return 0;
579}
580
581int ViERTP_RTCPImpl::SetTMMBRStatus(const int video_channel,
582 const bool enable) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000583 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
584 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000585 "%s(channel: %d, enable: %d)", __FUNCTION__, video_channel,
586 enable);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000587 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000588 ViEChannel* vie_channel = cs.Channel(video_channel);
589 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000590 WEBRTC_TRACE(kTraceError, kTraceVideo,
591 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000592 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000593 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000594 return -1;
595 }
596 if (vie_channel->EnableTMMBR(enable) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000597 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000598 return -1;
599 }
600 return 0;
601}
602
mflodman@webrtc.org6cf529d2012-01-24 06:16:16 +0000603int ViERTP_RTCPImpl::SetRembStatus(int video_channel, bool sender,
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000604 bool receiver) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000605 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
606 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000607 "ViERTP_RTCPImpl::SetRembStatus(%d, %d, %d)", video_channel,
608 sender, receiver);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000609 if (!shared_data_->channel_manager()->SetRembStatus(video_channel, sender,
610 receiver)) {
mflodman@webrtc.org6cf529d2012-01-24 06:16:16 +0000611 return -1;
612 }
613 return 0;
mflodman@webrtc.org84dc3d12011-12-22 10:26:13 +0000614}
615
stefan@webrtc.org976a7e62012-09-21 13:20:21 +0000616int ViERTP_RTCPImpl::SetBandwidthEstimationMode(BandwidthEstimationMode mode) {
617 WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(),
618 "ViERTP_RTCPImpl::SetBandwidthEstimationMode(%d)", mode);
619 if (!shared_data_->channel_manager()->SetBandwidthEstimationMode(mode)) {
620 return -1;
621 }
622 return 0;
623}
624
mflodman@webrtc.org90071dd2012-08-13 17:13:27 +0000625int ViERTP_RTCPImpl::SetSendTimestampOffsetStatus(int video_channel,
626 bool enable,
627 int id) {
628 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
629 ViEId(shared_data_->instance_id(), video_channel),
630 "ViERTP_RTCPImpl::SetSendTimestampOffsetStatus(%d, %d, %d)",
631 video_channel, enable, id);
632
633 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
634 ViEChannel* vie_channel = cs.Channel(video_channel);
635 if (!vie_channel) {
636 WEBRTC_TRACE(kTraceError, kTraceVideo,
637 ViEId(shared_data_->instance_id(), video_channel),
638 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
639 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
640 return -1;
641 }
642 if (vie_channel->SetSendTimestampOffsetStatus(enable, id) != 0) {
643 shared_data_->SetLastError(kViERtpRtcpUnknownError);
644 return -1;
645 }
646 return 0;
647}
648
649int ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(int video_channel,
650 bool enable,
651 int id) {
652 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
653 ViEId(shared_data_->instance_id(), video_channel),
654 "ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(%d, %d, %d)",
655 video_channel, enable, id);
656 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
657 ViEChannel* vie_channel = cs.Channel(video_channel);
658 if (!vie_channel) {
659 WEBRTC_TRACE(kTraceError, kTraceVideo,
660 ViEId(shared_data_->instance_id(), video_channel),
661 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
662 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
663 return -1;
664 }
665 if (vie_channel->SetReceiveTimestampOffsetStatus(enable, id) != 0) {
666 shared_data_->SetLastError(kViERtpRtcpUnknownError);
667 return -1;
668 }
669 return 0;
670}
671
mflodman@webrtc.org5a7507f2012-09-12 13:47:06 +0000672int ViERTP_RTCPImpl::SetTransmissionSmoothingStatus(int video_channel,
673 bool enable) {
674 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
675 ViEId(shared_data_->instance_id(), video_channel),
676 "%s(channel: %d, enble: %d)", __FUNCTION__, video_channel,
677 enable);
678 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
679 ViEChannel* vie_channel = cs.Channel(video_channel);
680 if (!vie_channel) {
681 WEBRTC_TRACE(kTraceError, kTraceVideo,
682 ViEId(shared_data_->instance_id(), video_channel),
683 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
684 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
685 return -1;
686 }
687 vie_channel->SetTransmissionSmoothingStatus(enable);
688 return 0;
689}
690
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000691int ViERTP_RTCPImpl::GetReceivedRTCPStatistics(const int video_channel,
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000692 uint16_t& fraction_lost,
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000693 unsigned int& cumulative_lost,
694 unsigned int& extended_max,
695 unsigned int& jitter,
696 int& rtt_ms) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000697 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
698 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000699 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000700 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000701 ViEChannel* vie_channel = cs.Channel(video_channel);
702 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000703 WEBRTC_TRACE(kTraceError, kTraceVideo,
704 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000705 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000706 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000707 return -1;
708 }
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000709 if (vie_channel->GetReceivedRtcpStatistics(&fraction_lost,
710 &cumulative_lost,
711 &extended_max,
712 &jitter,
713 &rtt_ms) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000714 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000715 return -1;
716 }
717 return 0;
718}
719
720int ViERTP_RTCPImpl::GetSentRTCPStatistics(const int video_channel,
mflodman@webrtc.org9ba151b2012-06-21 10:02:13 +0000721 uint16_t& fraction_lost,
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000722 unsigned int& cumulative_lost,
723 unsigned int& extended_max,
724 unsigned int& jitter,
725 int& rtt_ms) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000726 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
727 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000728 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000729 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000730 ViEChannel* vie_channel = cs.Channel(video_channel);
731 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000732 WEBRTC_TRACE(kTraceError, kTraceVideo,
733 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000734 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000735 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000736 return -1;
737 }
738
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000739 if (vie_channel->GetSendRtcpStatistics(&fraction_lost, &cumulative_lost,
740 &extended_max, &jitter,
741 &rtt_ms) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000742 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000743 return -1;
744 }
745 return 0;
746}
747
748int ViERTP_RTCPImpl::GetRTPStatistics(const int video_channel,
749 unsigned int& bytes_sent,
750 unsigned int& packets_sent,
751 unsigned int& bytes_received,
752 unsigned int& packets_received) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000753 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
754 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000755 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000756 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000757 ViEChannel* vie_channel = cs.Channel(video_channel);
758 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000759 WEBRTC_TRACE(kTraceError, kTraceVideo,
760 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000761 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000762 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000763 return -1;
764 }
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000765 if (vie_channel->GetRtpStatistics(&bytes_sent,
766 &packets_sent,
767 &bytes_received,
768 &packets_received) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000769 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000770 return -1;
771 }
772 return 0;
773}
774
775int ViERTP_RTCPImpl::GetBandwidthUsage(const int video_channel,
776 unsigned int& total_bitrate_sent,
777 unsigned int& video_bitrate_sent,
778 unsigned int& fec_bitrate_sent,
779 unsigned int& nackBitrateSent) const {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000780 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
781 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000782 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000783 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000784 ViEChannel* vie_channel = cs.Channel(video_channel);
785 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000786 WEBRTC_TRACE(kTraceError, kTraceVideo,
787 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000788 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000789 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000790 return -1;
791 }
mflodman@webrtc.orgf5e99db2012-06-27 09:49:37 +0000792 vie_channel->GetBandwidthUsage(&total_bitrate_sent,
793 &video_bitrate_sent,
794 &fec_bitrate_sent,
795 &nackBitrateSent);
stefan@webrtc.orgd0bdab02011-10-14 14:24:54 +0000796 return 0;
797}
798
stefan@webrtc.org439be292012-02-16 14:45:37 +0000799int ViERTP_RTCPImpl::GetEstimatedSendBandwidth(
stefan@webrtc.org07b45a52012-02-02 08:37:48 +0000800 const int video_channel,
801 unsigned int* estimated_bandwidth) const {
802 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
803 ViEId(shared_data_->instance_id(), video_channel),
804 "%s(channel: %d)", __FUNCTION__, video_channel);
805 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
806 ViEEncoder* vie_encoder = cs.Encoder(video_channel);
807 if (!vie_encoder) {
808 WEBRTC_TRACE(kTraceError, kTraceVideo,
809 ViEId(shared_data_->instance_id(), video_channel),
810 "%s: Could not get encoder for channel %d", __FUNCTION__,
811 video_channel);
812 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
813 return -1;
814 }
stefan@webrtc.org439be292012-02-16 14:45:37 +0000815 return vie_encoder->EstimatedSendBandwidth(
816 static_cast<WebRtc_UWord32*>(estimated_bandwidth));
817}
818
819int ViERTP_RTCPImpl::GetEstimatedReceiveBandwidth(
820 const int video_channel,
821 unsigned int* estimated_bandwidth) const {
822 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
823 ViEId(shared_data_->instance_id(), video_channel),
824 "%s(channel: %d)", __FUNCTION__, video_channel);
825 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
826 ViEChannel* vie_channel = cs.Channel(video_channel);
827 if (!vie_channel) {
828 WEBRTC_TRACE(kTraceError, kTraceVideo,
829 ViEId(shared_data_->instance_id(), video_channel),
830 "%s: Could not get channel %d", __FUNCTION__,
831 video_channel);
832 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
833 return -1;
834 }
835 return vie_channel->GetEstimatedReceiveBandwidth(
stefan@webrtc.org07b45a52012-02-02 08:37:48 +0000836 static_cast<WebRtc_UWord32*>(estimated_bandwidth));
837}
838
astor@webrtc.orgc0496e62012-08-10 10:14:43 +0000839int ViERTP_RTCPImpl::SetOverUseDetectorOptions(
840 const OverUseDetectorOptions& options) const {
841 if (!shared_data_->Initialized()) {
842 shared_data_->SetLastError(kViENotInitialized);
843 WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()),
844 "%s - ViE instance %d not initialized", __FUNCTION__,
845 shared_data_->instance_id());
846 return -1;
847 }
848 // Lock the channel manager to avoid creating a channel with
849 // "undefined" bwe settings (atomic copy).
850 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
851 shared_data_->SetOverUseDetectorOptions(options);
852 return 0;
853}
854
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000855int ViERTP_RTCPImpl::StartRTPDump(const int video_channel,
856 const char file_nameUTF8[1024],
857 RTPDirections direction) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000858 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
859 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000860 "%s(channel: %d, file_name: %s, direction: %d)", __FUNCTION__,
861 video_channel, file_nameUTF8, direction);
862 assert(FileWrapper::kMaxFileNameSize == 1024);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000863 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000864 ViEChannel* vie_channel = cs.Channel(video_channel);
865 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000866 WEBRTC_TRACE(kTraceError, kTraceVideo,
867 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000868 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000869 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000870 return -1;
871 }
872 if (vie_channel->StartRTPDump(file_nameUTF8, direction) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000873 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000874 return -1;
875 }
876 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000877}
878
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000879int ViERTP_RTCPImpl::StopRTPDump(const int video_channel,
880 RTPDirections direction) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000881 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
882 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000883 "%s(channel: %d, direction: %d)", __FUNCTION__, video_channel,
884 direction);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000885 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000886 ViEChannel* vie_channel = cs.Channel(video_channel);
887 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000888 WEBRTC_TRACE(kTraceError, kTraceVideo,
889 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000890 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000891 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000892 return -1;
893 }
894 if (vie_channel->StopRTPDump(direction) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000895 shared_data_->SetLastError(kViERtpRtcpUnknownError);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000896 return -1;
897 }
898 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000899}
900
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000901int ViERTP_RTCPImpl::RegisterRTPObserver(const int video_channel,
902 ViERTPObserver& observer) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000903 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
904 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000905 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000906 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000907 ViEChannel* vie_channel = cs.Channel(video_channel);
908 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000909 WEBRTC_TRACE(kTraceError, kTraceVideo,
910 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000911 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000912 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000913 return -1;
914 }
915 if (vie_channel->RegisterRtpObserver(&observer) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000916 shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000917 return -1;
918 }
919 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000920}
921
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000922int ViERTP_RTCPImpl::DeregisterRTPObserver(const int video_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000923 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
924 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000925 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000926 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000927 ViEChannel* vie_channel = cs.Channel(video_channel);
928 if (!vie_channel) {
929 WEBRTC_TRACE(kTraceError, kTraceVideo,
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000930 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000931 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000932 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000933 return -1;
934 }
935 if (vie_channel->RegisterRtpObserver(NULL) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000936 shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000937 return -1;
938 }
939 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000940}
941
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000942int ViERTP_RTCPImpl::RegisterRTCPObserver(const int video_channel,
943 ViERTCPObserver& observer) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000944 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
945 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000946 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000947 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000948 ViEChannel* vie_channel = cs.Channel(video_channel);
949 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000950 WEBRTC_TRACE(kTraceError, kTraceVideo,
951 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000952 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000953 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000954 return -1;
955 }
956 if (vie_channel->RegisterRtcpObserver(&observer) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000957 shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000958 return -1;
959 }
960 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000961}
962
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000963int ViERTP_RTCPImpl::DeregisterRTCPObserver(const int video_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000964 WEBRTC_TRACE(kTraceApiCall, kTraceVideo,
965 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000966 "%s(channel: %d)", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000967 ViEChannelManagerScoped cs(*(shared_data_->channel_manager()));
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000968 ViEChannel* vie_channel = cs.Channel(video_channel);
969 if (!vie_channel) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000970 WEBRTC_TRACE(kTraceError, kTraceVideo,
971 ViEId(shared_data_->instance_id(), video_channel),
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000972 "%s: Channel %d doesn't exist", __FUNCTION__, video_channel);
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000973 shared_data_->SetLastError(kViERtpRtcpInvalidChannelId);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000974 return -1;
975 }
976 if (vie_channel->RegisterRtcpObserver(NULL) != 0) {
mflodman@webrtc.orgb11424b2012-01-25 13:42:03 +0000977 shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered);
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000978 return -1;
979 }
980 return 0;
niklase@google.com470e71d2011-07-07 08:21:25 +0000981}
982
mflodman@webrtc.org8da24172011-12-19 14:18:41 +0000983} // namespace webrtc