| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Implements the Demuxer interface using FFmpeg's libavformat. At this time | 5 // Implements the Demuxer interface using FFmpeg's libavformat. At this time |
| 6 // will support demuxing any audio/video format thrown at it. The streams | 6 // will support demuxing any audio/video format thrown at it. The streams |
| 7 // output mime types audio/x-ffmpeg and video/x-ffmpeg and include an integer | 7 // output mime types audio/x-ffmpeg and video/x-ffmpeg and include an integer |
| 8 // key FFmpegCodecID which contains the CodecID enumeration value. The CodecIDs | 8 // key FFmpegCodecID which contains the CodecID enumeration value. The CodecIDs |
| 9 // can be used to create and initialize the corresponding FFmpeg decoder. | 9 // can be used to create and initialize the corresponding FFmpeg decoder. |
| 10 // | 10 // |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 #include <deque> | 25 #include <deque> |
| 26 #include <vector> | 26 #include <vector> |
| 27 | 27 |
| 28 #include "base/callback.h" | 28 #include "base/callback.h" |
| 29 #include "base/gtest_prod_util.h" | 29 #include "base/gtest_prod_util.h" |
| 30 #include "base/synchronization/waitable_event.h" | 30 #include "base/synchronization/waitable_event.h" |
| 31 #include "media/base/buffers.h" | 31 #include "media/base/buffers.h" |
| 32 #include "media/base/filters.h" | 32 #include "media/base/filters.h" |
| 33 #include "media/base/pipeline.h" | 33 #include "media/base/pipeline.h" |
| 34 #include "media/base/media_format.h" | |
| 35 #include "media/filters/ffmpeg_glue.h" | 34 #include "media/filters/ffmpeg_glue.h" |
| 36 | 35 |
| 37 // FFmpeg forward declarations. | 36 // FFmpeg forward declarations. |
| 38 struct AVFormatContext; | 37 struct AVFormatContext; |
| 39 struct AVPacket; | 38 struct AVPacket; |
| 40 struct AVRational; | 39 struct AVRational; |
| 41 struct AVStream; | 40 struct AVStream; |
| 42 | 41 |
| 43 namespace media { | 42 namespace media { |
| 44 | 43 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 66 virtual void FlushBuffers(); | 65 virtual void FlushBuffers(); |
| 67 | 66 |
| 68 // Empties the queues and ignores any additional calls to Read(). | 67 // Empties the queues and ignores any additional calls to Read(). |
| 69 virtual void Stop(); | 68 virtual void Stop(); |
| 70 | 69 |
| 71 // Returns the duration of this stream. | 70 // Returns the duration of this stream. |
| 72 virtual base::TimeDelta duration(); | 71 virtual base::TimeDelta duration(); |
| 73 | 72 |
| 74 // DemuxerStream implementation. | 73 // DemuxerStream implementation. |
| 75 virtual Type type(); | 74 virtual Type type(); |
| 76 virtual const MediaFormat& media_format(); | |
| 77 | 75 |
| 78 // If |buffer_queue_| is not empty will execute on caller's thread, otherwise | 76 // If |buffer_queue_| is not empty will execute on caller's thread, otherwise |
| 79 // will post ReadTask to execute on demuxer's thread. Read will acquire | 77 // will post ReadTask to execute on demuxer's thread. Read will acquire |
| 80 // |lock_| for the life of the function so that means |read_callback| must | 78 // |lock_| for the life of the function so that means |read_callback| must |
| 81 // not make calls into FFmpegDemuxerStream directly or that may cause a | 79 // not make calls into FFmpegDemuxerStream directly or that may cause a |
| 82 // deadlock. |read_callback| should execute as quickly as possible because | 80 // deadlock. |read_callback| should execute as quickly as possible because |
| 83 // |lock_| is held throughout the life of the callback. | 81 // |lock_| is held throughout the life of the callback. |
| 84 virtual void Read(const ReadCallback& read_callback); | 82 virtual void Read(const ReadCallback& read_callback); |
| 85 // Bitstream converter to convert input packet. | 83 // Bitstream converter to convert input packet. |
| 86 virtual void EnableBitstreamConverter(); | 84 virtual void EnableBitstreamConverter(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 97 // acquire |lock_| before calling this function. | 95 // acquire |lock_| before calling this function. |
| 98 void FulfillPendingRead(); | 96 void FulfillPendingRead(); |
| 99 | 97 |
| 100 // Converts an FFmpeg stream timestamp into a base::TimeDelta. | 98 // Converts an FFmpeg stream timestamp into a base::TimeDelta. |
| 101 static base::TimeDelta ConvertStreamTimestamp(const AVRational& time_base, | 99 static base::TimeDelta ConvertStreamTimestamp(const AVRational& time_base, |
| 102 int64 timestamp); | 100 int64 timestamp); |
| 103 | 101 |
| 104 FFmpegDemuxer* demuxer_; | 102 FFmpegDemuxer* demuxer_; |
| 105 AVStream* stream_; | 103 AVStream* stream_; |
| 106 Type type_; | 104 Type type_; |
| 107 MediaFormat media_format_; | |
| 108 base::TimeDelta duration_; | 105 base::TimeDelta duration_; |
| 109 bool discontinuous_; | 106 bool discontinuous_; |
| 110 bool stopped_; | 107 bool stopped_; |
| 111 | 108 |
| 112 typedef std::deque<scoped_refptr<Buffer> > BufferQueue; | 109 typedef std::deque<scoped_refptr<Buffer> > BufferQueue; |
| 113 BufferQueue buffer_queue_; | 110 BufferQueue buffer_queue_; |
| 114 | 111 |
| 115 typedef std::deque<ReadCallback> ReadQueue; | 112 typedef std::deque<ReadCallback> ReadQueue; |
| 116 ReadQueue read_queue_; | 113 ReadQueue read_queue_; |
| 117 | 114 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // starting clock value to match the timestamps in the media file. Default | 254 // starting clock value to match the timestamps in the media file. Default |
| 258 // is 0. | 255 // is 0. |
| 259 base::TimeDelta start_time_; | 256 base::TimeDelta start_time_; |
| 260 | 257 |
| 261 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 258 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
| 262 }; | 259 }; |
| 263 | 260 |
| 264 } // namespace media | 261 } // namespace media |
| 265 | 262 |
| 266 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 263 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
| OLD | NEW |