| 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/base64.h" | 10 #include "base/base64.h" |
| (...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 new_packet->dts = packet->dts; | 838 new_packet->dts = packet->dts; |
| 839 new_packet->pos = packet->pos; | 839 new_packet->pos = packet->pos; |
| 840 new_packet->duration = packet->duration; | 840 new_packet->duration = packet->duration; |
| 841 new_packet->convergence_duration = packet->convergence_duration; | 841 new_packet->convergence_duration = packet->convergence_duration; |
| 842 new_packet->flags = packet->flags; | 842 new_packet->flags = packet->flags; |
| 843 new_packet->stream_index = packet->stream_index; | 843 new_packet->stream_index = packet->stream_index; |
| 844 | 844 |
| 845 packet.swap(new_packet); | 845 packet.swap(new_packet); |
| 846 } | 846 } |
| 847 | 847 |
| 848 // Special case for opus in ogg. FFmpeg is pre-trimming the codec delay |
| 849 // from the packet timestamp. Chrome expects to handle this itself inside |
| 850 // the decoder, so shift timestamps by the delay in this case. |
| 851 // TODO(dalecurtis): Try to get fixed upstream. See http://crbug.com/328207 |
| 852 if (strcmp(glue_->format_context()->iformat->name, "ogg") == 0) { |
| 853 const AVCodecContext* codec_context = |
| 854 glue_->format_context()->streams[packet->stream_index]->codec; |
| 855 if (codec_context->codec_id == AV_CODEC_ID_OPUS && |
| 856 codec_context->delay > 0) { |
| 857 packet->pts += codec_context->delay; |
| 858 } |
| 859 } |
| 860 |
| 848 FFmpegDemuxerStream* demuxer_stream = streams_[packet->stream_index]; | 861 FFmpegDemuxerStream* demuxer_stream = streams_[packet->stream_index]; |
| 849 demuxer_stream->EnqueuePacket(packet.Pass()); | 862 demuxer_stream->EnqueuePacket(packet.Pass()); |
| 850 } | 863 } |
| 851 | 864 |
| 852 // Keep reading until we've reached capacity. | 865 // Keep reading until we've reached capacity. |
| 853 ReadFrameIfNeeded(); | 866 ReadFrameIfNeeded(); |
| 854 } | 867 } |
| 855 | 868 |
| 856 void FFmpegDemuxer::OnDataSourceStopped(const base::Closure& callback) { | 869 void FFmpegDemuxer::OnDataSourceStopped(const base::Closure& callback) { |
| 857 // This will block until all tasks complete. Note that after this returns it's | 870 // This will block until all tasks complete. Note that after this returns it's |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 } | 934 } |
| 922 for (size_t i = 0; i < buffered.size(); ++i) | 935 for (size_t i = 0; i < buffered.size(); ++i) |
| 923 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); | 936 host_->AddBufferedTimeRange(buffered.start(i), buffered.end(i)); |
| 924 } | 937 } |
| 925 | 938 |
| 926 void FFmpegDemuxer::OnDataSourceError() { | 939 void FFmpegDemuxer::OnDataSourceError() { |
| 927 host_->OnDemuxerError(PIPELINE_ERROR_READ); | 940 host_->OnDemuxerError(PIPELINE_ERROR_READ); |
| 928 } | 941 } |
| 929 | 942 |
| 930 } // namespace media | 943 } // namespace media |
| OLD | NEW |