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 14 matching lines...) Expand all Loading... |
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/audio_decoder_config.h" | 31 #include "media/base/audio_decoder_config.h" |
32 #include "media/base/buffers.h" | 32 #include "media/base/buffers.h" |
33 #include "media/base/demuxer.h" | 33 #include "media/base/demuxer.h" |
34 #include "media/base/pipeline.h" | 34 #include "media/base/pipeline.h" |
| 35 #include "media/base/video_decoder_config.h" |
35 #include "media/filters/ffmpeg_glue.h" | 36 #include "media/filters/ffmpeg_glue.h" |
36 | 37 |
37 // FFmpeg forward declarations. | 38 // FFmpeg forward declarations. |
38 struct AVFormatContext; | 39 struct AVFormatContext; |
39 struct AVPacket; | 40 struct AVPacket; |
40 struct AVRational; | 41 struct AVRational; |
41 | 42 |
42 namespace media { | 43 namespace media { |
43 | 44 |
44 class BitstreamConverter; | 45 class BitstreamConverter; |
(...skipping 29 matching lines...) Expand all Loading... |
74 virtual Type type() OVERRIDE; | 75 virtual Type type() OVERRIDE; |
75 | 76 |
76 // If |buffer_queue_| is not empty will execute on caller's thread, otherwise | 77 // If |buffer_queue_| is not empty will execute on caller's thread, otherwise |
77 // will post ReadTask to execute on demuxer's thread. Read will acquire | 78 // will post ReadTask to execute on demuxer's thread. Read will acquire |
78 // |lock_| for the life of the function so that means |read_callback| must | 79 // |lock_| for the life of the function so that means |read_callback| must |
79 // not make calls into FFmpegDemuxerStream directly or that may cause a | 80 // not make calls into FFmpegDemuxerStream directly or that may cause a |
80 // deadlock. |read_callback| should execute as quickly as possible because | 81 // deadlock. |read_callback| should execute as quickly as possible because |
81 // |lock_| is held throughout the life of the callback. | 82 // |lock_| is held throughout the life of the callback. |
82 virtual void Read(const ReadCallback& read_callback) OVERRIDE; | 83 virtual void Read(const ReadCallback& read_callback) OVERRIDE; |
83 virtual void EnableBitstreamConverter() OVERRIDE; | 84 virtual void EnableBitstreamConverter() OVERRIDE; |
84 virtual AVStream* GetAVStream() OVERRIDE; | |
85 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; | 85 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; |
| 86 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE; |
86 | 87 |
87 private: | 88 private: |
88 virtual ~FFmpegDemuxerStream(); | 89 virtual ~FFmpegDemuxerStream(); |
89 | 90 |
90 // Carries out enqueuing a pending read on the demuxer thread. | 91 // Carries out enqueuing a pending read on the demuxer thread. |
91 void ReadTask(const ReadCallback& read_callback); | 92 void ReadTask(const ReadCallback& read_callback); |
92 | 93 |
93 // Attempts to fulfill a single pending read by dequeueing a buffer and read | 94 // Attempts to fulfill a single pending read by dequeueing a buffer and read |
94 // callback pair and executing the callback. The calling function must | 95 // callback pair and executing the callback. The calling function must |
95 // acquire |lock_| before calling this function. | 96 // acquire |lock_| before calling this function. |
96 void FulfillPendingRead(); | 97 void FulfillPendingRead(); |
97 | 98 |
98 // Converts an FFmpeg stream timestamp into a base::TimeDelta. | 99 // Converts an FFmpeg stream timestamp into a base::TimeDelta. |
99 static base::TimeDelta ConvertStreamTimestamp(const AVRational& time_base, | 100 static base::TimeDelta ConvertStreamTimestamp(const AVRational& time_base, |
100 int64 timestamp); | 101 int64 timestamp); |
101 | 102 |
102 FFmpegDemuxer* demuxer_; | 103 FFmpegDemuxer* demuxer_; |
103 AVStream* stream_; | 104 AVStream* stream_; |
104 AudioDecoderConfig audio_config_; | 105 AudioDecoderConfig audio_config_; |
| 106 VideoDecoderConfig video_config_; |
105 Type type_; | 107 Type type_; |
106 base::TimeDelta duration_; | 108 base::TimeDelta duration_; |
107 bool discontinuous_; | 109 bool discontinuous_; |
108 bool stopped_; | 110 bool stopped_; |
109 | 111 |
110 typedef std::deque<scoped_refptr<Buffer> > BufferQueue; | 112 typedef std::deque<scoped_refptr<Buffer> > BufferQueue; |
111 BufferQueue buffer_queue_; | 113 BufferQueue buffer_queue_; |
112 | 114 |
113 typedef std::deque<ReadCallback> ReadQueue; | 115 typedef std::deque<ReadCallback> ReadQueue; |
114 ReadQueue read_queue_; | 116 ReadQueue read_queue_; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // starting clock value to match the timestamps in the media file. Default | 260 // starting clock value to match the timestamps in the media file. Default |
259 // is 0. | 261 // is 0. |
260 base::TimeDelta start_time_; | 262 base::TimeDelta start_time_; |
261 | 263 |
262 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 264 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |
263 }; | 265 }; |
264 | 266 |
265 } // namespace media | 267 } // namespace media |
266 | 268 |
267 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 269 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |
OLD | NEW |