Updates to VCMDecodedFrameCallback, VideoReceiver and a few related classes/tests.
* The _receiveCallback member of VCMDecodedFrameCallback does actually not require locking now that the threading model is slightly clearer. Documentation and checks have been added.
* UserReceiveCallback() never returns null and must always be called on the decoder thread. Checks have been added and the two test suites that were failing to set this callback, have been fixed and a new mock class added. (looks like sakal@ may have hit some issues with flaky tests there).
* Changed VcmPayloadSink to use move semantics which I suspect was the intention at the time the code was written (when we didn't have move semantics).
* Added thread checker to a couple of classes and started adding thread checks for known behavior. There's more to be done there.
* Remove the |_decoder| member variable in VideoReceiver. It is not needed and as it could be used, left us open to a race.
* TODOs added for places where we can reduce locking. I suspect that we can get away with not needing a lock around _codecDataBase in VideoReceiver once we've got a clear picture of the threading model and ensured that all adhere to it.
BUG=webrtc:7328
Review-Url: https://codereview.webrtc.org/2744013002
Cr-Commit-Position: refs/heads/master@{#17226}
diff --git a/webrtc/modules/video_coding/video_coding_impl.h b/webrtc/modules/video_coding/video_coding_impl.h
index a45105a..30641dc 100644
--- a/webrtc/modules/video_coding/video_coding_impl.h
+++ b/webrtc/modules/video_coding/video_coding_impl.h
@@ -18,8 +18,9 @@
#include <vector>
#include "webrtc/base/onetimeevent.h"
-#include "webrtc/base/thread_annotations.h"
#include "webrtc/base/sequenced_task_checker.h"
+#include "webrtc/base/thread_annotations.h"
+#include "webrtc/base/thread_checker.h"
#include "webrtc/common_video/include/frame_callback.h"
#include "webrtc/modules/video_coding/codec_database.h"
#include "webrtc/modules/video_coding/frame_buffer.h"
@@ -171,6 +172,9 @@
int32_t Decode(const webrtc::VCMEncodedFrame* frame);
+ // Called on the decoder thread when thread is exiting.
+ void DecodingStopped();
+
int32_t ReceiveCodec(VideoCodec* currentReceiveCodec) const;
VideoCodecType ReceiveCodec() const;
@@ -206,6 +210,7 @@
int32_t RequestSliceLossIndication(const uint64_t pictureID) const;
private:
+ rtc::ThreadChecker construction_thread_;
Clock* const clock_;
rtc::CriticalSection process_crit_;
rtc::CriticalSection receive_crit_;
@@ -216,7 +221,6 @@
VCMReceiveStatisticsCallback* _receiveStatsCallback GUARDED_BY(process_crit_);
VCMDecoderTimingCallback* _decoderTimingCallback GUARDED_BY(process_crit_);
VCMPacketRequestCallback* _packetRequestCallback GUARDED_BY(process_crit_);
- VCMGenericDecoder* _decoder;
VCMFrameBuffer _frameFromFile;
bool _scheduleKeyRequest GUARDED_BY(process_crit_);