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

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

Issue 1812543003: Allow muting/unmuting audio through media track API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blink-sb-tracks6
Patch Set: Avoid ChunkDemuxer/PipelineImpl deadlock Created 4 years, 8 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.cc » ('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 <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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 558
558 return pipeline_metadata_.has_video; 559 return pipeline_metadata_.has_video;
559 } 560 }
560 561
561 bool WebMediaPlayerImpl::hasAudio() const { 562 bool WebMediaPlayerImpl::hasAudio() const {
562 DCHECK(main_task_runner_->BelongsToCurrentThread()); 563 DCHECK(main_task_runner_->BelongsToCurrentThread());
563 564
564 return pipeline_metadata_.has_audio; 565 return pipeline_metadata_.has_audio;
565 } 566 }
566 567
568 void WebMediaPlayerImpl::enabledAudioTracksChanged(
569 const blink::WebVector<blink::WebMediaPlayer::TrackId>& enabledTrackIds) {
570 DCHECK(main_task_runner_->BelongsToCurrentThread());
571 CHECK(demuxer_.get());
572
573 std::vector<const DemuxerStream*> enabledAudioStreams;
574 std::stringstream trackIdsStr;
575 for (const auto& trackId : enabledTrackIds) {
576 const DemuxerStream* s = demuxer_->GetDemuxerStreamByTrackId(trackId);
577 CHECK(s);
578 enabledAudioStreams.push_back(s);
579 trackIdsStr << trackId << " ";
580 }
581 MEDIA_LOG(INFO, media_log_)
582 << "WebMediaPlayerImpl::enabledAudioTracksChanged enabledTrackIds="
583 << trackIdsStr.str();
584 pipeline_.OnEnabledAudioStreamsChanged(enabledAudioStreams);
585 }
586
587 void WebMediaPlayerImpl::selectedVideoTrackChanged(
588 blink::WebMediaPlayer::TrackId* selectedTrackId) {
589 DCHECK(main_task_runner_->BelongsToCurrentThread());
590 CHECK(demuxer_.get());
591
592 const DemuxerStream* selectedVideoStream = nullptr;
593 if (selectedTrackId) {
594 selectedVideoStream = demuxer_->GetDemuxerStreamByTrackId(*selectedTrackId);
595 CHECK(selectedVideoStream);
596 MEDIA_LOG(INFO, media_log_)
597 << "WebMediaPlayerImpl::selectedVideoTrackChanged selectedTrackId="
598 << *selectedTrackId << " selectedVideoStream=" << selectedVideoStream;
599 } else {
600 MEDIA_LOG(INFO, media_log_) << "WebMediaPlayerImpl::"
601 "selectedVideoTrackChanged "
602 "selectedTrackId=none";
603 }
604 pipeline_.OnSelectedVideoStreamChanged(selectedVideoStream);
605 }
606
567 blink::WebSize WebMediaPlayerImpl::naturalSize() const { 607 blink::WebSize WebMediaPlayerImpl::naturalSize() const {
568 DCHECK(main_task_runner_->BelongsToCurrentThread()); 608 DCHECK(main_task_runner_->BelongsToCurrentThread());
569 609
570 return blink::WebSize(pipeline_metadata_.natural_size); 610 return blink::WebSize(pipeline_metadata_.natural_size);
571 } 611 }
572 612
573 bool WebMediaPlayerImpl::paused() const { 613 bool WebMediaPlayerImpl::paused() const {
574 DCHECK(main_task_runner_->BelongsToCurrentThread()); 614 DCHECK(main_task_runner_->BelongsToCurrentThread());
575 615
576 #if defined(OS_ANDROID) // WMPI_CAST 616 #if defined(OS_ANDROID) // WMPI_CAST
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } 860 }
821 861
822 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated( 862 void WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated(
823 scoped_ptr<MediaTracks> tracks) { 863 scoped_ptr<MediaTracks> tracks) {
824 // For MSE/chunk_demuxer case the media track updates are handled by 864 // For MSE/chunk_demuxer case the media track updates are handled by
825 // WebSourceBufferImpl. 865 // WebSourceBufferImpl.
826 DCHECK(demuxer_.get()); 866 DCHECK(demuxer_.get());
827 DCHECK(!chunk_demuxer_); 867 DCHECK(!chunk_demuxer_);
828 868
829 // Report the media track information to blink. 869 // Report the media track information to blink.
870 std::vector<blink::WebMediaPlayer::TrackId> blinkTrackIds;
830 for (const auto& track : tracks->tracks()) { 871 for (const auto& track : tracks->tracks()) {
831 if (track->type() == MediaTrack::Audio) { 872 if (track->type() == MediaTrack::Audio) {
832 auto track_id = client_->addAudioTrack( 873 auto track_id = client_->addAudioTrack(
833 blink::WebString::fromUTF8(track->id()), 874 blink::WebString::fromUTF8(track->id()),
834 blink::WebMediaPlayerClient::AudioTrackKindMain, 875 blink::WebMediaPlayerClient::AudioTrackKindMain,
835 blink::WebString::fromUTF8(track->label()), 876 blink::WebString::fromUTF8(track->label()),
836 blink::WebString::fromUTF8(track->language()), 877 blink::WebString::fromUTF8(track->language()),
837 /*enabled*/ true); 878 /*enabled*/ true);
838 (void)track_id; 879 blinkTrackIds.push_back(track_id);
839 } else if (track->type() == MediaTrack::Video) { 880 } else if (track->type() == MediaTrack::Video) {
840 auto track_id = client_->addVideoTrack( 881 auto track_id = client_->addVideoTrack(
841 blink::WebString::fromUTF8(track->id()), 882 blink::WebString::fromUTF8(track->id()),
842 blink::WebMediaPlayerClient::VideoTrackKindMain, 883 blink::WebMediaPlayerClient::VideoTrackKindMain,
843 blink::WebString::fromUTF8(track->label()), 884 blink::WebString::fromUTF8(track->label()),
844 blink::WebString::fromUTF8(track->language()), 885 blink::WebString::fromUTF8(track->language()),
845 /*selected*/ true); 886 /*selected*/ true);
846 (void)track_id; 887 blinkTrackIds.push_back(track_id);
847 } else { 888 } else {
848 // Text tracks are not supported through this code path yet. 889 // Text tracks are not supported through this code path yet.
849 NOTREACHED(); 890 NOTREACHED();
850 } 891 }
851 } 892 }
893
894 demuxer_->OnTrackIdsAssigned(*tracks.get(), blinkTrackIds);
852 } 895 }
853 896
854 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { 897 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
855 encrypted_client_->didBlockPlaybackWaitingForKey(); 898 encrypted_client_->didBlockPlaybackWaitingForKey();
856 899
857 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 900 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
858 // when a key has been successfully added (e.g. OnSessionKeysChange() with 901 // when a key has been successfully added (e.g. OnSessionKeysChange() with
859 // |has_additional_usable_key| = true). http://crbug.com/461903 902 // |has_additional_usable_key| = true). http://crbug.com/461903
860 encrypted_client_->didResumePlaybackBlockedForKey(); 903 encrypted_client_->didResumePlaybackBlockedForKey();
861 } 904 }
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 << ", Video: " << stats.video_memory_usage << ", DataSource: " 1635 << ", Video: " << stats.video_memory_usage << ", DataSource: "
1593 << (data_source_ ? data_source_->GetMemoryUsage() : 0) 1636 << (data_source_ ? data_source_->GetMemoryUsage() : 0)
1594 << ", Demuxer: " << demuxer_memory_usage; 1637 << ", Demuxer: " << demuxer_memory_usage;
1595 1638
1596 const int64_t delta = current_memory_usage - last_reported_memory_usage_; 1639 const int64_t delta = current_memory_usage - last_reported_memory_usage_;
1597 last_reported_memory_usage_ = current_memory_usage; 1640 last_reported_memory_usage_ = current_memory_usage;
1598 adjust_allocated_memory_cb_.Run(delta); 1641 adjust_allocated_memory_cb_.Run(delta);
1599 } 1642 }
1600 1643
1601 } // namespace media 1644 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/websourcebuffer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698