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

Side by Side Diff: webrtc/modules/video_coding/generic_decoder.h

Issue 2792033003: Revert of Deliver video frames on Android, on the decode thread. (Closed)
Patch Set: Created 3 years, 8 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_
12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ 12 #define WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_
13 13
14 #include <memory> 14 #include "webrtc/base/criticalsection.h"
15
16 #include "webrtc/base/thread_checker.h" 15 #include "webrtc/base/thread_checker.h"
17 #include "webrtc/modules/include/module_common_types.h" 16 #include "webrtc/modules/include/module_common_types.h"
18 #include "webrtc/modules/video_coding/encoded_frame.h" 17 #include "webrtc/modules/video_coding/encoded_frame.h"
19 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 18 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
20 #include "webrtc/modules/video_coding/timestamp_map.h" 19 #include "webrtc/modules/video_coding/timestamp_map.h"
21 #include "webrtc/modules/video_coding/timing.h" 20 #include "webrtc/modules/video_coding/timing.h"
22 21
23 namespace webrtc { 22 namespace webrtc {
24 23
25 class VCMReceiveCallback; 24 class VCMReceiveCallback;
26 25
27 enum { kDecoderFrameMemoryLength = 10 }; 26 enum { kDecoderFrameMemoryLength = 10 };
28 27
29 struct VCMFrameInformation { 28 struct VCMFrameInformation {
30 int64_t renderTimeMs; 29 int64_t renderTimeMs;
31 int64_t decodeStartTimeMs; 30 int64_t decodeStartTimeMs;
32 void* userData; 31 void* userData;
33 VideoRotation rotation; 32 VideoRotation rotation;
34 }; 33 };
35 34
36 class VCMDecodedFrameCallback : public DecodedImageCallback { 35 class VCMDecodedFrameCallback : public DecodedImageCallback {
37 public: 36 public:
38 VCMDecodedFrameCallback(VCMTiming* timing, Clock* clock); 37 VCMDecodedFrameCallback(VCMTiming* timing, Clock* clock);
39 ~VCMDecodedFrameCallback() override; 38 ~VCMDecodedFrameCallback() override;
40
41 void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback); 39 void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback);
42 VCMReceiveCallback* UserReceiveCallback(); 40 VCMReceiveCallback* UserReceiveCallback();
43 41
44 int32_t Decoded(VideoFrame& decodedImage) override; 42 int32_t Decoded(VideoFrame& decodedImage) override;
45 int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override; 43 int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override;
46 void Decoded(VideoFrame& decodedImage, 44 void Decoded(VideoFrame& decodedImage,
47 rtc::Optional<int32_t> decode_time_ms, 45 rtc::Optional<int32_t> decode_time_ms,
48 rtc::Optional<uint8_t> qp) override; 46 rtc::Optional<uint8_t> qp) override;
49 int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) override; 47 int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) override;
50 int32_t ReceivedDecodedFrame(const uint64_t pictureId) override; 48 int32_t ReceivedDecodedFrame(const uint64_t pictureId) override;
51 49
52 uint64_t LastReceivedPictureID() const; 50 uint64_t LastReceivedPictureID() const;
53 void OnDecoderImplementationName(const char* implementation_name); 51 void OnDecoderImplementationName(const char* implementation_name);
54 52
55 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo); 53 void Map(uint32_t timestamp, VCMFrameInformation* frameInfo);
56 int32_t Pop(uint32_t timestamp); 54 int32_t Pop(uint32_t timestamp);
57 55
58 private: 56 private:
59 rtc::ThreadChecker construction_thread_; 57 rtc::ThreadChecker construction_thread_;
60 rtc::ThreadChecker decoder_thread_; 58 // Protect |_timestampMap|.
61 Clock* const _clock; 59 Clock* const _clock;
62 // This callback must be set before the decoder thread starts running 60 // This callback must be set before the decoder thread starts running
63 // and must only be unset when external threads (e.g decoder thread) 61 // and must only be unset when external threads (e.g decoder thread)
64 // have been stopped. Due to that, the variable should regarded as const 62 // have been stopped. Due to that, the variable should regarded as const
65 // while there are more than one threads involved, it must be set 63 // while there are more than one threads involved, it must be set
66 // from the same thread, and therfore a lock is not required to access it. 64 // from the same thread, and therfore a lock is not required to access it.
67 VCMReceiveCallback* _receiveCallback = nullptr; 65 VCMReceiveCallback* _receiveCallback = nullptr;
68 VCMTiming* _timing ACCESS_ON(decoder_thread_); 66 VCMTiming* _timing;
69 VCMTimestampMap _timestampMap ACCESS_ON(decoder_thread_); 67 rtc::CriticalSection lock_;
70 uint64_t _lastReceivedPictureID ACCESS_ON(decoder_thread_); 68 VCMTimestampMap _timestampMap GUARDED_BY(lock_);
69 uint64_t _lastReceivedPictureID;
71 }; 70 };
72 71
73 class VCMGenericDecoder { 72 class VCMGenericDecoder {
73 friend class VCMCodecDataBase;
74
74 public: 75 public:
75 explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false); 76 explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false);
76 ~VCMGenericDecoder(); 77 ~VCMGenericDecoder();
77 78
78 /** 79 /**
79 * Initialize the decoder with the information from the VideoCodec 80 * Initialize the decoder with the information from the VideoCodec
80 */ 81 */
81 int32_t InitDecode(const VideoCodec* settings, int32_t numberOfCores); 82 int32_t InitDecode(const VideoCodec* settings, int32_t numberOfCores);
82 83
83 /** 84 /**
84 * Decode to a raw I420 frame, 85 * Decode to a raw I420 frame,
85 * 86 *
86 * inputVideoBuffer reference to encoded video frame 87 * inputVideoBuffer reference to encoded video frame
87 */ 88 */
88 int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs); 89 int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs);
89 90
90 /** 91 /**
92 * Free the decoder memory
93 */
94 int32_t Release();
95
96 /**
91 * Set decode callback. Deregistering while decoding is illegal. 97 * Set decode callback. Deregistering while decoding is illegal.
92 */ 98 */
93 int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback); 99 int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback);
94 100
101 bool External() const;
95 bool PrefersLateDecoding() const; 102 bool PrefersLateDecoding() const;
96 103
97 #if defined(WEBRTC_ANDROID)
98 // See https://bugs.chromium.org/p/webrtc/issues/detail?id=7361
99 void PollDecodedFrames();
100 #endif
101
102 bool IsSameDecoder(VideoDecoder* decoder) const {
103 return decoder_.get() == decoder;
104 }
105
106 private: 104 private:
107 rtc::ThreadChecker decoder_thread_; 105 VCMDecodedFrameCallback* _callback;
108 VCMDecodedFrameCallback* _callback ACCESS_ON(decoder_thread_); 106 VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength];
109 VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength] ACCESS_ON( 107 uint32_t _nextFrameInfoIdx;
110 decoder_thread_); 108 VideoDecoder* const _decoder;
111 uint32_t _nextFrameInfoIdx ACCESS_ON(decoder_thread_); 109 VideoCodecType _codecType;
112 std::unique_ptr<VideoDecoder> decoder_; 110 bool _isExternal;
113 VideoCodecType _codecType ACCESS_ON(decoder_thread_); 111 bool _keyFrameDecoded;
114 const bool _isExternal;
115 }; 112 };
116 113
117 } // namespace webrtc 114 } // namespace webrtc
118 115
119 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_ 116 #endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codec_database.cc ('k') | webrtc/modules/video_coding/generic_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698