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