| 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 #include <string> | 10 #include <string> |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 635 |
| 636 unsigned WebMediaPlayerImpl::videoDecodedByteCount() const { | 636 unsigned WebMediaPlayerImpl::videoDecodedByteCount() const { |
| 637 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 637 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 638 | 638 |
| 639 PipelineStatistics stats = pipeline_.GetStatistics(); | 639 PipelineStatistics stats = pipeline_.GetStatistics(); |
| 640 return stats.video_bytes_decoded; | 640 return stats.video_bytes_decoded; |
| 641 } | 641 } |
| 642 | 642 |
| 643 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( | 643 bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture( |
| 644 blink::WebGraphicsContext3D* web_graphics_context, | 644 blink::WebGraphicsContext3D* web_graphics_context, |
| 645 unsigned int texture, | 645 const CopyVideoTextureParams& params) { |
| 646 unsigned int internal_format, | |
| 647 unsigned int type, | |
| 648 bool premultiply_alpha, | |
| 649 bool flip_y) { | |
| 650 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); | 646 TRACE_EVENT0("media", "WebMediaPlayerImpl:copyVideoTextureToPlatformTexture"); |
| 647 DCHECK((params.copyType == CopyVideoTextureParams::FullCopy && |
| 648 !params.xoffset && !params.yoffset) || |
| 649 (params.copyType == CopyVideoTextureParams::SubCopy && |
| 650 !params.internalFormat && !params.type)); |
| 651 | 651 |
| 652 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); | 652 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); |
| 653 | 653 |
| 654 if (!video_frame.get() || !video_frame->HasTextures() || | 654 if (!video_frame.get() || !video_frame->HasTextures() || |
| 655 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { | 655 media::VideoFrame::NumPlanes(video_frame->format()) != 1) { |
| 656 return false; | 656 return false; |
| 657 } | 657 } |
| 658 | 658 |
| 659 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to | 659 // TODO(dshwang): need more elegant way to convert WebGraphicsContext3D to |
| 660 // GLES2Interface. | 660 // GLES2Interface. |
| 661 gpu::gles2::GLES2Interface* gl = | 661 gpu::gles2::GLES2Interface* gl = |
| 662 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) | 662 static_cast<gpu_blink::WebGraphicsContext3DImpl*>(web_graphics_context) |
| 663 ->GetGLInterface(); | 663 ->GetGLInterface(); |
| 664 typedef SkCanvasVideoRenderer::CopyFrameSingleTextureParams CopyParams; |
| 664 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( | 665 SkCanvasVideoRenderer::CopyVideoFrameSingleTextureToGLTexture( |
| 665 gl, video_frame.get(), texture, internal_format, type, premultiply_alpha, | 666 gl, video_frame.get(), |
| 666 flip_y); | 667 CopyParams(params.copyType == CopyVideoTextureParams::FullCopy |
| 668 ? CopyParams::FullCopy |
| 669 : CopyParams::SubCopy, |
| 670 params.target, params.texture, params.internalFormat, |
| 671 params.type, params.level, params.xoffset, params.yoffset, |
| 672 params.premultiplyAlpha, params.flipY)); |
| 667 return true; | 673 return true; |
| 668 } | 674 } |
| 669 | 675 |
| 670 WebMediaPlayer::MediaKeyException | 676 WebMediaPlayer::MediaKeyException |
| 671 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, | 677 WebMediaPlayerImpl::generateKeyRequest(const WebString& key_system, |
| 672 const unsigned char* init_data, | 678 const unsigned char* init_data, |
| 673 unsigned init_data_length) { | 679 unsigned init_data_length) { |
| 674 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 680 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 675 | 681 |
| 676 return encrypted_media_support_.GenerateKeyRequest( | 682 return encrypted_media_support_.GenerateKeyRequest( |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 | 1083 |
| 1078 // pause() may be called after playback has ended and the HTMLMediaElement | 1084 // pause() may be called after playback has ended and the HTMLMediaElement |
| 1079 // requires that currentTime() == duration() after ending. We want to ensure | 1085 // requires that currentTime() == duration() after ending. We want to ensure |
| 1080 // |paused_time_| matches currentTime() in this case or a future seek() may | 1086 // |paused_time_| matches currentTime() in this case or a future seek() may |
| 1081 // incorrectly discard what it thinks is a seek to the existing time. | 1087 // incorrectly discard what it thinks is a seek to the existing time. |
| 1082 paused_time_ = | 1088 paused_time_ = |
| 1083 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); | 1089 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); |
| 1084 } | 1090 } |
| 1085 | 1091 |
| 1086 } // namespace media | 1092 } // namespace media |
| OLD | NEW |