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 <sstream> | |
10 #include <string> | 11 #include <string> |
11 #include <utility> | 12 #include <utility> |
12 | 13 |
13 #include "base/bind.h" | 14 #include "base/bind.h" |
14 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
15 #include "base/callback.h" | 16 #include "base/callback.h" |
16 #include "base/callback_helpers.h" | 17 #include "base/callback_helpers.h" |
17 #include "base/command_line.h" | 18 #include "base/command_line.h" |
18 #include "base/debug/alias.h" | 19 #include "base/debug/alias.h" |
19 #include "base/debug/crash_logging.h" | 20 #include "base/debug/crash_logging.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h" | 53 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h" |
53 #include "third_party/WebKit/public/platform/WebMediaSource.h" | 54 #include "third_party/WebKit/public/platform/WebMediaSource.h" |
54 #include "third_party/WebKit/public/platform/WebRect.h" | 55 #include "third_party/WebKit/public/platform/WebRect.h" |
55 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 56 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
56 #include "third_party/WebKit/public/platform/WebSize.h" | 57 #include "third_party/WebKit/public/platform/WebSize.h" |
57 #include "third_party/WebKit/public/platform/WebString.h" | 58 #include "third_party/WebKit/public/platform/WebString.h" |
58 #include "third_party/WebKit/public/platform/WebURL.h" | 59 #include "third_party/WebKit/public/platform/WebURL.h" |
59 #include "third_party/WebKit/public/web/WebDocument.h" | 60 #include "third_party/WebKit/public/web/WebDocument.h" |
60 #include "third_party/WebKit/public/web/WebFrame.h" | 61 #include "third_party/WebKit/public/web/WebFrame.h" |
61 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 62 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
63 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | |
62 #include "third_party/WebKit/public/web/WebView.h" | 64 #include "third_party/WebKit/public/web/WebView.h" |
63 | 65 |
64 using blink::WebCanvas; | 66 using blink::WebCanvas; |
65 using blink::WebMediaPlayer; | 67 using blink::WebMediaPlayer; |
66 using blink::WebRect; | 68 using blink::WebRect; |
67 using blink::WebSize; | 69 using blink::WebSize; |
68 using blink::WebString; | 70 using blink::WebString; |
69 using gpu::gles2::GLES2Interface; | 71 using gpu::gles2::GLES2Interface; |
70 | 72 |
71 #define STATIC_ASSERT_ENUM(a, b) \ | 73 #define STATIC_ASSERT_ENUM(a, b) \ |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
560 | 562 |
561 return pipeline_metadata_.has_video; | 563 return pipeline_metadata_.has_video; |
562 } | 564 } |
563 | 565 |
564 bool WebMediaPlayerImpl::hasAudio() const { | 566 bool WebMediaPlayerImpl::hasAudio() const { |
565 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 567 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
566 | 568 |
567 return pipeline_metadata_.has_audio; | 569 return pipeline_metadata_.has_audio; |
568 } | 570 } |
569 | 571 |
572 void WebMediaPlayerImpl::enabledAudioTracksChanged( | |
573 const blink::WebVector<blink::WebMediaPlayer::TrackId>& enabledTrackIds) { | |
574 DCHECK(main_task_runner_->BelongsToCurrentThread()); | |
575 CHECK(demuxer_.get()); | |
576 | |
577 std::vector<const DemuxerStream*> enabledAudioStreams; | |
578 std::stringstream trackIdsStr; | |
579 for (const auto& trackId : enabledTrackIds) { | |
580 const DemuxerStream* s = demuxer_->GetDemuxerStreamByTrackId(trackId); | |
581 DCHECK(s); | |
582 enabledAudioStreams.push_back(s); | |
583 trackIdsStr << trackId << " "; | |
584 } | |
585 DVLOG(5) << "WMPI::enabledAudioTracksChanged enabledTrackIds=" | |
wolenetz
2016/03/30 00:31:32
This seems appropriate for a MEDIA_LOG(INFO,...) e
servolk
2016/03/30 01:13:12
Done.
| |
586 << trackIdsStr.str(); | |
587 pipeline_.OnEnabledAudioStreamsChanged(enabledAudioStreams); | |
588 } | |
589 | |
590 void WebMediaPlayerImpl::selectedVideoTrackChanged( | |
591 blink::WebMediaPlayer::TrackId* selectedTrackId) { | |
592 DCHECK(main_task_runner_->BelongsToCurrentThread()); | |
593 CHECK(demuxer_.get()); | |
594 | |
595 const DemuxerStream* selectedVideoStream = nullptr; | |
596 if (selectedTrackId) { | |
597 DVLOG(5) << "WMPI::selectedVideoTrackChanged selectedTrackId=" | |
wolenetz
2016/03/30 00:31:32
ditto
servolk
2016/03/30 01:13:12
Done.
| |
598 << *selectedTrackId; | |
599 demuxer_->GetDemuxerStreamByTrackId(*selectedTrackId); | |
600 } else { | |
601 DVLOG(5) << "WMPI::selectedVideoTrackChanged selectedTrackId=<none>"; | |
wolenetz
2016/03/30 00:31:32
ditto
servolk
2016/03/30 01:13:13
Done.
| |
602 } | |
603 pipeline_.OnSelectedVideoStreamChanged(selectedVideoStream); | |
604 } | |
605 | |
570 blink::WebSize WebMediaPlayerImpl::naturalSize() const { | 606 blink::WebSize WebMediaPlayerImpl::naturalSize() const { |
571 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 607 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
572 | 608 |
573 return blink::WebSize(pipeline_metadata_.natural_size); | 609 return blink::WebSize(pipeline_metadata_.natural_size); |
574 } | 610 } |
575 | 611 |
576 bool WebMediaPlayerImpl::paused() const { | 612 bool WebMediaPlayerImpl::paused() const { |
577 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 613 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
578 | 614 |
579 #if defined(OS_ANDROID) // WMPI_CAST | 615 #if defined(OS_ANDROID) // WMPI_CAST |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 base::saturated_cast<unsigned int>(init_data.size())); | 852 base::saturated_cast<unsigned int>(init_data.size())); |
817 } | 853 } |
818 | 854 |
819 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( | 855 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( |
820 scoped_ptr<MediaTracks> tracks) { | 856 scoped_ptr<MediaTracks> tracks) { |
821 // For MSE/chunk_demuxer case the media track updates are handled by | 857 // For MSE/chunk_demuxer case the media track updates are handled by |
822 // WebSourceBufferImpl. | 858 // WebSourceBufferImpl. |
823 DCHECK(demuxer_.get()); | 859 DCHECK(demuxer_.get()); |
824 DCHECK(!chunk_demuxer_); | 860 DCHECK(!chunk_demuxer_); |
825 | 861 |
862 if (!blink::WebRuntimeFeatures::audioVideoTracksEnabled()) | |
863 return; | |
864 | |
826 // Report the media track information to blink. | 865 // Report the media track information to blink. |
827 for (const auto& track : tracks->tracks()) { | 866 for (const auto& track : tracks->tracks()) { |
828 if (track->type() == MediaTrack::Audio) { | 867 if (track->type() == MediaTrack::Audio) { |
829 auto track_id = client_->addAudioTrack( | 868 auto track_id = client_->addAudioTrack( |
830 blink::WebString::fromUTF8(track->id()), | 869 blink::WebString::fromUTF8(track->id()), |
831 blink::WebMediaPlayerClient::AudioTrackKindMain, | 870 blink::WebMediaPlayerClient::AudioTrackKindMain, |
832 blink::WebString::fromUTF8(track->label()), | 871 blink::WebString::fromUTF8(track->label()), |
833 blink::WebString::fromUTF8(track->language()), | 872 blink::WebString::fromUTF8(track->language()), |
834 /*enabled*/ true); | 873 /*enabled*/ true); |
835 (void)track_id; | 874 demuxer_->OnTrackIdAssigned(track_id, track.get()); |
836 } else if (track->type() == MediaTrack::Video) { | 875 } else if (track->type() == MediaTrack::Video) { |
837 auto track_id = client_->addVideoTrack( | 876 auto track_id = client_->addVideoTrack( |
838 blink::WebString::fromUTF8(track->id()), | 877 blink::WebString::fromUTF8(track->id()), |
839 blink::WebMediaPlayerClient::VideoTrackKindMain, | 878 blink::WebMediaPlayerClient::VideoTrackKindMain, |
840 blink::WebString::fromUTF8(track->label()), | 879 blink::WebString::fromUTF8(track->label()), |
841 blink::WebString::fromUTF8(track->language()), | 880 blink::WebString::fromUTF8(track->language()), |
842 /*selected*/ true); | 881 /*selected*/ true); |
843 (void)track_id; | 882 demuxer_->OnTrackIdAssigned(track_id, track.get()); |
844 } else { | 883 } else { |
845 // Text tracks are not supported through this code path yet. | 884 // Text tracks are not supported through this code path yet. |
846 NOTREACHED(); | 885 NOTREACHED(); |
847 } | 886 } |
848 } | 887 } |
849 } | 888 } |
850 | 889 |
851 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { | 890 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { |
852 encrypted_client_->didBlockPlaybackWaitingForKey(); | 891 encrypted_client_->didBlockPlaybackWaitingForKey(); |
853 | 892 |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 bool WebMediaPlayerImpl::IsAutomaticResumeAllowed() { | 1591 bool WebMediaPlayerImpl::IsAutomaticResumeAllowed() { |
1553 #if defined(OS_ANDROID) | 1592 #if defined(OS_ANDROID) |
1554 return !hasVideo() || (delegate_ && !delegate_->IsHidden()); | 1593 return !hasVideo() || (delegate_ && !delegate_->IsHidden()); |
1555 #else | 1594 #else |
1556 // On non-Android platforms Resume() is always allowed. | 1595 // On non-Android platforms Resume() is always allowed. |
1557 return true; | 1596 return true; |
1558 #endif | 1597 #endif |
1559 } | 1598 } |
1560 | 1599 |
1561 } // namespace media | 1600 } // namespace media |
OLD | NEW |