OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/video_track_recorder.h" | 5 #include "content/renderer/media/video_track_recorder.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 const VideoTrackRecorder::OnEncodedVideoCB& on_encoded_video_callback, | 246 const VideoTrackRecorder::OnEncodedVideoCB& on_encoded_video_callback, |
247 int32_t bits_per_second, | 247 int32_t bits_per_second, |
248 media::VideoCodecProfile codec); | 248 media::VideoCodecProfile codec); |
249 | 249 |
250 // media::VideoEncodeAccelerator::Client implementation. | 250 // media::VideoEncodeAccelerator::Client implementation. |
251 void RequireBitstreamBuffers(unsigned int input_count, | 251 void RequireBitstreamBuffers(unsigned int input_count, |
252 const gfx::Size& input_coded_size, | 252 const gfx::Size& input_coded_size, |
253 size_t output_buffer_size) override; | 253 size_t output_buffer_size) override; |
254 void BitstreamBufferReady(int32_t bitstream_buffer_id, | 254 void BitstreamBufferReady(int32_t bitstream_buffer_id, |
255 size_t payload_size, | 255 size_t payload_size, |
256 bool key_frame) override; | 256 bool key_frame, |
| 257 base::TimeDelta timestamp) override; |
257 void NotifyError(media::VideoEncodeAccelerator::Error error) override; | 258 void NotifyError(media::VideoEncodeAccelerator::Error error) override; |
258 | 259 |
259 private: | 260 private: |
260 using VideoFrameAndTimestamp = | 261 using VideoFrameAndTimestamp = |
261 std::pair<scoped_refptr<VideoFrame>, base::TimeTicks>; | 262 std::pair<scoped_refptr<VideoFrame>, base::TimeTicks>; |
262 | 263 |
263 void UseOutputBitstreamBufferId(int32_t bitstream_buffer_id); | 264 void UseOutputBitstreamBufferId(int32_t bitstream_buffer_id); |
264 void FrameFinished(std::unique_ptr<base::SharedMemory> shm); | 265 void FrameFinished(std::unique_ptr<base::SharedMemory> shm); |
265 | 266 |
266 // VideoTrackRecorder::Encoder implementation. | 267 // VideoTrackRecorder::Encoder implementation. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 if (shm) | 419 if (shm) |
419 output_buffers_.push_back(base::WrapUnique(shm.release())); | 420 output_buffers_.push_back(base::WrapUnique(shm.release())); |
420 } | 421 } |
421 | 422 |
422 for (size_t i = 0; i < output_buffers_.size(); ++i) | 423 for (size_t i = 0; i < output_buffers_.size(); ++i) |
423 UseOutputBitstreamBufferId(i); | 424 UseOutputBitstreamBufferId(i); |
424 } | 425 } |
425 | 426 |
426 void VEAEncoder::BitstreamBufferReady(int32_t bitstream_buffer_id, | 427 void VEAEncoder::BitstreamBufferReady(int32_t bitstream_buffer_id, |
427 size_t payload_size, | 428 size_t payload_size, |
428 bool keyframe) { | 429 bool keyframe, |
| 430 base::TimeDelta timestamp) { |
429 DVLOG(3) << __FUNCTION__; | 431 DVLOG(3) << __FUNCTION__; |
430 DCHECK(encoding_task_runner_->BelongsToCurrentThread()); | 432 DCHECK(encoding_task_runner_->BelongsToCurrentThread()); |
431 | 433 |
432 base::SharedMemory* output_buffer = | 434 base::SharedMemory* output_buffer = |
433 output_buffers_[bitstream_buffer_id].get(); | 435 output_buffers_[bitstream_buffer_id].get(); |
434 | 436 |
435 std::unique_ptr<std::string> data(new std::string); | 437 std::unique_ptr<std::string> data(new std::string); |
436 data->append(reinterpret_cast<char*>(output_buffer->memory()), payload_size); | 438 data->append(reinterpret_cast<char*>(output_buffer->memory()), payload_size); |
437 | 439 |
438 const auto front_frame = frames_in_encode_.front(); | 440 const auto front_frame = frames_in_encode_.front(); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 encoder_->SetPaused(false); | 983 encoder_->SetPaused(false); |
982 } | 984 } |
983 | 985 |
984 void VideoTrackRecorder::OnVideoFrameForTesting( | 986 void VideoTrackRecorder::OnVideoFrameForTesting( |
985 const scoped_refptr<media::VideoFrame>& frame, | 987 const scoped_refptr<media::VideoFrame>& frame, |
986 base::TimeTicks timestamp) { | 988 base::TimeTicks timestamp) { |
987 encoder_->StartFrameEncode(frame, timestamp); | 989 encoder_->StartFrameEncode(frame, timestamp); |
988 } | 990 } |
989 | 991 |
990 } // namespace content | 992 } // namespace content |
OLD | NEW |