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

Side by Side Diff: chrome/renderer/media/ipc_video_renderer.cc

Issue 1226001: Merged VideoSurface, VideoFrame and VideoFrameImpl in VideoFrame. (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « no previous file | media/base/buffers.h » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/media/ipc_video_renderer.h" 5 #include "chrome/renderer/media/ipc_video_renderer.h"
6 6
7 #include "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/renderer/render_thread.h" 8 #include "chrome/renderer/render_thread.h"
9 #include "media/base/buffers.h" 9 #include "media/base/video_frame.h"
10 #include "media/base/media_format.h" 10 #include "media/base/media_format.h"
11 11
12 IPCVideoRenderer::IPCVideoRenderer( 12 IPCVideoRenderer::IPCVideoRenderer(
13 webkit_glue::WebMediaPlayerImpl::Proxy* proxy, 13 webkit_glue::WebMediaPlayerImpl::Proxy* proxy,
14 int routing_id) 14 int routing_id)
15 : proxy_(proxy), 15 : proxy_(proxy),
16 created_(false), 16 created_(false),
17 routing_id_(routing_id), 17 routing_id_(routing_id),
18 stopped_(false, false) { 18 stopped_(false, false) {
19 // TODO(hclam): decide whether to do the following line in this thread or 19 // TODO(hclam): decide whether to do the following line in this thread or
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if (!created_ || video_rect_.IsEmpty() || stopped_.IsSignaled()) { 116 if (!created_ || video_rect_.IsEmpty() || stopped_.IsSignaled()) {
117 return; 117 return;
118 } 118 }
119 119
120 scoped_refptr<media::VideoFrame> frame; 120 scoped_refptr<media::VideoFrame> frame;
121 GetCurrentFrame(&frame); 121 GetCurrentFrame(&frame);
122 if (!frame) { 122 if (!frame) {
123 return; 123 return;
124 } 124 }
125 125
126 media::VideoSurface surface; 126 CHECK(frame->width() == static_cast<size_t>(video_size_.width()));
127 CHECK(frame->Lock(&surface)); 127 CHECK(frame->height() == static_cast<size_t>(video_size_.height()));
128 CHECK(surface.width == static_cast<size_t>(video_size_.width())); 128 CHECK(frame->format() == media::VideoFrame::YV12);
129 CHECK(surface.height == static_cast<size_t>(video_size_.height())); 129 CHECK(frame->planes() == 3);
130 CHECK(surface.format == media::VideoSurface::YV12);
131 CHECK(surface.planes == 3);
132 130
133 uint8* dest = reinterpret_cast<uint8*>(transport_dib_->memory()); 131 uint8* dest = reinterpret_cast<uint8*>(transport_dib_->memory());
134 132
135 // Copy Y plane. 133 // Copy Y plane.
136 const uint8* src = surface.data[media::VideoSurface::kYPlane]; 134 const uint8* src = frame->data(media::VideoFrame::kYPlane);
137 size_t stride = surface.strides[media::VideoSurface::kYPlane]; 135 size_t stride = frame->stride(media::VideoFrame::kYPlane);
138 for (size_t row = 0; row < surface.height; ++row) { 136 for (size_t row = 0; row < frame->height(); ++row) {
139 memcpy(dest, src, surface.width); 137 memcpy(dest, src, frame->width());
140 dest += surface.width; 138 dest += frame->width();
141 src += stride; 139 src += stride;
142 } 140 }
143 141
144 // Copy U plane. 142 // Copy U plane.
145 src = surface.data[media::VideoSurface::kUPlane]; 143 src = frame->data(media::VideoFrame::kUPlane);
146 stride = surface.strides[media::VideoSurface::kUPlane]; 144 stride = frame->stride(media::VideoFrame::kUPlane);
147 for (size_t row = 0; row < surface.height / 2; ++row) { 145 for (size_t row = 0; row < frame->height() / 2; ++row) {
148 memcpy(dest, src, surface.width / 2); 146 memcpy(dest, src, frame->width() / 2);
149 dest += surface.width / 2; 147 dest += frame->width() / 2;
150 src += stride; 148 src += stride;
151 } 149 }
152 150
153 // Copy V plane. 151 // Copy V plane.
154 src = surface.data[media::VideoSurface::kVPlane]; 152 src = frame->data(media::VideoFrame::kVPlane);
155 stride = surface.strides[media::VideoSurface::kVPlane]; 153 stride = frame->stride(media::VideoFrame::kVPlane);
156 for (size_t row = 0; row < surface.height / 2; ++row) { 154 for (size_t row = 0; row < frame->height() / 2; ++row) {
157 memcpy(dest, src, surface.width / 2); 155 memcpy(dest, src, frame->width() / 2);
158 dest += surface.width / 2; 156 dest += frame->width() / 2;
159 src += stride; 157 src += stride;
160 } 158 }
161 159
162 // Sanity check! 160 // Sanity check!
163 uint8* expected = reinterpret_cast<uint8*>(transport_dib_->memory()) + 161 uint8* expected = reinterpret_cast<uint8*>(transport_dib_->memory()) +
164 transport_dib_->size(); 162 transport_dib_->size();
165 CHECK(dest == expected); 163 CHECK(dest == expected);
166 164
167 Send(new ViewHostMsg_UpdateVideo(routing_id_, 165 Send(new ViewHostMsg_UpdateVideo(routing_id_,
168 transport_dib_->id(), 166 transport_dib_->id(),
169 video_rect_)); 167 video_rect_));
170
171 frame->Unlock();
172 } 168 }
173 169
174 void IPCVideoRenderer::DoDestroyVideo() { 170 void IPCVideoRenderer::DoDestroyVideo() {
175 DCHECK(MessageLoop::current() == proxy_->message_loop()); 171 DCHECK(MessageLoop::current() == proxy_->message_loop());
176 172
177 // We shouldn't receive any more messages after the browser receives this. 173 // We shouldn't receive any more messages after the browser receives this.
178 Send(new ViewHostMsg_DestroyVideo(routing_id_)); 174 Send(new ViewHostMsg_DestroyVideo(routing_id_));
179 175
180 // Detach ourselves from the proxy. 176 // Detach ourselves from the proxy.
181 proxy_->SetVideoRenderer(NULL); 177 proxy_->SetVideoRenderer(NULL);
182 proxy_ = NULL; 178 proxy_ = NULL;
183 } 179 }
OLDNEW
« no previous file with comments | « no previous file | media/base/buffers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698