A few simplifications to CodecDatabase and VCMGenericDecoder.
* Remove the ReleaseDecoder and Release methods that were used in combination with deleting the decoder object. Now simply deleting the object does the right thing.
* Remove 'friend' relationship between the two classes since they don't need to touch each other's state directly anymore.
* Use std::unique_ptr for holding pointers and transferring ownership.
These changes were previously reviewed here:
https://codereview.webrtc.org/2764573002/
BUG=webrtc:7361, 695438
Review-Url: https://codereview.webrtc.org/2966823002
Cr-Commit-Position: refs/heads/master@{#18908}
diff --git a/webrtc/modules/video_coding/generic_decoder.h b/webrtc/modules/video_coding/generic_decoder.h
index 8e26a8b..f7196f0 100644
--- a/webrtc/modules/video_coding/generic_decoder.h
+++ b/webrtc/modules/video_coding/generic_decoder.h
@@ -11,6 +11,8 @@
#ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_
#define WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_
+#include <memory>
+
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/modules/include/module_common_types.h"
@@ -73,8 +75,6 @@
};
class VCMGenericDecoder {
- friend class VCMCodecDataBase;
-
public:
explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false);
~VCMGenericDecoder();
@@ -92,26 +92,23 @@
int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs);
/**
- * Free the decoder memory
- */
- int32_t Release();
-
- /**
* Set decode callback. Deregistering while decoding is illegal.
*/
int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback);
bool External() const;
bool PrefersLateDecoding() const;
+ bool IsSameDecoder(VideoDecoder* decoder) const {
+ return decoder_.get() == decoder;
+ }
private:
VCMDecodedFrameCallback* _callback;
VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength];
uint32_t _nextFrameInfoIdx;
- VideoDecoder* const _decoder;
+ std::unique_ptr<VideoDecoder> decoder_;
VideoCodecType _codecType;
- bool _isExternal;
- bool _keyFrameDecoded;
+ const bool _isExternal;
VideoContentType _last_keyframe_content_type;
};