| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/webmediaplayer_ms.h" | 5 #include "content/renderer/media/webmediaplayer_ms.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 } | 340 } |
| 341 | 341 |
| 342 unsigned WebMediaPlayerMS::videoDecodedByteCount() const { | 342 unsigned WebMediaPlayerMS::videoDecodedByteCount() const { |
| 343 DCHECK(thread_checker_.CalledOnValidThread()); | 343 DCHECK(thread_checker_.CalledOnValidThread()); |
| 344 NOTIMPLEMENTED(); | 344 NOTIMPLEMENTED(); |
| 345 return 0; | 345 return 0; |
| 346 } | 346 } |
| 347 | 347 |
| 348 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture( | 348 bool WebMediaPlayerMS::copyVideoTextureToPlatformTexture( |
| 349 blink::WebGraphicsContext3D* web_graphics_context, | 349 blink::WebGraphicsContext3D* web_graphics_context, |
| 350 unsigned int texture, | 350 const CopyVideoTextureParams& params) { |
| 351 unsigned int internal_format, | |
| 352 unsigned int type, | |
| 353 bool premultiply_alpha, | |
| 354 bool flip_y) { | |
| 355 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture"); | 351 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture"); |
| 356 DCHECK(thread_checker_.CalledOnValidThread()); | 352 DCHECK(thread_checker_.CalledOnValidThread()); |
| 353 DCHECK((params.copyType == CopyVideoTextureParams::FullCopy && |
| 354 !params.xoffset && !params.yoffset) || |
| 355 (params.copyType == CopyVideoTextureParams::SubCopy && |
| 356 !params.internalFormat && !params.type)); |
| 357 | 357 |
| 358 scoped_refptr<media::VideoFrame> video_frame = compositor_->GetCurrentFrame(); | 358 scoped_refptr<media::VideoFrame> video_frame = compositor_->GetCurrentFrame(); |
| 359 | 359 |
| 360 if (!video_frame.get() || video_frame->HasTextures() || | 360 if (!video_frame.get() || video_frame->HasTextures() || |
| 361 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { | 361 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { |
| 362 return false; | 362 return false; |
| 363 } | 363 } |
| 364 | 364 |
| 365 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to | 365 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to |
| 366 // GLES2Interface. | 366 // GLES2Interface. |
| 367 gpu::gles2::GLES2Interface* const gl = | 367 gpu::gles2::GLES2Interface* const gl = |
| 368 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) | 368 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) |
| 369 ->GetGLInterface(); | 369 ->GetGLInterface(); |
| 370 typedef media::SkCanvasVideoRenderer::CopyFrameSingleTextureParams CopyParams; |
| 370 media::SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( | 371 media::SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( |
| 371 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, | 372 gl, video_frame.get(), |
| 372 flip_y); | 373 CopyParams(params.copyType == CopyVideoTextureParams::FullCopy |
| 374 ? CopyParams::FullCopy |
| 375 : CopyParams::SubCopy, |
| 376 params.target, params.texture, params.internalFormat, |
| 377 params.type, params.level, params.xoffset, params.yoffset, |
| 378 params.premultiplyAlpha, params.flipY)); |
| 373 return true; | 379 return true; |
| 374 } | 380 } |
| 375 | 381 |
| 376 void WebMediaPlayerMS::OnFrameAvailable( | 382 void WebMediaPlayerMS::OnFrameAvailable( |
| 377 const scoped_refptr<media::VideoFrame>& frame) { | 383 const scoped_refptr<media::VideoFrame>& frame) { |
| 378 DVLOG(3) << __FUNCTION__; | 384 DVLOG(3) << __FUNCTION__; |
| 379 DCHECK(thread_checker_.CalledOnValidThread()); | 385 DCHECK(thread_checker_.CalledOnValidThread()); |
| 380 | 386 |
| 381 base::TimeTicks render_time; | 387 base::TimeTicks render_time; |
| 382 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, | 388 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 get_client()->networkStateChanged(); | 438 get_client()->networkStateChanged(); |
| 433 } | 439 } |
| 434 | 440 |
| 435 void WebMediaPlayerMS::SetReadyState(WebMediaPlayer::ReadyState state) { | 441 void WebMediaPlayerMS::SetReadyState(WebMediaPlayer::ReadyState state) { |
| 436 DCHECK(thread_checker_.CalledOnValidThread()); | 442 DCHECK(thread_checker_.CalledOnValidThread()); |
| 437 ready_state_ = state; | 443 ready_state_ = state; |
| 438 // Always notify to ensure client has the latest value. | 444 // Always notify to ensure client has the latest value. |
| 439 get_client()->readyStateChanged(); | 445 get_client()->readyStateChanged(); |
| 440 } | 446 } |
| 441 } // namespace content | 447 } // namespace content |
| OLD | NEW |