OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 9 #include "base/message_loop.h" |
10 #include "media/base/pipeline_status.h" | 10 #include "media/base/pipeline_status.h" |
11 #include "media/filters/chunk_demuxer.h" | 11 #include "media/filters/chunk_demuxer.h" |
12 #include "webkit/media/web_video_renderer.h" | 12 #include "webkit/media/video_renderer_impl.h" |
13 #include "webkit/media/webmediaplayer_impl.h" | 13 #include "webkit/media/webmediaplayer_impl.h" |
14 | 14 |
15 using media::PipelineStatus; | 15 using media::PipelineStatus; |
16 | 16 |
17 namespace webkit_media { | 17 namespace webkit_media { |
18 | 18 |
19 // Limits the maximum outstanding repaints posted on render thread. | 19 // Limits the maximum outstanding repaints posted on render thread. |
20 // This number of 50 is a guess, it does not take too much memory on the task | 20 // This number of 50 is a guess, it does not take too much memory on the task |
21 // queue but gives up a pretty good latency on repaint. | 21 // queue but gives up a pretty good latency on repaint. |
22 static const int kMaxOutstandingRepaints = 50; | 22 static const int kMaxOutstandingRepaints = 50; |
(...skipping 15 matching lines...) Expand all Loading... |
38 base::AutoLock auto_lock(lock_); | 38 base::AutoLock auto_lock(lock_); |
39 if (outstanding_repaints_ < kMaxOutstandingRepaints) { | 39 if (outstanding_repaints_ < kMaxOutstandingRepaints) { |
40 ++outstanding_repaints_; | 40 ++outstanding_repaints_; |
41 | 41 |
42 render_loop_->PostTask(FROM_HERE, | 42 render_loop_->PostTask(FROM_HERE, |
43 NewRunnableMethod(this, &WebMediaPlayerProxy::RepaintTask)); | 43 NewRunnableMethod(this, &WebMediaPlayerProxy::RepaintTask)); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 void WebMediaPlayerProxy::SetVideoRenderer( | 47 void WebMediaPlayerProxy::SetVideoRenderer( |
48 scoped_refptr<WebVideoRenderer> video_renderer) { | 48 const scoped_refptr<VideoRendererImpl>& video_renderer) { |
49 video_renderer_ = video_renderer; | 49 video_renderer_ = video_renderer; |
50 } | 50 } |
51 | 51 |
52 WebDataSourceBuildObserverHack WebMediaPlayerProxy::GetBuildObserver() { | 52 WebDataSourceBuildObserverHack WebMediaPlayerProxy::GetBuildObserver() { |
53 return base::Bind(&WebMediaPlayerProxy::AddDataSource, this); | 53 return base::Bind(&WebMediaPlayerProxy::AddDataSource, this); |
54 } | 54 } |
55 | 55 |
56 void WebMediaPlayerProxy::Paint(SkCanvas* canvas, const gfx::Rect& dest_rect) { | 56 void WebMediaPlayerProxy::Paint(SkCanvas* canvas, const gfx::Rect& dest_rect) { |
57 DCHECK(MessageLoop::current() == render_loop_); | 57 DCHECK(MessageLoop::current() == render_loop_); |
58 if (video_renderer_) { | 58 if (video_renderer_) { |
59 video_renderer_->Paint(canvas, dest_rect); | 59 video_renderer_->Paint(canvas, dest_rect); |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 void WebMediaPlayerProxy::SetSize(const gfx::Rect& rect) { | |
64 DCHECK(MessageLoop::current() == render_loop_); | |
65 if (video_renderer_) { | |
66 video_renderer_->SetRect(rect); | |
67 } | |
68 } | |
69 | |
70 bool WebMediaPlayerProxy::HasSingleOrigin() { | 63 bool WebMediaPlayerProxy::HasSingleOrigin() { |
71 DCHECK(MessageLoop::current() == render_loop_); | 64 DCHECK(MessageLoop::current() == render_loop_); |
72 | 65 |
73 base::AutoLock auto_lock(data_sources_lock_); | 66 base::AutoLock auto_lock(data_sources_lock_); |
74 | 67 |
75 for (DataSourceList::iterator itr = data_sources_.begin(); | 68 for (DataSourceList::iterator itr = data_sources_.begin(); |
76 itr != data_sources_.end(); | 69 itr != data_sources_.end(); |
77 itr++) { | 70 itr++) { |
78 if (!(*itr)->HasSingleOrigin()) | 71 if (!(*itr)->HasSingleOrigin()) |
79 return false; | 72 return false; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 chunk_demuxer_ = demuxer; | 220 chunk_demuxer_ = demuxer; |
228 if (webmediaplayer_) | 221 if (webmediaplayer_) |
229 webmediaplayer_->OnDemuxerOpened(); | 222 webmediaplayer_->OnDemuxerOpened(); |
230 } | 223 } |
231 | 224 |
232 void WebMediaPlayerProxy::DemuxerClosedTask() { | 225 void WebMediaPlayerProxy::DemuxerClosedTask() { |
233 chunk_demuxer_ = NULL; | 226 chunk_demuxer_ = NULL; |
234 } | 227 } |
235 | 228 |
236 } // namespace webkit_media | 229 } // namespace webkit_media |
OLD | NEW |