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 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
847 ConvertToWebInitDataType(init_data_type), init_data.data(), | 847 ConvertToWebInitDataType(init_data_type), init_data.data(), |
848 base::saturated_cast<unsigned int>(init_data.size())); | 848 base::saturated_cast<unsigned int>(init_data.size())); |
849 } | 849 } |
850 | 850 |
851 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( | 851 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( |
852 scoped_ptr<MediaTracks> tracks) { | 852 scoped_ptr<MediaTracks> tracks) { |
853 // For MSE/chunk_demuxer case the media track updates are handled by | 853 // For MSE/chunk_demuxer case the media track updates are handled by |
854 // WebSourceBufferImpl. | 854 // WebSourceBufferImpl. |
855 DCHECK(demuxer_.get()); | 855 DCHECK(demuxer_.get()); |
856 DCHECK(!chunk_demuxer_); | 856 DCHECK(!chunk_demuxer_); |
857 DCHECK(client_); | |
wolenetz
2016/03/11 23:19:54
nit: are you aware of any path, in any WMPI method
servolk
2016/03/18 18:36:42
Good point, indeed the client_ is set only once in
| |
858 | |
859 // Remove the old tracks first, if any were present | |
wolenetz
2016/03/11 23:19:54
I'm not aware of any code path that allows multipl
servolk
2016/03/18 18:36:42
Yes, currently FFmpeg tracks are only going to be
| |
860 while (!blink_audio_tracks_.empty()) { | |
861 client_->removeAudioTrack(blink_audio_tracks_[0]); | |
862 blink_audio_tracks_.erase(blink_audio_tracks_.begin()); | |
863 } | |
864 while (!blink_video_tracks_.empty()) { | |
865 client_->removeVideoTrack(blink_video_tracks_[0]); | |
866 blink_audio_tracks_.erase(blink_audio_tracks_.begin()); | |
867 } | |
868 | |
869 // Now report the new media tracks to blink | |
870 for (const auto& track : tracks->tracks()) { | |
871 if (track->type() == MediaTrack::Audio) { | |
872 auto track_id = client_->addAudioTrack( | |
873 blink::WebString::fromUTF8(track->id()), | |
874 blink::WebMediaPlayerClient::AudioTrackKindMain, | |
875 blink::WebString::fromUTF8(track->label()), | |
876 blink::WebString::fromUTF8(track->language()), | |
877 /*enabled*/ true); | |
878 blink_audio_tracks_.push_back(track_id); | |
879 } else if (track->type() == MediaTrack::Video) { | |
880 auto track_id = client_->addVideoTrack( | |
881 blink::WebString::fromUTF8(track->id()), | |
882 blink::WebMediaPlayerClient::VideoTrackKindMain, | |
883 blink::WebString::fromUTF8(track->label()), | |
884 blink::WebString::fromUTF8(track->language()), | |
885 /*selected*/ true); | |
886 blink_video_tracks_.push_back(track_id); | |
887 } else { | |
888 // Text tracks are not supported yet. | |
889 NOTREACHED(); | |
890 } | |
891 } | |
857 } | 892 } |
858 | 893 |
859 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { | 894 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { |
860 encrypted_client_->didBlockPlaybackWaitingForKey(); | 895 encrypted_client_->didBlockPlaybackWaitingForKey(); |
861 | 896 |
862 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called | 897 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called |
863 // when a key has been successfully added (e.g. OnSessionKeysChange() with | 898 // when a key has been successfully added (e.g. OnSessionKeysChange() with |
864 // |has_additional_usable_key| = true). http://crbug.com/461903 | 899 // |has_additional_usable_key| = true). http://crbug.com/461903 |
865 encrypted_client_->didResumePlaybackBlockedForKey(); | 900 encrypted_client_->didResumePlaybackBlockedForKey(); |
866 } | 901 } |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1610 << ", Video: " << stats.video_memory_usage << ", DataSource: " | 1645 << ", Video: " << stats.video_memory_usage << ", DataSource: " |
1611 << (data_source_ ? data_source_->GetMemoryUsage() : 0) | 1646 << (data_source_ ? data_source_->GetMemoryUsage() : 0) |
1612 << ", Demuxer: " << demuxer_memory_usage; | 1647 << ", Demuxer: " << demuxer_memory_usage; |
1613 | 1648 |
1614 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 1649 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
1615 last_reported_memory_usage_ = current_memory_usage; | 1650 last_reported_memory_usage_ = current_memory_usage; |
1616 adjust_allocated_memory_cb_.Run(delta); | 1651 adjust_allocated_memory_cb_.Run(delta); |
1617 } | 1652 } |
1618 | 1653 |
1619 } // namespace media | 1654 } // namespace media |
OLD | NEW |