Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 } else { | 270 } else { |
| 271 return rtc::Optional<RtcpFeedback>( | 271 return rtc::Optional<RtcpFeedback>( |
| 272 RtcpFeedback(RtcpFeedbackType::TRANSPORT_CC)); | 272 RtcpFeedback(RtcpFeedbackType::TRANSPORT_CC)); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 LOG(LS_WARNING) << "Unsupported RTCP feedback type: " | 275 LOG(LS_WARNING) << "Unsupported RTCP feedback type: " |
| 276 << cricket_feedback.id(); | 276 << cricket_feedback.id(); |
| 277 return rtc::Optional<RtcpFeedback>(); | 277 return rtc::Optional<RtcpFeedback>(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 std::vector<RtpEncodingParameters> ToRtpEncodings( | |
| 281 const cricket::StreamParamsVec& stream_params) { | |
| 282 std::vector<RtpEncodingParameters> rtp_encodings; | |
| 283 if (stream_params.size() > 0) { | |
|
Taylor Brandstetter
2017/03/08 22:35:49
What if there are more than 1 StreamParams? The si
Zhi Huang
2017/03/08 23:56:49
Oh, I was wrong. I thought that since ORTC api doe
Taylor Brandstetter
2017/03/09 00:41:43
You're right that the ORTC RtpSender/RtpReceiver d
| |
| 284 const cricket::StreamParams& stream_param = stream_params[0]; | |
| 285 RtpEncodingParameters rtp_encoding; | |
| 286 rtp_encoding.ssrc = rtc::Optional<uint32_t>(stream_param.first_ssrc()); | |
|
Taylor Brandstetter
2017/03/08 22:35:49
nit: Instead of "= rtc::Optional...", you can do "
Zhi Huang
2017/03/08 23:56:49
Done.
| |
| 287 uint32_t rtx_ssrc = 0; | |
| 288 if (stream_param.GetFidSsrc(stream_param.first_ssrc(), &rtx_ssrc)) { | |
| 289 RtpRtxParameters rtx_param(rtx_ssrc); | |
| 290 rtp_encoding.rtx = rtc::Optional<RtpRtxParameters>(rtx_param); | |
| 291 } | |
| 292 rtp_encodings.push_back(std::move(rtp_encoding)); | |
| 293 } | |
| 294 return rtp_encodings; | |
| 295 } | |
| 296 | |
| 280 template <typename C> | 297 template <typename C> |
| 281 cricket::MediaType KindOfCodec(); | 298 cricket::MediaType KindOfCodec(); |
| 282 | 299 |
| 283 template <> | 300 template <> |
| 284 cricket::MediaType KindOfCodec<cricket::AudioCodec>() { | 301 cricket::MediaType KindOfCodec<cricket::AudioCodec>() { |
| 285 return cricket::MEDIA_TYPE_AUDIO; | 302 return cricket::MEDIA_TYPE_AUDIO; |
| 286 } | 303 } |
| 287 | 304 |
| 288 template <> | 305 template <> |
| 289 cricket::MediaType KindOfCodec<cricket::VideoCodec>() { | 306 cricket::MediaType KindOfCodec<cricket::VideoCodec>() { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 325 codec.parameters.insert(cricket_codec.params.begin(), | 342 codec.parameters.insert(cricket_codec.params.begin(), |
| 326 cricket_codec.params.end()); | 343 cricket_codec.params.end()); |
| 327 return codec; | 344 return codec; |
| 328 } | 345 } |
| 329 | 346 |
| 330 template RtpCodecCapability ToRtpCodecCapability<cricket::AudioCodec>( | 347 template RtpCodecCapability ToRtpCodecCapability<cricket::AudioCodec>( |
| 331 const cricket::AudioCodec& cricket_codec); | 348 const cricket::AudioCodec& cricket_codec); |
| 332 template RtpCodecCapability ToRtpCodecCapability<cricket::VideoCodec>( | 349 template RtpCodecCapability ToRtpCodecCapability<cricket::VideoCodec>( |
| 333 const cricket::VideoCodec& cricket_codec); | 350 const cricket::VideoCodec& cricket_codec); |
| 334 | 351 |
| 352 template <typename C> | |
| 353 static void ToRtpCodecParametersTypeSpecific(const C& cricket_codec, | |
| 354 RtpCodecParameters* codec); | |
| 355 template <> | |
| 356 void ToRtpCodecParametersTypeSpecific<cricket::AudioCodec>( | |
| 357 const cricket::AudioCodec& cricket_codec, | |
| 358 RtpCodecParameters* codec) { | |
| 359 codec->num_channels = | |
| 360 rtc::Optional<int>(static_cast<int>(cricket_codec.channels)); | |
| 361 } | |
| 362 | |
| 363 template <> | |
| 364 void ToRtpCodecParametersTypeSpecific<cricket::VideoCodec>( | |
| 365 const cricket::VideoCodec& cricket_codec, | |
| 366 RtpCodecParameters* codec) {} | |
| 367 | |
| 368 template <typename C> | |
| 369 RtpCodecParameters ToRtpCodecParameters(const C& cricket_codec) { | |
| 370 RtpCodecParameters codec_param; | |
| 371 codec_param.name = cricket_codec.name; | |
| 372 codec_param.kind = KindOfCodec<C>(); | |
| 373 codec_param.clock_rate.emplace(cricket_codec.clockrate); | |
| 374 codec_param.payload_type = cricket_codec.id; | |
| 375 for (const cricket::FeedbackParam& cricket_feedback : | |
| 376 cricket_codec.feedback_params.params()) { | |
| 377 rtc::Optional<RtcpFeedback> feedback = ToRtcpFeedback(cricket_feedback); | |
| 378 if (feedback) { | |
| 379 codec_param.rtcp_feedback.push_back(feedback.MoveValue()); | |
| 380 } | |
| 381 } | |
| 382 ToRtpCodecParametersTypeSpecific(cricket_codec, &codec_param); | |
| 383 codec_param.parameters.insert(cricket_codec.params.begin(), | |
| 384 cricket_codec.params.end()); | |
| 385 return codec_param; | |
| 386 } | |
| 387 | |
| 388 template RtpCodecParameters ToRtpCodecParameters<cricket::AudioCodec>( | |
| 389 const cricket::AudioCodec& cricket_codec); | |
| 390 template RtpCodecParameters ToRtpCodecParameters<cricket::VideoCodec>( | |
| 391 const cricket::VideoCodec& cricket_codec); | |
| 392 | |
| 335 template <class C> | 393 template <class C> |
| 336 RtpCapabilities ToRtpCapabilities( | 394 RtpCapabilities ToRtpCapabilities( |
| 337 const std::vector<C>& cricket_codecs, | 395 const std::vector<C>& cricket_codecs, |
| 338 const cricket::RtpHeaderExtensions& cricket_extensions) { | 396 const cricket::RtpHeaderExtensions& cricket_extensions) { |
| 339 RtpCapabilities capabilities; | 397 RtpCapabilities capabilities; |
| 340 bool have_red = false; | 398 bool have_red = false; |
| 341 bool have_ulpfec = false; | 399 bool have_ulpfec = false; |
| 342 bool have_flexfec = false; | 400 bool have_flexfec = false; |
| 343 for (const C& cricket_codec : cricket_codecs) { | 401 for (const C& cricket_codec : cricket_codecs) { |
| 344 if (cricket_codec.name == cricket::kRedCodecName) { | 402 if (cricket_codec.name == cricket::kRedCodecName) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 366 return capabilities; | 424 return capabilities; |
| 367 } | 425 } |
| 368 | 426 |
| 369 template RtpCapabilities ToRtpCapabilities<cricket::AudioCodec>( | 427 template RtpCapabilities ToRtpCapabilities<cricket::AudioCodec>( |
| 370 const std::vector<cricket::AudioCodec>& cricket_codecs, | 428 const std::vector<cricket::AudioCodec>& cricket_codecs, |
| 371 const cricket::RtpHeaderExtensions& cricket_extensions); | 429 const cricket::RtpHeaderExtensions& cricket_extensions); |
| 372 template RtpCapabilities ToRtpCapabilities<cricket::VideoCodec>( | 430 template RtpCapabilities ToRtpCapabilities<cricket::VideoCodec>( |
| 373 const std::vector<cricket::VideoCodec>& cricket_codecs, | 431 const std::vector<cricket::VideoCodec>& cricket_codecs, |
| 374 const cricket::RtpHeaderExtensions& cricket_extensions); | 432 const cricket::RtpHeaderExtensions& cricket_extensions); |
| 375 | 433 |
| 434 template <class C> | |
| 435 RtpParameters ToRtpParameters( | |
| 436 const std::vector<C>& cricket_codecs, | |
| 437 const cricket::RtpHeaderExtensions& cricket_extensions, | |
| 438 const cricket::StreamParamsVec& stream_params) { | |
| 439 RtpParameters rtp_parameters; | |
| 440 for (const C& cricket_codec : cricket_codecs) { | |
| 441 rtp_parameters.codecs.push_back(ToRtpCodecParameters(cricket_codec)); | |
| 442 } | |
| 443 for (const RtpExtension& cricket_extension : cricket_extensions) { | |
| 444 rtp_parameters.header_extensions.emplace_back(cricket_extension.uri, | |
| 445 cricket_extension.id); | |
| 446 } | |
| 447 rtp_parameters.encodings = ToRtpEncodings(stream_params); | |
| 448 return rtp_parameters; | |
| 449 } | |
| 450 | |
| 451 template RtpParameters ToRtpParameters<cricket::AudioCodec>( | |
| 452 const std::vector<cricket::AudioCodec>& cricket_codecs, | |
| 453 const cricket::RtpHeaderExtensions& cricket_extensions, | |
| 454 const cricket::StreamParamsVec& stream_params); | |
| 455 template RtpParameters ToRtpParameters<cricket::VideoCodec>( | |
| 456 const std::vector<cricket::VideoCodec>& cricket_codecs, | |
| 457 const cricket::RtpHeaderExtensions& cricket_extensions, | |
| 458 const cricket::StreamParamsVec& stream_params); | |
| 459 | |
| 376 } // namespace webrtc | 460 } // namespace webrtc |
| OLD | NEW |