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

Side by Side Diff: content/renderer/media/video_track_recorder.cc

Issue 2325833002: Handle frames sent from peer connection in VideoTrackRecorder (Closed)
Patch Set: Created 4 years, 3 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 // 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 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 619
620 // If first frame hasn't been encoded, do it first. 620 // If first frame hasn't been encoded, do it first.
621 if (last_frame_) { 621 if (last_frame_) {
622 std::unique_ptr<VideoFrameAndTimestamp> last_frame(last_frame_.release()); 622 std::unique_ptr<VideoFrameAndTimestamp> last_frame(last_frame_.release());
623 EncodeOnEncodingTaskRunner(last_frame->first, last_frame->second); 623 EncodeOnEncodingTaskRunner(last_frame->first, last_frame->second);
624 } 624 }
625 625
626 // Lower resolutions may fall back to SW encoder in some platforms, i.e. Mac. 626 // Lower resolutions may fall back to SW encoder in some platforms, i.e. Mac.
627 // In that case, the encoder expects more frames before returning result. 627 // In that case, the encoder expects more frames before returning result.
628 // Therefore, a copy is necessary to release the current frame. 628 // Therefore, a copy is necessary to release the current frame.
629 // Only STORAGE_SHMEM backed frames can be shared with GPU process, therefore
630 // a copy is required for other storage types.
629 scoped_refptr<media::VideoFrame> video_frame = frame; 631 scoped_refptr<media::VideoFrame> video_frame = frame;
630 if (vea_requested_input_size_ != input_size_ || 632 if (video_frame->storage_type() != VideoFrame::STORAGE_SHMEM ||
633 vea_requested_input_size_ != input_size_ ||
631 input_size_.width() < kVEAEncoderMinResolutionWidth || 634 input_size_.width() < kVEAEncoderMinResolutionWidth ||
632 input_size_.height() < kVEAEncoderMinResolutionHeight) { 635 input_size_.height() < kVEAEncoderMinResolutionHeight) {
633 // Create SharedMemory backed input buffers as necessary. These SharedMemory 636 // Create SharedMemory backed input buffers as necessary. These SharedMemory
634 // instances will be shared with GPU process. 637 // instances will be shared with GPU process.
635 std::unique_ptr<base::SharedMemory> input_buffer; 638 std::unique_ptr<base::SharedMemory> input_buffer;
636 const size_t desired_mapped_size = media::VideoFrame::AllocationSize( 639 const size_t desired_mapped_size = media::VideoFrame::AllocationSize(
637 media::PIXEL_FORMAT_I420, vea_requested_input_size_); 640 media::PIXEL_FORMAT_I420, vea_requested_input_size_);
638 if (input_buffers_.empty()) { 641 if (input_buffers_.empty()) {
639 input_buffer = gpu_factories_->CreateSharedMemory(desired_mapped_size); 642 input_buffer = gpu_factories_->CreateSharedMemory(desired_mapped_size);
640 } else { 643 } else {
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 encoder_->SetPaused(paused_before_init_); 1143 encoder_->SetPaused(paused_before_init_);
1141 1144
1142 // StartFrameEncode() will be called on Render IO thread. 1145 // StartFrameEncode() will be called on Render IO thread.
1143 MediaStreamVideoSink::ConnectToTrack( 1146 MediaStreamVideoSink::ConnectToTrack(
1144 track_, 1147 track_,
1145 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), 1148 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_),
1146 false); 1149 false);
1147 } 1150 }
1148 1151
1149 } // namespace content 1152 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webrtc/webrtc_media_recorder_browsertest.cc ('k') | content/test/data/media/mediarecorder_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698