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_impl.h" | 5 #include "content/renderer/media/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 540 |
541 // TODO(scherkus): Clarify paint() API contract to better understand when and | 541 // TODO(scherkus): Clarify paint() API contract to better understand when and |
542 // why it's being called. For example, today paint() is called when: | 542 // why it's being called. For example, today paint() is called when: |
543 // - We haven't reached HAVE_CURRENT_DATA and need to paint black | 543 // - We haven't reached HAVE_CURRENT_DATA and need to paint black |
544 // - We're painting to a canvas | 544 // - We're painting to a canvas |
545 // See http://crbug.com/341225 http://crbug.com/342621 for details. | 545 // See http://crbug.com/341225 http://crbug.com/342621 for details. |
546 scoped_refptr<media::VideoFrame> video_frame = | 546 scoped_refptr<media::VideoFrame> video_frame = |
547 GetCurrentFrameFromCompositor(); | 547 GetCurrentFrameFromCompositor(); |
548 | 548 |
549 gfx::Rect gfx_rect(rect); | 549 gfx::Rect gfx_rect(rect); |
| 550 |
| 551 if (pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_90 || |
| 552 pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_270) { |
| 553 gfx_rect.set_size(gfx::Size(gfx_rect.size().height(), |
| 554 gfx_rect.size().width())); |
| 555 } |
| 556 |
550 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); | 557 skcanvas_video_renderer_.Paint(video_frame.get(), canvas, gfx_rect, alpha); |
551 } | 558 } |
552 | 559 |
553 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { | 560 bool WebMediaPlayerImpl::hasSingleSecurityOrigin() const { |
554 if (data_source_) | 561 if (data_source_) |
555 return data_source_->HasSingleOrigin(); | 562 return data_source_->HasSingleOrigin(); |
556 return true; | 563 return true; |
557 } | 564 } |
558 | 565 |
559 bool WebMediaPlayerImpl::didPassCORSAccessCheck() const { | 566 bool WebMediaPlayerImpl::didPassCORSAccessCheck() const { |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 | 946 |
940 pipeline_metadata_ = metadata; | 947 pipeline_metadata_ = metadata; |
941 | 948 |
942 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", | 949 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", |
943 metadata.video_rotation, | 950 metadata.video_rotation, |
944 media::VIDEO_ROTATION_MAX + 1); | 951 media::VIDEO_ROTATION_MAX + 1); |
945 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 952 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
946 | 953 |
947 if (hasVideo()) { | 954 if (hasVideo()) { |
948 DCHECK(!video_weblayer_); | 955 DCHECK(!video_weblayer_); |
949 video_weblayer_.reset( | 956 scoped_refptr<cc::VideoLayer> layer = |
950 new WebLayerImpl(cc::VideoLayer::Create(compositor_))); | 957 cc::VideoLayer::Create(compositor_, pipeline_metadata_.video_rotation); |
| 958 |
| 959 if (pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_90 || |
| 960 pipeline_metadata_.video_rotation == media::VIDEO_ROTATION_270) { |
| 961 gfx::Size size = pipeline_metadata_.natural_size; |
| 962 pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width()); |
| 963 } |
| 964 |
| 965 video_weblayer_.reset(new WebLayerImpl(layer)); |
951 video_weblayer_->setOpaque(opaque_); | 966 video_weblayer_->setOpaque(opaque_); |
952 client_->setWebLayer(video_weblayer_.get()); | 967 client_->setWebLayer(video_weblayer_.get()); |
953 } | 968 } |
954 } | 969 } |
955 | 970 |
956 void WebMediaPlayerImpl::OnPipelineBufferingStateChanged( | 971 void WebMediaPlayerImpl::OnPipelineBufferingStateChanged( |
957 media::BufferingState buffering_state) { | 972 media::BufferingState buffering_state) { |
958 DVLOG(1) << __FUNCTION__ << "(" << buffering_state << ")"; | 973 DVLOG(1) << __FUNCTION__ << "(" << buffering_state << ")"; |
959 | 974 |
960 // Ignore buffering state changes until we've completed all outstanding seeks. | 975 // Ignore buffering state changes until we've completed all outstanding seeks. |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 compositor_task_runner_->PostTask(FROM_HERE, | 1340 compositor_task_runner_->PostTask(FROM_HERE, |
1326 base::Bind(&GetCurrentFrameAndSignal, | 1341 base::Bind(&GetCurrentFrameAndSignal, |
1327 base::Unretained(compositor_), | 1342 base::Unretained(compositor_), |
1328 &video_frame, | 1343 &video_frame, |
1329 &event)); | 1344 &event)); |
1330 event.Wait(); | 1345 event.Wait(); |
1331 return video_frame; | 1346 return video_frame; |
1332 } | 1347 } |
1333 | 1348 |
1334 } // namespace content | 1349 } // namespace content |
OLD | NEW |