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