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

Side by Side Diff: webkit/media/webmediaplayer_proxy.cc

Issue 10855188: media::BindToLoop() is born, with example uses to slim down WebMediaPlayerProxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: now with macro Created 8 years, 4 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
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 "webkit/media/webmediaplayer_proxy.h" 5 #include "webkit/media/webmediaplayer_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "media/base/pipeline_status.h" 10 #include "media/base/pipeline_status.h"
(...skipping 27 matching lines...) Expand all
38 void WebMediaPlayerProxy::Repaint() { 38 void WebMediaPlayerProxy::Repaint() {
39 base::AutoLock auto_lock(lock_); 39 base::AutoLock auto_lock(lock_);
40 if (outstanding_repaints_ < kMaxOutstandingRepaints) { 40 if (outstanding_repaints_ < kMaxOutstandingRepaints) {
41 ++outstanding_repaints_; 41 ++outstanding_repaints_;
42 42
43 render_loop_->PostTask(FROM_HERE, base::Bind( 43 render_loop_->PostTask(FROM_HERE, base::Bind(
44 &WebMediaPlayerProxy::RepaintTask, this)); 44 &WebMediaPlayerProxy::RepaintTask, this));
45 } 45 }
46 } 46 }
47 47
48 void WebMediaPlayerProxy::SetOpaque(bool opaque) {
49 render_loop_->PostTask(FROM_HERE, base::Bind(
50 &WebMediaPlayerProxy::SetOpaqueTask, this, opaque));
51 }
52
53 void WebMediaPlayerProxy::Paint(SkCanvas* canvas, 48 void WebMediaPlayerProxy::Paint(SkCanvas* canvas,
54 const gfx::Rect& dest_rect, 49 const gfx::Rect& dest_rect,
55 uint8_t alpha) { 50 uint8_t alpha) {
56 DCHECK(render_loop_->BelongsToCurrentThread()); 51 DCHECK(render_loop_->BelongsToCurrentThread());
57 if (frame_provider_) { 52 if (frame_provider_) {
58 scoped_refptr<media::VideoFrame> video_frame; 53 scoped_refptr<media::VideoFrame> video_frame;
59 frame_provider_->GetCurrentFrame(&video_frame); 54 frame_provider_->GetCurrentFrame(&video_frame);
60 video_renderer_.Paint(video_frame, canvas, dest_rect, alpha); 55 video_renderer_.Paint(video_frame, canvas, dest_rect, alpha);
61 frame_provider_->PutCurrentFrame(video_frame); 56 frame_provider_->PutCurrentFrame(video_frame);
62 } 57 }
(...skipping 19 matching lines...) Expand all
82 data_source_->Abort(); 77 data_source_->Abort();
83 } 78 }
84 79
85 void WebMediaPlayerProxy::Detach() { 80 void WebMediaPlayerProxy::Detach() {
86 DCHECK(render_loop_->BelongsToCurrentThread()); 81 DCHECK(render_loop_->BelongsToCurrentThread());
87 webmediaplayer_ = NULL; 82 webmediaplayer_ = NULL;
88 data_source_ = NULL; 83 data_source_ = NULL;
89 frame_provider_ = NULL; 84 frame_provider_ = NULL;
90 } 85 }
91 86
92 void WebMediaPlayerProxy::PipelineInitializationCallback(
93 PipelineStatus status) {
94 render_loop_->PostTask(FROM_HERE, base::Bind(
95 &WebMediaPlayerProxy::PipelineInitializationTask, this, status));
96 }
97
98 void WebMediaPlayerProxy::PipelineSeekCallback(PipelineStatus status) {
99 render_loop_->PostTask(FROM_HERE, base::Bind(
100 &WebMediaPlayerProxy::PipelineSeekTask, this, status));
101 }
102
103 void WebMediaPlayerProxy::PipelineEndedCallback(PipelineStatus status) {
104 render_loop_->PostTask(FROM_HERE, base::Bind(
105 &WebMediaPlayerProxy::PipelineEndedTask, this, status));
106 }
107
108 void WebMediaPlayerProxy::PipelineErrorCallback(PipelineStatus error) {
109 DCHECK_NE(error, media::PIPELINE_OK);
110 render_loop_->PostTask(FROM_HERE, base::Bind(
111 &WebMediaPlayerProxy::PipelineErrorTask, this, error));
112 }
113
114 void WebMediaPlayerProxy::RepaintTask() { 87 void WebMediaPlayerProxy::RepaintTask() {
115 DCHECK(render_loop_->BelongsToCurrentThread()); 88 DCHECK(render_loop_->BelongsToCurrentThread());
116 { 89 {
117 base::AutoLock auto_lock(lock_); 90 base::AutoLock auto_lock(lock_);
118 --outstanding_repaints_; 91 --outstanding_repaints_;
119 DCHECK_GE(outstanding_repaints_, 0); 92 DCHECK_GE(outstanding_repaints_, 0);
120 } 93 }
121 if (webmediaplayer_) { 94 if (webmediaplayer_) {
122 webmediaplayer_->Repaint(); 95 webmediaplayer_->Repaint();
123 } 96 }
124 } 97 }
125 98
126 void WebMediaPlayerProxy::PipelineInitializationTask(PipelineStatus status) {
127 DCHECK(render_loop_->BelongsToCurrentThread());
128 if (webmediaplayer_)
129 webmediaplayer_->OnPipelineInitialize(status);
130 }
131
132 void WebMediaPlayerProxy::PipelineSeekTask(PipelineStatus status) {
133 DCHECK(render_loop_->BelongsToCurrentThread());
134 if (webmediaplayer_)
135 webmediaplayer_->OnPipelineSeek(status);
136 }
137
138 void WebMediaPlayerProxy::PipelineEndedTask(PipelineStatus status) {
139 DCHECK(render_loop_->BelongsToCurrentThread());
140 if (webmediaplayer_)
141 webmediaplayer_->OnPipelineEnded(status);
142 }
143
144 void WebMediaPlayerProxy::PipelineErrorTask(PipelineStatus error) {
145 DCHECK(render_loop_->BelongsToCurrentThread());
146 if (webmediaplayer_)
147 webmediaplayer_->OnPipelineError(error);
148 }
149
150 void WebMediaPlayerProxy::SetOpaqueTask(bool opaque) {
151 DCHECK(render_loop_->BelongsToCurrentThread());
152 if (webmediaplayer_)
153 webmediaplayer_->SetOpaque(opaque);
154 }
155
156 void WebMediaPlayerProxy::GetCurrentFrame( 99 void WebMediaPlayerProxy::GetCurrentFrame(
157 scoped_refptr<media::VideoFrame>* frame_out) { 100 scoped_refptr<media::VideoFrame>* frame_out) {
158 if (frame_provider_) 101 if (frame_provider_)
159 frame_provider_->GetCurrentFrame(frame_out); 102 frame_provider_->GetCurrentFrame(frame_out);
160 } 103 }
161 104
162 void WebMediaPlayerProxy::PutCurrentFrame( 105 void WebMediaPlayerProxy::PutCurrentFrame(
163 scoped_refptr<media::VideoFrame> frame) { 106 scoped_refptr<media::VideoFrame> frame) {
164 if (frame_provider_) 107 if (frame_provider_)
165 frame_provider_->PutCurrentFrame(frame); 108 frame_provider_->PutCurrentFrame(frame);
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 const std::string& session_id, 254 const std::string& session_id,
312 scoped_array<uint8> init_data, 255 scoped_array<uint8> init_data,
313 int init_data_size) { 256 int init_data_size) {
314 DCHECK(render_loop_->BelongsToCurrentThread()); 257 DCHECK(render_loop_->BelongsToCurrentThread());
315 if (webmediaplayer_) 258 if (webmediaplayer_)
316 webmediaplayer_->OnNeedKey(key_system, session_id, 259 webmediaplayer_->OnNeedKey(key_system, session_id,
317 init_data.Pass(), init_data_size); 260 init_data.Pass(), init_data_size);
318 } 261 }
319 262
320 } // namespace webkit_media 263 } // namespace webkit_media
OLDNEW
« media/base/bind_to_loop.h ('K') | « webkit/media/webmediaplayer_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698