OLD | NEW |
---|---|
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 16 matching lines...) Expand all Loading... | |
27 webmediaplayer_(webmediaplayer), | 27 webmediaplayer_(webmediaplayer), |
28 outstanding_repaints_(0) { | 28 outstanding_repaints_(0) { |
29 DCHECK(render_loop_); | 29 DCHECK(render_loop_); |
30 DCHECK(webmediaplayer_); | 30 DCHECK(webmediaplayer_); |
31 } | 31 } |
32 | 32 |
33 WebMediaPlayerProxy::~WebMediaPlayerProxy() { | 33 WebMediaPlayerProxy::~WebMediaPlayerProxy() { |
34 Detach(); | 34 Detach(); |
35 } | 35 } |
36 | 36 |
37 void WebMediaPlayerProxy::Repaint() { | 37 void WebMediaPlayerProxy::FrameReady( |
38 const scoped_refptr<media::VideoFrame>& frame) { | |
38 base::AutoLock auto_lock(lock_); | 39 base::AutoLock auto_lock(lock_); |
40 current_frame_ = frame; | |
acolwell GONE FROM CHROMIUM
2013/02/01 00:24:34
I think you need more code in here to track droppe
scherkus (not reviewing)
2013/02/01 22:45:25
As discussed offline, I added back the frame dropp
| |
41 | |
39 if (outstanding_repaints_ < kMaxOutstandingRepaints) { | 42 if (outstanding_repaints_ < kMaxOutstandingRepaints) { |
40 ++outstanding_repaints_; | 43 ++outstanding_repaints_; |
41 | 44 |
42 render_loop_->PostTask(FROM_HERE, base::Bind( | 45 render_loop_->PostTask(FROM_HERE, base::Bind( |
43 &WebMediaPlayerProxy::RepaintTask, this)); | 46 &WebMediaPlayerProxy::RepaintTask, this)); |
44 } | 47 } |
45 } | 48 } |
46 | 49 |
47 void WebMediaPlayerProxy::Paint(SkCanvas* canvas, | 50 void WebMediaPlayerProxy::Paint(SkCanvas* canvas, |
48 const gfx::Rect& dest_rect, | 51 const gfx::Rect& dest_rect, |
49 uint8_t alpha) { | 52 uint8_t alpha) { |
50 DCHECK(render_loop_->BelongsToCurrentThread()); | 53 DCHECK(render_loop_->BelongsToCurrentThread()); |
51 if (frame_provider_) { | 54 |
52 scoped_refptr<media::VideoFrame> video_frame; | 55 // Use GetCurrentFrame() to avoid locking while painting in software. |
53 frame_provider_->GetCurrentFrame(&video_frame); | 56 scoped_refptr<media::VideoFrame> video_frame; |
54 video_renderer_.Paint(video_frame, canvas, dest_rect, alpha); | 57 GetCurrentFrame(&video_frame); |
55 frame_provider_->PutCurrentFrame(video_frame); | 58 video_renderer_.Paint(video_frame, canvas, dest_rect, alpha); |
56 } | |
57 } | 59 } |
58 | 60 |
59 bool WebMediaPlayerProxy::HasSingleOrigin() { | 61 bool WebMediaPlayerProxy::HasSingleOrigin() { |
60 DCHECK(render_loop_->BelongsToCurrentThread()); | 62 DCHECK(render_loop_->BelongsToCurrentThread()); |
61 if (data_source_) | 63 if (data_source_) |
62 return data_source_->HasSingleOrigin(); | 64 return data_source_->HasSingleOrigin(); |
63 return true; | 65 return true; |
64 } | 66 } |
65 | 67 |
66 bool WebMediaPlayerProxy::DidPassCORSAccessCheck() const { | 68 bool WebMediaPlayerProxy::DidPassCORSAccessCheck() const { |
(...skipping 23 matching lines...) Expand all Loading... | |
90 --outstanding_repaints_; | 92 --outstanding_repaints_; |
91 DCHECK_GE(outstanding_repaints_, 0); | 93 DCHECK_GE(outstanding_repaints_, 0); |
92 } | 94 } |
93 if (webmediaplayer_) { | 95 if (webmediaplayer_) { |
94 webmediaplayer_->Repaint(); | 96 webmediaplayer_->Repaint(); |
95 } | 97 } |
96 } | 98 } |
97 | 99 |
98 void WebMediaPlayerProxy::GetCurrentFrame( | 100 void WebMediaPlayerProxy::GetCurrentFrame( |
99 scoped_refptr<media::VideoFrame>* frame_out) { | 101 scoped_refptr<media::VideoFrame>* frame_out) { |
100 if (frame_provider_) | 102 base::AutoLock auto_lock(lock_); |
101 frame_provider_->GetCurrentFrame(frame_out); | 103 *frame_out = current_frame_; |
102 } | |
103 | |
104 void WebMediaPlayerProxy::PutCurrentFrame( | |
105 scoped_refptr<media::VideoFrame> frame) { | |
106 if (frame_provider_) | |
107 frame_provider_->PutCurrentFrame(frame); | |
108 } | 104 } |
109 | 105 |
110 } // namespace webkit_media | 106 } // namespace webkit_media |
OLD | NEW |