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

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

Issue 1735803002: Implemented passing media track info from ffmpeg into blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wolenetz@ CR feedback + better track info extraction in ffmpeg Created 4 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
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/websourcebuffer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } 836 }
837 837
838 // TODO(xhwang): Update this UMA name. 838 // TODO(xhwang): Update this UMA name.
839 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); 839 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1);
840 840
841 encrypted_client_->encrypted( 841 encrypted_client_->encrypted(
842 ConvertToWebInitDataType(init_data_type), init_data.data(), 842 ConvertToWebInitDataType(init_data_type), init_data.data(),
843 base::saturated_cast<unsigned int>(init_data.size())); 843 base::saturated_cast<unsigned int>(init_data.size()));
844 } 844 }
845 845
846 void WebMediaPlayerImpl::OnMediaTracksUpdated(scoped_ptr<MediaTracks> tracks) {
847 // For MSE/chunk_demuxer case the media tracks should be handled by WSBI
848 DCHECK(!chunk_demuxer_);
849 DCHECK(client_);
850
851 // Remove the old tracks first, if any were present
852 while (!blink_audio_tracks_.empty()) {
853 client_->removeAudioTrack(blink_audio_tracks_[0]);
854 blink_audio_tracks_.erase(blink_audio_tracks_.begin());
855 }
856 while (!blink_video_tracks_.empty()) {
857 client_->removeVideoTrack(blink_video_tracks_[0]);
858 blink_audio_tracks_.erase(blink_audio_tracks_.begin());
859 }
860
861 // Now report the new media tracks to blink
862 for (const auto& track : tracks->tracks()) {
863 if (track->type() == MediaTrack::Audio) {
864 auto track_id = client_->addAudioTrack(
865 blink::WebString::fromUTF8(track->id()),
866 blink::WebMediaPlayerClient::AudioTrackKindMain,
867 blink::WebString::fromUTF8(track->label()),
868 blink::WebString::fromUTF8(track->language()),
869 /*enabled*/ true);
870 blink_audio_tracks_.push_back(track_id);
871 } else if (track->type() == MediaTrack::Video) {
872 auto track_id = client_->addVideoTrack(
873 blink::WebString::fromUTF8(track->id()),
874 blink::WebMediaPlayerClient::VideoTrackKindMain,
875 blink::WebString::fromUTF8(track->label()),
876 blink::WebString::fromUTF8(track->language()),
877 /*selected*/ true);
878 blink_video_tracks_.push_back(track_id);
879 } else {
880 // Text tracks are not supported yet.
881 NOTREACHED();
882 }
883 }
884 }
885
846 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { 886 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
847 encrypted_client_->didBlockPlaybackWaitingForKey(); 887 encrypted_client_->didBlockPlaybackWaitingForKey();
848 888
849 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 889 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
850 // when a key has been successfully added (e.g. OnSessionKeysChange() with 890 // when a key has been successfully added (e.g. OnSessionKeysChange() with
851 // |has_additional_usable_key| = true). http://crbug.com/461903 891 // |has_additional_usable_key| = true). http://crbug.com/461903
852 encrypted_client_->didResumePlaybackBlockedForKey(); 892 encrypted_client_->didResumePlaybackBlockedForKey();
853 } 893 }
854 894
855 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb, 895 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb,
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 media_task_runner_, worker_task_runner_, audio_source_provider_.get(), 1404 media_task_runner_, worker_task_runner_, audio_source_provider_.get(),
1365 compositor_, request_surface_cb); 1405 compositor_, request_surface_cb);
1366 } 1406 }
1367 1407
1368 void WebMediaPlayerImpl::StartPipeline() { 1408 void WebMediaPlayerImpl::StartPipeline() {
1369 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1409 DCHECK(main_task_runner_->BelongsToCurrentThread());
1370 1410
1371 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = 1411 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb =
1372 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData); 1412 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData);
1373 1413
1414 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb =
1415 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnMediaTracksUpdated);
1416
1374 // Figure out which demuxer to use. 1417 // Figure out which demuxer to use.
1375 if (load_type_ != LoadTypeMediaSource) { 1418 if (load_type_ != LoadTypeMediaSource) {
1376 DCHECK(!chunk_demuxer_); 1419 DCHECK(!chunk_demuxer_);
1377 DCHECK(data_source_); 1420 DCHECK(data_source_);
1378 1421
1379 #if !defined(MEDIA_DISABLE_FFMPEG) 1422 #if !defined(MEDIA_DISABLE_FFMPEG)
1380 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), 1423 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(),
1381 encrypted_media_init_data_cb, media_log_)); 1424 encrypted_media_init_data_cb,
1425 media_tracks_updated_cb, media_log_));
1382 #else 1426 #else
1383 OnPipelineError(PipelineStatus::DEMUXER_ERROR_COULD_NOT_OPEN); 1427 OnPipelineError(PipelineStatus::DEMUXER_ERROR_COULD_NOT_OPEN);
1384 return; 1428 return;
1385 #endif 1429 #endif
1386 } else { 1430 } else {
1387 DCHECK(!chunk_demuxer_); 1431 DCHECK(!chunk_demuxer_);
1388 DCHECK(!data_source_); 1432 DCHECK(!data_source_);
1389 1433
1390 chunk_demuxer_ = new ChunkDemuxer( 1434 chunk_demuxer_ = new ChunkDemuxer(
1391 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), 1435 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened),
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1624 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1581 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1625 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1582 << ", Demuxer: " << demuxer_memory_usage; 1626 << ", Demuxer: " << demuxer_memory_usage;
1583 1627
1584 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1628 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1585 last_reported_memory_usage_ = current_memory_usage; 1629 last_reported_memory_usage_ = current_memory_usage;
1586 adjust_allocated_memory_cb_.Run(delta); 1630 adjust_allocated_memory_cb_.Run(delta);
1587 } 1631 }
1588 1632
1589 } // namespace media 1633 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/websourcebuffer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698