Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: media/filters/ffmpeg_demuxer.h

Issue 692323002: Move Liveness from DemuxerStreamProvider to DemuxerStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // Enables fixes for ogg files with negative timestamps. For AUDIO streams, 80 // Enables fixes for ogg files with negative timestamps. For AUDIO streams,
81 // all packets with negative timestamps will be marked for post-decode 81 // all packets with negative timestamps will be marked for post-decode
82 // discard. For all other stream types, if FFmpegDemuxer::start_time() is 82 // discard. For all other stream types, if FFmpegDemuxer::start_time() is
83 // negative, it will not be used to shift timestamps during EnqueuePacket(). 83 // negative, it will not be used to shift timestamps during EnqueuePacket().
84 void enable_negative_timestamp_fixups_for_ogg() { 84 void enable_negative_timestamp_fixups_for_ogg() {
85 fixup_negative_ogg_timestamps_ = true; 85 fixup_negative_ogg_timestamps_ = true;
86 } 86 }
87 87
88 // DemuxerStream implementation. 88 // DemuxerStream implementation.
89 Type type() override; 89 Type type() override;
90 Liveness liveness() override;
90 void Read(const ReadCB& read_cb) override; 91 void Read(const ReadCB& read_cb) override;
91 void EnableBitstreamConverter() override; 92 void EnableBitstreamConverter() override;
92 bool SupportsConfigChanges() override; 93 bool SupportsConfigChanges() override;
93 AudioDecoderConfig audio_decoder_config() override; 94 AudioDecoderConfig audio_decoder_config() override;
94 VideoDecoderConfig video_decoder_config() override; 95 VideoDecoderConfig video_decoder_config() override;
95 VideoRotation video_rotation() override; 96 VideoRotation video_rotation() override;
96 97
98 void SetLiveness(Liveness liveness);
99
97 // Returns the range of buffered data in this stream. 100 // Returns the range of buffered data in this stream.
98 Ranges<base::TimeDelta> GetBufferedRanges() const; 101 Ranges<base::TimeDelta> GetBufferedRanges() const;
99 102
100 // Returns elapsed time based on the already queued packets. 103 // Returns elapsed time based on the already queued packets.
101 // Used to determine stream duration when it's not known ahead of time. 104 // Used to determine stream duration when it's not known ahead of time.
102 base::TimeDelta GetElapsedTime() const; 105 base::TimeDelta GetElapsedTime() const;
103 106
104 // Returns true if this stream has capacity for additional data. 107 // Returns true if this stream has capacity for additional data.
105 bool HasAvailableCapacity(); 108 bool HasAvailableCapacity();
106 109
(...skipping 19 matching lines...) Expand all
126 129
127 // Resets any currently active bitstream converters. 130 // Resets any currently active bitstream converters.
128 void ResetBitstreamConverter(); 131 void ResetBitstreamConverter();
129 132
130 FFmpegDemuxer* demuxer_; 133 FFmpegDemuxer* demuxer_;
131 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 134 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
132 AVStream* stream_; 135 AVStream* stream_;
133 AudioDecoderConfig audio_config_; 136 AudioDecoderConfig audio_config_;
134 VideoDecoderConfig video_config_; 137 VideoDecoderConfig video_config_;
135 Type type_; 138 Type type_;
139 Liveness liveness_;
136 base::TimeDelta duration_; 140 base::TimeDelta duration_;
137 bool end_of_stream_; 141 bool end_of_stream_;
138 base::TimeDelta last_packet_timestamp_; 142 base::TimeDelta last_packet_timestamp_;
139 base::TimeDelta last_packet_duration_; 143 base::TimeDelta last_packet_duration_;
140 Ranges<base::TimeDelta> buffered_ranges_; 144 Ranges<base::TimeDelta> buffered_ranges_;
141 VideoRotation video_rotation_; 145 VideoRotation video_rotation_;
142 146
143 DecoderBufferQueue buffer_queue_; 147 DecoderBufferQueue buffer_queue_;
144 ReadCB read_cb_; 148 ReadCB read_cb_;
145 149
(...skipping 19 matching lines...) Expand all
165 169
166 // Demuxer implementation. 170 // Demuxer implementation.
167 void Initialize(DemuxerHost* host, 171 void Initialize(DemuxerHost* host,
168 const PipelineStatusCB& status_cb, 172 const PipelineStatusCB& status_cb,
169 bool enable_text_tracks) override; 173 bool enable_text_tracks) override;
170 void Stop() override; 174 void Stop() override;
171 void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; 175 void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override;
172 base::Time GetTimelineOffset() const override; 176 base::Time GetTimelineOffset() const override;
173 DemuxerStream* GetStream(DemuxerStream::Type type) override; 177 DemuxerStream* GetStream(DemuxerStream::Type type) override;
174 base::TimeDelta GetStartTime() const override; 178 base::TimeDelta GetStartTime() const override;
175 Liveness GetLiveness() const override;
176 179
177 // Calls |need_key_cb_| with the initialization data encountered in the file. 180 // Calls |need_key_cb_| with the initialization data encountered in the file.
178 void FireNeedKey(const std::string& init_data_type, 181 void FireNeedKey(const std::string& init_data_type,
179 const std::string& encryption_key_id); 182 const std::string& encryption_key_id);
180 183
181 // Allow FFmpegDemuxerStream to notify us when there is updated information 184 // Allow FFmpegDemuxerStream to notify us when there is updated information
182 // about capacity and what buffered data is available. 185 // about capacity and what buffered data is available.
183 void NotifyCapacityAvailable(); 186 void NotifyCapacityAvailable();
184 void NotifyBufferingChanged(); 187 void NotifyBufferingChanged();
185 188
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 void OnDataSourceError(); 220 void OnDataSourceError();
218 221
219 // Returns the stream from |streams_| that matches |type| as an 222 // Returns the stream from |streams_| that matches |type| as an
220 // FFmpegDemuxerStream. 223 // FFmpegDemuxerStream.
221 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const; 224 FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const;
222 225
223 // Called after the streams have been collected from the media, to allow 226 // Called after the streams have been collected from the media, to allow
224 // the text renderer to bind each text stream to the cue rendering engine. 227 // the text renderer to bind each text stream to the cue rendering engine.
225 void AddTextStreams(); 228 void AddTextStreams();
226 229
230 void SetLiveness(DemuxerStream::Liveness liveness);
231
227 DemuxerHost* host_; 232 DemuxerHost* host_;
228 233
229 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 234 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
230 235
231 // Thread on which all blocking FFmpeg operations are executed. 236 // Thread on which all blocking FFmpeg operations are executed.
232 base::Thread blocking_thread_; 237 base::Thread blocking_thread_;
233 238
234 // Tracks if there's an outstanding av_read_frame() operation. 239 // Tracks if there's an outstanding av_read_frame() operation.
235 // 240 //
236 // TODO(scherkus): Allow more than one read in flight for higher read 241 // TODO(scherkus): Allow more than one read in flight for higher read
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // point occurs after its associated start time. Otherwise it will use 280 // point occurs after its associated start time. Otherwise it will use
276 // |fallback_stream_for_seeking_|. 281 // |fallback_stream_for_seeking_|.
277 typedef std::pair<int, base::TimeDelta> StreamSeekInfo; 282 typedef std::pair<int, base::TimeDelta> StreamSeekInfo;
278 StreamSeekInfo preferred_stream_for_seeking_; 283 StreamSeekInfo preferred_stream_for_seeking_;
279 StreamSeekInfo fallback_stream_for_seeking_; 284 StreamSeekInfo fallback_stream_for_seeking_;
280 285
281 // The Time associated with timestamp 0. Set to a null 286 // The Time associated with timestamp 0. Set to a null
282 // time if the file doesn't have an association to Time. 287 // time if the file doesn't have an association to Time.
283 base::Time timeline_offset_; 288 base::Time timeline_offset_;
284 289
285 // Liveness of the stream.
286 Liveness liveness_;
287
288 // Whether text streams have been enabled for this demuxer. 290 // Whether text streams have been enabled for this demuxer.
289 bool text_enabled_; 291 bool text_enabled_;
290 292
291 // Set if we know duration of the audio stream. Used when processing end of 293 // Set if we know duration of the audio stream. Used when processing end of
292 // stream -- at this moment we definitely know duration. 294 // stream -- at this moment we definitely know duration.
293 bool duration_known_; 295 bool duration_known_;
294 296
295 // FFmpegURLProtocol implementation and corresponding glue bits. 297 // FFmpegURLProtocol implementation and corresponding glue bits.
296 scoped_ptr<BlockingUrlProtocol> url_protocol_; 298 scoped_ptr<BlockingUrlProtocol> url_protocol_;
297 scoped_ptr<FFmpegGlue> glue_; 299 scoped_ptr<FFmpegGlue> glue_;
298 300
299 const NeedKeyCB need_key_cb_; 301 const NeedKeyCB need_key_cb_;
300 302
301 // NOTE: Weak pointers must be invalidated before all other member variables. 303 // NOTE: Weak pointers must be invalidated before all other member variables.
302 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; 304 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_;
303 305
304 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 306 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
305 }; 307 };
306 308
307 } // namespace media 309 } // namespace media
308 310
309 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 311 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698