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