pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 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 | b581c90 | 2013-10-28 16:32:01 +0000 | [diff] [blame] | 11 | #include "webrtc/video/video_send_stream.h" |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 12 | |
henrik.lundin@webrtc.org | ce21c82 | 2013-10-23 11:04:57 +0000 | [diff] [blame] | 13 | #include <string> |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 14 | #include <vector> |
| 15 | |
| 16 | #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
| 17 | #include "webrtc/video_engine/include/vie_base.h" |
| 18 | #include "webrtc/video_engine/include/vie_capture.h" |
| 19 | #include "webrtc/video_engine/include/vie_codec.h" |
stefan@webrtc.org | a0a91d8 | 2013-08-22 09:29:56 +0000 | [diff] [blame] | 20 | #include "webrtc/video_engine/include/vie_external_codec.h" |
pbos@webrtc.org | 3ba57eb | 2013-10-21 10:34:43 +0000 | [diff] [blame] | 21 | #include "webrtc/video_engine/include/vie_image_process.h" |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 22 | #include "webrtc/video_engine/include/vie_network.h" |
| 23 | #include "webrtc/video_engine/include/vie_rtp_rtcp.h" |
pbos@webrtc.org | b581c90 | 2013-10-28 16:32:01 +0000 | [diff] [blame] | 24 | #include "webrtc/video_send_stream.h" |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 25 | |
| 26 | namespace webrtc { |
| 27 | namespace internal { |
| 28 | |
mflodman@webrtc.org | ecbeb2b | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 29 | // Super simple and temporary overuse logic. This will move to the application |
| 30 | // as soon as the new API allows changing send codec on the fly. |
| 31 | class ResolutionAdaptor : public webrtc::CpuOveruseObserver { |
| 32 | public: |
| 33 | ResolutionAdaptor(ViECodec* codec, int channel, size_t width, size_t height) |
| 34 | : codec_(codec), |
| 35 | channel_(channel), |
| 36 | max_width_(width), |
| 37 | max_height_(height) {} |
| 38 | |
| 39 | virtual ~ResolutionAdaptor() {} |
| 40 | |
| 41 | virtual void OveruseDetected() OVERRIDE { |
| 42 | VideoCodec codec; |
| 43 | if (codec_->GetSendCodec(channel_, codec) != 0) |
| 44 | return; |
| 45 | |
| 46 | if (codec.width / 2 < min_width || codec.height / 2 < min_height) |
| 47 | return; |
| 48 | |
| 49 | codec.width /= 2; |
| 50 | codec.height /= 2; |
| 51 | codec_->SetSendCodec(channel_, codec); |
| 52 | } |
| 53 | |
| 54 | virtual void NormalUsage() OVERRIDE { |
| 55 | VideoCodec codec; |
| 56 | if (codec_->GetSendCodec(channel_, codec) != 0) |
| 57 | return; |
| 58 | |
| 59 | if (codec.width * 2u > max_width_ || codec.height * 2u > max_height_) |
| 60 | return; |
| 61 | |
| 62 | codec.width *= 2; |
| 63 | codec.height *= 2; |
| 64 | codec_->SetSendCodec(channel_, codec); |
| 65 | } |
| 66 | |
| 67 | private: |
| 68 | // Temporary and arbitrary chosen minimum resolution. |
| 69 | static const size_t min_width = 160; |
| 70 | static const size_t min_height = 120; |
| 71 | |
| 72 | ViECodec* codec_; |
| 73 | const int channel_; |
| 74 | |
| 75 | const size_t max_width_; |
| 76 | const size_t max_height_; |
| 77 | }; |
| 78 | |
pbos@webrtc.org | 12d5ede | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 79 | VideoSendStream::VideoSendStream(newapi::Transport* transport, |
mflodman@webrtc.org | ecbeb2b | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 80 | bool overuse_detection, |
pbos@webrtc.org | 12d5ede | 2013-07-09 08:02:33 +0000 | [diff] [blame] | 81 | webrtc::VideoEngine* video_engine, |
mflodman@webrtc.org | e4d538a | 2013-12-13 09:40:45 +0000 | [diff] [blame] | 82 | const VideoSendStream::Config& config, |
| 83 | int base_channel) |
pbos@webrtc.org | 8f2997c | 2013-11-14 08:58:14 +0000 | [diff] [blame] | 84 | : transport_adapter_(transport), |
sprang@webrtc.org | 4a9843f | 2013-11-26 11:41:59 +0000 | [diff] [blame] | 85 | encoded_frame_proxy_(config.post_encode_callback), |
pbos@webrtc.org | 8f2997c | 2013-11-14 08:58:14 +0000 | [diff] [blame] | 86 | codec_lock_(CriticalSectionWrapper::CreateCriticalSection()), |
| 87 | config_(config), |
mflodman@webrtc.org | e4d538a | 2013-12-13 09:40:45 +0000 | [diff] [blame] | 88 | external_codec_(NULL), |
| 89 | channel_(-1) { |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 90 | video_engine_base_ = ViEBase::GetInterface(video_engine); |
mflodman@webrtc.org | e4d538a | 2013-12-13 09:40:45 +0000 | [diff] [blame] | 91 | video_engine_base_->CreateChannel(channel_, base_channel); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 92 | assert(channel_ != -1); |
| 93 | |
| 94 | rtp_rtcp_ = ViERTP_RTCP::GetInterface(video_engine); |
| 95 | assert(rtp_rtcp_ != NULL); |
| 96 | |
pbos@webrtc.org | 8f2997c | 2013-11-14 08:58:14 +0000 | [diff] [blame] | 97 | assert(config_.rtp.ssrcs.size() > 0); |
henrik.lundin@webrtc.org | d7d60c8 | 2013-11-21 14:05:40 +0000 | [diff] [blame] | 98 | if (config_.suspend_below_min_bitrate) |
| 99 | config_.pacing = true; |
stefan@webrtc.org | a0a91d8 | 2013-08-22 09:29:56 +0000 | [diff] [blame] | 100 | rtp_rtcp_->SetTransmissionSmoothingStatus(channel_, config_.pacing); |
pbos@webrtc.org | 905cebd | 2013-09-11 10:14:56 +0000 | [diff] [blame] | 101 | |
| 102 | for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { |
| 103 | const std::string& extension = config_.rtp.extensions[i].name; |
| 104 | int id = config_.rtp.extensions[i].id; |
pbos@webrtc.org | 60108c2 | 2013-11-20 11:48:56 +0000 | [diff] [blame] | 105 | if (extension == RtpExtension::kTOffset) { |
pbos@webrtc.org | 905cebd | 2013-09-11 10:14:56 +0000 | [diff] [blame] | 106 | if (rtp_rtcp_->SetSendTimestampOffsetStatus(channel_, true, id) != 0) |
| 107 | abort(); |
pbos@webrtc.org | 60108c2 | 2013-11-20 11:48:56 +0000 | [diff] [blame] | 108 | } else if (extension == RtpExtension::kAbsSendTime) { |
pbos@webrtc.org | e22b761 | 2013-09-11 19:00:39 +0000 | [diff] [blame] | 109 | if (rtp_rtcp_->SetSendAbsoluteSendTimeStatus(channel_, true, id) != 0) |
| 110 | abort(); |
pbos@webrtc.org | 905cebd | 2013-09-11 10:14:56 +0000 | [diff] [blame] | 111 | } else { |
| 112 | abort(); // Unsupported extension. |
| 113 | } |
| 114 | } |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 115 | |
mflodman@webrtc.org | ab6ccbc | 2013-12-13 16:36:28 +0000 | [diff] [blame] | 116 | rtp_rtcp_->SetRembStatus(channel_, true, false); |
| 117 | |
pbos@webrtc.org | aa693dd | 2013-09-20 11:56:26 +0000 | [diff] [blame] | 118 | // Enable NACK, FEC or both. |
| 119 | if (config_.rtp.fec.red_payload_type != -1) { |
| 120 | assert(config_.rtp.fec.ulpfec_payload_type != -1); |
| 121 | if (config_.rtp.nack.rtp_history_ms > 0) { |
| 122 | rtp_rtcp_->SetHybridNACKFECStatus( |
| 123 | channel_, |
| 124 | true, |
| 125 | static_cast<unsigned char>(config_.rtp.fec.red_payload_type), |
| 126 | static_cast<unsigned char>(config_.rtp.fec.ulpfec_payload_type)); |
| 127 | } else { |
| 128 | rtp_rtcp_->SetFECStatus( |
| 129 | channel_, |
| 130 | true, |
| 131 | static_cast<unsigned char>(config_.rtp.fec.red_payload_type), |
| 132 | static_cast<unsigned char>(config_.rtp.fec.ulpfec_payload_type)); |
| 133 | } |
| 134 | } else { |
| 135 | rtp_rtcp_->SetNACKStatus(channel_, config_.rtp.nack.rtp_history_ms > 0); |
| 136 | } |
| 137 | |
pbos@webrtc.org | debc672 | 2013-08-22 09:42:17 +0000 | [diff] [blame] | 138 | char rtcp_cname[ViERTP_RTCP::KMaxRTCPCNameLength]; |
| 139 | assert(config_.rtp.c_name.length() < ViERTP_RTCP::KMaxRTCPCNameLength); |
| 140 | strncpy(rtcp_cname, config_.rtp.c_name.c_str(), sizeof(rtcp_cname) - 1); |
| 141 | rtcp_cname[sizeof(rtcp_cname) - 1] = '\0'; |
| 142 | |
| 143 | rtp_rtcp_->SetRTCPCName(channel_, rtcp_cname); |
| 144 | |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 145 | capture_ = ViECapture::GetInterface(video_engine); |
| 146 | capture_->AllocateExternalCaptureDevice(capture_id_, external_capture_); |
| 147 | capture_->ConnectCaptureDevice(capture_id_, channel_); |
| 148 | |
| 149 | network_ = ViENetwork::GetInterface(video_engine); |
| 150 | assert(network_ != NULL); |
| 151 | |
pbos@webrtc.org | 26d75f3 | 2013-09-18 11:52:42 +0000 | [diff] [blame] | 152 | network_->RegisterSendTransport(channel_, transport_adapter_); |
sprang@webrtc.org | 6133dd5 | 2013-10-16 13:29:14 +0000 | [diff] [blame] | 153 | // 28 to match packet overhead in ModuleRtpRtcpImpl. |
pbos@webrtc.org | b581c90 | 2013-10-28 16:32:01 +0000 | [diff] [blame] | 154 | network_->SetMTU(channel_, |
| 155 | static_cast<unsigned int>(config_.rtp.max_packet_size + 28)); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 156 | |
stefan@webrtc.org | a0a91d8 | 2013-08-22 09:29:56 +0000 | [diff] [blame] | 157 | if (config.encoder) { |
| 158 | external_codec_ = ViEExternalCodec::GetInterface(video_engine); |
| 159 | if (external_codec_->RegisterExternalSendCodec( |
| 160 | channel_, config.codec.plType, config.encoder, |
| 161 | config.internal_source) != 0) { |
| 162 | abort(); |
| 163 | } |
| 164 | } |
| 165 | |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 166 | codec_ = ViECodec::GetInterface(video_engine); |
pbos@webrtc.org | 8f2997c | 2013-11-14 08:58:14 +0000 | [diff] [blame] | 167 | if (!SetCodec(config_.codec)) |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 168 | abort(); |
mflodman@webrtc.org | ecbeb2b | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 169 | |
| 170 | if (overuse_detection) { |
| 171 | overuse_observer_.reset( |
| 172 | new ResolutionAdaptor(codec_, channel_, config_.codec.width, |
| 173 | config_.codec.height)); |
| 174 | video_engine_base_->RegisterCpuOveruseObserver(channel_, |
pbos@webrtc.org | 905cebd | 2013-09-11 10:14:56 +0000 | [diff] [blame] | 175 | overuse_observer_.get()); |
mflodman@webrtc.org | ecbeb2b | 2013-07-23 11:35:00 +0000 | [diff] [blame] | 176 | } |
pbos@webrtc.org | 3ba57eb | 2013-10-21 10:34:43 +0000 | [diff] [blame] | 177 | |
| 178 | image_process_ = ViEImageProcess::GetInterface(video_engine); |
| 179 | image_process_->RegisterPreEncodeCallback(channel_, |
| 180 | config_.pre_encode_callback); |
sprang@webrtc.org | 4a9843f | 2013-11-26 11:41:59 +0000 | [diff] [blame] | 181 | if (config_.post_encode_callback) { |
| 182 | image_process_->RegisterPostEncodeImageCallback(channel_, |
| 183 | &encoded_frame_proxy_); |
| 184 | } |
henrik.lundin@webrtc.org | ce21c82 | 2013-10-23 11:04:57 +0000 | [diff] [blame] | 185 | |
henrik.lundin@webrtc.org | 8fdf191 | 2013-11-18 12:18:43 +0000 | [diff] [blame] | 186 | if (config.suspend_below_min_bitrate) { |
| 187 | codec_->SuspendBelowMinBitrate(channel_); |
henrik.lundin@webrtc.org | ce21c82 | 2013-10-23 11:04:57 +0000 | [diff] [blame] | 188 | } |
sprang@webrtc.org | ca72300 | 2014-01-07 09:54:34 +0000 | [diff] [blame^] | 189 | |
| 190 | stats_proxy_.reset( |
| 191 | new SendStatisticsProxy(config, this)); |
| 192 | |
| 193 | rtp_rtcp_->RegisterSendChannelRtcpStatisticsCallback(channel_, |
| 194 | stats_proxy_.get()); |
| 195 | rtp_rtcp_->RegisterSendChannelRtpStatisticsCallback(channel_, |
| 196 | stats_proxy_.get()); |
| 197 | rtp_rtcp_->RegisterSendBitrateObserver(channel_, stats_proxy_.get()); |
| 198 | rtp_rtcp_->RegisterSendFrameCountObserver(channel_, stats_proxy_.get()); |
| 199 | |
| 200 | codec_->RegisterEncoderObserver(channel_, *stats_proxy_); |
| 201 | capture_->RegisterObserver(capture_id_, *stats_proxy_); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | VideoSendStream::~VideoSendStream() { |
sprang@webrtc.org | ca72300 | 2014-01-07 09:54:34 +0000 | [diff] [blame^] | 205 | capture_->DeregisterObserver(capture_id_); |
| 206 | codec_->DeregisterEncoderObserver(channel_); |
| 207 | |
| 208 | rtp_rtcp_->DeregisterSendFrameCountObserver(channel_, stats_proxy_.get()); |
| 209 | rtp_rtcp_->DeregisterSendBitrateObserver(channel_, stats_proxy_.get()); |
| 210 | rtp_rtcp_->DeregisterSendChannelRtpStatisticsCallback(channel_, |
| 211 | stats_proxy_.get()); |
| 212 | rtp_rtcp_->DeregisterSendChannelRtcpStatisticsCallback(channel_, |
| 213 | stats_proxy_.get()); |
| 214 | |
pbos@webrtc.org | 3ba57eb | 2013-10-21 10:34:43 +0000 | [diff] [blame] | 215 | image_process_->DeRegisterPreEncodeCallback(channel_); |
| 216 | |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 217 | network_->DeregisterSendTransport(channel_); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 218 | |
| 219 | capture_->DisconnectCaptureDevice(channel_); |
| 220 | capture_->ReleaseCaptureDevice(capture_id_); |
| 221 | |
stefan@webrtc.org | a0a91d8 | 2013-08-22 09:29:56 +0000 | [diff] [blame] | 222 | if (external_codec_) { |
| 223 | external_codec_->DeRegisterExternalSendCodec(channel_, |
| 224 | config_.codec.plType); |
| 225 | } |
| 226 | |
pbos@webrtc.org | 3ba57eb | 2013-10-21 10:34:43 +0000 | [diff] [blame] | 227 | video_engine_base_->DeleteChannel(channel_); |
| 228 | |
| 229 | image_process_->Release(); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 230 | video_engine_base_->Release(); |
| 231 | capture_->Release(); |
| 232 | codec_->Release(); |
stefan@webrtc.org | a0a91d8 | 2013-08-22 09:29:56 +0000 | [diff] [blame] | 233 | if (external_codec_) |
| 234 | external_codec_->Release(); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 235 | network_->Release(); |
| 236 | rtp_rtcp_->Release(); |
| 237 | } |
| 238 | |
pbos@webrtc.org | 7123a80 | 2013-12-11 16:26:16 +0000 | [diff] [blame] | 239 | void VideoSendStream::PutFrame(const I420VideoFrame& frame) { |
| 240 | input_frame_.CopyFrame(frame); |
| 241 | SwapFrame(&input_frame_); |
| 242 | } |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 243 | |
pbos@webrtc.org | 7123a80 | 2013-12-11 16:26:16 +0000 | [diff] [blame] | 244 | void VideoSendStream::SwapFrame(I420VideoFrame* frame) { |
| 245 | // TODO(pbos): Warn if frame is "too far" into the future, or too old. This |
| 246 | // would help detect if frame's being used without NTP. |
| 247 | // TO REVIEWER: Is there any good check for this? Should it be |
| 248 | // skipped? |
| 249 | if (frame != &input_frame_) |
| 250 | input_frame_.SwapFrame(frame); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 251 | |
pbos@webrtc.org | 7123a80 | 2013-12-11 16:26:16 +0000 | [diff] [blame] | 252 | // TODO(pbos): Local rendering should not be done on the capture thread. |
| 253 | if (config_.local_renderer != NULL) |
| 254 | config_.local_renderer->RenderFrame(input_frame_, 0); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 255 | |
pbos@webrtc.org | 7123a80 | 2013-12-11 16:26:16 +0000 | [diff] [blame] | 256 | external_capture_->SwapFrame(&input_frame_); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 257 | } |
| 258 | |
pbos@webrtc.org | d8e92c9 | 2013-08-23 09:19:30 +0000 | [diff] [blame] | 259 | VideoSendStreamInput* VideoSendStream::Input() { return this; } |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 260 | |
pbos@webrtc.org | 48cc9dc | 2013-11-20 11:36:47 +0000 | [diff] [blame] | 261 | void VideoSendStream::StartSending() { |
pbos@webrtc.org | d9f9185 | 2013-05-23 12:37:11 +0000 | [diff] [blame] | 262 | if (video_engine_base_->StartSend(channel_) != 0) |
| 263 | abort(); |
pbos@webrtc.org | bf9bc32 | 2013-08-05 12:01:36 +0000 | [diff] [blame] | 264 | if (video_engine_base_->StartReceive(channel_) != 0) |
| 265 | abort(); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 266 | } |
| 267 | |
pbos@webrtc.org | 48cc9dc | 2013-11-20 11:36:47 +0000 | [diff] [blame] | 268 | void VideoSendStream::StopSending() { |
pbos@webrtc.org | d9f9185 | 2013-05-23 12:37:11 +0000 | [diff] [blame] | 269 | if (video_engine_base_->StopSend(channel_) != 0) |
| 270 | abort(); |
pbos@webrtc.org | bf9bc32 | 2013-08-05 12:01:36 +0000 | [diff] [blame] | 271 | if (video_engine_base_->StopReceive(channel_) != 0) |
| 272 | abort(); |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 273 | } |
| 274 | |
pbos@webrtc.org | 8f2997c | 2013-11-14 08:58:14 +0000 | [diff] [blame] | 275 | bool VideoSendStream::SetCodec(const VideoCodec& codec) { |
pbos@webrtc.org | 9105cbd | 2013-11-28 11:59:31 +0000 | [diff] [blame] | 276 | assert(config_.rtp.ssrcs.size() >= codec.numberOfSimulcastStreams); |
pbos@webrtc.org | 8f2997c | 2013-11-14 08:58:14 +0000 | [diff] [blame] | 277 | |
| 278 | CriticalSectionScoped crit(codec_lock_.get()); |
| 279 | if (codec_->SetSendCodec(channel_, codec) != 0) |
| 280 | return false; |
| 281 | |
pbos@webrtc.org | 9105cbd | 2013-11-28 11:59:31 +0000 | [diff] [blame] | 282 | for (size_t i = 0; i < config_.rtp.ssrcs.size(); ++i) { |
| 283 | rtp_rtcp_->SetLocalSSRC(channel_, |
| 284 | config_.rtp.ssrcs[i], |
| 285 | kViEStreamTypeNormal, |
| 286 | static_cast<unsigned char>(i)); |
| 287 | } |
| 288 | |
pbos@webrtc.org | 8f2997c | 2013-11-14 08:58:14 +0000 | [diff] [blame] | 289 | config_.codec = codec; |
pbos@webrtc.org | 9105cbd | 2013-11-28 11:59:31 +0000 | [diff] [blame] | 290 | if (config_.rtp.rtx.ssrcs.empty()) |
| 291 | return true; |
| 292 | |
| 293 | // Set up RTX. |
| 294 | assert(config_.rtp.rtx.ssrcs.size() == config_.rtp.ssrcs.size()); |
| 295 | for (size_t i = 0; i < config_.rtp.ssrcs.size(); ++i) { |
| 296 | rtp_rtcp_->SetLocalSSRC(channel_, |
| 297 | config_.rtp.rtx.ssrcs[i], |
| 298 | kViEStreamTypeRtx, |
| 299 | static_cast<unsigned char>(i)); |
| 300 | } |
| 301 | |
| 302 | if (config_.rtp.rtx.rtx_payload_type != 0) { |
| 303 | rtp_rtcp_->SetRtxSendPayloadType(channel_, |
| 304 | config_.rtp.rtx.rtx_payload_type); |
| 305 | } |
| 306 | |
pbos@webrtc.org | 8f2997c | 2013-11-14 08:58:14 +0000 | [diff] [blame] | 307 | return true; |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 308 | } |
| 309 | |
pbos@webrtc.org | 8f2997c | 2013-11-14 08:58:14 +0000 | [diff] [blame] | 310 | VideoCodec VideoSendStream::GetCodec() { |
| 311 | CriticalSectionScoped crit(codec_lock_.get()); |
| 312 | return config_.codec; |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 313 | } |
| 314 | |
pbos@webrtc.org | bf9bc32 | 2013-08-05 12:01:36 +0000 | [diff] [blame] | 315 | bool VideoSendStream::DeliverRtcp(const uint8_t* packet, size_t length) { |
| 316 | return network_->ReceivedRTCPPacket( |
pbos@webrtc.org | 30c741a | 2013-08-05 13:25:51 +0000 | [diff] [blame] | 317 | channel_, packet, static_cast<int>(length)) == 0; |
pbos@webrtc.org | bf9bc32 | 2013-08-05 12:01:36 +0000 | [diff] [blame] | 318 | } |
sprang@webrtc.org | ca72300 | 2014-01-07 09:54:34 +0000 | [diff] [blame^] | 319 | |
| 320 | VideoSendStream::Stats VideoSendStream::GetStats() const { |
| 321 | return stats_proxy_->GetStats(); |
| 322 | } |
| 323 | |
| 324 | bool VideoSendStream::GetSendSideDelay(VideoSendStream::Stats* stats) { |
| 325 | return codec_->GetSendSideDelay( |
| 326 | channel_, &stats->avg_delay_ms, &stats->max_delay_ms); |
| 327 | } |
| 328 | |
| 329 | std::string VideoSendStream::GetCName() { |
| 330 | char rtcp_cname[ViERTP_RTCP::KMaxRTCPCNameLength]; |
| 331 | rtp_rtcp_->GetRTCPCName(channel_, rtcp_cname); |
| 332 | return rtcp_cname; |
| 333 | } |
| 334 | |
pbos@webrtc.org | dc8c883 | 2013-05-16 12:08:03 +0000 | [diff] [blame] | 335 | } // namespace internal |
| 336 | } // namespace webrtc |