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 for (const cricket::StreamParams& stream_param : stream_params) { |
| 284 RtpEncodingParameters rtp_encoding; |
| 285 rtp_encoding.ssrc.emplace(stream_param.first_ssrc()); |
| 286 uint32_t rtx_ssrc = 0; |
| 287 if (stream_param.GetFidSsrc(stream_param.first_ssrc(), &rtx_ssrc)) { |
| 288 RtpRtxParameters rtx_param(rtx_ssrc); |
| 289 rtp_encoding.rtx.emplace(rtx_param); |
| 290 } |
| 291 rtp_encodings.push_back(std::move(rtp_encoding)); |
| 292 } |
| 293 return rtp_encodings; |
| 294 } |
| 295 |
280 template <typename C> | 296 template <typename C> |
281 cricket::MediaType KindOfCodec(); | 297 cricket::MediaType KindOfCodec(); |
282 | 298 |
283 template <> | 299 template <> |
284 cricket::MediaType KindOfCodec<cricket::AudioCodec>() { | 300 cricket::MediaType KindOfCodec<cricket::AudioCodec>() { |
285 return cricket::MEDIA_TYPE_AUDIO; | 301 return cricket::MEDIA_TYPE_AUDIO; |
286 } | 302 } |
287 | 303 |
288 template <> | 304 template <> |
289 cricket::MediaType KindOfCodec<cricket::VideoCodec>() { | 305 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(), | 341 codec.parameters.insert(cricket_codec.params.begin(), |
326 cricket_codec.params.end()); | 342 cricket_codec.params.end()); |
327 return codec; | 343 return codec; |
328 } | 344 } |
329 | 345 |
330 template RtpCodecCapability ToRtpCodecCapability<cricket::AudioCodec>( | 346 template RtpCodecCapability ToRtpCodecCapability<cricket::AudioCodec>( |
331 const cricket::AudioCodec& cricket_codec); | 347 const cricket::AudioCodec& cricket_codec); |
332 template RtpCodecCapability ToRtpCodecCapability<cricket::VideoCodec>( | 348 template RtpCodecCapability ToRtpCodecCapability<cricket::VideoCodec>( |
333 const cricket::VideoCodec& cricket_codec); | 349 const cricket::VideoCodec& cricket_codec); |
334 | 350 |
| 351 template <typename C> |
| 352 static void ToRtpCodecParametersTypeSpecific(const C& cricket_codec, |
| 353 RtpCodecParameters* codec); |
| 354 template <> |
| 355 void ToRtpCodecParametersTypeSpecific<cricket::AudioCodec>( |
| 356 const cricket::AudioCodec& cricket_codec, |
| 357 RtpCodecParameters* codec) { |
| 358 codec->num_channels = |
| 359 rtc::Optional<int>(static_cast<int>(cricket_codec.channels)); |
| 360 } |
| 361 |
| 362 template <> |
| 363 void ToRtpCodecParametersTypeSpecific<cricket::VideoCodec>( |
| 364 const cricket::VideoCodec& cricket_codec, |
| 365 RtpCodecParameters* codec) {} |
| 366 |
| 367 template <typename C> |
| 368 RtpCodecParameters ToRtpCodecParameters(const C& cricket_codec) { |
| 369 RtpCodecParameters codec_param; |
| 370 codec_param.name = cricket_codec.name; |
| 371 codec_param.kind = KindOfCodec<C>(); |
| 372 codec_param.clock_rate.emplace(cricket_codec.clockrate); |
| 373 codec_param.payload_type = cricket_codec.id; |
| 374 for (const cricket::FeedbackParam& cricket_feedback : |
| 375 cricket_codec.feedback_params.params()) { |
| 376 rtc::Optional<RtcpFeedback> feedback = ToRtcpFeedback(cricket_feedback); |
| 377 if (feedback) { |
| 378 codec_param.rtcp_feedback.push_back(feedback.MoveValue()); |
| 379 } |
| 380 } |
| 381 ToRtpCodecParametersTypeSpecific(cricket_codec, &codec_param); |
| 382 codec_param.parameters.insert(cricket_codec.params.begin(), |
| 383 cricket_codec.params.end()); |
| 384 return codec_param; |
| 385 } |
| 386 |
| 387 template RtpCodecParameters ToRtpCodecParameters<cricket::AudioCodec>( |
| 388 const cricket::AudioCodec& cricket_codec); |
| 389 template RtpCodecParameters ToRtpCodecParameters<cricket::VideoCodec>( |
| 390 const cricket::VideoCodec& cricket_codec); |
| 391 |
335 template <class C> | 392 template <class C> |
336 RtpCapabilities ToRtpCapabilities( | 393 RtpCapabilities ToRtpCapabilities( |
337 const std::vector<C>& cricket_codecs, | 394 const std::vector<C>& cricket_codecs, |
338 const cricket::RtpHeaderExtensions& cricket_extensions) { | 395 const cricket::RtpHeaderExtensions& cricket_extensions) { |
339 RtpCapabilities capabilities; | 396 RtpCapabilities capabilities; |
340 bool have_red = false; | 397 bool have_red = false; |
341 bool have_ulpfec = false; | 398 bool have_ulpfec = false; |
342 bool have_flexfec = false; | 399 bool have_flexfec = false; |
343 for (const C& cricket_codec : cricket_codecs) { | 400 for (const C& cricket_codec : cricket_codecs) { |
344 if (cricket_codec.name == cricket::kRedCodecName) { | 401 if (cricket_codec.name == cricket::kRedCodecName) { |
(...skipping 21 matching lines...) Expand all Loading... |
366 return capabilities; | 423 return capabilities; |
367 } | 424 } |
368 | 425 |
369 template RtpCapabilities ToRtpCapabilities<cricket::AudioCodec>( | 426 template RtpCapabilities ToRtpCapabilities<cricket::AudioCodec>( |
370 const std::vector<cricket::AudioCodec>& cricket_codecs, | 427 const std::vector<cricket::AudioCodec>& cricket_codecs, |
371 const cricket::RtpHeaderExtensions& cricket_extensions); | 428 const cricket::RtpHeaderExtensions& cricket_extensions); |
372 template RtpCapabilities ToRtpCapabilities<cricket::VideoCodec>( | 429 template RtpCapabilities ToRtpCapabilities<cricket::VideoCodec>( |
373 const std::vector<cricket::VideoCodec>& cricket_codecs, | 430 const std::vector<cricket::VideoCodec>& cricket_codecs, |
374 const cricket::RtpHeaderExtensions& cricket_extensions); | 431 const cricket::RtpHeaderExtensions& cricket_extensions); |
375 | 432 |
| 433 template <class C> |
| 434 RtpParameters ToRtpParameters( |
| 435 const std::vector<C>& cricket_codecs, |
| 436 const cricket::RtpHeaderExtensions& cricket_extensions, |
| 437 const cricket::StreamParamsVec& stream_params) { |
| 438 RtpParameters rtp_parameters; |
| 439 for (const C& cricket_codec : cricket_codecs) { |
| 440 rtp_parameters.codecs.push_back(ToRtpCodecParameters(cricket_codec)); |
| 441 } |
| 442 for (const RtpExtension& cricket_extension : cricket_extensions) { |
| 443 rtp_parameters.header_extensions.emplace_back(cricket_extension.uri, |
| 444 cricket_extension.id); |
| 445 } |
| 446 rtp_parameters.encodings = ToRtpEncodings(stream_params); |
| 447 return rtp_parameters; |
| 448 } |
| 449 |
| 450 template RtpParameters ToRtpParameters<cricket::AudioCodec>( |
| 451 const std::vector<cricket::AudioCodec>& cricket_codecs, |
| 452 const cricket::RtpHeaderExtensions& cricket_extensions, |
| 453 const cricket::StreamParamsVec& stream_params); |
| 454 template RtpParameters ToRtpParameters<cricket::VideoCodec>( |
| 455 const std::vector<cricket::VideoCodec>& cricket_codecs, |
| 456 const cricket::RtpHeaderExtensions& cricket_extensions, |
| 457 const cricket::StreamParamsVec& stream_params); |
| 458 |
376 } // namespace webrtc | 459 } // namespace webrtc |
OLD | NEW |