Revert of Deliver video frames on Android, on the decode thread. (patchset #7 id:120001 of https://codereview.webrtc.org/2764573002/ )
Reason for revert:
Breaks Chrome FYI Android bots.
See:
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus9%29/builds/20418
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus6%29/builds/14724
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28L%20Nexus5%29/builds/20133
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Android%20Tests%20%28dbg%29%20%28K%20Nexus5%29/builds/15111
Original issue's description:
> Deliver video frames on Android, on the decode thread.
>
> VideoCoding
> * Adding a method for polling for frames on Android only until the capture implementation takes care of this (longer term plan).
>
> CodecDatabase
> * Add an accessor for the current decoder
> * Use std::unique_ptr<> for ownership.
> * Remove "Release()" and "ReleaseDecoder()". Instead just delete.
> * Remove |friend| relationship between CodecDatabase and VCMGenericDecoder.
>
> VCMDecodedFrameCallback
> * DCHECKs for thread correctness.
> * Remove |lock_| now that a threading model has been established and verified.
>
> VCMGenericDecoder
> * All methods now have thread checks.
> * Variable access associated with thread checkers.
>
> VideoReceiver
> * Added two notification methods, DecoderThreadStarting() and DecoderThreadStopped()
> * Allows us to establish a period when the decoder thread is not running and it is safe to modify variables such as callbacks, that are only read when the decoder thread is running.
> * Allows us to DCHECK thread guarantees.
> * Allows synchronizing callbacks from the module process thread and have them only active while the decoder thread is running.
> * The above, allows us to establish two modes for the thread, single-threaded-mutable and multi-threaded-const.
> * Using that knowledge, we can remove |receive_crit_| as well as locking for a number of member variables.
>
> MediaCodecVideoDecoder
> * Removed frame polling code from this class, since this is now done from the root thread function in VideoReceiveStream.
>
> VideoReceiveStream
> * On Android: Polls for decoded frames every 10ms (same interval as previously in MediaCodecVideoDecoder)
> * [Un]Registers the |video_receiver_| with the module thread only around the time the decoder thread is started/stopped.
> * Notifies the receiver of start/stop events of the decoder thread.
> * Changed the decoder thread to use the new PlatformThread callback type.
>
> BUG=webrtc:7361, 695438
>
> Review-Url: https://codereview.webrtc.org/2764573002
> Cr-Commit-Position: refs/heads/master@{#17527}
> Committed: https://chromium.googlesource.com/external/webrtc/+/e3aa88bbd5accadec73fa7e38584dfbf6aabe8a9
TBR=sakal@webrtc.org,mflodman@webrtc.org,stefan@webrtc.org,tommi@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7361, 695438
Review-Url: https://codereview.webrtc.org/2792033003
Cr-Commit-Position: refs/heads/master@{#17530}
diff --git a/webrtc/modules/video_coding/generic_decoder.h b/webrtc/modules/video_coding/generic_decoder.h
index 1df2060..891ec89 100644
--- a/webrtc/modules/video_coding/generic_decoder.h
+++ b/webrtc/modules/video_coding/generic_decoder.h
@@ -11,8 +11,7 @@
#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"
#include "webrtc/modules/video_coding/encoded_frame.h"
@@ -37,7 +36,6 @@
public:
VCMDecodedFrameCallback(VCMTiming* timing, Clock* clock);
~VCMDecodedFrameCallback() override;
-
void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback);
VCMReceiveCallback* UserReceiveCallback();
@@ -57,7 +55,7 @@
private:
rtc::ThreadChecker construction_thread_;
- rtc::ThreadChecker decoder_thread_;
+ // Protect |_timestampMap|.
Clock* const _clock;
// This callback must be set before the decoder thread starts running
// and must only be unset when external threads (e.g decoder thread)
@@ -65,12 +63,15 @@
// while there are more than one threads involved, it must be set
// from the same thread, and therfore a lock is not required to access it.
VCMReceiveCallback* _receiveCallback = nullptr;
- VCMTiming* _timing ACCESS_ON(decoder_thread_);
- VCMTimestampMap _timestampMap ACCESS_ON(decoder_thread_);
- uint64_t _lastReceivedPictureID ACCESS_ON(decoder_thread_);
+ VCMTiming* _timing;
+ rtc::CriticalSection lock_;
+ VCMTimestampMap _timestampMap GUARDED_BY(lock_);
+ uint64_t _lastReceivedPictureID;
};
class VCMGenericDecoder {
+ friend class VCMCodecDataBase;
+
public:
explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false);
~VCMGenericDecoder();
@@ -88,30 +89,26 @@
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;
-#if defined(WEBRTC_ANDROID)
- // See https://bugs.chromium.org/p/webrtc/issues/detail?id=7361
- void PollDecodedFrames();
-#endif
-
- bool IsSameDecoder(VideoDecoder* decoder) const {
- return decoder_.get() == decoder;
- }
-
private:
- rtc::ThreadChecker decoder_thread_;
- VCMDecodedFrameCallback* _callback ACCESS_ON(decoder_thread_);
- VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength] ACCESS_ON(
- decoder_thread_);
- uint32_t _nextFrameInfoIdx ACCESS_ON(decoder_thread_);
- std::unique_ptr<VideoDecoder> decoder_;
- VideoCodecType _codecType ACCESS_ON(decoder_thread_);
- const bool _isExternal;
+ VCMDecodedFrameCallback* _callback;
+ VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength];
+ uint32_t _nextFrameInfoIdx;
+ VideoDecoder* const _decoder;
+ VideoCodecType _codecType;
+ bool _isExternal;
+ bool _keyFrameDecoded;
};
} // namespace webrtc