| 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 27 matching lines...) Expand all Loading... |
| 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 Loading... |
| 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::PipelineSeekCallback(PipelineStatus status) { | |
| 93 render_loop_->PostTask(FROM_HERE, base::Bind( | |
| 94 &WebMediaPlayerProxy::PipelineSeekTask, this, status)); | |
| 95 } | |
| 96 | |
| 97 void WebMediaPlayerProxy::PipelineEndedCallback(PipelineStatus status) { | |
| 98 render_loop_->PostTask(FROM_HERE, base::Bind( | |
| 99 &WebMediaPlayerProxy::PipelineEndedTask, this, status)); | |
| 100 } | |
| 101 | |
| 102 void WebMediaPlayerProxy::PipelineErrorCallback(PipelineStatus error) { | |
| 103 DCHECK_NE(error, media::PIPELINE_OK); | |
| 104 render_loop_->PostTask(FROM_HERE, base::Bind( | |
| 105 &WebMediaPlayerProxy::PipelineErrorTask, this, error)); | |
| 106 } | |
| 107 | |
| 108 void WebMediaPlayerProxy::PipelineBufferingStateCallback( | |
| 109 media::Pipeline::BufferingState buffering_state) { | |
| 110 render_loop_->PostTask(FROM_HERE, base::Bind( | |
| 111 &WebMediaPlayerProxy::PipelineBufferingStateTask, this, buffering_state)); | |
| 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::PipelineSeekTask(PipelineStatus status) { | |
| 127 DCHECK(render_loop_->BelongsToCurrentThread()); | |
| 128 if (webmediaplayer_) | |
| 129 webmediaplayer_->OnPipelineSeek(status); | |
| 130 } | |
| 131 | |
| 132 void WebMediaPlayerProxy::PipelineEndedTask(PipelineStatus status) { | |
| 133 DCHECK(render_loop_->BelongsToCurrentThread()); | |
| 134 if (webmediaplayer_) | |
| 135 webmediaplayer_->OnPipelineEnded(status); | |
| 136 } | |
| 137 | |
| 138 void WebMediaPlayerProxy::PipelineErrorTask(PipelineStatus error) { | |
| 139 DCHECK(render_loop_->BelongsToCurrentThread()); | |
| 140 if (webmediaplayer_) | |
| 141 webmediaplayer_->OnPipelineError(error); | |
| 142 } | |
| 143 | |
| 144 void WebMediaPlayerProxy::PipelineBufferingStateTask( | |
| 145 media::Pipeline::BufferingState buffering_state) { | |
| 146 DCHECK(render_loop_->BelongsToCurrentThread()); | |
| 147 if (webmediaplayer_) | |
| 148 webmediaplayer_->OnPipelineBufferingState(buffering_state); | |
| 149 } | |
| 150 | |
| 151 void WebMediaPlayerProxy::SetOpaqueTask(bool opaque) { | |
| 152 DCHECK(render_loop_->BelongsToCurrentThread()); | |
| 153 if (webmediaplayer_) | |
| 154 webmediaplayer_->SetOpaque(opaque); | |
| 155 } | |
| 156 | |
| 157 void WebMediaPlayerProxy::GetCurrentFrame( | 99 void WebMediaPlayerProxy::GetCurrentFrame( |
| 158 scoped_refptr<media::VideoFrame>* frame_out) { | 100 scoped_refptr<media::VideoFrame>* frame_out) { |
| 159 if (frame_provider_) | 101 if (frame_provider_) |
| 160 frame_provider_->GetCurrentFrame(frame_out); | 102 frame_provider_->GetCurrentFrame(frame_out); |
| 161 } | 103 } |
| 162 | 104 |
| 163 void WebMediaPlayerProxy::PutCurrentFrame( | 105 void WebMediaPlayerProxy::PutCurrentFrame( |
| 164 scoped_refptr<media::VideoFrame> frame) { | 106 scoped_refptr<media::VideoFrame> frame) { |
| 165 if (frame_provider_) | 107 if (frame_provider_) |
| 166 frame_provider_->PutCurrentFrame(frame); | 108 frame_provider_->PutCurrentFrame(frame); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 const std::string& session_id, | 254 const std::string& session_id, |
| 313 scoped_array<uint8> init_data, | 255 scoped_array<uint8> init_data, |
| 314 int init_data_size) { | 256 int init_data_size) { |
| 315 DCHECK(render_loop_->BelongsToCurrentThread()); | 257 DCHECK(render_loop_->BelongsToCurrentThread()); |
| 316 if (webmediaplayer_) | 258 if (webmediaplayer_) |
| 317 webmediaplayer_->OnNeedKey(key_system, session_id, | 259 webmediaplayer_->OnNeedKey(key_system, session_id, |
| 318 init_data.Pass(), init_data_size); | 260 init_data.Pass(), init_data_size); |
| 319 } | 261 } |
| 320 | 262 |
| 321 } // namespace webkit_media | 263 } // namespace webkit_media |
| OLD | NEW |