| 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 const CopyVideoTextureParams& params) { | 350 unsigned int texture, |
| 351 unsigned int internal_format, |
| 352 unsigned int type, |
| 353 bool premultiply_alpha, |
| 354 bool flip_y) { |
| 351 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture"); | 355 TRACE_EVENT0("media", "WebMediaPlayerMS:copyVideoTextureToPlatformTexture"); |
| 352 DCHECK(thread_checker_.CalledOnValidThread()); | 356 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; | |
| 371 media::SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( | 370 media::SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( |
| 372 gl, video_frame.get(), | 371 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, |
| 373 CopyParams(params.copyType == CopyVideoTextureParams::FullCopy | 372 flip_y); |
| 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)); | |
| 379 return true; | 373 return true; |
| 380 } | 374 } |
| 381 | 375 |
| 382 void WebMediaPlayerMS::OnFrameAvailable( | 376 void WebMediaPlayerMS::OnFrameAvailable( |
| 383 const scoped_refptr<media::VideoFrame>& frame) { | 377 const scoped_refptr<media::VideoFrame>& frame) { |
| 384 DVLOG(3) << __FUNCTION__; | 378 DVLOG(3) << __FUNCTION__; |
| 385 DCHECK(thread_checker_.CalledOnValidThread()); | 379 DCHECK(thread_checker_.CalledOnValidThread()); |
| 386 | 380 |
| 387 base::TimeTicks render_time; | 381 base::TimeTicks render_time; |
| 388 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, | 382 if (frame->metadata()->GetTimeTicks(media::VideoFrameMetadata::REFERENCE_TIME, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 get_client()->networkStateChanged(); | 432 get_client()->networkStateChanged(); |
| 439 } | 433 } |
| 440 | 434 |
| 441 void WebMediaPlayerMS::SetReadyState(WebMediaPlayer::ReadyState state) { | 435 void WebMediaPlayerMS::SetReadyState(WebMediaPlayer::ReadyState state) { |
| 442 DCHECK(thread_checker_.CalledOnValidThread()); | 436 DCHECK(thread_checker_.CalledOnValidThread()); |
| 443 ready_state_ = state; | 437 ready_state_ = state; |
| 444 // Always notify to ensure client has the latest value. | 438 // Always notify to ensure client has the latest value. |
| 445 get_client()->readyStateChanged(); | 439 get_client()->readyStateChanged(); |
| 446 } | 440 } |
| 447 } // namespace content | 441 } // namespace content |
| OLD | NEW |