| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 // Queue the packet with the appropriate stream. | 581 // Queue the packet with the appropriate stream. |
| 582 DCHECK_GE(packet->stream_index, 0); | 582 DCHECK_GE(packet->stream_index, 0); |
| 583 DCHECK_LT(packet->stream_index, static_cast<int>(streams_.size())); | 583 DCHECK_LT(packet->stream_index, static_cast<int>(streams_.size())); |
| 584 | 584 |
| 585 // Defend against ffmpeg giving us a bad stream index. | 585 // Defend against ffmpeg giving us a bad stream index. |
| 586 if (packet->stream_index >= 0 && | 586 if (packet->stream_index >= 0 && |
| 587 packet->stream_index < static_cast<int>(streams_.size()) && | 587 packet->stream_index < static_cast<int>(streams_.size()) && |
| 588 streams_[packet->stream_index] && | 588 streams_[packet->stream_index] && |
| 589 (!audio_disabled_ || | 589 (!audio_disabled_ || |
| 590 streams_[packet->stream_index]->type() != DemuxerStream::AUDIO)) { | 590 streams_[packet->stream_index]->type() != DemuxerStream::AUDIO)) { |
| 591 |
| 592 // TODO(scherkus): Fix demuxing upstream to never return packets w/o data |
| 593 // when av_read_frame() returns success code. See bug comment for ideas: |
| 594 // |
| 595 // https://code.google.com/p/chromium/issues/detail?id=169133#c10 |
| 596 if (!packet->data) { |
| 597 ScopedAVPacket new_packet(new AVPacket()); |
| 598 av_new_packet(new_packet.get(), 0); |
| 599 |
| 600 new_packet->pts = packet->pts; |
| 601 new_packet->dts = packet->dts; |
| 602 new_packet->pos = packet->pos; |
| 603 new_packet->duration = packet->duration; |
| 604 new_packet->convergence_duration = packet->convergence_duration; |
| 605 new_packet->flags = packet->flags; |
| 606 new_packet->stream_index = packet->stream_index; |
| 607 |
| 608 packet.swap(new_packet); |
| 609 } |
| 610 |
| 591 FFmpegDemuxerStream* demuxer_stream = streams_[packet->stream_index]; | 611 FFmpegDemuxerStream* demuxer_stream = streams_[packet->stream_index]; |
| 592 demuxer_stream->EnqueuePacket(packet.Pass()); | 612 demuxer_stream->EnqueuePacket(packet.Pass()); |
| 593 } | 613 } |
| 594 | 614 |
| 595 // Keep reading until we've reached capacity. | 615 // Keep reading until we've reached capacity. |
| 596 ReadFrameIfNeeded(); | 616 ReadFrameIfNeeded(); |
| 597 } | 617 } |
| 598 | 618 |
| 599 void FFmpegDemuxer::OnDataSourceStopped(const base::Closure& callback) { | 619 void FFmpegDemuxer::OnDataSourceStopped(const base::Closure& callback) { |
| 600 // This will block until all tasks complete. Note that after this returns it's | 620 // This will block until all tasks complete. Note that after this returns it's |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 } | 678 } |
| 659 for (size_t i = 0; i < buffered.size(); ++i) | 679 for (size_t i = 0; i < buffered.size(); ++i) |
| 660 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); | 680 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); |
| 661 } | 681 } |
| 662 | 682 |
| 663 void FFmpegDemuxer::OnDataSourceError() { | 683 void FFmpegDemuxer::OnDataSourceError() { |
| 664 host_->OnDemuxerError(PIPELINE_ERROR_READ); | 684 host_->OnDemuxerError(PIPELINE_ERROR_READ); |
| 665 } | 685 } |
| 666 | 686 |
| 667 } // namespace media | 687 } // namespace media |
| OLD | NEW |