Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2.cc

Issue 2088233004: Add RTX codecs for codecs only supported by external encoder. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removing now-unused constant. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 // duration hasn't been implemented. 335 // duration hasn't been implemented.
336 static const int kNackHistoryMs = 1000; 336 static const int kNackHistoryMs = 1000;
337 337
338 static const int kDefaultQpMax = 56; 338 static const int kDefaultQpMax = 56;
339 339
340 static const int kDefaultRtcpReceiverReportSsrc = 1; 340 static const int kDefaultRtcpReceiverReportSsrc = 1;
341 341
342 // Down grade resolution at most 2 times for CPU reasons. 342 // Down grade resolution at most 2 times for CPU reasons.
343 static const int kMaxCpuDowngrades = 2; 343 static const int kMaxCpuDowngrades = 2;
344 344
345 // Adds |codec| to |list|, and also adds an RTX codec if |codec|'s name is
346 // recognized.
347 // TODO(deadbeef): Should we add RTX codecs for external codecs whose names we
348 // don't recognize?
349 void AddCodecAndMaybeRtxCodec(const VideoCodec& codec,
350 std::vector<VideoCodec>* codecs) {
351 codecs->push_back(codec);
352 int rtx_payload_type = 0;
353 if (CodecNamesEq(codec.name, kVp8CodecName)) {
354 rtx_payload_type = kDefaultRtxVp8PlType;
355 } else if (CodecNamesEq(codec.name, kVp9CodecName)) {
356 rtx_payload_type = kDefaultRtxVp9PlType;
357 } else if (CodecNamesEq(codec.name, kH264CodecName)) {
358 rtx_payload_type = kDefaultRtxH264PlType;
359 } else if (CodecNamesEq(codec.name, kRedCodecName)) {
360 rtx_payload_type = kDefaultRtxRedPlType;
361 } else {
362 return;
363 }
364 codecs->push_back(VideoCodec::CreateRtxCodec(rtx_payload_type, codec.id));
365 }
366
345 std::vector<VideoCodec> DefaultVideoCodecList() { 367 std::vector<VideoCodec> DefaultVideoCodecList() {
346 std::vector<VideoCodec> codecs; 368 std::vector<VideoCodec> codecs;
347 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp8PlType, 369 AddCodecAndMaybeRtxCodec(
348 kVp8CodecName)); 370 MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp8PlType, kVp8CodecName),
349 codecs.push_back( 371 &codecs);
350 VideoCodec::CreateRtxCodec(kDefaultRtxVp8PlType, kDefaultVp8PlType));
351 if (CodecIsInternallySupported(kVp9CodecName)) { 372 if (CodecIsInternallySupported(kVp9CodecName)) {
352 codecs.push_back(MakeVideoCodecWithDefaultFeedbackParams(kDefaultVp9PlType, 373 AddCodecAndMaybeRtxCodec(MakeVideoCodecWithDefaultFeedbackParams(
353 kVp9CodecName)); 374 kDefaultVp9PlType, kVp9CodecName),
354 codecs.push_back( 375 &codecs);
355 VideoCodec::CreateRtxCodec(kDefaultRtxVp9PlType, kDefaultVp9PlType));
356 } 376 }
357 if (CodecIsInternallySupported(kH264CodecName)) { 377 if (CodecIsInternallySupported(kH264CodecName)) {
358 VideoCodec codec = MakeVideoCodecWithDefaultFeedbackParams( 378 VideoCodec codec = MakeVideoCodecWithDefaultFeedbackParams(
359 kDefaultH264PlType, kH264CodecName); 379 kDefaultH264PlType, kH264CodecName);
360 // TODO(hta): Move all parameter generation for SDP into the codec 380 // TODO(hta): Move all parameter generation for SDP into the codec
361 // implementation, for all codecs and parameters. 381 // implementation, for all codecs and parameters.
362 // TODO(hta): Move selection of profile-level-id to H.264 codec 382 // TODO(hta): Move selection of profile-level-id to H.264 codec
363 // implementation. 383 // implementation.
364 // TODO(hta): Set FMTP parameters for all codecs of type H264. 384 // TODO(hta): Set FMTP parameters for all codecs of type H264.
365 codec.SetParam(kH264FmtpProfileLevelId, 385 codec.SetParam(kH264FmtpProfileLevelId,
366 kH264ProfileLevelConstrainedBaseline); 386 kH264ProfileLevelConstrainedBaseline);
367 codec.SetParam(kH264FmtpLevelAsymmetryAllowed, "1"); 387 codec.SetParam(kH264FmtpLevelAsymmetryAllowed, "1");
368 codec.SetParam(kH264FmtpPacketizationMode, "1"); 388 codec.SetParam(kH264FmtpPacketizationMode, "1");
369 codecs.push_back(codec); 389 AddCodecAndMaybeRtxCodec(codec, &codecs);
370 codecs.push_back(
371 VideoCodec::CreateRtxCodec(kDefaultRtxH264PlType, kDefaultH264PlType));
372 } 390 }
373 codecs.push_back(VideoCodec(kDefaultRedPlType, kRedCodecName)); 391 AddCodecAndMaybeRtxCodec(VideoCodec(kDefaultRedPlType, kRedCodecName),
374 codecs.push_back( 392 &codecs);
375 VideoCodec::CreateRtxCodec(kDefaultRtxRedPlType, kDefaultRedPlType));
376 codecs.push_back(VideoCodec(kDefaultUlpfecType, kUlpfecCodecName)); 393 codecs.push_back(VideoCodec(kDefaultUlpfecType, kUlpfecCodecName));
377 return codecs; 394 return codecs;
378 } 395 }
379 396
380 std::vector<webrtc::VideoStream> 397 std::vector<webrtc::VideoStream>
381 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateSimulcastVideoStreams( 398 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateSimulcastVideoStreams(
382 const VideoCodec& codec, 399 const VideoCodec& codec,
383 const VideoOptions& options, 400 const VideoOptions& options,
384 int max_bitrate_bps, 401 int max_bitrate_bps,
385 size_t num_streams) { 402 size_t num_streams) {
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 if (i != codecs.size() - 1) { 632 if (i != codecs.size() - 1) {
616 out << ", "; 633 out << ", ";
617 } 634 }
618 // Don't add internally-supported codecs twice. 635 // Don't add internally-supported codecs twice.
619 if (CodecIsInternallySupported(codecs[i].name)) { 636 if (CodecIsInternallySupported(codecs[i].name)) {
620 continue; 637 continue;
621 } 638 }
622 639
623 // External video encoders are given payloads 120-127. This also means that 640 // External video encoders are given payloads 120-127. This also means that
624 // we only support up to 8 external payload types. 641 // we only support up to 8 external payload types.
642 // TODO(deadbeef): mediasession.cc already has code to dynamically
643 // determine a payload type. We should be able to just leave the payload
644 // type empty and let mediasession determine it. However, currently RTX
645 // codecs are associated to codecs by payload type, meaning we DO need
646 // to allocate unique payload types here. So to make this change we would
647 // need to make RTX codecs associated by name instead.
625 const int kExternalVideoPayloadTypeBase = 120; 648 const int kExternalVideoPayloadTypeBase = 120;
626 size_t payload_type = kExternalVideoPayloadTypeBase + i; 649 size_t payload_type = kExternalVideoPayloadTypeBase + i;
627 RTC_DCHECK(payload_type < 128); 650 RTC_DCHECK(payload_type < 128);
628 VideoCodec codec(static_cast<int>(payload_type), codecs[i].name, 651 VideoCodec codec(static_cast<int>(payload_type), codecs[i].name,
629 codecs[i].max_width, codecs[i].max_height, 652 codecs[i].max_width, codecs[i].max_height,
630 codecs[i].max_fps); 653 codecs[i].max_fps);
631 654
632 AddDefaultFeedbackParams(&codec); 655 AddDefaultFeedbackParams(&codec);
633 supported_codecs.push_back(codec); 656 AddCodecAndMaybeRtxCodec(codec, &supported_codecs);
634 } 657 }
635 LOG(LS_INFO) << "Supported codecs (incl. external codecs): " 658 LOG(LS_INFO) << "Supported codecs (incl. external codecs): "
636 << CodecVectorToString(supported_codecs); 659 << CodecVectorToString(supported_codecs);
637 LOG(LS_INFO) << "Codecs supported by the external encoder factory: " 660 LOG(LS_INFO) << "Codecs supported by the external encoder factory: "
638 << out.str(); 661 << out.str();
639 return supported_codecs; 662 return supported_codecs;
640 } 663 }
641 664
642 WebRtcVideoChannel2::WebRtcVideoChannel2( 665 WebRtcVideoChannel2::WebRtcVideoChannel2(
643 webrtc::Call* call, 666 webrtc::Call* call,
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 rtx_mapping[video_codecs[i].codec.id] != 2651 rtx_mapping[video_codecs[i].codec.id] !=
2629 fec_settings.red_payload_type) { 2652 fec_settings.red_payload_type) {
2630 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2653 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2631 } 2654 }
2632 } 2655 }
2633 2656
2634 return video_codecs; 2657 return video_codecs;
2635 } 2658 }
2636 2659
2637 } // namespace cricket 2660 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698