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

Unified Diff: webrtc/media/engine/webrtcvideoengine.h

Issue 3007643002: Clean up ownership of webrtc::VideoEncoder (Closed)
Patch Set: Fix Created 3 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/engine/simulcast_encoder_adapter.cc ('k') | webrtc/media/engine/webrtcvideoengine.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvideoengine.h
diff --git a/webrtc/media/engine/webrtcvideoengine.h b/webrtc/media/engine/webrtcvideoengine.h
index 64581dc061e342333085d6cf5984460990f238ff..caca11c1fffb5a696b302d7130c03daaf8257a17 100644
--- a/webrtc/media/engine/webrtcvideoengine.h
+++ b/webrtc/media/engine/webrtcvideoengine.h
@@ -122,7 +122,6 @@ class WebRtcVideoEngine {
WebRtcVideoDecoderFactory* external_decoder_factory_;
WebRtcVideoEncoderFactory* external_encoder_factory_;
- std::unique_ptr<WebRtcVideoEncoderFactory> simulcast_encoder_factory_;
};
class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport {
@@ -311,24 +310,46 @@ class WebRtcVideoChannel : public VideoMediaChannel, public webrtc::Transport {
webrtc::VideoEncoderConfig encoder_config;
};
- struct AllocatedEncoder {
- AllocatedEncoder(webrtc::VideoEncoder* encoder,
+ class AllocatedEncoder {
+ public:
+ AllocatedEncoder() = default;
+ AllocatedEncoder(AllocatedEncoder&&) = default;
+ AllocatedEncoder& operator=(AllocatedEncoder&&) = default;
+
+ AllocatedEncoder(std::unique_ptr<webrtc::VideoEncoder> encoder,
+ std::unique_ptr<webrtc::VideoEncoder> external_encoder,
const cricket::VideoCodec& codec,
- bool external);
- webrtc::VideoEncoder* encoder;
- webrtc::VideoEncoder* external_encoder;
- cricket::VideoCodec codec;
- bool external;
+ bool has_internal_source);
+
+ // Returns a raw pointer to the allocated encoder. This object still has
+ // ownership of the encoder and is responsible for deleting it.
+ webrtc::VideoEncoder* encoder() { return encoder_.get(); }
+
+ // Returns true if the encoder is external.
+ bool IsExternal() { return static_cast<bool>(external_encoder_); }
+
+ cricket::VideoCodec codec() { return codec_; }
+
+ bool HasInternalSource() { return has_internal_source_; }
+
+ // Release the encoders this object manages.
+ void Reset();
+
+ private:
+ std::unique_ptr<webrtc::VideoEncoder> encoder_;
+ // TODO(magjed): |external_encoder_| is not used except for managing
+ // the lifetime when we use VideoEncoderSoftwareFallbackWrapper. Let
+ // VideoEncoderSoftwareFallbackWrapper own the external encoder instead
+ // and remove this member variable.
+ std::unique_ptr<webrtc::VideoEncoder> external_encoder_;
+ cricket::VideoCodec codec_;
+ bool has_internal_source_;
};
rtc::scoped_refptr<webrtc::VideoEncoderConfig::EncoderSpecificSettings>
ConfigureVideoEncoderSettings(const VideoCodec& codec);
- // If force_encoder_allocation is true, a new AllocatedEncoder is always
- // created. If false, the allocated encoder may be reused, if the type
- // matches.
- AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec,
- bool force_encoder_allocation);
- void DestroyVideoEncoder(AllocatedEncoder* encoder);
+ // Creates and returns a new AllocatedEncoder of the specified codec type.
+ AllocatedEncoder CreateVideoEncoder(const VideoCodec& codec);
void SetCodec(const VideoCodecSettings& codec,
bool force_encoder_allocation);
void RecreateWebRtcStream();
« no previous file with comments | « webrtc/media/engine/simulcast_encoder_adapter.cc ('k') | webrtc/media/engine/webrtcvideoengine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698