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

Side by Side Diff: media/filters/media_source_state.cc

Issue 2170303002: Make MSE buffer sizes configurable via command line (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback Created 4 years, 4 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
« media/base/media_switches.cc ('K') | « media/base/media_switches.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/filters/media_source_state.h" 5 #include "media/filters/media_source_state.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/command_line.h"
8 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "media/base/media_switches.h"
9 #include "media/base/media_track.h" 12 #include "media/base/media_track.h"
10 #include "media/base/media_tracks.h" 13 #include "media/base/media_tracks.h"
11 #include "media/filters/chunk_demuxer.h" 14 #include "media/filters/chunk_demuxer.h"
12 #include "media/filters/frame_processor.h" 15 #include "media/filters/frame_processor.h"
13 #include "media/filters/source_buffer_stream.h" 16 #include "media/filters/source_buffer_stream.h"
14 17
15 namespace media { 18 namespace media {
16 19
17 enum { 20 enum {
18 // Limits the number of MEDIA_LOG() calls warning the user that a muxed stream 21 // Limits the number of MEDIA_LOG() calls warning the user that a muxed stream
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 if (audio_config.IsValidConfig()) { 569 if (audio_config.IsValidConfig()) {
567 if (!audio_) { 570 if (!audio_) {
568 media_log_->SetBooleanProperty("found_audio_stream", true); 571 media_log_->SetBooleanProperty("found_audio_stream", true);
569 } 572 }
570 if (!audio_ || 573 if (!audio_ ||
571 audio_->audio_decoder_config().codec() != audio_config.codec()) { 574 audio_->audio_decoder_config().codec() != audio_config.codec()) {
572 media_log_->SetStringProperty("audio_codec_name", 575 media_log_->SetStringProperty("audio_codec_name",
573 GetCodecName(audio_config.codec())); 576 GetCodecName(audio_config.codec()));
574 } 577 }
575 578
579 bool audio_stream_just_created = false;
576 if (!audio_) { 580 if (!audio_) {
577 audio_ = create_demuxer_stream_cb_.Run(DemuxerStream::AUDIO); 581 audio_ = create_demuxer_stream_cb_.Run(DemuxerStream::AUDIO);
578 582
579 if (!audio_) { 583 if (!audio_) {
580 DVLOG(1) << "Failed to create an audio stream."; 584 DVLOG(1) << "Failed to create an audio stream.";
581 return false; 585 return false;
582 } 586 }
587 audio_stream_just_created = true;
583 588
584 if (!frame_processor_->AddTrack(FrameProcessor::kAudioTrackId, audio_)) { 589 if (!frame_processor_->AddTrack(FrameProcessor::kAudioTrackId, audio_)) {
585 DVLOG(1) << "Failed to add audio track to frame processor."; 590 DVLOG(1) << "Failed to add audio track to frame processor.";
586 return false; 591 return false;
587 } 592 }
588 } 593 }
589 594
590 frame_processor_->OnPossibleAudioConfigUpdate(audio_config); 595 frame_processor_->OnPossibleAudioConfigUpdate(audio_config);
591 success &= audio_->UpdateAudioConfig(audio_config, media_log_); 596 success &= audio_->UpdateAudioConfig(audio_config, media_log_);
597
598 if (audio_stream_just_created) {
alokp 2016/07/29 21:36:21 can you just move this into "if (!audio_)" block a
servolk 2016/07/29 22:14:10 I tried that (see earlier patchsets), but this nee
alokp 2016/07/30 00:08:26 OK. Although I would prefer the buffer size limits
599 std::string audioBufferSwitchStr =
alokp 2016/07/29 21:36:21 variable names do not follow chromium style guide.
servolk 2016/07/29 22:14:10 Done.
600 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
601 switches::kMSEAudioBufferSizeLimit);
602 unsigned mseAudioBufferSizeLimit = 0;
alokp 2016/07/29 21:36:21 variable name
servolk 2016/07/29 22:14:10 Done.
603 if (base::StringToUint(audioBufferSwitchStr, &mseAudioBufferSizeLimit) &&
604 mseAudioBufferSizeLimit > 0) {
605 MEDIA_LOG(INFO, media_log_) << "Custom MSE audio SourceBuffer size="
606 << mseAudioBufferSizeLimit;
607 audio_->SetStreamMemoryLimit(mseAudioBufferSizeLimit);
608 }
609 }
592 } 610 }
593 611
594 if (video_config.IsValidConfig()) { 612 if (video_config.IsValidConfig()) {
595 if (!video_) { 613 if (!video_) {
596 media_log_->SetBooleanProperty("found_video_stream", true); 614 media_log_->SetBooleanProperty("found_video_stream", true);
597 } 615 }
598 if (!video_ || 616 if (!video_ ||
599 video_->video_decoder_config().codec() != video_config.codec()) { 617 video_->video_decoder_config().codec() != video_config.codec()) {
600 media_log_->SetStringProperty("video_codec_name", 618 media_log_->SetStringProperty("video_codec_name",
601 GetCodecName(video_config.codec())); 619 GetCodecName(video_config.codec()));
602 } 620 }
603 621
622 bool video_stream_just_created = false;
alokp 2016/07/29 21:36:21 ditto
servolk 2016/07/29 22:14:10 Done.
604 if (!video_) { 623 if (!video_) {
605 video_ = create_demuxer_stream_cb_.Run(DemuxerStream::VIDEO); 624 video_ = create_demuxer_stream_cb_.Run(DemuxerStream::VIDEO);
606 625
607 if (!video_) { 626 if (!video_) {
608 DVLOG(1) << "Failed to create a video stream."; 627 DVLOG(1) << "Failed to create a video stream.";
609 return false; 628 return false;
610 } 629 }
630 video_stream_just_created = true;
611 631
612 if (!frame_processor_->AddTrack(FrameProcessor::kVideoTrackId, video_)) { 632 if (!frame_processor_->AddTrack(FrameProcessor::kVideoTrackId, video_)) {
613 DVLOG(1) << "Failed to add video track to frame processor."; 633 DVLOG(1) << "Failed to add video track to frame processor.";
614 return false; 634 return false;
615 } 635 }
616 } 636 }
617 637
618 success &= video_->UpdateVideoConfig(video_config, media_log_); 638 success &= video_->UpdateVideoConfig(video_config, media_log_);
639
640 if (video_stream_just_created) {
641 std::string videoBufferSwitchStr =
642 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
643 switches::kMSEVideoBufferSizeLimit);
644 unsigned mseVideoBufferSizeLimit = 0;
645 if (base::StringToUint(videoBufferSwitchStr, &mseVideoBufferSizeLimit) &&
646 mseVideoBufferSizeLimit > 0) {
647 MEDIA_LOG(INFO, media_log_) << "Custom MSE video SourceBuffer size="
648 << mseVideoBufferSizeLimit;
649 video_->SetStreamMemoryLimit(mseVideoBufferSizeLimit);
650 }
651 }
619 } 652 }
620 653
621 typedef StreamParser::TextTrackConfigMap::const_iterator TextConfigItr; 654 typedef StreamParser::TextTrackConfigMap::const_iterator TextConfigItr;
622 if (text_stream_map_.empty()) { 655 if (text_stream_map_.empty()) {
623 for (TextConfigItr itr = text_configs.begin(); itr != text_configs.end(); 656 for (TextConfigItr itr = text_configs.begin(); itr != text_configs.end();
624 ++itr) { 657 ++itr) {
625 ChunkDemuxerStream* const text_stream = 658 ChunkDemuxerStream* const text_stream =
626 create_demuxer_stream_cb_.Run(DemuxerStream::TEXT); 659 create_demuxer_stream_cb_.Run(DemuxerStream::TEXT);
627 if (!frame_processor_->AddTrack(itr->first, text_stream)) { 660 if (!frame_processor_->AddTrack(itr->first, text_stream)) {
628 success &= false; 661 success &= false;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 825
793 void MediaSourceState::OnSourceInitDone( 826 void MediaSourceState::OnSourceInitDone(
794 const StreamParser::InitParameters& params) { 827 const StreamParser::InitParameters& params) {
795 DCHECK_EQ(state_, PENDING_PARSER_INIT); 828 DCHECK_EQ(state_, PENDING_PARSER_INIT);
796 state_ = PARSER_INITIALIZED; 829 state_ = PARSER_INITIALIZED;
797 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset; 830 auto_update_timestamp_offset_ = params.auto_update_timestamp_offset;
798 base::ResetAndReturn(&init_cb_).Run(params); 831 base::ResetAndReturn(&init_cb_).Run(params);
799 } 832 }
800 833
801 } // namespace media 834 } // namespace media
OLDNEW
« media/base/media_switches.cc ('K') | « media/base/media_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698