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

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

Issue 2284923003: Implement support for multiple tracks in FFmpegDemuxer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 months 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
« no previous file with comments | « no previous file | media/filters/ffmpeg_demuxer.cc » ('j') | media/filters/ffmpeg_demuxer.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
25 #include <stddef.h> 25 #include <stddef.h>
26 #include <stdint.h> 26 #include <stdint.h>
27 27
28 #include <memory> 28 #include <memory>
29 #include <string> 29 #include <string>
30 #include <utility> 30 #include <utility>
31 #include <vector> 31 #include <vector>
32 32
33 #include "base/callback.h" 33 #include "base/callback.h"
34 #include "base/macros.h" 34 #include "base/macros.h"
35 #include "base/memory/scoped_vector.h"
36 #include "base/threading/thread.h" 35 #include "base/threading/thread.h"
37 #include "media/base/audio_decoder_config.h" 36 #include "media/base/audio_decoder_config.h"
38 #include "media/base/decoder_buffer.h" 37 #include "media/base/decoder_buffer.h"
39 #include "media/base/decoder_buffer_queue.h" 38 #include "media/base/decoder_buffer_queue.h"
40 #include "media/base/demuxer.h" 39 #include "media/base/demuxer.h"
41 #include "media/base/pipeline_status.h" 40 #include "media/base/pipeline_status.h"
42 #include "media/base/text_track_config.h" 41 #include "media/base/text_track_config.h"
43 #include "media/base/video_decoder_config.h" 42 #include "media/base/video_decoder_config.h"
44 #include "media/ffmpeg/ffmpeg_deleters.h" 43 #include "media/ffmpeg/ffmpeg_deleters.h"
45 #include "media/filters/blocking_url_protocol.h" 44 #include "media/filters/blocking_url_protocol.h"
46 45
47 // FFmpeg forward declarations. 46 // FFmpeg forward declarations.
47 struct AVFormatContext;
48 struct AVPacket; 48 struct AVPacket;
49 struct AVRational; 49 struct AVRational;
50 struct AVStream; 50 struct AVStream;
51 51
52 namespace media { 52 namespace media {
53 53
54 class MediaLog; 54 class MediaLog;
55 class FFmpegBitstreamConverter; 55 class FFmpegBitstreamConverter;
56 class FFmpegDemuxer; 56 class FFmpegDemuxer;
57 class FFmpegGlue; 57 class FFmpegGlue;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 base::TimeDelta start_time() const { return start_time_; } 242 base::TimeDelta start_time() const { return start_time_; }
243 243
244 private: 244 private:
245 // To allow tests access to privates. 245 // To allow tests access to privates.
246 friend class FFmpegDemuxerTest; 246 friend class FFmpegDemuxerTest;
247 247
248 // FFmpeg callbacks during initialization. 248 // FFmpeg callbacks during initialization.
249 void OnOpenContextDone(const PipelineStatusCB& status_cb, bool result); 249 void OnOpenContextDone(const PipelineStatusCB& status_cb, bool result);
250 void OnFindStreamInfoDone(const PipelineStatusCB& status_cb, int result); 250 void OnFindStreamInfoDone(const PipelineStatusCB& status_cb, int result);
251 251
252 void LogMetadata(AVFormatContext* avctx, base::TimeDelta max_duration);
253
252 // FFmpeg callbacks during seeking. 254 // FFmpeg callbacks during seeking.
253 void OnSeekFrameDone(const PipelineStatusCB& cb, int result); 255 void OnSeekFrameDone(const PipelineStatusCB& cb, int result);
254 256
255 // FFmpeg callbacks during reading + helper method to initiate reads. 257 // FFmpeg callbacks during reading + helper method to initiate reads.
256 void ReadFrameIfNeeded(); 258 void ReadFrameIfNeeded();
257 void OnReadFrameDone(ScopedAVPacket packet, int result); 259 void OnReadFrameDone(ScopedAVPacket packet, int result);
258 260
259 // Returns true iff any stream has additional capacity. Note that streams can 261 // Returns true iff any stream has additional capacity. Note that streams can
260 // go over capacity depending on how the file is muxed. 262 // go over capacity depending on how the file is muxed.
261 bool StreamsHaveAvailableCapacity(); 263 bool StreamsHaveAvailableCapacity();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 300
299 // |streams_| mirrors the AVStream array in AVFormatContext. It contains 301 // |streams_| mirrors the AVStream array in AVFormatContext. It contains
300 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index. 302 // FFmpegDemuxerStreams encapsluating AVStream objects at the same index.
301 // 303 //
302 // Since we only support a single audio and video stream, |streams_| will 304 // Since we only support a single audio and video stream, |streams_| will
303 // contain NULL entries for additional audio/video streams as well as for 305 // contain NULL entries for additional audio/video streams as well as for
304 // stream types that we do not currently support. 306 // stream types that we do not currently support.
305 // 307 //
306 // Once initialized, operations on FFmpegDemuxerStreams should be carried out 308 // Once initialized, operations on FFmpegDemuxerStreams should be carried out
307 // on the demuxer thread. 309 // on the demuxer thread.
308 typedef ScopedVector<FFmpegDemuxerStream> StreamVector; 310 using StreamVector = std::vector<std::unique_ptr<FFmpegDemuxerStream>>;
309 StreamVector streams_; 311 StreamVector streams_;
310 312
311 // Provides asynchronous IO to this demuxer. Consumed by |url_protocol_| to 313 // Provides asynchronous IO to this demuxer. Consumed by |url_protocol_| to
312 // integrate with libavformat. 314 // integrate with libavformat.
313 DataSource* data_source_; 315 DataSource* data_source_;
314 316
315 scoped_refptr<MediaLog> media_log_; 317 scoped_refptr<MediaLog> media_log_;
316 318
317 // Derived bitrate after initialization has completed. 319 // Derived bitrate after initialization has completed.
318 int bitrate_; 320 int bitrate_;
(...skipping 21 matching lines...) Expand all
340 bool duration_known_; 342 bool duration_known_;
341 343
342 // FFmpegURLProtocol implementation and corresponding glue bits. 344 // FFmpegURLProtocol implementation and corresponding glue bits.
343 std::unique_ptr<BlockingUrlProtocol> url_protocol_; 345 std::unique_ptr<BlockingUrlProtocol> url_protocol_;
344 std::unique_ptr<FFmpegGlue> glue_; 346 std::unique_ptr<FFmpegGlue> glue_;
345 347
346 const EncryptedMediaInitDataCB encrypted_media_init_data_cb_; 348 const EncryptedMediaInitDataCB encrypted_media_init_data_cb_;
347 349
348 const MediaTracksUpdatedCB media_tracks_updated_cb_; 350 const MediaTracksUpdatedCB media_tracks_updated_cb_;
349 351
350 std::map<MediaTrack::Id, const DemuxerStream*> track_id_to_demux_stream_map_; 352 std::map<MediaTrack::Id, DemuxerStream*> track_id_to_demux_stream_map_;
351 353
352 // NOTE: Weak pointers must be invalidated before all other member variables. 354 // NOTE: Weak pointers must be invalidated before all other member variables.
353 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; 355 base::WeakPtrFactory<FFmpegDemuxer> weak_factory_;
354 356
355 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); 357 DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer);
356 }; 358 };
357 359
358 } // namespace media 360 } // namespace media
359 361
360 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ 362 #endif // MEDIA_FILTERS_FFMPEG_DEMUXER_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/ffmpeg_demuxer.cc » ('j') | media/filters/ffmpeg_demuxer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698