| 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 "media/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 622 |
| 623 unsigned WebMediaPlayerImpl::videoDecodedByteCount() const { | 623 unsigned WebMediaPlayerImpl::videoDecodedByteCount() const { |
| 624 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 624 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 625 | 625 |
| 626 PipelineStatistics stats = pipeline_.GetStatistics(); | 626 PipelineStatistics stats = pipeline_.GetStatistics(); |
| 627 return stats.video_bytes_decoded; | 627 return stats.video_bytes_decoded; |
| 628 } | 628 } |
| 629 | 629 |
| 630 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( | 630 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( |
| 631 blink::WebGraphicsContext3D* web_graphics_context, | 631 blink::WebGraphicsContext3D* web_graphics_context, |
| 632 unsigned int texture, | 632 const CopyVideoTextureParams& params) { |
| 633 unsigned int internal_format, | |
| 634 unsigned int type, | |
| 635 bool premultiply_alpha, | |
| 636 bool flip_y) { | |
| 637 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); | 633 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); |
| 634 DCHECK((params.copyType == CopyVideoTextureParams::FullCopy && |
| 635 !params.xoffset && !params.yoffset) || |
| 636 (params.copyType == CopyVideoTextureParams::SubCopy && |
| 637 !params.internalFormat && !params.type)); |
| 638 | 638 |
| 639 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); | 639 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); |
| 640 | 640 |
| 641 if (!video_frame.get() || !video_frame->HasTextures() || | 641 if (!video_frame.get() || !video_frame->HasTextures() || |
| 642 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { | 642 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { |
| 643 return false; | 643 return false; |
| 644 } | 644 } |
| 645 | 645 |
| 646 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to | 646 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to |
| 647 // GLES2Interface. | 647 // GLES2Interface. |
| 648 gpu::gles2::GLES2Interface* gl = | 648 gpu::gles2::GLES2Interface* gl = |
| 649 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) | 649 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) |
| 650 ->GetGLInterface(); | 650 ->GetGLInterface(); |
| 651 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( | 651 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( |
| 652 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, | 652 gl, video_frame.get(), |
| 653 flip_y); | 653 {params.copyType == CopyVideoTextureParams::FullCopy |
| 654 ? SkCanvasVideoRenderer::CopyFrameSingleTextureParams::FullCopy |
| 655 : SkCanvasVideoRenderer::CopyFrameSingleTextureParams::SubCopy, |
| 656 params.target, params.texture, params.internalFormat, params.type, |
| 657 params.level, params.xoffset, params.yoffset, params.premultiplyAlpha, |
| 658 params.flipY}); |
| 654 return true; | 659 return true; |
| 655 } | 660 } |
| 656 | 661 |
| 657 WebMediaPlayer::MediaKeyException | 662 WebMediaPlayer::MediaKeyException |
| 658 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, | 663 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, |
| 659 const unsigned char* init_data, | 664 const unsigned char* init_data, |
| 660 unsigned init_data_length) { | 665 unsigned init_data_length) { |
| 661 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 666 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 662 | 667 |
| 663 return encrypted_media_support_.GenerateKeyRequest( | 668 return encrypted_media_support_.GenerateKeyRequest( |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 | 1069 |
| 1065 // pause() may be called after playback has ended and the HTMLMediaElement | 1070 // pause() may be called after playback has ended and the HTMLMediaElement |
| 1066 // requires that currentTime() == duration() after ending. We want to ensure | 1071 // requires that currentTime() == duration() after ending. We want to ensure |
| 1067 // |paused_time_| matches currentTime() in this case or a future seek() may | 1072 // |paused_time_| matches currentTime() in this case or a future seek() may |
| 1068 // incorrectly discard what it thinks is a seek to the existing time. | 1073 // incorrectly discard what it thinks is a seek to the existing time. |
| 1069 paused_time_ = | 1074 paused_time_ = |
| 1070 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 1075 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); |
| 1071 } | 1076 } |
| 1072 | 1077 |
| 1073 } // namespace media | 1078 } // namespace media |
| OLD | NEW |