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

Side by Side Diff: webrtc/modules/video_coding/video_coding_impl.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
(...skipping 17 matching lines...) Expand all
28 #include "webrtc/modules/video_coding/generic_encoder.h" 28 #include "webrtc/modules/video_coding/generic_encoder.h"
29 #include "webrtc/modules/video_coding/jitter_buffer.h" 29 #include "webrtc/modules/video_coding/jitter_buffer.h"
30 #include "webrtc/modules/video_coding/media_optimization.h" 30 #include "webrtc/modules/video_coding/media_optimization.h"
31 #include "webrtc/modules/video_coding/qp_parser.h" 31 #include "webrtc/modules/video_coding/qp_parser.h"
32 #include "webrtc/modules/video_coding/receiver.h" 32 #include "webrtc/modules/video_coding/receiver.h"
33 #include "webrtc/modules/video_coding/timing.h" 33 #include "webrtc/modules/video_coding/timing.h"
34 #include "webrtc/system_wrappers/include/clock.h" 34 #include "webrtc/system_wrappers/include/clock.h"
35 35
36 namespace webrtc { 36 namespace webrtc {
37 37
38 class ProcessThread;
39 class VideoBitrateAllocator; 38 class VideoBitrateAllocator;
40 class VideoBitrateAllocationObserver; 39 class VideoBitrateAllocationObserver;
41 40
42 namespace vcm { 41 namespace vcm {
43 42
44 class VCMProcessTimer { 43 class VCMProcessTimer {
45 public: 44 public:
46 static const int64_t kDefaultProcessIntervalMs = 1000; 45 static const int64_t kDefaultProcessIntervalMs = 1000;
47 46
48 VCMProcessTimer(int64_t periodMs, Clock* clock) 47 VCMProcessTimer(int64_t periodMs, Clock* clock)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 }; 143 };
145 144
146 class VideoReceiver : public Module { 145 class VideoReceiver : public Module {
147 public: 146 public:
148 VideoReceiver(Clock* clock, 147 VideoReceiver(Clock* clock,
149 EventFactory* event_factory, 148 EventFactory* event_factory,
150 EncodedImageCallback* pre_decode_image_callback, 149 EncodedImageCallback* pre_decode_image_callback,
151 VCMTiming* timing, 150 VCMTiming* timing,
152 NackSender* nack_sender = nullptr, 151 NackSender* nack_sender = nullptr,
153 KeyFrameRequestSender* keyframe_request_sender = nullptr); 152 KeyFrameRequestSender* keyframe_request_sender = nullptr);
154 ~VideoReceiver() override; 153 ~VideoReceiver();
155 154
156 int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec, 155 int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec,
157 int32_t numberOfCores, 156 int32_t numberOfCores,
158 bool requireKeyFrame); 157 bool requireKeyFrame);
159 158
160 void RegisterExternalDecoder(VideoDecoder* externalDecoder, 159 void RegisterExternalDecoder(VideoDecoder* externalDecoder,
161 uint8_t payloadType); 160 uint8_t payloadType);
162 int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback); 161 int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback);
163 int32_t RegisterReceiveStatisticsCallback( 162 int32_t RegisterReceiveStatisticsCallback(
164 VCMReceiveStatisticsCallback* receiveStats); 163 VCMReceiveStatisticsCallback* receiveStats);
165 int32_t RegisterFrameTypeCallback(VCMFrameTypeCallback* frameTypeCallback); 164 int32_t RegisterFrameTypeCallback(VCMFrameTypeCallback* frameTypeCallback);
166 int32_t RegisterPacketRequestCallback(VCMPacketRequestCallback* callback); 165 int32_t RegisterPacketRequestCallback(VCMPacketRequestCallback* callback);
167 166
168 int32_t Decode(uint16_t maxWaitTimeMs); 167 int32_t Decode(uint16_t maxWaitTimeMs);
169 168
170 int32_t Decode(const webrtc::VCMEncodedFrame* frame); 169 int32_t Decode(const webrtc::VCMEncodedFrame* frame);
171 170
172 #if defined(WEBRTC_ANDROID) 171 // Called on the decoder thread when thread is exiting.
173 // See https://bugs.chromium.org/p/webrtc/issues/detail?id=7361 172 void DecodingStopped();
174 void PollDecodedFrames();
175 #endif
176 173
177 int32_t IncomingPacket(const uint8_t* incomingPayload, 174 int32_t IncomingPacket(const uint8_t* incomingPayload,
178 size_t payloadLength, 175 size_t payloadLength,
179 const WebRtcRTPHeader& rtpInfo); 176 const WebRtcRTPHeader& rtpInfo);
180 int32_t SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs); 177 int32_t SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs);
181 int32_t SetRenderDelay(uint32_t timeMS); 178 int32_t SetRenderDelay(uint32_t timeMS);
182 int32_t Delay() const; 179 int32_t Delay() const;
183 180
184 // DEPRECATED. 181 // DEPRECATED.
185 int SetReceiverRobustnessMode( 182 int SetReceiverRobustnessMode(
186 VideoCodingModule::ReceiverRobustness robustnessMode, 183 VideoCodingModule::ReceiverRobustness robustnessMode,
187 VCMDecodeErrorMode errorMode); 184 VCMDecodeErrorMode errorMode);
188 185
189 void SetNackSettings(size_t max_nack_list_size, 186 void SetNackSettings(size_t max_nack_list_size,
190 int max_packet_age_to_nack, 187 int max_packet_age_to_nack,
191 int max_incomplete_time_ms); 188 int max_incomplete_time_ms);
192 189
193 void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode); 190 void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode);
194 int SetMinReceiverDelay(int desired_delay_ms); 191 int SetMinReceiverDelay(int desired_delay_ms);
195 192
196 int32_t SetReceiveChannelParameters(int64_t rtt); 193 int32_t SetReceiveChannelParameters(int64_t rtt);
197 int32_t SetVideoProtection(VCMVideoProtection videoProtection, bool enable); 194 int32_t SetVideoProtection(VCMVideoProtection videoProtection, bool enable);
198 195
199 int64_t TimeUntilNextProcess() override; 196 int64_t TimeUntilNextProcess() override;
200 void Process() override; 197 void Process() override;
201 void ProcessThreadAttached(ProcessThread* process_thread) override;
202 198
203 void TriggerDecoderShutdown(); 199 void TriggerDecoderShutdown();
204 void DecoderThreadStarting();
205 void DecoderThreadStopped();
206 200
207 protected: 201 protected:
208 int32_t Decode(const webrtc::VCMEncodedFrame& frame); 202 int32_t Decode(const webrtc::VCMEncodedFrame& frame)
203 EXCLUSIVE_LOCKS_REQUIRED(receive_crit_);
209 int32_t RequestKeyFrame(); 204 int32_t RequestKeyFrame();
210 205
211 private: 206 private:
212 // Used for DCHECKing thread correctness.
213 // In build where DCHECKs are enabled, will return false before
214 // DecoderThreadStarting is called, then true until DecoderThreadStopped
215 // is called.
216 // In builds where DCHECKs aren't enabled, it will return true.
217 bool IsDecoderThreadRunning();
218
219 rtc::ThreadChecker construction_thread_; 207 rtc::ThreadChecker construction_thread_;
220 rtc::ThreadChecker decoder_thread_;
221 rtc::ThreadChecker module_thread_;
222 Clock* const clock_; 208 Clock* const clock_;
223 rtc::CriticalSection process_crit_; 209 rtc::CriticalSection process_crit_;
210 rtc::CriticalSection receive_crit_;
224 VCMTiming* _timing; 211 VCMTiming* _timing;
225 VCMReceiver _receiver; 212 VCMReceiver _receiver;
226 VCMDecodedFrameCallback _decodedFrameCallback; 213 VCMDecodedFrameCallback _decodedFrameCallback;
214 VCMFrameTypeCallback* _frameTypeCallback GUARDED_BY(process_crit_);
215 VCMReceiveStatisticsCallback* _receiveStatsCallback GUARDED_BY(process_crit_);
216 VCMPacketRequestCallback* _packetRequestCallback GUARDED_BY(process_crit_);
227 217
228 // These callbacks are set on the construction thread before being attached 218 VCMFrameBuffer _frameFromFile;
229 // to the module thread or decoding started, so a lock is not required.
230 VCMFrameTypeCallback* _frameTypeCallback;
231 VCMReceiveStatisticsCallback* _receiveStatsCallback;
232 VCMPacketRequestCallback* _packetRequestCallback;
233
234 // Used on both the module and decoder thread.
235 bool _scheduleKeyRequest GUARDED_BY(process_crit_); 219 bool _scheduleKeyRequest GUARDED_BY(process_crit_);
236 bool drop_frames_until_keyframe_ GUARDED_BY(process_crit_); 220 bool drop_frames_until_keyframe_ GUARDED_BY(process_crit_);
221 size_t max_nack_list_size_ GUARDED_BY(process_crit_);
237 222
238 // Modified on the construction thread while not attached to the process 223 VCMCodecDataBase _codecDataBase GUARDED_BY(receive_crit_);
239 // thread. Once attached to the process thread, its value is only read 224 EncodedImageCallback* pre_decode_image_callback_;
240 // so a lock is not required.
241 size_t max_nack_list_size_;
242 225
243 // Callbacks are set before the decoder thread starts. 226 VCMProcessTimer _receiveStatsTimer;
244 // Once the decoder thread has been started, usage of |_codecDataBase| moves 227 VCMProcessTimer _retransmissionTimer;
245 // over to the decoder thread. 228 VCMProcessTimer _keyRequestTimer;
246 VCMCodecDataBase _codecDataBase; 229 QpParser qp_parser_;
247 EncodedImageCallback* const pre_decode_image_callback_; 230 ThreadUnsafeOneTimeEvent first_frame_received_;
248
249 VCMProcessTimer _receiveStatsTimer ACCESS_ON(module_thread_);
250 VCMProcessTimer _retransmissionTimer ACCESS_ON(module_thread_);
251 VCMProcessTimer _keyRequestTimer ACCESS_ON(module_thread_);
252 QpParser qp_parser_ ACCESS_ON(decoder_thread_);
253 ThreadUnsafeOneTimeEvent first_frame_received_ ACCESS_ON(decoder_thread_);
254 // Modified on the construction thread. Can be read without a lock and assumed
255 // to be non-null on the module and decoder threads.
256 ProcessThread* process_thread_ = nullptr;
257 bool is_attached_to_process_thread_ ACCESS_ON(construction_thread_) = false;
258 #if RTC_DCHECK_IS_ON
259 bool decoder_thread_is_running_ = false;
260 #endif
261 }; 231 };
262 232
263 } // namespace vcm 233 } // namespace vcm
264 } // namespace webrtc 234 } // namespace webrtc
265 #endif // WEBRTC_MODULES_VIDEO_CODING_VIDEO_CODING_IMPL_H_ 235 #endif // WEBRTC_MODULES_VIDEO_CODING_VIDEO_CODING_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/generic_decoder.cc ('k') | webrtc/modules/video_coding/video_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698