Chromium Code Reviews| 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 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1516 } | 1516 } |
| 1517 } | 1517 } |
| 1518 params.SetBoolean("found_audio_stream", (audio_track_count > 0)); | 1518 params.SetBoolean("found_audio_stream", (audio_track_count > 0)); |
| 1519 params.SetBoolean("found_video_stream", (video_track_count > 0)); | 1519 params.SetBoolean("found_video_stream", (video_track_count > 0)); |
| 1520 SetTimeProperty(metadata_event.get(), "max_duration", max_duration); | 1520 SetTimeProperty(metadata_event.get(), "max_duration", max_duration); |
| 1521 SetTimeProperty(metadata_event.get(), "start_time", start_time_); | 1521 SetTimeProperty(metadata_event.get(), "start_time", start_time_); |
| 1522 metadata_event->params.SetInteger("bitrate", bitrate_); | 1522 metadata_event->params.SetInteger("bitrate", bitrate_); |
| 1523 media_log_->AddEvent(std::move(metadata_event)); | 1523 media_log_->AddEvent(std::move(metadata_event)); |
| 1524 } | 1524 } |
| 1525 | 1525 |
| 1526 FFmpegDemuxerStream* FFmpegDemuxer::FindPreferredStreamForSeeking( | 1526 FFmpegDemuxerStream* FFmpegDemuxer::FindPreferredStreamForSeeking( |
|
DaleCurtis
2016/12/05 22:18:08
Does this code really need to care about disabled
servolk
2016/12/05 22:24:00
I think we do need to care about disabled streams
| |
| 1527 base::TimeDelta seek_time) { | 1527 base::TimeDelta seek_time) { |
| 1528 // If we have a selected/enabled video stream and its start time is lower | 1528 // If we have a selected/enabled video stream and its start time is lower |
| 1529 // than the |seek_time| or unknown, then always prefer it for seeking. | 1529 // than the |seek_time| or unknown, then always prefer it for seeking. |
| 1530 FFmpegDemuxerStream* video_stream = nullptr; | 1530 FFmpegDemuxerStream* video_stream = nullptr; |
| 1531 for (const auto& stream : streams_) { | 1531 for (const auto& stream : streams_) { |
| 1532 if (stream && stream->type() == DemuxerStream::VIDEO && stream->enabled()) { | 1532 if (stream && stream->type() == DemuxerStream::VIDEO && stream->enabled()) { |
| 1533 video_stream = stream.get(); | 1533 video_stream = stream.get(); |
| 1534 if (video_stream->start_time() == kNoTimestamp || | 1534 if (video_stream->start_time() == kNoTimestamp || |
| 1535 video_stream->start_time() <= seek_time) { | 1535 video_stream->start_time() <= seek_time) { |
| 1536 return video_stream; | 1536 return video_stream; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1550 lowest_start_time_stream = stream.get(); | 1550 lowest_start_time_stream = stream.get(); |
| 1551 } | 1551 } |
| 1552 } | 1552 } |
| 1553 // If we found a stream with start time lower than |seek_time|, then use it. | 1553 // If we found a stream with start time lower than |seek_time|, then use it. |
| 1554 if (lowest_start_time_stream && | 1554 if (lowest_start_time_stream && |
| 1555 lowest_start_time_stream->start_time() <= seek_time) { | 1555 lowest_start_time_stream->start_time() <= seek_time) { |
| 1556 return lowest_start_time_stream; | 1556 return lowest_start_time_stream; |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 // If we couldn't find any streams with the start time lower than |seek_time| | 1559 // If we couldn't find any streams with the start time lower than |seek_time| |
| 1560 // then use either video (if one exists) or any audio stream. | 1560 // then use either video (if one exists) or any enabled audio stream. |
| 1561 return video_stream ? video_stream : static_cast<FFmpegDemuxerStream*>( | 1561 if (video_stream) |
| 1562 GetStream(DemuxerStream::AUDIO)); | 1562 return video_stream; |
| 1563 | |
| 1564 for (const auto& stream : streams_) { | |
| 1565 if (stream && stream->type() == DemuxerStream::AUDIO && stream->enabled()) | |
| 1566 return stream.get(); | |
| 1567 } | |
| 1568 | |
| 1569 // If there's no enabled audio/video streams, then just fall back to any | |
|
DaleCurtis
2016/12/05 23:11:27
Seems like instead this code should loop the whole
servolk
2016/12/06 00:36:05
I agree that it would be nice and more consistent
| |
| 1570 // non-null stream, even if it's disabled. | |
| 1571 for (const auto& stream : streams_) { | |
| 1572 if (stream) | |
| 1573 return stream.get(); | |
| 1574 } | |
| 1575 | |
| 1576 NOTREACHED(); | |
| 1577 return nullptr; | |
| 1563 } | 1578 } |
| 1564 | 1579 |
| 1565 void FFmpegDemuxer::OnSeekFrameDone(int result) { | 1580 void FFmpegDemuxer::OnSeekFrameDone(int result) { |
| 1566 DCHECK(task_runner_->BelongsToCurrentThread()); | 1581 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1567 CHECK(!pending_seek_cb_.is_null()); | 1582 CHECK(!pending_seek_cb_.is_null()); |
| 1568 | 1583 |
| 1569 if (!blocking_thread_.IsRunning()) { | 1584 if (!blocking_thread_.IsRunning()) { |
| 1570 MEDIA_LOG(ERROR, media_log_) << GetDisplayName() << ": bad state"; | 1585 MEDIA_LOG(ERROR, media_log_) << GetDisplayName() << ": bad state"; |
| 1571 base::ResetAndReturn(&pending_seek_cb_).Run(PIPELINE_ERROR_ABORT); | 1586 base::ResetAndReturn(&pending_seek_cb_).Run(PIPELINE_ERROR_ABORT); |
| 1572 return; | 1587 return; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1783 | 1798 |
| 1784 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { | 1799 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { |
| 1785 DCHECK(task_runner_->BelongsToCurrentThread()); | 1800 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 1786 for (const auto& stream : streams_) { | 1801 for (const auto& stream : streams_) { |
| 1787 if (stream) | 1802 if (stream) |
| 1788 stream->SetLiveness(liveness); | 1803 stream->SetLiveness(liveness); |
| 1789 } | 1804 } |
| 1790 } | 1805 } |
| 1791 | 1806 |
| 1792 } // namespace media | 1807 } // namespace media |
| OLD | NEW |