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