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

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

Issue 2474993002: Pass selected cricket::VideoCodec down to internal H264 encoder (Closed)
Patch Set: Fix. Created 4 years, 1 month 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
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 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 int max_bitrate_bps, 1519 int max_bitrate_bps,
1520 const rtc::Optional<VideoCodecSettings>& codec_settings) 1520 const rtc::Optional<VideoCodecSettings>& codec_settings)
1521 : config(std::move(config)), 1521 : config(std::move(config)),
1522 options(options), 1522 options(options),
1523 max_bitrate_bps(max_bitrate_bps), 1523 max_bitrate_bps(max_bitrate_bps),
1524 conference_mode(false), 1524 conference_mode(false),
1525 codec_settings(codec_settings) {} 1525 codec_settings(codec_settings) {}
1526 1526
1527 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder::AllocatedEncoder( 1527 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder::AllocatedEncoder(
1528 webrtc::VideoEncoder* encoder, 1528 webrtc::VideoEncoder* encoder,
1529 webrtc::VideoCodecType type, 1529 const cricket::VideoCodec& codec,
1530 bool external) 1530 bool external)
1531 : encoder(encoder), 1531 : encoder(encoder),
1532 external_encoder(nullptr), 1532 external_encoder(nullptr),
1533 type(type), 1533 codec(codec),
1534 external(external) { 1534 external(external) {
1535 if (external) { 1535 if (external) {
1536 external_encoder = encoder; 1536 external_encoder = encoder;
1537 this->encoder = 1537 this->encoder =
1538 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); 1538 new webrtc::VideoEncoderSoftwareFallbackWrapper(codec, encoder);
1539 } 1539 }
1540 } 1540 }
1541 1541
1542 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( 1542 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
1543 webrtc::Call* call, 1543 webrtc::Call* call,
1544 const StreamParams& sp, 1544 const StreamParams& sp,
1545 webrtc::VideoSendStream::Config config, 1545 webrtc::VideoSendStream::Config config,
1546 const VideoOptions& options, 1546 const VideoOptions& options,
1547 WebRtcVideoEncoderFactory* external_encoder_factory, 1547 WebRtcVideoEncoderFactory* external_encoder_factory,
1548 bool enable_cpu_overuse_detection, 1548 bool enable_cpu_overuse_detection,
1549 int max_bitrate_bps, 1549 int max_bitrate_bps,
1550 const rtc::Optional<VideoCodecSettings>& codec_settings, 1550 const rtc::Optional<VideoCodecSettings>& codec_settings,
1551 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, 1551 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions,
1552 // TODO(deadbeef): Don't duplicate information between send_params, 1552 // TODO(deadbeef): Don't duplicate information between send_params,
1553 // rtp_extensions, options, etc. 1553 // rtp_extensions, options, etc.
1554 const VideoSendParameters& send_params) 1554 const VideoSendParameters& send_params)
1555 : worker_thread_(rtc::Thread::Current()), 1555 : worker_thread_(rtc::Thread::Current()),
1556 ssrcs_(sp.ssrcs), 1556 ssrcs_(sp.ssrcs),
1557 ssrc_groups_(sp.ssrc_groups), 1557 ssrc_groups_(sp.ssrc_groups),
1558 call_(call), 1558 call_(call),
1559 enable_cpu_overuse_detection_(enable_cpu_overuse_detection), 1559 enable_cpu_overuse_detection_(enable_cpu_overuse_detection),
1560 source_(nullptr), 1560 source_(nullptr),
1561 external_encoder_factory_(external_encoder_factory), 1561 external_encoder_factory_(external_encoder_factory),
1562 stream_(nullptr), 1562 stream_(nullptr),
1563 encoder_sink_(nullptr), 1563 encoder_sink_(nullptr),
1564 parameters_(std::move(config), options, max_bitrate_bps, codec_settings), 1564 parameters_(std::move(config), options, max_bitrate_bps, codec_settings),
1565 rtp_parameters_(CreateRtpParametersWithOneEncoding()), 1565 rtp_parameters_(CreateRtpParametersWithOneEncoding()),
1566 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), 1566 allocated_encoder_(nullptr, cricket::VideoCodec(), false),
1567 sending_(false), 1567 sending_(false),
1568 last_frame_timestamp_us_(0) { 1568 last_frame_timestamp_us_(0) {
1569 parameters_.config.rtp.max_packet_size = kVideoMtu; 1569 parameters_.config.rtp.max_packet_size = kVideoMtu;
1570 parameters_.conference_mode = send_params.conference_mode; 1570 parameters_.conference_mode = send_params.conference_mode;
1571 1571
1572 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs); 1572 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);
1573 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, 1573 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs,
1574 &parameters_.config.rtp.rtx.ssrcs); 1574 &parameters_.config.rtp.rtx.ssrcs);
1575 parameters_.config.rtp.c_name = sp.cname; 1575 parameters_.config.rtp.c_name = sp.cname;
1576 if (rtp_extensions) { 1576 if (rtp_extensions) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 1691
1692 const std::vector<uint32_t>& 1692 const std::vector<uint32_t>&
1693 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { 1693 WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const {
1694 return ssrcs_; 1694 return ssrcs_;
1695 } 1695 }
1696 1696
1697 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder 1697 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder
1698 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoder( 1698 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoder(
1699 const VideoCodec& codec) { 1699 const VideoCodec& codec) {
1700 RTC_DCHECK_RUN_ON(&thread_checker_); 1700 RTC_DCHECK_RUN_ON(&thread_checker_);
1701 webrtc::VideoCodecType type = CodecTypeFromName(codec.name);
1702 1701
1703 // Do not re-create encoders of the same type. 1702 // Do not re-create encoders of the same type.
1704 if (type == allocated_encoder_.type && allocated_encoder_.encoder != NULL) { 1703 if (codec == allocated_encoder_.codec &&
1704 allocated_encoder_.encoder != nullptr) {
1705 return allocated_encoder_; 1705 return allocated_encoder_;
1706 } 1706 }
1707 1707
1708 // Try creating external encoder.
1708 if (external_encoder_factory_ != NULL) { 1709 if (external_encoder_factory_ != NULL) {
1709 webrtc::VideoEncoder* encoder = 1710 webrtc::VideoEncoder* encoder =
1710 external_encoder_factory_->CreateVideoEncoder(codec); 1711 external_encoder_factory_->CreateVideoEncoder(codec);
1711 if (encoder != NULL) { 1712 if (encoder != NULL) {
1712 return AllocatedEncoder(encoder, type, true); 1713 return AllocatedEncoder(encoder, codec, true /* is_external */);
1713 } 1714 }
1714 } 1715 }
1715 1716
1716 if (type == webrtc::kVideoCodecVP8) { 1717 // Try creating internal encoder.
1717 return AllocatedEncoder( 1718 if (webrtc::VideoEncoder::IsSupportedSoftware(codec)) {
1718 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp8), type, false); 1719 return AllocatedEncoder(webrtc::VideoEncoder::Create(codec), codec,
1719 } else if (type == webrtc::kVideoCodecVP9) { 1720 false /* is_external */);
1720 return AllocatedEncoder(
1721 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kVp9), type, false);
1722 } else if (type == webrtc::kVideoCodecH264) {
1723 return AllocatedEncoder(
1724 webrtc::VideoEncoder::Create(webrtc::VideoEncoder::kH264), type, false);
1725 } 1721 }
1726 1722
1727 // This shouldn't happen, we should not be trying to create something we don't 1723 // This shouldn't happen, we should not be trying to create something we don't
1728 // support. 1724 // support.
1729 RTC_DCHECK(false); 1725 RTC_NOTREACHED();
1730 return AllocatedEncoder(NULL, webrtc::kVideoCodecUnknown, false); 1726 return AllocatedEncoder(NULL, cricket::VideoCodec(), false);
1731 } 1727 }
1732 1728
1733 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( 1729 void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder(
1734 AllocatedEncoder* encoder) { 1730 AllocatedEncoder* encoder) {
1735 RTC_DCHECK_RUN_ON(&thread_checker_); 1731 RTC_DCHECK_RUN_ON(&thread_checker_);
1736 if (encoder->external) { 1732 if (encoder->external) {
1737 external_encoder_factory_->DestroyVideoEncoder(encoder->external_encoder); 1733 external_encoder_factory_->DestroyVideoEncoder(encoder->external_encoder);
1738 } 1734 }
1739 delete encoder->encoder; 1735 delete encoder->encoder;
1740 } 1736 }
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
2563 rtx_mapping[video_codecs[i].codec.id] != 2559 rtx_mapping[video_codecs[i].codec.id] !=
2564 ulpfec_config.red_payload_type) { 2560 ulpfec_config.red_payload_type) {
2565 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2561 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2566 } 2562 }
2567 } 2563 }
2568 2564
2569 return video_codecs; 2565 return video_codecs;
2570 } 2566 }
2571 2567
2572 } // namespace cricket 2568 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698