| OLD | NEW |
| 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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 // Some metadata is named differently in FFmpeg for webm files. | 1331 // Some metadata is named differently in FFmpeg for webm files. |
| 1332 if (strstr(format_context->iformat->name, "webm") || | 1332 if (strstr(format_context->iformat->name, "webm") || |
| 1333 strstr(format_context->iformat->name, "matroska")) { | 1333 strstr(format_context->iformat->name, "matroska")) { |
| 1334 // TODO(servolk): FFmpeg doesn't set stream->id correctly for webm files. | 1334 // TODO(servolk): FFmpeg doesn't set stream->id correctly for webm files. |
| 1335 // Need to fix that and use it as track id. crbug.com/323183 | 1335 // Need to fix that and use it as track id. crbug.com/323183 |
| 1336 track_id = | 1336 track_id = |
| 1337 static_cast<StreamParser::TrackId>(media_tracks->tracks().size() + 1); | 1337 static_cast<StreamParser::TrackId>(media_tracks->tracks().size() + 1); |
| 1338 track_label = streams_[i]->GetMetadata("title"); | 1338 track_label = streams_[i]->GetMetadata("title"); |
| 1339 } | 1339 } |
| 1340 | 1340 |
| 1341 if (codec_type == AVMEDIA_TYPE_AUDIO) { |
| 1342 streams_[i]->set_enabled(detected_audio_track_count == 1, |
| 1343 base::TimeDelta()); |
| 1344 } else if (codec_type == AVMEDIA_TYPE_VIDEO) { |
| 1345 streams_[i]->set_enabled(detected_video_track_count == 1, |
| 1346 base::TimeDelta()); |
| 1347 } |
| 1348 |
| 1341 if ((codec_type == AVMEDIA_TYPE_AUDIO && | 1349 if ((codec_type == AVMEDIA_TYPE_AUDIO && |
| 1342 media_tracks->getAudioConfig(track_id).IsValidConfig()) || | 1350 media_tracks->getAudioConfig(track_id).IsValidConfig()) || |
| 1343 (codec_type == AVMEDIA_TYPE_VIDEO && | 1351 (codec_type == AVMEDIA_TYPE_VIDEO && |
| 1344 media_tracks->getVideoConfig(track_id).IsValidConfig())) { | 1352 media_tracks->getVideoConfig(track_id).IsValidConfig())) { |
| 1345 MEDIA_LOG(INFO, media_log_) | 1353 MEDIA_LOG(INFO, media_log_) |
| 1346 << GetDisplayName() | 1354 << GetDisplayName() |
| 1347 << ": skipping duplicate media stream id=" << track_id; | 1355 << ": skipping duplicate media stream id=" << track_id; |
| 1348 continue; | 1356 continue; |
| 1349 } | 1357 } |
| 1350 | 1358 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 void FFmpegDemuxer::OnEnabledAudioTracksChanged( | 1657 void FFmpegDemuxer::OnEnabledAudioTracksChanged( |
| 1650 const std::vector<MediaTrack::Id>& track_ids, | 1658 const std::vector<MediaTrack::Id>& track_ids, |
| 1651 base::TimeDelta curr_time) { | 1659 base::TimeDelta curr_time) { |
| 1652 DCHECK(task_runner_->BelongsToCurrentThread()); | 1660 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1653 | 1661 |
| 1654 std::set<FFmpegDemuxerStream*> enabled_streams; | 1662 std::set<FFmpegDemuxerStream*> enabled_streams; |
| 1655 for (const auto& id : track_ids) { | 1663 for (const auto& id : track_ids) { |
| 1656 FFmpegDemuxerStream* stream = track_id_to_demux_stream_map_[id]; | 1664 FFmpegDemuxerStream* stream = track_id_to_demux_stream_map_[id]; |
| 1657 DCHECK(stream); | 1665 DCHECK(stream); |
| 1658 DCHECK_EQ(DemuxerStream::AUDIO, stream->type()); | 1666 DCHECK_EQ(DemuxerStream::AUDIO, stream->type()); |
| 1667 // TODO(servolk): Remove after multiple enabled audio tracks are supported |
| 1668 // by the media::RendererImpl. |
| 1669 if (!enabled_streams.empty()) { |
| 1670 MEDIA_LOG(INFO, media_log_) |
| 1671 << "Only one enabled audio track is supported, ignoring track " << id; |
| 1672 continue; |
| 1673 } |
| 1659 enabled_streams.insert(stream); | 1674 enabled_streams.insert(stream); |
| 1660 } | 1675 } |
| 1661 | 1676 |
| 1662 // First disable all streams that need to be disabled and then enable streams | 1677 // First disable all streams that need to be disabled and then enable streams |
| 1663 // that are enabled. | 1678 // that are enabled. |
| 1664 for (const auto& stream : streams_) { | 1679 for (const auto& stream : streams_) { |
| 1665 if (stream && stream->type() == DemuxerStream::AUDIO && | 1680 if (stream && stream->type() == DemuxerStream::AUDIO && |
| 1666 enabled_streams.find(stream.get()) == enabled_streams.end()) { | 1681 enabled_streams.find(stream.get()) == enabled_streams.end()) { |
| 1667 DVLOG(1) << __func__ << ": disabling stream " << stream.get(); | 1682 DVLOG(1) << __func__ << ": disabling stream " << stream.get(); |
| 1668 stream->set_enabled(false, curr_time); | 1683 stream->set_enabled(false, curr_time); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 | 1867 |
| 1853 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1868 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
| 1854 DCHECK(task_runner_->BelongsToCurrentThread()); | 1869 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1855 for (const auto& stream : streams_) { | 1870 for (const auto& stream : streams_) { |
| 1856 if (stream) | 1871 if (stream) |
| 1857 stream->SetLiveness(liveness); | 1872 stream->SetLiveness(liveness); |
| 1858 } | 1873 } |
| 1859 } | 1874 } |
| 1860 | 1875 |
| 1861 } // namespace media | 1876 } // namespace media |
| OLD | NEW |