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

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

Issue 11339014: Move content\browser\renderer_host\media to content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/local_video_capture.h" 5 #include "content/renderer/media/local_video_capture.h"
6 6
7 #include "content/renderer/media/video_capture_impl_manager.h" 7 #include "content/renderer/media/video_capture_impl_manager.h"
8 #include "media/base/video_util.h" 8 #include "media/base/video_util.h"
9 #include "media/video/capture/video_capture_proxy.h" 9 #include "media/video/capture/video_capture_proxy.h"
10 10
(...skipping 12 matching lines...) Expand all
23 : video_stream_id_(video_stream_id), 23 : video_stream_id_(video_stream_id),
24 vc_manager_(vc_manager), 24 vc_manager_(vc_manager),
25 capability_(capability), 25 capability_(capability),
26 error_cb_(error_cb), 26 error_cb_(error_cb),
27 repaint_cb_(repaint_cb), 27 repaint_cb_(repaint_cb),
28 capture_engine_(NULL), 28 capture_engine_(NULL),
29 message_loop_proxy_(base::MessageLoopProxy::current()), 29 message_loop_proxy_(base::MessageLoopProxy::current()),
30 ALLOW_THIS_IN_INITIALIZER_LIST( 30 ALLOW_THIS_IN_INITIALIZER_LIST(
31 handler_proxy_(new media::VideoCaptureHandlerProxy( 31 handler_proxy_(new media::VideoCaptureHandlerProxy(
32 this, message_loop_proxy_))), 32 this, message_loop_proxy_))),
33 state_(video_capture::kStopped) { 33 state_(VIDEO_CAPTURE_STATE_STOPPED) {
34 DVLOG(3) << "LocalVideoCapture::ctor"; 34 DVLOG(3) << "LocalVideoCapture::ctor";
35 DCHECK(vc_manager); 35 DCHECK(vc_manager);
36 } 36 }
37 37
38 LocalVideoCapture::~LocalVideoCapture() { 38 LocalVideoCapture::~LocalVideoCapture() {
39 DVLOG(3) << "LocalVideoCapture::dtor"; 39 DVLOG(3) << "LocalVideoCapture::dtor";
40 } 40 }
41 41
42 void LocalVideoCapture::Start() { 42 void LocalVideoCapture::Start() {
43 DVLOG(3) << "LocalVideoCapture::Start"; 43 DVLOG(3) << "LocalVideoCapture::Start";
44 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 44 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
45 DCHECK_EQ(state_, video_capture::kStopped); 45 DCHECK_EQ(state_, VIDEO_CAPTURE_STATE_STOPPED);
46 46
47 capture_engine_ = vc_manager_->AddDevice(video_stream_id_, this); 47 capture_engine_ = vc_manager_->AddDevice(video_stream_id_, this);
48 state_ = video_capture::kStarted; 48 state_ = VIDEO_CAPTURE_STATE_STARTED;
49 AddRef(); // Will be balanced in OnRemoved(). 49 AddRef(); // Will be balanced in OnRemoved().
50 capture_engine_->StartCapture(handler_proxy_.get(), capability_); 50 capture_engine_->StartCapture(handler_proxy_.get(), capability_);
51 } 51 }
52 52
53 void LocalVideoCapture::Stop() { 53 void LocalVideoCapture::Stop() {
54 DVLOG(3) << "LocalVideoCapture::Stop"; 54 DVLOG(3) << "LocalVideoCapture::Stop";
55 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 55 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
56 if (capture_engine_) { 56 if (capture_engine_) {
57 state_ = video_capture::kStopping; 57 state_ = VIDEO_CAPTURE_STATE_STOPPING;
58 capture_engine_->StopCapture(handler_proxy_.get()); 58 capture_engine_->StopCapture(handler_proxy_.get());
59 capture_engine_ = NULL; 59 capture_engine_ = NULL;
60 } 60 }
61 } 61 }
62 62
63 void LocalVideoCapture::Play() { 63 void LocalVideoCapture::Play() {
64 DVLOG(3) << "LocalVideoCapture::Play"; 64 DVLOG(3) << "LocalVideoCapture::Play";
65 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 65 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
66 if (capture_engine_ && state_ == video_capture::kPaused) { 66 if (capture_engine_ && state_ == VIDEO_CAPTURE_STATE_PAUSED) {
67 state_ = video_capture::kStarted; 67 state_ = VIDEO_CAPTURE_STATE_STARTED;
68 } 68 }
69 } 69 }
70 70
71 void LocalVideoCapture::Pause() { 71 void LocalVideoCapture::Pause() {
72 DVLOG(3) << "LocalVideoCapture::Pause"; 72 DVLOG(3) << "LocalVideoCapture::Pause";
73 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 73 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
74 if (capture_engine_ && state_ == video_capture::kStarted) { 74 if (capture_engine_ && state_ == VIDEO_CAPTURE_STATE_STARTED) {
75 state_ = video_capture::kPaused; 75 state_ = VIDEO_CAPTURE_STATE_PAUSED;
76 } 76 }
77 } 77 }
78 78
79 void LocalVideoCapture::OnStarted(media::VideoCapture* capture) { 79 void LocalVideoCapture::OnStarted(media::VideoCapture* capture) {
80 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 80 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
81 NOTIMPLEMENTED(); 81 NOTIMPLEMENTED();
82 } 82 }
83 83
84 void LocalVideoCapture::OnStopped(media::VideoCapture* capture) { 84 void LocalVideoCapture::OnStopped(media::VideoCapture* capture) {
85 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 85 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
(...skipping 26 matching lines...) Expand all
112 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 112 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
113 } 113 }
114 114
115 void LocalVideoCapture::OnBufferReady( 115 void LocalVideoCapture::OnBufferReady(
116 media::VideoCapture* capture, 116 media::VideoCapture* capture,
117 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) { 117 scoped_refptr<media::VideoCapture::VideoFrameBuffer> buf) {
118 DVLOG(3) << "LocalVideoCapture::OnBufferReady, state:" << state_; 118 DVLOG(3) << "LocalVideoCapture::OnBufferReady, state:" << state_;
119 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 119 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
120 DCHECK(buf); 120 DCHECK(buf);
121 121
122 if (state_ != video_capture::kStarted) { 122 if (state_ != VIDEO_CAPTURE_STATE_STARTED) {
123 capture->FeedBuffer(buf); 123 capture->FeedBuffer(buf);
124 return; 124 return;
125 } 125 }
126 126
127 gfx::Size natural_size(buf->width, buf->height); 127 gfx::Size natural_size(buf->width, buf->height);
128 scoped_refptr<media::VideoFrame> current_frame = 128 scoped_refptr<media::VideoFrame> current_frame =
129 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, 129 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
130 natural_size, natural_size, 130 natural_size, natural_size,
131 buf->timestamp - base::Time()); 131 buf->timestamp - base::Time());
132 uint8* buffer = buf->memory_pointer; 132 uint8* buffer = buf->memory_pointer;
(...skipping 11 matching lines...) Expand all
144 buffer += y_width * y_height; 144 buffer += y_width * y_height;
145 CopyUPlane(buffer, uv_width, uv_height, current_frame); 145 CopyUPlane(buffer, uv_width, uv_height, current_frame);
146 buffer += uv_width * uv_height; 146 buffer += uv_width * uv_height;
147 CopyVPlane(buffer, uv_width, uv_height, current_frame); 147 CopyVPlane(buffer, uv_width, uv_height, current_frame);
148 148
149 capture->FeedBuffer(buf); 149 capture->FeedBuffer(buf);
150 repaint_cb_.Run(current_frame); 150 repaint_cb_.Run(current_frame);
151 } 151 }
152 152
153 } // namespace content 153 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698