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

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor.h

Issue 2995403002: Remove unnecessary RTPFragmentationHeader from VideoProcessor callbacks. (Closed)
Patch Set: Created 3 years, 4 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 : video_processor_(video_processor), 201 : video_processor_(video_processor),
202 task_queue_(rtc::TaskQueue::Current()) {} 202 task_queue_(rtc::TaskQueue::Current()) {}
203 203
204 Result OnEncodedImage( 204 Result OnEncodedImage(
205 const webrtc::EncodedImage& encoded_image, 205 const webrtc::EncodedImage& encoded_image,
206 const webrtc::CodecSpecificInfo* codec_specific_info, 206 const webrtc::CodecSpecificInfo* codec_specific_info,
207 const webrtc::RTPFragmentationHeader* fragmentation) override { 207 const webrtc::RTPFragmentationHeader* fragmentation) override {
208 RTC_CHECK(codec_specific_info); 208 RTC_CHECK(codec_specific_info);
209 209
210 if (task_queue_ && !task_queue_->IsCurrent()) { 210 if (task_queue_ && !task_queue_->IsCurrent()) {
211 task_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>( 211 task_queue_->PostTask(
212 new EncodeCallbackTask(video_processor_, encoded_image, 212 std::unique_ptr<rtc::QueuedTask>(new EncodeCallbackTask(
213 codec_specific_info, fragmentation))); 213 video_processor_, encoded_image, codec_specific_info)));
214 return Result(Result::OK, 0); 214 return Result(Result::OK, 0);
215 } 215 }
216 216
217 video_processor_->FrameEncoded(codec_specific_info->codecType, 217 video_processor_->FrameEncoded(codec_specific_info->codecType,
218 encoded_image, fragmentation); 218 encoded_image);
219 return Result(Result::OK, 0); 219 return Result(Result::OK, 0);
220 } 220 }
221 221
222 private: 222 private:
223 class EncodeCallbackTask : public rtc::QueuedTask { 223 class EncodeCallbackTask : public rtc::QueuedTask {
224 public: 224 public:
225 EncodeCallbackTask(VideoProcessor* video_processor, 225 EncodeCallbackTask(VideoProcessor* video_processor,
226 const webrtc::EncodedImage& encoded_image, 226 const webrtc::EncodedImage& encoded_image,
227 const webrtc::CodecSpecificInfo* codec_specific_info, 227 const webrtc::CodecSpecificInfo* codec_specific_info)
228 const webrtc::RTPFragmentationHeader* fragmentation)
229 : video_processor_(video_processor), 228 : video_processor_(video_processor),
230 buffer_(encoded_image._buffer, encoded_image._length), 229 buffer_(encoded_image._buffer, encoded_image._length),
231 encoded_image_(encoded_image), 230 encoded_image_(encoded_image),
232 codec_specific_info_(*codec_specific_info) { 231 codec_specific_info_(*codec_specific_info) {
233 encoded_image_._buffer = buffer_.data(); 232 encoded_image_._buffer = buffer_.data();
234 RTC_CHECK(fragmentation);
235 fragmentation_.CopyFrom(*fragmentation);
236 } 233 }
237 234
238 bool Run() override { 235 bool Run() override {
239 video_processor_->FrameEncoded(codec_specific_info_.codecType, 236 video_processor_->FrameEncoded(codec_specific_info_.codecType,
240 encoded_image_, &fragmentation_); 237 encoded_image_);
241 return true; 238 return true;
242 } 239 }
243 240
244 private: 241 private:
245 VideoProcessor* const video_processor_; 242 VideoProcessor* const video_processor_;
246 rtc::Buffer buffer_; 243 rtc::Buffer buffer_;
247 webrtc::EncodedImage encoded_image_; 244 webrtc::EncodedImage encoded_image_;
248 const webrtc::CodecSpecificInfo codec_specific_info_; 245 const webrtc::CodecSpecificInfo codec_specific_info_;
249 webrtc::RTPFragmentationHeader fragmentation_;
250 }; 246 };
251 247
252 VideoProcessor* const video_processor_; 248 VideoProcessor* const video_processor_;
253 rtc::TaskQueue* const task_queue_; 249 rtc::TaskQueue* const task_queue_;
254 }; 250 };
255 251
256 class VideoProcessorDecodeCompleteCallback 252 class VideoProcessorDecodeCompleteCallback
257 : public webrtc::DecodedImageCallback { 253 : public webrtc::DecodedImageCallback {
258 public: 254 public:
259 explicit VideoProcessorDecodeCompleteCallback( 255 explicit VideoProcessorDecodeCompleteCallback(
260 VideoProcessor* video_processor) 256 VideoProcessor* video_processor)
261 : video_processor_(video_processor), 257 : video_processor_(video_processor),
262 task_queue_(rtc::TaskQueue::Current()) {} 258 task_queue_(rtc::TaskQueue::Current()) {}
263 259
264 int32_t Decoded(webrtc::VideoFrame& image) override { 260 int32_t Decoded(webrtc::VideoFrame& image) override {
265 if (task_queue_ && !task_queue_->IsCurrent()) { 261 if (task_queue_ && !task_queue_->IsCurrent()) {
266 task_queue_->PostTask( 262 task_queue_->PostTask(
267 [this, image]() { video_processor_->FrameDecoded(image); }); 263 [this, image]() { video_processor_->FrameDecoded(image); });
268 return 0; 264 return 0;
269 } 265 }
270
271 video_processor_->FrameDecoded(image); 266 video_processor_->FrameDecoded(image);
272 return 0; 267 return 0;
273 } 268 }
274 269
275 int32_t Decoded(webrtc::VideoFrame& image, 270 int32_t Decoded(webrtc::VideoFrame& image,
276 int64_t decode_time_ms) override { 271 int64_t decode_time_ms) override {
277 return Decoded(image); 272 return Decoded(image);
278 } 273 }
279 274
280 void Decoded(webrtc::VideoFrame& image, 275 void Decoded(webrtc::VideoFrame& image,
281 rtc::Optional<int32_t> decode_time_ms, 276 rtc::Optional<int32_t> decode_time_ms,
282 rtc::Optional<uint8_t> qp) override { 277 rtc::Optional<uint8_t> qp) override {
283 Decoded(image); 278 Decoded(image);
284 } 279 }
285 280
286 private: 281 private:
287 VideoProcessor* const video_processor_; 282 VideoProcessor* const video_processor_;
288 rtc::TaskQueue* const task_queue_; 283 rtc::TaskQueue* const task_queue_;
289 }; 284 };
290 285
291 // Invoked by the callback adapter when a frame has completed encoding. 286 // Invoked by the callback adapter when a frame has completed encoding.
292 void FrameEncoded(webrtc::VideoCodecType codec, 287 void FrameEncoded(webrtc::VideoCodecType codec,
293 const webrtc::EncodedImage& encodedImage, 288 const webrtc::EncodedImage& encodedImage);
294 const webrtc::RTPFragmentationHeader* fragmentation);
295 289
296 // Invoked by the callback adapter when a frame has completed decoding. 290 // Invoked by the callback adapter when a frame has completed decoding.
297 void FrameDecoded(const webrtc::VideoFrame& image); 291 void FrameDecoded(const webrtc::VideoFrame& image);
298 292
299 // Use the frame number as the basis for timestamp to identify frames. Let the 293 // Use the frame number as the basis for timestamp to identify frames. Let the
300 // first timestamp be non-zero, to not make the IvfFileWriter believe that we 294 // first timestamp be non-zero, to not make the IvfFileWriter believe that we
301 // want to use capture timestamps in the IVF files. 295 // want to use capture timestamps in the IVF files.
302 uint32_t FrameNumberToTimestamp(int frame_number) const; 296 uint32_t FrameNumberToTimestamp(int frame_number) const;
303 int TimestampToFrameNumber(uint32_t timestamp) const; 297 int TimestampToFrameNumber(uint32_t timestamp) const;
304 298
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 344
351 rtc::SequencedTaskChecker sequence_checker_; 345 rtc::SequencedTaskChecker sequence_checker_;
352 346
353 RTC_DISALLOW_COPY_AND_ASSIGN(VideoProcessor); 347 RTC_DISALLOW_COPY_AND_ASSIGN(VideoProcessor);
354 }; 348 };
355 349
356 } // namespace test 350 } // namespace test
357 } // namespace webrtc 351 } // namespace webrtc
358 352
359 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ 353 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698