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 | } |
stefan@webrtc.org | c74c3c2 | 2013-05-23 13:48:22 +0000 | [diff] [blame] | 250 | if (vie_channel->SetRtxSendPayloadType(payload_type) != 0) { |
mflodman@webrtc.org | 9f5ebb5 | 2013-04-12 14:55:46 +0000 | [diff] [blame] | 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 | } |
tnakamura@webrtc.org | aa4d96a | 2013-07-16 19:25:04 +0000 | [diff] [blame] | 504 | vie_encoder->UpdateProtectionMethod(); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 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 | } |
tnakamura@webrtc.org | aa4d96a | 2013-07-16 19:25:04 +0000 | [diff] [blame] | 545 | vie_encoder->UpdateProtectionMethod(); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 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 | } |
tnakamura@webrtc.org | aa4d96a | 2013-07-16 19:25:04 +0000 | [diff] [blame] | 590 | vie_encoder->UpdateProtectionMethod(); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 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 | |
solenberg@webrtc.org | cb9cff0 | 2013-05-20 12:00:23 +0000 | [diff] [blame] | 768 | int ViERTP_RTCPImpl::SetSendAbsoluteSendTimeStatus(int video_channel, |
| 769 | bool enable, |
| 770 | int id) { |
| 771 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 772 | ViEId(shared_data_->instance_id(), video_channel), |
| 773 | "ViERTP_RTCPImpl::SetSendAbsoluteSendTimeStatus(%d, %d, %d)", |
| 774 | video_channel, enable, id); |
| 775 | |
| 776 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 777 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 778 | if (!vie_channel) { |
| 779 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 780 | ViEId(shared_data_->instance_id(), video_channel), |
| 781 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 782 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 783 | return -1; |
| 784 | } |
| 785 | if (vie_channel->SetSendAbsoluteSendTimeStatus(enable, id) != 0) { |
| 786 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
| 787 | return -1; |
| 788 | } |
| 789 | return 0; |
| 790 | } |
| 791 | |
| 792 | int ViERTP_RTCPImpl::SetReceiveAbsoluteSendTimeStatus(int video_channel, |
| 793 | bool enable, |
| 794 | int id) { |
| 795 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 796 | ViEId(shared_data_->instance_id(), video_channel), |
| 797 | "ViERTP_RTCPImpl::SetReceiveAbsoluteSendTimeStatus(%d, %d, %d)", |
| 798 | video_channel, enable, id); |
solenberg@webrtc.org | a6db54d | 2013-05-27 16:02:56 +0000 | [diff] [blame] | 799 | if (!shared_data_->channel_manager()->SetReceiveAbsoluteSendTimeStatus( |
| 800 | video_channel, enable, id)) { |
solenberg@webrtc.org | cb9cff0 | 2013-05-20 12:00:23 +0000 | [diff] [blame] | 801 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
| 802 | return -1; |
| 803 | } |
| 804 | return 0; |
| 805 | } |
| 806 | |
mflodman@webrtc.org | 5a7507f | 2012-09-12 13:47:06 +0000 | [diff] [blame] | 807 | int ViERTP_RTCPImpl::SetTransmissionSmoothingStatus(int video_channel, |
| 808 | bool enable) { |
| 809 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 810 | ViEId(shared_data_->instance_id(), video_channel), |
| 811 | "%s(channel: %d, enble: %d)", __FUNCTION__, video_channel, |
| 812 | enable); |
| 813 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 814 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 815 | if (!vie_channel) { |
| 816 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 817 | ViEId(shared_data_->instance_id(), video_channel), |
| 818 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
| 819 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 820 | return -1; |
| 821 | } |
| 822 | vie_channel->SetTransmissionSmoothingStatus(enable); |
| 823 | return 0; |
| 824 | } |
| 825 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 826 | int ViERTP_RTCPImpl::GetReceivedRTCPStatistics(const int video_channel, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 827 | uint16_t& fraction_lost, |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 828 | unsigned int& cumulative_lost, |
| 829 | unsigned int& extended_max, |
| 830 | unsigned int& jitter, |
| 831 | int& rtt_ms) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 832 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 833 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 834 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 835 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 836 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 837 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 838 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 839 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 840 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 841 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 842 | return -1; |
| 843 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 844 | if (vie_channel->GetReceivedRtcpStatistics(&fraction_lost, |
| 845 | &cumulative_lost, |
| 846 | &extended_max, |
| 847 | &jitter, |
| 848 | &rtt_ms) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 849 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 850 | return -1; |
| 851 | } |
| 852 | return 0; |
| 853 | } |
| 854 | |
| 855 | int ViERTP_RTCPImpl::GetSentRTCPStatistics(const int video_channel, |
mflodman@webrtc.org | 9ba151b | 2012-06-21 10:02:13 +0000 | [diff] [blame] | 856 | uint16_t& fraction_lost, |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 857 | unsigned int& cumulative_lost, |
| 858 | unsigned int& extended_max, |
| 859 | unsigned int& jitter, |
| 860 | int& rtt_ms) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 861 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 862 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 863 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 864 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 865 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 866 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 867 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 868 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 869 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 870 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 871 | return -1; |
| 872 | } |
| 873 | |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 874 | if (vie_channel->GetSendRtcpStatistics(&fraction_lost, &cumulative_lost, |
| 875 | &extended_max, &jitter, |
| 876 | &rtt_ms) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 877 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 878 | return -1; |
| 879 | } |
| 880 | return 0; |
| 881 | } |
| 882 | |
| 883 | int ViERTP_RTCPImpl::GetRTPStatistics(const int video_channel, |
| 884 | unsigned int& bytes_sent, |
| 885 | unsigned int& packets_sent, |
| 886 | unsigned int& bytes_received, |
| 887 | unsigned int& packets_received) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 888 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 889 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 890 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 891 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 892 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 893 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 894 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 895 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 896 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 897 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 898 | return -1; |
| 899 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 900 | if (vie_channel->GetRtpStatistics(&bytes_sent, |
| 901 | &packets_sent, |
| 902 | &bytes_received, |
| 903 | &packets_received) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 904 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 905 | return -1; |
| 906 | } |
| 907 | return 0; |
| 908 | } |
| 909 | |
| 910 | int ViERTP_RTCPImpl::GetBandwidthUsage(const int video_channel, |
| 911 | unsigned int& total_bitrate_sent, |
| 912 | unsigned int& video_bitrate_sent, |
| 913 | unsigned int& fec_bitrate_sent, |
| 914 | unsigned int& nackBitrateSent) const { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 915 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 916 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 917 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 918 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 919 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 920 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 921 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 922 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 923 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 924 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 925 | return -1; |
| 926 | } |
mflodman@webrtc.org | f5e99db | 2012-06-27 09:49:37 +0000 | [diff] [blame] | 927 | vie_channel->GetBandwidthUsage(&total_bitrate_sent, |
| 928 | &video_bitrate_sent, |
| 929 | &fec_bitrate_sent, |
| 930 | &nackBitrateSent); |
stefan@webrtc.org | d0bdab0 | 2011-10-14 14:24:54 +0000 | [diff] [blame] | 931 | return 0; |
| 932 | } |
| 933 | |
stefan@webrtc.org | 439be29 | 2012-02-16 14:45:37 +0000 | [diff] [blame] | 934 | int ViERTP_RTCPImpl::GetEstimatedSendBandwidth( |
stefan@webrtc.org | 07b45a5 | 2012-02-02 08:37:48 +0000 | [diff] [blame] | 935 | const int video_channel, |
| 936 | unsigned int* estimated_bandwidth) const { |
| 937 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 938 | ViEId(shared_data_->instance_id(), video_channel), |
| 939 | "%s(channel: %d)", __FUNCTION__, video_channel); |
| 940 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 941 | ViEEncoder* vie_encoder = cs.Encoder(video_channel); |
| 942 | if (!vie_encoder) { |
| 943 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 944 | ViEId(shared_data_->instance_id(), video_channel), |
| 945 | "%s: Could not get encoder for channel %d", __FUNCTION__, |
| 946 | video_channel); |
| 947 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 948 | return -1; |
| 949 | } |
stefan@webrtc.org | 439be29 | 2012-02-16 14:45:37 +0000 | [diff] [blame] | 950 | return vie_encoder->EstimatedSendBandwidth( |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 951 | static_cast<uint32_t*>(estimated_bandwidth)); |
stefan@webrtc.org | 439be29 | 2012-02-16 14:45:37 +0000 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | int ViERTP_RTCPImpl::GetEstimatedReceiveBandwidth( |
| 955 | const int video_channel, |
| 956 | unsigned int* estimated_bandwidth) const { |
| 957 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 958 | ViEId(shared_data_->instance_id(), video_channel), |
| 959 | "%s(channel: %d)", __FUNCTION__, video_channel); |
| 960 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
| 961 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 962 | if (!vie_channel) { |
| 963 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 964 | ViEId(shared_data_->instance_id(), video_channel), |
| 965 | "%s: Could not get channel %d", __FUNCTION__, |
| 966 | video_channel); |
| 967 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
| 968 | return -1; |
| 969 | } |
mflodman@webrtc.org | 4fd5527 | 2013-02-06 17:46:39 +0000 | [diff] [blame] | 970 | vie_channel->GetEstimatedReceiveBandwidth( |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 971 | static_cast<uint32_t*>(estimated_bandwidth)); |
mflodman@webrtc.org | 4fd5527 | 2013-02-06 17:46:39 +0000 | [diff] [blame] | 972 | return 0; |
stefan@webrtc.org | 07b45a5 | 2012-02-02 08:37:48 +0000 | [diff] [blame] | 973 | } |
| 974 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 975 | int ViERTP_RTCPImpl::StartRTPDump(const int video_channel, |
| 976 | const char file_nameUTF8[1024], |
| 977 | RTPDirections direction) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 978 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 979 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 980 | "%s(channel: %d, file_name: %s, direction: %d)", __FUNCTION__, |
| 981 | video_channel, file_nameUTF8, direction); |
| 982 | assert(FileWrapper::kMaxFileNameSize == 1024); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 983 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 984 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 985 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 986 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 987 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 988 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 989 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 990 | return -1; |
| 991 | } |
| 992 | if (vie_channel->StartRTPDump(file_nameUTF8, direction) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 993 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 994 | return -1; |
| 995 | } |
| 996 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 997 | } |
| 998 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 999 | int ViERTP_RTCPImpl::StopRTPDump(const int video_channel, |
| 1000 | RTPDirections direction) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1001 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 1002 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1003 | "%s(channel: %d, direction: %d)", __FUNCTION__, video_channel, |
| 1004 | direction); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1005 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1006 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 1007 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1008 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 1009 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1010 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1011 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1012 | return -1; |
| 1013 | } |
| 1014 | if (vie_channel->StopRTPDump(direction) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1015 | shared_data_->SetLastError(kViERtpRtcpUnknownError); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1016 | return -1; |
| 1017 | } |
| 1018 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1019 | } |
| 1020 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1021 | int ViERTP_RTCPImpl::RegisterRTPObserver(const int video_channel, |
| 1022 | ViERTPObserver& observer) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1023 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 1024 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1025 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1026 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1027 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 1028 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1029 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 1030 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1031 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1032 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1033 | return -1; |
| 1034 | } |
| 1035 | if (vie_channel->RegisterRtpObserver(&observer) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1036 | shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1037 | return -1; |
| 1038 | } |
| 1039 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1040 | } |
| 1041 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1042 | int ViERTP_RTCPImpl::DeregisterRTPObserver(const int video_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1043 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 1044 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1045 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1046 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1047 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 1048 | if (!vie_channel) { |
| 1049 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1050 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1051 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1052 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1053 | return -1; |
| 1054 | } |
| 1055 | if (vie_channel->RegisterRtpObserver(NULL) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1056 | shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1057 | return -1; |
| 1058 | } |
| 1059 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1060 | } |
| 1061 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1062 | int ViERTP_RTCPImpl::RegisterRTCPObserver(const int video_channel, |
| 1063 | ViERTCPObserver& observer) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1064 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 1065 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1066 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1067 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1068 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 1069 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1070 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 1071 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1072 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1073 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1074 | return -1; |
| 1075 | } |
| 1076 | if (vie_channel->RegisterRtcpObserver(&observer) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1077 | shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1078 | return -1; |
| 1079 | } |
| 1080 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1081 | } |
| 1082 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1083 | int ViERTP_RTCPImpl::DeregisterRTCPObserver(const int video_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1084 | WEBRTC_TRACE(kTraceApiCall, kTraceVideo, |
| 1085 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1086 | "%s(channel: %d)", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1087 | ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1088 | ViEChannel* vie_channel = cs.Channel(video_channel); |
| 1089 | if (!vie_channel) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1090 | WEBRTC_TRACE(kTraceError, kTraceVideo, |
| 1091 | ViEId(shared_data_->instance_id(), video_channel), |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1092 | "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1093 | shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1094 | return -1; |
| 1095 | } |
| 1096 | if (vie_channel->RegisterRtcpObserver(NULL) != 0) { |
mflodman@webrtc.org | b11424b | 2012-01-25 13:42:03 +0000 | [diff] [blame] | 1097 | shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered); |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1098 | return -1; |
| 1099 | } |
| 1100 | return 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1101 | } |
| 1102 | |
mflodman@webrtc.org | 8da2417 | 2011-12-19 14:18:41 +0000 | [diff] [blame] | 1103 | } // namespace webrtc |