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

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

Issue 2718483003: Use base::Optional for selected video track. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ffmpeg_demuxer.h" 5 #include "media/filters/ffmpeg_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 } 1655 }
1656 } 1656 }
1657 for (const auto& stream : enabled_streams) { 1657 for (const auto& stream : enabled_streams) {
1658 DCHECK(stream); 1658 DCHECK(stream);
1659 DVLOG(1) << __func__ << ": enabling stream " << stream; 1659 DVLOG(1) << __func__ << ": enabling stream " << stream;
1660 stream->set_enabled(true, currTime); 1660 stream->set_enabled(true, currTime);
1661 } 1661 }
1662 } 1662 }
1663 1663
1664 void FFmpegDemuxer::OnSelectedVideoTrackChanged( 1664 void FFmpegDemuxer::OnSelectedVideoTrackChanged(
1665 const std::vector<MediaTrack::Id>& track_ids, 1665 base::Optional<MediaTrack::Id> track_id,
1666 base::TimeDelta currTime) { 1666 base::TimeDelta currTime) {
1667 DCHECK(task_runner_->BelongsToCurrentThread()); 1667 DCHECK(task_runner_->BelongsToCurrentThread());
1668 DCHECK_LE(track_ids.size(), 1u);
1669 1668
1670 FFmpegDemuxerStream* selected_stream = nullptr; 1669 FFmpegDemuxerStream* selected_stream = nullptr;
1671 if (!track_ids.empty()) { 1670 if (track_id) {
1672 selected_stream = track_id_to_demux_stream_map_[track_ids[0]]; 1671 selected_stream = track_id_to_demux_stream_map_[*track_id];
1673 DCHECK(selected_stream); 1672 DCHECK(selected_stream);
1674 DCHECK_EQ(DemuxerStream::VIDEO, selected_stream->type()); 1673 DCHECK_EQ(DemuxerStream::VIDEO, selected_stream->type());
1675 } 1674 }
1676 1675
1677 // First disable all streams that need to be disabled and then enable the 1676 // First disable all streams that need to be disabled and then enable the
1678 // stream that needs to be enabled (if any). 1677 // stream that needs to be enabled (if any).
1679 for (const auto& stream : streams_) { 1678 for (const auto& stream : streams_) {
1680 if (stream && stream->type() == DemuxerStream::VIDEO && 1679 if (stream && stream->type() == DemuxerStream::VIDEO &&
1681 stream.get() != selected_stream) { 1680 stream.get() != selected_stream) {
1682 DVLOG(1) << __func__ << ": disabling stream " << stream.get(); 1681 DVLOG(1) << __func__ << ": disabling stream " << stream.get();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1837 1836
1838 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1837 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1839 DCHECK(task_runner_->BelongsToCurrentThread()); 1838 DCHECK(task_runner_->BelongsToCurrentThread());
1840 for (const auto& stream : streams_) { 1839 for (const auto& stream : streams_) {
1841 if (stream) 1840 if (stream)
1842 stream->SetLiveness(liveness); 1841 stream->SetLiveness(liveness);
1843 } 1842 }
1844 } 1843 }
1845 1844
1846 } // namespace media 1845 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698