niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
stefan@webrtc.org | 07b45a5 | 2012-02-02 08:37:48 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
pbos@webrtc.org | f5d4cb1 | 2013-05-17 13:44:48 +0000 | [diff] [blame^] | 11 | #include "webrtc/video_engine/vie_rtp_rtcp_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
pbos@webrtc.org | f5d4cb1 | 2013-05-17 13:44:48 +0000 | [diff] [blame^] | 13 | #include "webrtc/engine_configurations.h" |
| 14 | #include "webrtc/system_wrappers/interface/file_wrapper.h" |
| 15 | #include "webrtc/system_wrappers/interface/trace.h" |
| 16 | #include "webrtc/video_engine/include/vie_errors.h" |
| 17 | #include "webrtc/video_engine/vie_channel.h" |
| 18 | #include "webrtc/video_engine/vie_channel_manager.h" |
| 19 | #include "webrtc/video_engine/vie_defines.h" |
| 20 | #include "webrtc/video_engine/vie_encoder.h" |
| 21 | #include "webrtc/video_engine/vie_impl.h" |
| 22 | #include "webrtc/video_engine/vie_shared_data.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 24 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 25 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 26 | // Helper methods for converting between module format and ViE API format. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 28 | static RTCPMethod ViERTCPModeToRTCPMethod(ViERTCPMode api_mode) { |
| 29 | switch (api_mode) { |
| 30 | case kRtcpNone: |
| 31 | return kRtcpOff; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 33 | case kRtcpCompound_RFC4585: |
| 34 | return kRtcpCompound; |
| 35 | |
| 36 | case kRtcpNonCompound_RFC5506: |
| 37 | return kRtcpNonCompound; |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 38 | } |
mflodman@webrtc.org | 657b2a4 | 2012-02-06 11:06:01 +0000 | [diff] [blame] | 39 | assert(false); |
| 40 | return kRtcpOff; |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | static 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.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 53 | } |
mflodman@webrtc.org | 657b2a4 | 2012-02-06 11:06:01 +0000 | [diff] [blame] | 54 | assert(false); |
| 55 | return kRtcpNone; |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | static 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.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 72 | } |
mflodman@webrtc.org | 657b2a4 | 2012-02-06 11:06:01 +0000 | [diff] [blame] | 73 | assert(false); |
| 74 | return kKeyFrameReqFirRtp; |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | ViERTP_RTCP* ViERTP_RTCP::GetInterface(VideoEngine* video_engine) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 78 | #ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 79 | if (!video_engine) { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | return NULL; |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 81 | } |
andrew@webrtc.org | d72262d | 2013-05-09 02:12:07 +0000 | [diff] [blame] | 82 | VideoEngineImpl* vie_impl = static_cast<VideoEngineImpl*>(video_engine); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | #endif |
| 90 | } |
| 91 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 92 | int ViERTP_RTCPImpl::Release() { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 93 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 94 | "ViERTP_RTCP::Release()"); |
| 95 | // Decrease ref count. |
| 96 | (*this)--; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 97 | |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 98 | int32_t ref_count = GetCount(); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 99 | if (ref_count < 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 100 | WEBRTC_TRACE(kTraceWarning, kTraceVideo, shared_data_->instance_id(), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 101 | "ViERTP_RTCP release too many times"); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 102 | shared_data_->SetLastError(kViEAPIDoesNotExist); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 103 | return -1; |
| 104 | } |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 105 | WEBRTC_TRACE(kTraceInfo, kTraceVideo, shared_data_->instance_id(), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 106 | "ViERTP_RTCP reference count: %d", ref_count); |
| 107 | return ref_count; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 108 | } |
| 109 | |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 110 | ViERTP_RTCPImpl::ViERTP_RTCPImpl(ViESharedData* shared_data) |
| 111 | : shared_data_(shared_data) { |
| 112 | WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 113 | "ViERTP_RTCPImpl::ViERTP_RTCPImpl() Ctor"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | } |
| 115 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 116 | ViERTP_RTCPImpl::~ViERTP_RTCPImpl() { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 117 | WEBRTC_TRACE(kTraceMemory, kTraceVideo, shared_data_->instance_id(), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 118 | "ViERTP_RTCPImpl::~ViERTP_RTCPImpl() Dtor"); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 119 | } |
| 120 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 121 | int ViERTP_RTCPImpl::SetLocalSSRC(const int video_channel, |
pwestin@webrtc.org | 1da1ce0 | 2011-10-13 15:19:55 +0000 | [diff] [blame] | 122 | const unsigned int SSRC, |
| 123 | const StreamType usage, |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 124 | const unsigned char simulcast_idx) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 125 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 126 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 127 | "%s(channel: %d, SSRC: %d)", __FUNCTION__, video_channel, SSRC); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 128 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 129 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 130 | if (!vie_channel) { |
stefan@webrtc.org | d0bdab0 | 2011-10-14 14:24:54 +0000 | [diff] [blame] | 131 | // The channel doesn't exists |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 132 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 133 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 134 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 135 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 136 | return -1; |
| 137 | } |
| 138 | if (vie_channel->SetSSRC(SSRC, usage, simulcast_idx) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 139 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 140 | return -1; |
| 141 | } |
| 142 | return 0; |
| 143 | } |
| 144 | |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 145 | int 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.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 149 | ViEId(shared_data_->instance_id(), videoChannel), |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 150 | "%s(channel: %d, usage:%d SSRC: 0x%x)", |
| 151 | __FUNCTION__, usage, videoChannel, SSRC); |
| 152 | |
| 153 | // Get the channel |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 154 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 155 | ViEChannel* ptrViEChannel = cs.Channel(videoChannel); |
| 156 | if (ptrViEChannel == NULL) { |
| 157 | // The channel doesn't exists |
| 158 | WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 159 | ViEId(shared_data_->instance_id(), videoChannel), |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 160 | "%s: Channel %d doesn't exist", |
| 161 | __FUNCTION__, videoChannel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 162 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 163 | return -1; |
| 164 | } |
| 165 | if (ptrViEChannel->SetRemoteSSRCType(usage, SSRC) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 166 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
pwestin@webrtc.org | 8281e7d | 2012-01-10 14:09:18 +0000 | [diff] [blame] | 167 | return -1; |
| 168 | } |
| 169 | return 0; |
| 170 | } |
| 171 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 172 | int ViERTP_RTCPImpl::GetLocalSSRC(const int video_channel, |
| 173 | unsigned int& SSRC) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 174 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 175 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 176 | "%s(channel: %d, SSRC: %d)", __FUNCTION__, video_channel, SSRC); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 177 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 178 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 179 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 180 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 181 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 182 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 183 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 184 | return -1; |
| 185 | } |
mflodman@webrtc.org | d6ec386 | 2012-10-25 11:30:29 +0000 | [diff] [blame] | 186 | uint8_t idx = 0; |
| 187 | if (vie_channel->GetLocalSSRC(idx, &SSRC) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 188 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 189 | return -1; |
| 190 | } |
| 191 | return 0; |
| 192 | } |
| 193 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 194 | int ViERTP_RTCPImpl::GetRemoteSSRC(const int video_channel, |
| 195 | unsigned int& SSRC) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 196 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 197 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 198 | "%s(channel: %d)", __FUNCTION__, video_channel, SSRC); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 199 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 200 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 201 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 202 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 203 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 204 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 205 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 206 | return -1; |
| 207 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 208 | if (vie_channel->GetRemoteSSRC(&SSRC) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 209 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 210 | return -1; |
| 211 | } |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | int ViERTP_RTCPImpl::GetRemoteCSRCs(const int video_channel, |
| 216 | unsigned int CSRCs[kRtpCsrcSize]) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 217 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 218 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 219 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 220 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 221 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 222 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 223 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 224 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 225 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 226 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 227 | return -1; |
| 228 | } |
| 229 | if (vie_channel->GetRemoteCSRC(CSRCs) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 230 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 231 | return -1; |
| 232 | } |
| 233 | return 0; |
| 234 | } |
| 235 | |
mflodman@webrtc.org | 9f5ebb5 | 2013-04-12 14:55:46 +0000 | [diff] [blame] | 236 | int ViERTP_RTCPImpl::SetRtxSendPayloadType(const int video_channel, |
| 237 | const uint8_t payload_type) { |
| 238 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 239 | ViEId(shared_data_->instance_id(), video_channel), |
| 240 | "%s(channel: %d)", __FUNCTION__, video_channel); |
| 241 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 242 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 243 | if (!vie_channel) { |
| 244 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 245 | ViEId(shared_data_->instance_id(), video_channel), |
| 246 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 247 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 248 | return -1; |
| 249 | } |
| 250 | if (!vie_channel->SetRtxSendPayloadType(payload_type)) { |
| 251 | return -1; |
| 252 | } |
| 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | int ViERTP_RTCPImpl::SetRtxReceivePayloadType(const int video_channel, |
| 257 | const uint8_t payload_type) { |
| 258 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 259 | ViEId(shared_data_->instance_id(), video_channel), |
| 260 | "%s(channel: %d)", __FUNCTION__, video_channel); |
| 261 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 262 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 263 | if (!vie_channel) { |
| 264 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 265 | ViEId(shared_data_->instance_id(), video_channel), |
| 266 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 267 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 268 | return -1; |
| 269 | } |
| 270 | vie_channel->SetRtxReceivePayloadType(payload_type); |
| 271 | return 0; |
| 272 | } |
| 273 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 274 | int ViERTP_RTCPImpl::SetStartSequenceNumber(const int video_channel, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 275 | uint16_t sequence_number) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 276 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 277 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 278 | "%s(channel: %d, sequence_number: %u)", __FUNCTION__, |
| 279 | video_channel, sequence_number); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 280 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 281 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 282 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 283 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 284 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 285 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 286 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 287 | return -1; |
| 288 | } |
| 289 | if (vie_channel->Sending()) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 290 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 291 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 292 | "%s: Channel %d already sending.", __FUNCTION__, |
| 293 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 294 | shared_data_->SetLastError(kViERtpRtcpAlreadySending); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 295 | return -1; |
| 296 | } |
| 297 | if (vie_channel->SetStartSequenceNumber(sequence_number) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 298 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 299 | return -1; |
| 300 | } |
| 301 | return 0; |
| 302 | } |
| 303 | |
| 304 | int ViERTP_RTCPImpl::SetRTCPStatus(const int video_channel, |
| 305 | const ViERTCPMode rtcp_mode) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 306 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 307 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 308 | "%s(channel: %d, mode: %d)", __FUNCTION__, video_channel, |
| 309 | rtcp_mode); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 310 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 311 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 312 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 313 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 314 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 315 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 316 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
stefan@webrtc.org | d0bdab0 | 2011-10-14 14:24:54 +0000 | [diff] [blame] | 317 | return -1; |
| 318 | } |
| 319 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 320 | RTCPMethod module_mode = ViERTCPModeToRTCPMethod(rtcp_mode); |
| 321 | if (vie_channel->SetRTCPMode(module_mode) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 322 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 323 | return -1; |
| 324 | } |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | int ViERTP_RTCPImpl::GetRTCPStatus(const int video_channel, |
| 329 | ViERTCPMode& rtcp_mode) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 330 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 331 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 332 | "%s(channel: %d)", __FUNCTION__, video_channel, rtcp_mode); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 333 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 334 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 335 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 336 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 337 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 338 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 339 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 340 | return -1; |
| 341 | } |
| 342 | RTCPMethod module_mode = kRtcpOff; |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 343 | if (vie_channel->GetRTCPMode(&module_mode) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 344 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 345 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 346 | "%s: could not get current RTCP mode", __FUNCTION__); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 347 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 348 | return -1; |
| 349 | } |
| 350 | rtcp_mode = RTCPMethodToViERTCPMode(module_mode); |
| 351 | return 0; |
| 352 | } |
| 353 | |
| 354 | int ViERTP_RTCPImpl::SetRTCPCName(const int video_channel, |
| 355 | const char rtcp_cname[KMaxRTCPCNameLength]) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 356 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 357 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 358 | "%s(channel: %d, name: %s)", __FUNCTION__, video_channel, |
| 359 | rtcp_cname); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 360 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 361 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 362 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 363 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 364 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 365 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 366 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 367 | return -1; |
| 368 | } |
| 369 | if (vie_channel->Sending()) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 370 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 371 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 372 | "%s: Channel %d already sending.", __FUNCTION__, |
| 373 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 374 | shared_data_->SetLastError(kViERtpRtcpAlreadySending); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 375 | return -1; |
| 376 | } |
| 377 | if (vie_channel->SetRTCPCName(rtcp_cname) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 378 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 379 | return -1; |
| 380 | } |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | int ViERTP_RTCPImpl::GetRTCPCName(const int video_channel, |
| 385 | char rtcp_cname[KMaxRTCPCNameLength]) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 386 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 387 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 388 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 389 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 390 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 391 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 392 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 393 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 394 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 395 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 396 | return -1; |
| 397 | } |
| 398 | if (vie_channel->GetRTCPCName(rtcp_cname) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 399 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 400 | return -1; |
| 401 | } |
| 402 | return 0; |
| 403 | } |
| 404 | |
| 405 | int ViERTP_RTCPImpl::GetRemoteRTCPCName( |
| 406 | const int video_channel, |
| 407 | char rtcp_cname[KMaxRTCPCNameLength]) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 408 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 409 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 410 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 411 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 412 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 413 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 414 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 415 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 416 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 417 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 418 | return -1; |
| 419 | } |
| 420 | if (vie_channel->GetRemoteRTCPCName(rtcp_cname) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 421 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 422 | return -1; |
| 423 | } |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | int ViERTP_RTCPImpl::SendApplicationDefinedRTCPPacket( |
| 428 | const int video_channel, |
| 429 | const unsigned char sub_type, |
| 430 | unsigned int name, |
| 431 | const char* data, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 432 | uint16_t data_length_in_bytes) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 433 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 434 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 435 | "%s(channel: %d, sub_type: %c, name: %d, data: x, length: %u)", |
| 436 | __FUNCTION__, video_channel, sub_type, name, |
| 437 | data_length_in_bytes); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 438 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 439 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 440 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 441 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 442 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 443 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 444 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 445 | return -1; |
| 446 | } |
| 447 | if (!vie_channel->Sending()) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 448 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 449 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 450 | "%s: Channel %d not sending", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 451 | shared_data_->SetLastError(kViERtpRtcpNotSending); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 452 | return -1; |
| 453 | } |
| 454 | RTCPMethod method; |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 455 | if (vie_channel->GetRTCPMode(&method) != 0 || method == kRtcpOff) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 456 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 457 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 458 | "%s: RTCP disabled on channel %d.", __FUNCTION__, |
| 459 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 460 | shared_data_->SetLastError(kViERtpRtcpRtcpDisabled); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 461 | return -1; |
| 462 | } |
| 463 | if (vie_channel->SendApplicationDefinedRTCPPacket( |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 464 | sub_type, name, reinterpret_cast<const uint8_t*>(data), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 465 | data_length_in_bytes) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 466 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 467 | return -1; |
| 468 | } |
| 469 | return 0; |
| 470 | } |
| 471 | |
| 472 | int ViERTP_RTCPImpl::SetNACKStatus(const int video_channel, const bool enable) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 473 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 474 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 475 | "%s(channel: %d, enable: %d)", __FUNCTION__, video_channel, |
| 476 | enable); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 477 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 478 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 479 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 480 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 481 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 482 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 483 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 484 | return -1; |
| 485 | } |
| 486 | if (vie_channel->SetNACKStatus(enable) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 487 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 488 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 489 | "%s: failed for channel %d", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 490 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 491 | return -1; |
| 492 | } |
| 493 | |
| 494 | // Update the encoder |
| 495 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 496 | if (!vie_encoder) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 497 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 498 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 499 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 500 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 501 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 502 | return -1; |
| 503 | } |
| 504 | vie_encoder->UpdateProtectionMethod(); |
| 505 | return 0; |
| 506 | } |
| 507 | |
| 508 | int ViERTP_RTCPImpl::SetFECStatus(const int video_channel, const bool enable, |
| 509 | const unsigned char payload_typeRED, |
| 510 | const unsigned char payload_typeFEC) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 511 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 512 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 513 | "%s(channel: %d, enable: %d, payload_typeRED: %u, " |
| 514 | "payloadTypeFEC: %u)", |
| 515 | __FUNCTION__, video_channel, enable, payload_typeRED, |
| 516 | payload_typeFEC); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 517 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 518 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 519 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 520 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 521 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 522 | "%s: Channel %d doesn't exist", __FUNCTION__, |
| 523 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 524 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 525 | return -1; |
| 526 | } |
| 527 | if (vie_channel->SetFECStatus(enable, payload_typeRED, |
| 528 | payload_typeFEC) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 529 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 530 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 531 | "%s: failed for channel %d", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 532 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 533 | return -1; |
| 534 | } |
| 535 | // Update the encoder. |
| 536 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 537 | if (!vie_encoder) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 538 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 539 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 540 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 541 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 542 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 543 | return -1; |
| 544 | } |
| 545 | vie_encoder->UpdateProtectionMethod(); |
| 546 | return 0; |
| 547 | } |
| 548 | |
| 549 | int ViERTP_RTCPImpl::SetHybridNACKFECStatus( |
| 550 | const int video_channel, |
| 551 | const bool enable, |
| 552 | const unsigned char payload_typeRED, |
| 553 | const unsigned char payload_typeFEC) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 554 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 555 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 556 | "%s(channel: %d, enable: %d, payload_typeRED: %u, " |
| 557 | "payloadTypeFEC: %u)", |
| 558 | __FUNCTION__, video_channel, enable, payload_typeRED, |
| 559 | payload_typeFEC); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 560 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 561 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 562 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 563 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 564 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 565 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 566 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 567 | return -1; |
| 568 | } |
| 569 | |
| 570 | // Update the channel status with hybrid NACK FEC mode. |
| 571 | if (vie_channel->SetHybridNACKFECStatus(enable, payload_typeRED, |
| 572 | payload_typeFEC) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 573 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 574 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 575 | "%s: failed for channel %d", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 576 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 577 | return -1; |
| 578 | } |
| 579 | |
| 580 | // Update the encoder. |
| 581 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 582 | if (!vie_encoder) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 583 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 584 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 585 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 586 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 587 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 588 | return -1; |
| 589 | } |
| 590 | vie_encoder->UpdateProtectionMethod(); |
| 591 | return 0; |
| 592 | } |
| 593 | |
mikhal@webrtc.org | ef9f76a | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 594 | int ViERTP_RTCPImpl::SetSenderBufferingMode(int video_channel, |
mikhal@webrtc.org | dbe97d2 | 2013-02-01 19:33:21 +0000 | [diff] [blame] | 595 | int target_delay_ms) { |
| 596 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 597 | ViEId(shared_data_->instance_id(), video_channel), |
mikhal@webrtc.org | ef9f76a | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 598 | "%s(channel: %d, sender target_delay: %d)", |
mikhal@webrtc.org | dbe97d2 | 2013-02-01 19:33:21 +0000 | [diff] [blame] | 599 | __FUNCTION__, video_channel, target_delay_ms); |
| 600 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 601 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 602 | if (!vie_channel) { |
| 603 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 604 | ViEId(shared_data_->instance_id(), video_channel), |
| 605 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 606 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 607 | return -1; |
| 608 | } |
mikhal@webrtc.org | 3d305c6 | 2013-02-10 18:42:55 +0000 | [diff] [blame] | 609 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 610 | if (!vie_encoder) { |
| 611 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 612 | ViEId(shared_data_->instance_id(), video_channel), |
| 613 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 614 | video_channel); |
| 615 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 616 | return -1; |
| 617 | } |
mikhal@webrtc.org | dbe97d2 | 2013-02-01 19:33:21 +0000 | [diff] [blame] | 618 | |
mikhal@webrtc.org | ef9f76a | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 619 | // Update the channel with buffering mode settings. |
| 620 | if (vie_channel->SetSenderBufferingMode(target_delay_ms) != 0) { |
mikhal@webrtc.org | dbe97d2 | 2013-02-01 19:33:21 +0000 | [diff] [blame] | 621 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 622 | ViEId(shared_data_->instance_id(), video_channel), |
| 623 | "%s: failed for channel %d", __FUNCTION__, video_channel); |
| 624 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
| 625 | return -1; |
| 626 | } |
mikhal@webrtc.org | 3d305c6 | 2013-02-10 18:42:55 +0000 | [diff] [blame] | 627 | |
mikhal@webrtc.org | ef9f76a | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 628 | // Update the encoder's buffering mode settings. |
| 629 | vie_encoder->SetSenderBufferingMode(target_delay_ms); |
| 630 | return 0; |
| 631 | } |
| 632 | |
| 633 | int ViERTP_RTCPImpl::SetReceiverBufferingMode(int video_channel, |
stefan@webrtc.org | 8ca8a71 | 2013-04-23 16:48:32 +0000 | [diff] [blame] | 634 | int target_delay_ms) { |
mikhal@webrtc.org | ef9f76a | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 635 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 636 | ViEId(shared_data_->instance_id(), video_channel), |
| 637 | "%s(channel: %d, receiver target_delay: %d)", |
| 638 | __FUNCTION__, video_channel, target_delay_ms); |
| 639 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 640 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 641 | if (!vie_channel) { |
| 642 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 643 | ViEId(shared_data_->instance_id(), video_channel), |
| 644 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 645 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 646 | return -1; |
| 647 | } |
stefan@webrtc.org | 8ca8a71 | 2013-04-23 16:48:32 +0000 | [diff] [blame] | 648 | |
mikhal@webrtc.org | ef9f76a | 2013-02-15 23:22:18 +0000 | [diff] [blame] | 649 | // Update the channel with buffering mode settings. |
| 650 | if (vie_channel->SetReceiverBufferingMode(target_delay_ms) != 0) { |
| 651 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 652 | ViEId(shared_data_->instance_id(), video_channel), |
| 653 | "%s: failed for channel %d", __FUNCTION__, video_channel); |
| 654 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
| 655 | return -1; |
| 656 | } |
mikhal@webrtc.org | dbe97d2 | 2013-02-01 19:33:21 +0000 | [diff] [blame] | 657 | return 0; |
| 658 | } |
| 659 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 660 | int ViERTP_RTCPImpl::SetKeyFrameRequestMethod( |
| 661 | const int video_channel, |
| 662 | const ViEKeyFrameRequestMethod method) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 663 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 664 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 665 | "%s(channel: %d, method: %d)", __FUNCTION__, video_channel, |
| 666 | method); |
| 667 | |
| 668 | // Get the channel. |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 669 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 670 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 671 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 672 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 673 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 674 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 675 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 676 | return -1; |
| 677 | } |
| 678 | KeyFrameRequestMethod module_method = APIRequestToModuleRequest(method); |
| 679 | if (vie_channel->SetKeyFrameRequestMethod(module_method) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 680 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 681 | return -1; |
| 682 | } |
| 683 | return 0; |
| 684 | } |
| 685 | |
| 686 | int ViERTP_RTCPImpl::SetTMMBRStatus(const int video_channel, |
| 687 | const bool enable) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 688 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 689 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 690 | "%s(channel: %d, enable: %d)", __FUNCTION__, video_channel, |
| 691 | enable); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 692 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 693 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 694 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 695 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 696 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 697 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 698 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 699 | return -1; |
| 700 | } |
| 701 | if (vie_channel->EnableTMMBR(enable) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 702 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 703 | return -1; |
| 704 | } |
| 705 | return 0; |
| 706 | } |
| 707 | |
mflodman@webrtc.org | 6cf529d | 2012-01-24 06:16:16 +0000 | [diff] [blame] | 708 | int ViERTP_RTCPImpl::SetRembStatus(int video_channel, bool sender, |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 709 | bool receiver) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 710 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 711 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 712 | "ViERTP_RTCPImpl::SetRembStatus(%d, %d, %d)", video_channel, |
| 713 | sender, receiver); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 714 | if (!shared_data_->channel_manager()->SetRembStatus(video_channel, sender, |
| 715 | receiver)) { |
mflodman@webrtc.org | 6cf529d | 2012-01-24 06:16:16 +0000 | [diff] [blame] | 716 | return -1; |
| 717 | } |
| 718 | return 0; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 719 | } |
| 720 | |
mflodman@webrtc.org | 90071dd | 2012-08-13 17:13:27 +0000 | [diff] [blame] | 721 | int ViERTP_RTCPImpl::SetSendTimestampOffsetStatus(int video_channel, |
| 722 | bool enable, |
| 723 | int id) { |
| 724 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 725 | ViEId(shared_data_->instance_id(), video_channel), |
| 726 | "ViERTP_RTCPImpl::SetSendTimestampOffsetStatus(%d, %d, %d)", |
| 727 | video_channel, enable, id); |
| 728 | |
| 729 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 730 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 731 | if (!vie_channel) { |
| 732 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 733 | ViEId(shared_data_->instance_id(), video_channel), |
| 734 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 735 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 736 | return -1; |
| 737 | } |
| 738 | if (vie_channel->SetSendTimestampOffsetStatus(enable, id) != 0) { |
| 739 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
| 740 | return -1; |
| 741 | } |
| 742 | return 0; |
| 743 | } |
| 744 | |
| 745 | int ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(int video_channel, |
| 746 | bool enable, |
| 747 | int id) { |
| 748 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 749 | ViEId(shared_data_->instance_id(), video_channel), |
| 750 | "ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(%d, %d, %d)", |
| 751 | video_channel, enable, id); |
| 752 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 753 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 754 | if (!vie_channel) { |
| 755 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 756 | ViEId(shared_data_->instance_id(), video_channel), |
| 757 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 758 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 759 | return -1; |
| 760 | } |
| 761 | if (vie_channel->SetReceiveTimestampOffsetStatus(enable, id) != 0) { |
| 762 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
| 763 | return -1; |
| 764 | } |
| 765 | return 0; |
| 766 | } |
| 767 | |
mflodman@webrtc.org | 5a7507f | 2012-09-12 13:47:06 +0000 | [diff] [blame] | 768 | int ViERTP_RTCPImpl::SetTransmissionSmoothingStatus(int video_channel, |
| 769 | bool enable) { |
| 770 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 771 | ViEId(shared_data_->instance_id(), video_channel), |
| 772 | "%s(channel: %d, enble: %d)", __FUNCTION__, video_channel, |
| 773 | enable); |
| 774 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 775 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 776 | if (!vie_channel) { |
| 777 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 778 | ViEId(shared_data_->instance_id(), video_channel), |
| 779 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 780 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 781 | return -1; |
| 782 | } |
| 783 | vie_channel->SetTransmissionSmoothingStatus(enable); |
| 784 | return 0; |
| 785 | } |
| 786 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 787 | int ViERTP_RTCPImpl::GetReceivedRTCPStatistics(const int video_channel, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 788 | uint16_t& fraction_lost, |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 789 | unsigned int& cumulative_lost, |
| 790 | unsigned int& extended_max, |
| 791 | unsigned int& jitter, |
| 792 | int& rtt_ms) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 793 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 794 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 795 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 796 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 797 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 798 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 799 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 800 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 801 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 802 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 803 | return -1; |
| 804 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 805 | if (vie_channel->GetReceivedRtcpStatistics(&fraction_lost, |
| 806 | &cumulative_lost, |
| 807 | &extended_max, |
| 808 | &jitter, |
| 809 | &rtt_ms) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 810 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 811 | return -1; |
| 812 | } |
| 813 | return 0; |
| 814 | } |
| 815 | |
| 816 | int ViERTP_RTCPImpl::GetSentRTCPStatistics(const int video_channel, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 817 | uint16_t& fraction_lost, |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 818 | unsigned int& cumulative_lost, |
| 819 | unsigned int& extended_max, |
| 820 | unsigned int& jitter, |
| 821 | int& rtt_ms) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 822 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 823 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 824 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 825 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 826 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 827 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 828 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 829 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 830 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 831 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 832 | return -1; |
| 833 | } |
| 834 | |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 835 | if (vie_channel->GetSendRtcpStatistics(&fraction_lost, &cumulative_lost, |
| 836 | &extended_max, &jitter, |
| 837 | &rtt_ms) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 838 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 839 | return -1; |
| 840 | } |
| 841 | return 0; |
| 842 | } |
| 843 | |
| 844 | int ViERTP_RTCPImpl::GetRTPStatistics(const int video_channel, |
| 845 | unsigned int& bytes_sent, |
| 846 | unsigned int& packets_sent, |
| 847 | unsigned int& bytes_received, |
| 848 | unsigned int& packets_received) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 849 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 850 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 851 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 852 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 853 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 854 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 855 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 856 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 857 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 858 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 859 | return -1; |
| 860 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 861 | if (vie_channel->GetRtpStatistics(&bytes_sent, |
| 862 | &packets_sent, |
| 863 | &bytes_received, |
| 864 | &packets_received) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 865 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 866 | return -1; |
| 867 | } |
| 868 | return 0; |
| 869 | } |
| 870 | |
| 871 | int ViERTP_RTCPImpl::GetBandwidthUsage(const int video_channel, |
| 872 | unsigned int& total_bitrate_sent, |
| 873 | unsigned int& video_bitrate_sent, |
| 874 | unsigned int& fec_bitrate_sent, |
| 875 | unsigned int& nackBitrateSent) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 876 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 877 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 878 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 879 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 880 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 881 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 882 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 883 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 884 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 885 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 886 | return -1; |
| 887 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 888 | vie_channel->GetBandwidthUsage(&total_bitrate_sent, |
| 889 | &video_bitrate_sent, |
| 890 | &fec_bitrate_sent, |
| 891 | &nackBitrateSent); |
stefan@webrtc.org | d0bdab0 | 2011-10-14 14:24:54 +0000 | [diff] [blame] | 892 | return 0; |
| 893 | } |
| 894 | |
stefan@webrtc.org | 439be29 | 2012-02-16 14:45:37 +0000 | [diff] [blame] | 895 | int ViERTP_RTCPImpl::GetEstimatedSendBandwidth( |
stefan@webrtc.org | 07b45a5 | 2012-02-02 08:37:48 +0000 | [diff] [blame] | 896 | const int video_channel, |
| 897 | unsigned int* estimated_bandwidth) const { |
| 898 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 899 | ViEId(shared_data_->instance_id(), video_channel), |
| 900 | "%s(channel: %d)", __FUNCTION__, video_channel); |
| 901 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 902 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 903 | if (!vie_encoder) { |
| 904 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 905 | ViEId(shared_data_->instance_id(), video_channel), |
| 906 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 907 | video_channel); |
| 908 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 909 | return -1; |
| 910 | } |
stefan@webrtc.org | 439be29 | 2012-02-16 14:45:37 +0000 | [diff] [blame] | 911 | return vie_encoder->EstimatedSendBandwidth( |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 912 | static_cast<uint32_t*>(estimated_bandwidth)); |
stefan@webrtc.org | 439be29 | 2012-02-16 14:45:37 +0000 | [diff] [blame] | 913 | } |
| 914 | |
| 915 | int ViERTP_RTCPImpl::GetEstimatedReceiveBandwidth( |
| 916 | const int video_channel, |
| 917 | unsigned int* estimated_bandwidth) const { |
| 918 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 919 | ViEId(shared_data_->instance_id(), video_channel), |
| 920 | "%s(channel: %d)", __FUNCTION__, video_channel); |
| 921 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 922 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 923 | if (!vie_channel) { |
| 924 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 925 | ViEId(shared_data_->instance_id(), video_channel), |
| 926 | "%s: Could not get channel %d", __FUNCTION__, |
| 927 | video_channel); |
| 928 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 929 | return -1; |
| 930 | } |
mflodman@webrtc.org | 4fd5527 | 2013-02-06 17:46:39 +0000 | [diff] [blame] | 931 | vie_channel->GetEstimatedReceiveBandwidth( |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 932 | static_cast<uint32_t*>(estimated_bandwidth)); |
mflodman@webrtc.org | 4fd5527 | 2013-02-06 17:46:39 +0000 | [diff] [blame] | 933 | return 0; |
stefan@webrtc.org | 07b45a5 | 2012-02-02 08:37:48 +0000 | [diff] [blame] | 934 | } |
| 935 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 936 | int ViERTP_RTCPImpl::StartRTPDump(const int video_channel, |
| 937 | const char file_nameUTF8[1024], |
| 938 | RTPDirections direction) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 939 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 940 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 941 | "%s(channel: %d, file_name: %s, direction: %d)", __FUNCTION__, |
| 942 | video_channel, file_nameUTF8, direction); |
| 943 | assert(FileWrapper::kMaxFileNameSize == 1024); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 944 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 945 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 946 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 947 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 948 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 949 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 950 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 951 | return -1; |
| 952 | } |
| 953 | if (vie_channel->StartRTPDump(file_nameUTF8, direction) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 954 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 955 | return -1; |
| 956 | } |
| 957 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 958 | } |
| 959 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 960 | int ViERTP_RTCPImpl::StopRTPDump(const int video_channel, |
| 961 | RTPDirections direction) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 962 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 963 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 964 | "%s(channel: %d, direction: %d)", __FUNCTION__, video_channel, |
| 965 | direction); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 966 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 967 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 968 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 969 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 970 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 971 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 972 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 973 | return -1; |
| 974 | } |
| 975 | if (vie_channel->StopRTPDump(direction) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 976 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 977 | return -1; |
| 978 | } |
| 979 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 980 | } |
| 981 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 982 | int ViERTP_RTCPImpl::RegisterRTPObserver(const int video_channel, |
| 983 | ViERTPObserver& observer) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 984 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 985 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 986 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 987 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 988 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 989 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 990 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 991 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 992 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 993 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 994 | return -1; |
| 995 | } |
| 996 | if (vie_channel->RegisterRtpObserver(&observer) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 997 | shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 998 | return -1; |
| 999 | } |
| 1000 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1001 | } |
| 1002 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1003 | int ViERTP_RTCPImpl::DeregisterRTPObserver(const int video_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1004 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 1005 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1006 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1007 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1008 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 1009 | if (!vie_channel) { |
| 1010 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1011 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1012 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1013 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1014 | return -1; |
| 1015 | } |
| 1016 | if (vie_channel->RegisterRtpObserver(NULL) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1017 | shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1018 | return -1; |
| 1019 | } |
| 1020 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1021 | } |
| 1022 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1023 | int ViERTP_RTCPImpl::RegisterRTCPObserver(const int video_channel, |
| 1024 | ViERTCPObserver& observer) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1025 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 1026 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1027 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1028 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1029 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 1030 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1031 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 1032 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1033 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1034 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1035 | return -1; |
| 1036 | } |
| 1037 | if (vie_channel->RegisterRtcpObserver(&observer) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1038 | shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1039 | return -1; |
| 1040 | } |
| 1041 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1042 | } |
| 1043 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1044 | int ViERTP_RTCPImpl::DeregisterRTCPObserver(const int video_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1045 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 1046 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1047 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1048 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1049 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 1050 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1051 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 1052 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1053 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1054 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1055 | return -1; |
| 1056 | } |
| 1057 | if (vie_channel->RegisterRtcpObserver(NULL) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1058 | shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1059 | return -1; |
| 1060 | } |
| 1061 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1062 | } |
| 1063 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1064 | } // namespace webrtc |