Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2749653003: Prototype HTMLVideoElement properties for WebGL texImage2D (Closed)
Patch Set: update Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 DCHECK(main_task_runner_->BelongsToCurrentThread()); 695 DCHECK(main_task_runner_->BelongsToCurrentThread());
696 696
697 base::Optional<MediaTrack::Id> selected_video_track_id; 697 base::Optional<MediaTrack::Id> selected_video_track_id;
698 if (selectedTrackId && !video_track_disabled_) 698 if (selectedTrackId && !video_track_disabled_)
699 selected_video_track_id = MediaTrack::Id(selectedTrackId->utf8().data()); 699 selected_video_track_id = MediaTrack::Id(selectedTrackId->utf8().data());
700 MEDIA_LOG(INFO, media_log_) << "Selected video track: [" 700 MEDIA_LOG(INFO, media_log_) << "Selected video track: ["
701 << selected_video_track_id.value_or("") << "]"; 701 << selected_video_track_id.value_or("") << "]";
702 pipeline_controller_.OnSelectedVideoTrackChanged(selected_video_track_id); 702 pipeline_controller_.OnSelectedVideoTrackChanged(selected_video_track_id);
703 } 703 }
704 704
705 bool WebMediaPlayerImpl::getLastUploadedFrameInfo(unsigned* width,
706 unsigned* height,
707 double* timestamp) {
708 *width = last_uploaded_frame_width_;
709 *height = last_uploaded_frame_height_;
710 *timestamp = last_uploaded_frame_timestamp_;
711 return true;
712 }
713
705 blink::WebSize WebMediaPlayerImpl::naturalSize() const { 714 blink::WebSize WebMediaPlayerImpl::naturalSize() const {
706 DCHECK(main_task_runner_->BelongsToCurrentThread()); 715 DCHECK(main_task_runner_->BelongsToCurrentThread());
707 716
708 return blink::WebSize(pipeline_metadata_.natural_size); 717 return blink::WebSize(pipeline_metadata_.natural_size);
709 } 718 }
710 719
711 bool WebMediaPlayerImpl::paused() const { 720 bool WebMediaPlayerImpl::paused() const {
712 DCHECK(main_task_runner_->BelongsToCurrentThread()); 721 DCHECK(main_task_runner_->BelongsToCurrentThread());
713 722
714 #if defined(OS_ANDROID) // WMPI_CAST 723 #if defined(OS_ANDROID) // WMPI_CAST
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 TRACE_EVENT0("media", "WebMediaPlayerImpl:paint"); 896 TRACE_EVENT0("media", "WebMediaPlayerImpl:paint");
888 897
889 // TODO(sandersd): Move this check into GetCurrentFrameFromCompositor() when 898 // TODO(sandersd): Move this check into GetCurrentFrameFromCompositor() when
890 // we have other ways to check if decoder owns video frame. 899 // we have other ways to check if decoder owns video frame.
891 // See http://crbug.com/595716 and http://crbug.com/602708 900 // See http://crbug.com/595716 and http://crbug.com/602708
892 if (cdm_) 901 if (cdm_)
893 return; 902 return;
894 903
895 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); 904 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor();
896 905
906 UpdateLastUploadedFrameInfo(video_frame.get());
907
897 gfx::Rect gfx_rect(rect); 908 gfx::Rect gfx_rect(rect);
898 Context3D context_3d; 909 Context3D context_3d;
899 if (video_frame.get() && video_frame->HasTextures()) { 910 if (video_frame.get() && video_frame->HasTextures()) {
900 if (!context_3d_cb_.is_null()) 911 if (!context_3d_cb_.is_null())
901 context_3d = context_3d_cb_.Run(); 912 context_3d = context_3d_cb_.Run();
902 if (!context_3d.gl) 913 if (!context_3d.gl)
903 return; // Unable to get/create a shared main thread context. 914 return; // Unable to get/create a shared main thread context.
904 if (!context_3d.gr_context) 915 if (!context_3d.gr_context)
905 return; // The context has been lost since and can't setup a GrContext. 916 return; // The context has been lost since and can't setup a GrContext.
906 } 917 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 // we have other ways to check if decoder owns video frame. 976 // we have other ways to check if decoder owns video frame.
966 // See http://crbug.com/595716 and http://crbug.com/602708 977 // See http://crbug.com/595716 and http://crbug.com/602708
967 if (cdm_) 978 if (cdm_)
968 return false; 979 return false;
969 980
970 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor(); 981 scoped_refptr<VideoFrame> video_frame = GetCurrentFrameFromCompositor();
971 if (!video_frame.get() || !video_frame->HasTextures()) { 982 if (!video_frame.get() || !video_frame->HasTextures()) {
972 return false; 983 return false;
973 } 984 }
974 985
986 UpdateLastUploadedFrameInfo(video_frame.get());
987
975 Context3D context_3d; 988 Context3D context_3d;
976 if (!context_3d_cb_.is_null()) 989 if (!context_3d_cb_.is_null())
977 context_3d = context_3d_cb_.Run(); 990 context_3d = context_3d_cb_.Run();
978 return skcanvas_video_renderer_.CopyVideoFrameTexturesToGLTexture( 991 return skcanvas_video_renderer_.CopyVideoFrameTexturesToGLTexture(
979 context_3d, gl, video_frame.get(), texture, premultiply_alpha, flip_y); 992 context_3d, gl, video_frame.get(), texture, premultiply_alpha, flip_y);
980 } 993 }
981 994
982 void WebMediaPlayerImpl::setContentDecryptionModule( 995 void WebMediaPlayerImpl::setContentDecryptionModule(
983 blink::WebContentDecryptionModule* cdm, 996 blink::WebContentDecryptionModule* cdm,
984 blink::WebContentDecryptionModuleResult result) { 997 blink::WebContentDecryptionModuleResult result) {
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 } 2332 }
2320 2333
2321 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { 2334 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) {
2322 DCHECK(data_source_ || chunk_demuxer_); 2335 DCHECK(data_source_ || chunk_demuxer_);
2323 if (data_source_) 2336 if (data_source_)
2324 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); 2337 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration);
2325 else 2338 else
2326 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); 2339 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration);
2327 } 2340 }
2328 2341
2342 void WebMediaPlayerImpl::UpdateLastUploadedFrameInfo(VideoFrame* video_frame) {
2343 if (!video_frame) {
2344 last_uploaded_frame_width_ = 0;
2345 last_uploaded_frame_height_ = 0;
2346 last_uploaded_frame_timestamp_ = 0.0;
2347 return;
2348 }
2349
2350 last_uploaded_frame_width_ = video_frame->natural_size().width();
2351 last_uploaded_frame_height_ = video_frame->natural_size().height();
2352 last_uploaded_frame_timestamp_ = video_frame->timestamp().InSecondsF();
2353 }
2354
2329 } // namespace media 2355 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698