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

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

Issue 3007683002: Let VideoEncoderSoftwareFallbackWrapper own the wrapped encoder (Closed)
Patch Set: Created 3 years, 3 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
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 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 int max_bitrate_bps, 1408 int max_bitrate_bps,
1409 const rtc::Optional<VideoCodecSettings>& codec_settings) 1409 const rtc::Optional<VideoCodecSettings>& codec_settings)
1410 : config(std::move(config)), 1410 : config(std::move(config)),
1411 options(options), 1411 options(options),
1412 max_bitrate_bps(max_bitrate_bps), 1412 max_bitrate_bps(max_bitrate_bps),
1413 conference_mode(false), 1413 conference_mode(false),
1414 codec_settings(codec_settings) {} 1414 codec_settings(codec_settings) {}
1415 1415
1416 WebRtcVideoChannel::WebRtcVideoSendStream::AllocatedEncoder::AllocatedEncoder( 1416 WebRtcVideoChannel::WebRtcVideoSendStream::AllocatedEncoder::AllocatedEncoder(
1417 std::unique_ptr<webrtc::VideoEncoder> encoder, 1417 std::unique_ptr<webrtc::VideoEncoder> encoder,
1418 std::unique_ptr<webrtc::VideoEncoder> external_encoder, 1418 bool is_external,
1419 const cricket::VideoCodec& codec, 1419 const cricket::VideoCodec& codec,
1420 bool has_internal_source) 1420 bool has_internal_source)
1421 : encoder_(std::move(encoder)), 1421 : encoder_(std::move(encoder)),
1422 external_encoder_(std::move(external_encoder)), 1422 is_external_(is_external),
1423 codec_(codec), 1423 codec_(codec),
1424 has_internal_source_(has_internal_source) {} 1424 has_internal_source_(has_internal_source) {}
1425 1425
1426 void WebRtcVideoChannel::WebRtcVideoSendStream::AllocatedEncoder::Reset() { 1426 void WebRtcVideoChannel::WebRtcVideoSendStream::AllocatedEncoder::Reset() {
1427 external_encoder_.reset();
1428 encoder_.reset(); 1427 encoder_.reset();
1429 codec_ = cricket::VideoCodec(); 1428 codec_ = cricket::VideoCodec();
1430 } 1429 }
1431 1430
1432 WebRtcVideoChannel::WebRtcVideoSendStream::WebRtcVideoSendStream( 1431 WebRtcVideoChannel::WebRtcVideoSendStream::WebRtcVideoSendStream(
1433 webrtc::Call* call, 1432 webrtc::Call* call,
1434 const StreamParams& sp, 1433 const StreamParams& sp,
1435 webrtc::VideoSendStream::Config config, 1434 webrtc::VideoSendStream::Config config,
1436 const VideoOptions& options, 1435 const VideoOptions& options,
1437 WebRtcVideoEncoderFactory* external_encoder_factory, 1436 WebRtcVideoEncoderFactory* external_encoder_factory,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 // If it's a codec type we can simulcast, create a wrapped encoder. 1594 // If it's a codec type we can simulcast, create a wrapped encoder.
1596 external_encoder = std::unique_ptr<webrtc::VideoEncoder>( 1595 external_encoder = std::unique_ptr<webrtc::VideoEncoder>(
1597 new webrtc::SimulcastEncoderAdapter(external_encoder_factory_)); 1596 new webrtc::SimulcastEncoderAdapter(external_encoder_factory_));
1598 } else { 1597 } else {
1599 external_encoder = 1598 external_encoder =
1600 CreateScopedVideoEncoder(external_encoder_factory_, codec); 1599 CreateScopedVideoEncoder(external_encoder_factory_, codec);
1601 } 1600 }
1602 if (external_encoder) { 1601 if (external_encoder) {
1603 std::unique_ptr<webrtc::VideoEncoder> internal_encoder( 1602 std::unique_ptr<webrtc::VideoEncoder> internal_encoder(
1604 new webrtc::VideoEncoderSoftwareFallbackWrapper( 1603 new webrtc::VideoEncoderSoftwareFallbackWrapper(
1605 codec, external_encoder.get())); 1604 codec, std::move(external_encoder)));
andersc 2017/08/29 07:27:33 Is it normal to call std::move both here and in th
magjed_webrtc 2017/08/29 07:56:48 Yes, it won't compile otherwise. Every time you cr
1606 const webrtc::VideoCodecType codec_type = 1605 const webrtc::VideoCodecType codec_type =
1607 webrtc::PayloadStringToCodecType(codec.name); 1606 webrtc::PayloadStringToCodecType(codec.name);
1608 const bool has_internal_source = 1607 const bool has_internal_source =
1609 external_encoder_factory_->EncoderTypeHasInternalSource(codec_type); 1608 external_encoder_factory_->EncoderTypeHasInternalSource(codec_type);
1610 return AllocatedEncoder(std::move(internal_encoder), 1609 return AllocatedEncoder(std::move(internal_encoder),
1611 std::move(external_encoder), codec, 1610 true /* is_external */, codec,
1612 has_internal_source); 1611 has_internal_source);
1613 } 1612 }
1614 } 1613 }
1615 1614
1616 // Try creating internal encoder. 1615 // Try creating internal encoder.
1617 std::unique_ptr<webrtc::VideoEncoder> internal_encoder; 1616 std::unique_ptr<webrtc::VideoEncoder> internal_encoder;
1618 if (FindMatchingCodec(internal_encoder_factory_->supported_codecs(), codec)) { 1617 if (FindMatchingCodec(internal_encoder_factory_->supported_codecs(), codec)) {
1619 if (CodecNamesEq(codec.name.c_str(), kVp8CodecName) && 1618 if (CodecNamesEq(codec.name.c_str(), kVp8CodecName) &&
1620 parameters_.encoder_config.content_type == 1619 parameters_.encoder_config.content_type ==
1621 webrtc::VideoEncoderConfig::ContentType::kScreen && 1620 webrtc::VideoEncoderConfig::ContentType::kScreen &&
1622 parameters_.conference_mode && UseSimulcastScreenshare()) { 1621 parameters_.conference_mode && UseSimulcastScreenshare()) {
1623 // TODO(sprang): Remove this adapter once libvpx supports simulcast with 1622 // TODO(sprang): Remove this adapter once libvpx supports simulcast with
1624 // same-resolution substreams. 1623 // same-resolution substreams.
1625 internal_encoder = std::unique_ptr<webrtc::VideoEncoder>( 1624 internal_encoder = std::unique_ptr<webrtc::VideoEncoder>(
1626 new webrtc::SimulcastEncoderAdapter(internal_encoder_factory_.get())); 1625 new webrtc::SimulcastEncoderAdapter(internal_encoder_factory_.get()));
1627 } else { 1626 } else {
1628 internal_encoder = std::unique_ptr<webrtc::VideoEncoder>( 1627 internal_encoder = std::unique_ptr<webrtc::VideoEncoder>(
1629 internal_encoder_factory_->CreateVideoEncoder(codec)); 1628 internal_encoder_factory_->CreateVideoEncoder(codec));
1630 } 1629 }
1631 return AllocatedEncoder(std::move(internal_encoder), 1630 return AllocatedEncoder(std::move(internal_encoder),
1632 nullptr /* external_encoder */, codec, 1631 false /* is_external */, codec,
1633 false /* has_internal_source */); 1632 false /* has_internal_source */);
1634 } 1633 }
1635 1634
1636 // This shouldn't happen, we should not be trying to create something we don't 1635 // This shouldn't happen, we should not be trying to create something we don't
1637 // support. 1636 // support.
1638 RTC_NOTREACHED(); 1637 RTC_NOTREACHED();
1639 return AllocatedEncoder(); 1638 return AllocatedEncoder();
1640 } 1639 }
1641 1640
1642 void WebRtcVideoChannel::WebRtcVideoSendStream::SetCodec( 1641 void WebRtcVideoChannel::WebRtcVideoSendStream::SetCodec(
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 stream.temporal_layer_thresholds_bps.resize(GetDefaultVp9TemporalLayers() - 2572 stream.temporal_layer_thresholds_bps.resize(GetDefaultVp9TemporalLayers() -
2574 1); 2573 1);
2575 } 2574 }
2576 2575
2577 std::vector<webrtc::VideoStream> streams; 2576 std::vector<webrtc::VideoStream> streams;
2578 streams.push_back(stream); 2577 streams.push_back(stream);
2579 return streams; 2578 return streams;
2580 } 2579 }
2581 2580
2582 } // namespace cricket 2581 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698