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 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 11 | #include "video_engine/vie_rtp_rtcp_impl.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 12 | |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 13 | #include "engine_configurations.h" // NOLINT |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 14 | #include "system_wrappers/interface/file_wrapper.h" |
| 15 | #include "system_wrappers/interface/trace.h" |
mflodman@webrtc.org | a4863db | 2011-12-22 08:51:52 +0000 | [diff] [blame] | 16 | #include "video_engine/include/vie_errors.h" |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 17 | #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.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 22 | #include "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 | } |
| 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.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 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 98 | WebRtc_Word32 ref_count = GetCount(); |
| 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 | |
| 236 | int ViERTP_RTCPImpl::SetStartSequenceNumber(const int video_channel, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 237 | uint16_t sequence_number) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 238 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 239 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 240 | "%s(channel: %d, sequence_number: %u)", __FUNCTION__, |
| 241 | video_channel, sequence_number); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 242 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 243 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 244 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 245 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 246 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 247 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 248 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 249 | return -1; |
| 250 | } |
| 251 | if (vie_channel->Sending()) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 252 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 253 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 254 | "%s: Channel %d already sending.", __FUNCTION__, |
| 255 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 256 | shared_data_->SetLastError(kViERtpRtcpAlreadySending); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 257 | return -1; |
| 258 | } |
| 259 | if (vie_channel->SetStartSequenceNumber(sequence_number) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 260 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 261 | return -1; |
| 262 | } |
| 263 | return 0; |
| 264 | } |
| 265 | |
| 266 | int ViERTP_RTCPImpl::SetRTCPStatus(const int video_channel, |
| 267 | const ViERTCPMode rtcp_mode) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 268 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 269 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 270 | "%s(channel: %d, mode: %d)", __FUNCTION__, video_channel, |
| 271 | rtcp_mode); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 272 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 273 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 274 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 275 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 276 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 277 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 278 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
stefan@webrtc.org | d0bdab0 | 2011-10-14 14:24:54 +0000 | [diff] [blame] | 279 | return -1; |
| 280 | } |
| 281 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 282 | RTCPMethod module_mode = ViERTCPModeToRTCPMethod(rtcp_mode); |
| 283 | if (vie_channel->SetRTCPMode(module_mode) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 284 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 285 | return -1; |
| 286 | } |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | int ViERTP_RTCPImpl::GetRTCPStatus(const int video_channel, |
| 291 | ViERTCPMode& rtcp_mode) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 292 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 293 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 294 | "%s(channel: %d)", __FUNCTION__, video_channel, rtcp_mode); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 295 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 296 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 297 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 298 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 299 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 300 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 301 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 302 | return -1; |
| 303 | } |
| 304 | RTCPMethod module_mode = kRtcpOff; |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 305 | if (vie_channel->GetRTCPMode(&module_mode) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 306 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 307 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 308 | "%s: could not get current RTCP mode", __FUNCTION__); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 309 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 310 | return -1; |
| 311 | } |
| 312 | rtcp_mode = RTCPMethodToViERTCPMode(module_mode); |
| 313 | return 0; |
| 314 | } |
| 315 | |
| 316 | int ViERTP_RTCPImpl::SetRTCPCName(const int video_channel, |
| 317 | const char rtcp_cname[KMaxRTCPCNameLength]) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 318 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 319 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 320 | "%s(channel: %d, name: %s)", __FUNCTION__, video_channel, |
| 321 | rtcp_cname); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 322 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 323 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 324 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 325 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 326 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 327 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 328 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 329 | return -1; |
| 330 | } |
| 331 | if (vie_channel->Sending()) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 332 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 333 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 334 | "%s: Channel %d already sending.", __FUNCTION__, |
| 335 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 336 | shared_data_->SetLastError(kViERtpRtcpAlreadySending); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 337 | return -1; |
| 338 | } |
| 339 | if (vie_channel->SetRTCPCName(rtcp_cname) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 340 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 341 | return -1; |
| 342 | } |
| 343 | return 0; |
| 344 | } |
| 345 | |
| 346 | int ViERTP_RTCPImpl::GetRTCPCName(const int video_channel, |
| 347 | char rtcp_cname[KMaxRTCPCNameLength]) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 348 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 349 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 350 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 351 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 352 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 353 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 354 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 355 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 356 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 357 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 358 | return -1; |
| 359 | } |
| 360 | if (vie_channel->GetRTCPCName(rtcp_cname) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 361 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 362 | return -1; |
| 363 | } |
| 364 | return 0; |
| 365 | } |
| 366 | |
| 367 | int ViERTP_RTCPImpl::GetRemoteRTCPCName( |
| 368 | const int video_channel, |
| 369 | char rtcp_cname[KMaxRTCPCNameLength]) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 370 | WEBRTC_TRACE(kTraceApiCall, 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)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 373 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 374 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 375 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 376 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 377 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 378 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 379 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 380 | return -1; |
| 381 | } |
| 382 | if (vie_channel->GetRemoteRTCPCName(rtcp_cname) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 383 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 384 | return -1; |
| 385 | } |
| 386 | return 0; |
| 387 | } |
| 388 | |
| 389 | int ViERTP_RTCPImpl::SendApplicationDefinedRTCPPacket( |
| 390 | const int video_channel, |
| 391 | const unsigned char sub_type, |
| 392 | unsigned int name, |
| 393 | const char* data, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 394 | uint16_t data_length_in_bytes) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 395 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 396 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 397 | "%s(channel: %d, sub_type: %c, name: %d, data: x, length: %u)", |
| 398 | __FUNCTION__, video_channel, sub_type, name, |
| 399 | data_length_in_bytes); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 400 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 401 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 402 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 403 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 404 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 405 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 406 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 407 | return -1; |
| 408 | } |
| 409 | if (!vie_channel->Sending()) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 410 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 411 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 412 | "%s: Channel %d not sending", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 413 | shared_data_->SetLastError(kViERtpRtcpNotSending); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 414 | return -1; |
| 415 | } |
| 416 | RTCPMethod method; |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 417 | if (vie_channel->GetRTCPMode(&method) != 0 || method == kRtcpOff) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 418 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 419 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 420 | "%s: RTCP disabled on channel %d.", __FUNCTION__, |
| 421 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 422 | shared_data_->SetLastError(kViERtpRtcpRtcpDisabled); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 423 | return -1; |
| 424 | } |
| 425 | if (vie_channel->SendApplicationDefinedRTCPPacket( |
| 426 | sub_type, name, reinterpret_cast<const WebRtc_UWord8*>(data), |
| 427 | data_length_in_bytes) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 428 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 429 | return -1; |
| 430 | } |
| 431 | return 0; |
| 432 | } |
| 433 | |
| 434 | int ViERTP_RTCPImpl::SetNACKStatus(const int video_channel, const bool enable) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 435 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 436 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 437 | "%s(channel: %d, enable: %d)", __FUNCTION__, video_channel, |
| 438 | enable); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 439 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 440 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 441 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 442 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 443 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 444 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 445 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 446 | return -1; |
| 447 | } |
| 448 | if (vie_channel->SetNACKStatus(enable) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 449 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 450 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 451 | "%s: failed for channel %d", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 452 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 453 | return -1; |
| 454 | } |
| 455 | |
| 456 | // Update the encoder |
| 457 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 458 | if (!vie_encoder) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 459 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 460 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 461 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 462 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 463 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 464 | return -1; |
| 465 | } |
| 466 | vie_encoder->UpdateProtectionMethod(); |
| 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | int ViERTP_RTCPImpl::SetFECStatus(const int video_channel, const bool enable, |
| 471 | const unsigned char payload_typeRED, |
| 472 | const unsigned char payload_typeFEC) { |
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, payload_typeRED: %u, " |
| 476 | "payloadTypeFEC: %u)", |
| 477 | __FUNCTION__, video_channel, enable, payload_typeRED, |
| 478 | payload_typeFEC); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 479 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 480 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 481 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 482 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 483 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 484 | "%s: Channel %d doesn't exist", __FUNCTION__, |
| 485 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 486 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 487 | return -1; |
| 488 | } |
| 489 | if (vie_channel->SetFECStatus(enable, payload_typeRED, |
| 490 | payload_typeFEC) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 491 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 492 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 493 | "%s: failed for channel %d", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 494 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 495 | return -1; |
| 496 | } |
| 497 | // Update the encoder. |
| 498 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 499 | if (!vie_encoder) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 500 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 501 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 502 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 503 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 504 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 505 | return -1; |
| 506 | } |
| 507 | vie_encoder->UpdateProtectionMethod(); |
| 508 | return 0; |
| 509 | } |
| 510 | |
| 511 | int ViERTP_RTCPImpl::SetHybridNACKFECStatus( |
| 512 | const int video_channel, |
| 513 | const bool enable, |
| 514 | const unsigned char payload_typeRED, |
| 515 | const unsigned char payload_typeFEC) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 516 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 517 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 518 | "%s(channel: %d, enable: %d, payload_typeRED: %u, " |
| 519 | "payloadTypeFEC: %u)", |
| 520 | __FUNCTION__, video_channel, enable, payload_typeRED, |
| 521 | payload_typeFEC); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 522 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 523 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 524 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 525 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 526 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 527 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 528 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 529 | return -1; |
| 530 | } |
| 531 | |
| 532 | // Update the channel status with hybrid NACK FEC mode. |
| 533 | if (vie_channel->SetHybridNACKFECStatus(enable, payload_typeRED, |
| 534 | payload_typeFEC) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 535 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 536 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 537 | "%s: failed for channel %d", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 538 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 539 | return -1; |
| 540 | } |
| 541 | |
| 542 | // Update the encoder. |
| 543 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 544 | if (!vie_encoder) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 545 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 546 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 547 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 548 | video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 549 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 550 | return -1; |
| 551 | } |
| 552 | vie_encoder->UpdateProtectionMethod(); |
| 553 | return 0; |
| 554 | } |
| 555 | |
mikhal@webrtc.org | dbe97d2 | 2013-02-01 19:33:21 +0000 | [diff] [blame] | 556 | int ViERTP_RTCPImpl::EnableSenderStreamingMode(int video_channel, |
| 557 | int target_delay_ms) { |
| 558 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 559 | ViEId(shared_data_->instance_id(), video_channel), |
| 560 | "%s(channel: %d, target_delay: %d)", |
| 561 | __FUNCTION__, video_channel, target_delay_ms); |
| 562 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 563 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 564 | if (!vie_channel) { |
| 565 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 566 | ViEId(shared_data_->instance_id(), video_channel), |
| 567 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 568 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 569 | return -1; |
| 570 | } |
| 571 | |
| 572 | // Update the channel's streaming mode settings. |
| 573 | if (vie_channel->EnableSenderStreamingMode(target_delay_ms) != 0) { |
| 574 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 575 | ViEId(shared_data_->instance_id(), video_channel), |
| 576 | "%s: failed for channel %d", __FUNCTION__, video_channel); |
| 577 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
| 578 | return -1; |
| 579 | } |
| 580 | return 0; |
| 581 | } |
| 582 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 583 | int ViERTP_RTCPImpl::SetKeyFrameRequestMethod( |
| 584 | const int video_channel, |
| 585 | const ViEKeyFrameRequestMethod method) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 586 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 587 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 588 | "%s(channel: %d, method: %d)", __FUNCTION__, video_channel, |
| 589 | method); |
| 590 | |
| 591 | // Get the channel. |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 592 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 593 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 594 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 595 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 596 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 597 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 598 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 599 | return -1; |
| 600 | } |
| 601 | KeyFrameRequestMethod module_method = APIRequestToModuleRequest(method); |
| 602 | if (vie_channel->SetKeyFrameRequestMethod(module_method) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 603 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 604 | return -1; |
| 605 | } |
| 606 | return 0; |
| 607 | } |
| 608 | |
| 609 | int ViERTP_RTCPImpl::SetTMMBRStatus(const int video_channel, |
| 610 | const bool enable) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 611 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 612 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 613 | "%s(channel: %d, enable: %d)", __FUNCTION__, video_channel, |
| 614 | enable); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 615 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 616 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 617 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 618 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 619 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 620 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 621 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 622 | return -1; |
| 623 | } |
| 624 | if (vie_channel->EnableTMMBR(enable) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 625 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 626 | return -1; |
| 627 | } |
| 628 | return 0; |
| 629 | } |
| 630 | |
mflodman@webrtc.org | 6cf529d | 2012-01-24 06:16:16 +0000 | [diff] [blame] | 631 | int ViERTP_RTCPImpl::SetRembStatus(int video_channel, bool sender, |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 632 | bool receiver) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 633 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 634 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 635 | "ViERTP_RTCPImpl::SetRembStatus(%d, %d, %d)", video_channel, |
| 636 | sender, receiver); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 637 | if (!shared_data_->channel_manager()->SetRembStatus(video_channel, sender, |
| 638 | receiver)) { |
mflodman@webrtc.org | 6cf529d | 2012-01-24 06:16:16 +0000 | [diff] [blame] | 639 | return -1; |
| 640 | } |
| 641 | return 0; |
mflodman@webrtc.org | 84dc3d1 | 2011-12-22 10:26:13 +0000 | [diff] [blame] | 642 | } |
| 643 | |
stefan@webrtc.org | 976a7e6 | 2012-09-21 13:20:21 +0000 | [diff] [blame] | 644 | int ViERTP_RTCPImpl::SetBandwidthEstimationMode(BandwidthEstimationMode mode) { |
| 645 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, shared_data_->instance_id(), |
| 646 | "ViERTP_RTCPImpl::SetBandwidthEstimationMode(%d)", mode); |
| 647 | if (!shared_data_->channel_manager()->SetBandwidthEstimationMode(mode)) { |
| 648 | return -1; |
| 649 | } |
| 650 | return 0; |
| 651 | } |
| 652 | |
mflodman@webrtc.org | 90071dd | 2012-08-13 17:13:27 +0000 | [diff] [blame] | 653 | int ViERTP_RTCPImpl::SetSendTimestampOffsetStatus(int video_channel, |
| 654 | bool enable, |
| 655 | int id) { |
| 656 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 657 | ViEId(shared_data_->instance_id(), video_channel), |
| 658 | "ViERTP_RTCPImpl::SetSendTimestampOffsetStatus(%d, %d, %d)", |
| 659 | video_channel, enable, id); |
| 660 | |
| 661 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 662 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 663 | if (!vie_channel) { |
| 664 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 665 | ViEId(shared_data_->instance_id(), video_channel), |
| 666 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 667 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 668 | return -1; |
| 669 | } |
| 670 | if (vie_channel->SetSendTimestampOffsetStatus(enable, id) != 0) { |
| 671 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
| 672 | return -1; |
| 673 | } |
| 674 | return 0; |
| 675 | } |
| 676 | |
| 677 | int ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(int video_channel, |
| 678 | bool enable, |
| 679 | int id) { |
| 680 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 681 | ViEId(shared_data_->instance_id(), video_channel), |
| 682 | "ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(%d, %d, %d)", |
| 683 | video_channel, enable, id); |
| 684 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 685 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 686 | if (!vie_channel) { |
| 687 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 688 | ViEId(shared_data_->instance_id(), video_channel), |
| 689 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 690 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 691 | return -1; |
| 692 | } |
| 693 | if (vie_channel->SetReceiveTimestampOffsetStatus(enable, id) != 0) { |
| 694 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
| 695 | return -1; |
| 696 | } |
| 697 | return 0; |
| 698 | } |
| 699 | |
mflodman@webrtc.org | 5a7507f | 2012-09-12 13:47:06 +0000 | [diff] [blame] | 700 | int ViERTP_RTCPImpl::SetTransmissionSmoothingStatus(int video_channel, |
| 701 | bool enable) { |
| 702 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 703 | ViEId(shared_data_->instance_id(), video_channel), |
| 704 | "%s(channel: %d, enble: %d)", __FUNCTION__, video_channel, |
| 705 | enable); |
| 706 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 707 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 708 | if (!vie_channel) { |
| 709 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 710 | ViEId(shared_data_->instance_id(), video_channel), |
| 711 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 712 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 713 | return -1; |
| 714 | } |
| 715 | vie_channel->SetTransmissionSmoothingStatus(enable); |
| 716 | return 0; |
| 717 | } |
| 718 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 719 | int ViERTP_RTCPImpl::GetReceivedRTCPStatistics(const int video_channel, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 720 | uint16_t& fraction_lost, |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 721 | unsigned int& cumulative_lost, |
| 722 | unsigned int& extended_max, |
| 723 | unsigned int& jitter, |
| 724 | int& rtt_ms) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 725 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 726 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 727 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 728 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 729 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 730 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 731 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 732 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 733 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 734 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 735 | return -1; |
| 736 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 737 | if (vie_channel->GetReceivedRtcpStatistics(&fraction_lost, |
| 738 | &cumulative_lost, |
| 739 | &extended_max, |
| 740 | &jitter, |
| 741 | &rtt_ms) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 742 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 743 | return -1; |
| 744 | } |
| 745 | return 0; |
| 746 | } |
| 747 | |
| 748 | int ViERTP_RTCPImpl::GetSentRTCPStatistics(const int video_channel, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 749 | uint16_t& fraction_lost, |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 750 | unsigned int& cumulative_lost, |
| 751 | unsigned int& extended_max, |
| 752 | unsigned int& jitter, |
| 753 | int& rtt_ms) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 754 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 755 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 756 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 757 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 758 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 759 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 760 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 761 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 762 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 763 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 764 | return -1; |
| 765 | } |
| 766 | |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 767 | if (vie_channel->GetSendRtcpStatistics(&fraction_lost, &cumulative_lost, |
| 768 | &extended_max, &jitter, |
| 769 | &rtt_ms) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 770 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 771 | return -1; |
| 772 | } |
| 773 | return 0; |
| 774 | } |
| 775 | |
| 776 | int ViERTP_RTCPImpl::GetRTPStatistics(const int video_channel, |
| 777 | unsigned int& bytes_sent, |
| 778 | unsigned int& packets_sent, |
| 779 | unsigned int& bytes_received, |
| 780 | unsigned int& packets_received) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 781 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 782 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 783 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 784 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 785 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 786 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 787 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 788 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 789 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 790 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 791 | return -1; |
| 792 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 793 | if (vie_channel->GetRtpStatistics(&bytes_sent, |
| 794 | &packets_sent, |
| 795 | &bytes_received, |
| 796 | &packets_received) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 797 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 798 | return -1; |
| 799 | } |
| 800 | return 0; |
| 801 | } |
| 802 | |
| 803 | int ViERTP_RTCPImpl::GetBandwidthUsage(const int video_channel, |
| 804 | unsigned int& total_bitrate_sent, |
| 805 | unsigned int& video_bitrate_sent, |
| 806 | unsigned int& fec_bitrate_sent, |
| 807 | unsigned int& nackBitrateSent) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 808 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 809 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 810 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 811 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 812 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 813 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 814 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 815 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 816 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 817 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 818 | return -1; |
| 819 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 820 | vie_channel->GetBandwidthUsage(&total_bitrate_sent, |
| 821 | &video_bitrate_sent, |
| 822 | &fec_bitrate_sent, |
| 823 | &nackBitrateSent); |
stefan@webrtc.org | d0bdab0 | 2011-10-14 14:24:54 +0000 | [diff] [blame] | 824 | return 0; |
| 825 | } |
| 826 | |
stefan@webrtc.org | 439be29 | 2012-02-16 14:45:37 +0000 | [diff] [blame] | 827 | int ViERTP_RTCPImpl::GetEstimatedSendBandwidth( |
stefan@webrtc.org | 07b45a5 | 2012-02-02 08:37:48 +0000 | [diff] [blame] | 828 | const int video_channel, |
| 829 | unsigned int* estimated_bandwidth) const { |
| 830 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 831 | ViEId(shared_data_->instance_id(), video_channel), |
| 832 | "%s(channel: %d)", __FUNCTION__, video_channel); |
| 833 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 834 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 835 | if (!vie_encoder) { |
| 836 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 837 | ViEId(shared_data_->instance_id(), video_channel), |
| 838 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 839 | video_channel); |
| 840 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 841 | return -1; |
| 842 | } |
stefan@webrtc.org | 439be29 | 2012-02-16 14:45:37 +0000 | [diff] [blame] | 843 | return vie_encoder->EstimatedSendBandwidth( |
| 844 | static_cast<WebRtc_UWord32*>(estimated_bandwidth)); |
| 845 | } |
| 846 | |
| 847 | int ViERTP_RTCPImpl::GetEstimatedReceiveBandwidth( |
| 848 | const int video_channel, |
| 849 | unsigned int* estimated_bandwidth) const { |
| 850 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 851 | ViEId(shared_data_->instance_id(), video_channel), |
| 852 | "%s(channel: %d)", __FUNCTION__, video_channel); |
| 853 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 854 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 855 | if (!vie_channel) { |
| 856 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 857 | ViEId(shared_data_->instance_id(), video_channel), |
| 858 | "%s: Could not get channel %d", __FUNCTION__, |
| 859 | video_channel); |
| 860 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 861 | return -1; |
| 862 | } |
mflodman@webrtc.org | 4fd5527 | 2013-02-06 17:46:39 +0000 | [diff] [blame^] | 863 | vie_channel->GetEstimatedReceiveBandwidth( |
stefan@webrtc.org | 07b45a5 | 2012-02-02 08:37:48 +0000 | [diff] [blame] | 864 | static_cast<WebRtc_UWord32*>(estimated_bandwidth)); |
mflodman@webrtc.org | 4fd5527 | 2013-02-06 17:46:39 +0000 | [diff] [blame^] | 865 | return 0; |
stefan@webrtc.org | 07b45a5 | 2012-02-02 08:37:48 +0000 | [diff] [blame] | 866 | } |
| 867 | |
astor@webrtc.org | c0496e6 | 2012-08-10 10:14:43 +0000 | [diff] [blame] | 868 | int ViERTP_RTCPImpl::SetOverUseDetectorOptions( |
| 869 | const OverUseDetectorOptions& options) const { |
| 870 | if (!shared_data_->Initialized()) { |
| 871 | shared_data_->SetLastError(kViENotInitialized); |
| 872 | WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(shared_data_->instance_id()), |
| 873 | "%s - ViE instance %d not initialized", __FUNCTION__, |
| 874 | shared_data_->instance_id()); |
| 875 | return -1; |
| 876 | } |
| 877 | // Lock the channel manager to avoid creating a channel with |
| 878 | // "undefined" bwe settings (atomic copy). |
| 879 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 880 | shared_data_->SetOverUseDetectorOptions(options); |
| 881 | return 0; |
| 882 | } |
| 883 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 884 | int ViERTP_RTCPImpl::StartRTPDump(const int video_channel, |
| 885 | const char file_nameUTF8[1024], |
| 886 | RTPDirections direction) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 887 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 888 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 889 | "%s(channel: %d, file_name: %s, direction: %d)", __FUNCTION__, |
| 890 | video_channel, file_nameUTF8, direction); |
| 891 | assert(FileWrapper::kMaxFileNameSize == 1024); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 892 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 893 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 894 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 895 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 896 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 897 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 898 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 899 | return -1; |
| 900 | } |
| 901 | if (vie_channel->StartRTPDump(file_nameUTF8, direction) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 902 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 903 | return -1; |
| 904 | } |
| 905 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 906 | } |
| 907 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 908 | int ViERTP_RTCPImpl::StopRTPDump(const int video_channel, |
| 909 | RTPDirections direction) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 910 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 911 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 912 | "%s(channel: %d, direction: %d)", __FUNCTION__, video_channel, |
| 913 | direction); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 914 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 915 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 916 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 917 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 918 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 919 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 920 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 921 | return -1; |
| 922 | } |
| 923 | if (vie_channel->StopRTPDump(direction) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 924 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 925 | return -1; |
| 926 | } |
| 927 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 928 | } |
| 929 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 930 | int ViERTP_RTCPImpl::RegisterRTPObserver(const int video_channel, |
| 931 | ViERTPObserver& observer) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 932 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 933 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 934 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 935 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 936 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 937 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 938 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 939 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 940 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 941 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 942 | return -1; |
| 943 | } |
| 944 | if (vie_channel->RegisterRtpObserver(&observer) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 945 | shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 946 | return -1; |
| 947 | } |
| 948 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 949 | } |
| 950 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 951 | int ViERTP_RTCPImpl::DeregisterRTPObserver(const int video_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 952 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 953 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 954 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 955 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 956 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 957 | if (!vie_channel) { |
| 958 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 959 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 960 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 961 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 962 | return -1; |
| 963 | } |
| 964 | if (vie_channel->RegisterRtpObserver(NULL) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 965 | shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 966 | return -1; |
| 967 | } |
| 968 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 969 | } |
| 970 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 971 | int ViERTP_RTCPImpl::RegisterRTCPObserver(const int video_channel, |
| 972 | ViERTCPObserver& observer) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 973 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 974 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 975 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 976 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 977 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 978 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 979 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 980 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 981 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 982 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 983 | return -1; |
| 984 | } |
| 985 | if (vie_channel->RegisterRtcpObserver(&observer) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 986 | shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 987 | return -1; |
| 988 | } |
| 989 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 990 | } |
| 991 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 992 | int ViERTP_RTCPImpl::DeregisterRTCPObserver(const int video_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 993 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 994 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 995 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 996 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 997 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 998 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 999 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 1000 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1001 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1002 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1003 | return -1; |
| 1004 | } |
| 1005 | if (vie_channel->RegisterRtcpObserver(NULL) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1006 | shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1007 | return -1; |
| 1008 | } |
| 1009 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1012 | } // namespace webrtc |