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

Side by Side Diff: content/renderer/media/webrtc/video_destination_handler.cc

Issue 224013002: Fix tearing in video from VideoDestinationHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/webrtc/video_destination_handler.h" 5 #include "content/renderer/media/webrtc/video_destination_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return; 78 return;
79 } 79 }
80 80
81 const gfx::Size frame_size(bitmap->width(), bitmap->height()); 81 const gfx::Size frame_size(bitmap->width(), bitmap->height());
82 82
83 if (!first_frame_received_) { 83 if (!first_frame_received_) {
84 first_frame_received_ = true; 84 first_frame_received_ = true;
85 format_ = media::VideoCaptureFormat( 85 format_ = media::VideoCaptureFormat(
86 frame_size, 86 frame_size,
87 MediaStreamVideoSource::kDefaultFrameRate, 87 MediaStreamVideoSource::kDefaultFrameRate,
88 media::PIXEL_FORMAT_I420); 88 media::PIXEL_FORMAT_YV12);
89 if (state() == MediaStreamVideoSource::RETRIEVING_CAPABILITIES) { 89 if (state() == MediaStreamVideoSource::RETRIEVING_CAPABILITIES) {
90 media::VideoCaptureFormats formats; 90 media::VideoCaptureFormats formats;
91 formats.push_back(format_); 91 formats.push_back(format_);
92 OnSupportedFormats(formats); 92 OnSupportedFormats(formats);
93 } 93 }
94 } 94 }
95 95
96 if (state() != MediaStreamVideoSource::STARTED) 96 if (state() != MediaStreamVideoSource::STARTED)
97 return; 97 return;
98 98
99 const base::TimeDelta timestamp = base::TimeDelta::FromMilliseconds( 99 const base::TimeDelta timestamp = base::TimeDelta::FromMilliseconds(
100 time_stamp_ns / talk_base::kNumNanosecsPerMillisec); 100 time_stamp_ns / talk_base::kNumNanosecsPerMillisec);
101 101
102 // TODO(perkj): It would be more efficient to use I420 here. Using YV12 will
103 // force a copy into a tightly packed I420 frame in
104 // WebRtcVideoCapturerAdapter before the frame is delivered to libJingle.
105 // crbug/359587.
102 scoped_refptr<media::VideoFrame> new_frame = 106 scoped_refptr<media::VideoFrame> new_frame =
103 frame_pool_.CreateFrame(media::VideoFrame::I420, frame_size, 107 frame_pool_.CreateFrame(media::VideoFrame::YV12, frame_size,
104 gfx::Rect(frame_size), frame_size, timestamp); 108 gfx::Rect(frame_size), frame_size, timestamp);
105 109
106 libyuv::BGRAToI420(reinterpret_cast<uint8*>(bitmap->getPixels()), 110 libyuv::BGRAToI420(reinterpret_cast<uint8*>(bitmap->getPixels()),
107 bitmap->rowBytes(), 111 bitmap->rowBytes(),
108 new_frame->data(media::VideoFrame::kYPlane), 112 new_frame->data(media::VideoFrame::kYPlane),
109 new_frame->stride(media::VideoFrame::kYPlane), 113 new_frame->stride(media::VideoFrame::kYPlane),
110 new_frame->data(media::VideoFrame::kUPlane), 114 new_frame->data(media::VideoFrame::kUPlane),
111 new_frame->stride(media::VideoFrame::kUPlane), 115 new_frame->stride(media::VideoFrame::kUPlane),
112 new_frame->data(media::VideoFrame::kVPlane), 116 new_frame->data(media::VideoFrame::kVPlane),
113 new_frame->stride(media::VideoFrame::kVPlane), 117 new_frame->stride(media::VideoFrame::kVPlane),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 stream.addTrack(MediaStreamVideoTrack::CreateVideoTrack( 190 stream.addTrack(MediaStreamVideoTrack::CreateVideoTrack(
187 writer, constraints, MediaStreamVideoSource::ConstraintsCallback(), 191 writer, constraints, MediaStreamVideoSource::ConstraintsCallback(),
188 track_enabled, factory)); 192 track_enabled, factory));
189 193
190 *frame_writer = new PpFrameWriterProxy(writer->AsWeakPtr()); 194 *frame_writer = new PpFrameWriterProxy(writer->AsWeakPtr());
191 return true; 195 return true;
192 } 196 }
193 197
194 } // namespace content 198 } // namespace content
195 199
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698