| 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 // 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   79  |   79  | 
|   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() const override; | 
 |   90   Liveness liveness() const 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 22 matching lines...) Expand all  Loading... | 
|  129  |  132  | 
|  130   // Create new bitstream converter, destroying active converter if present. |  133   // Create new bitstream converter, destroying active converter if present. | 
|  131   void InitBitstreamConverter(); |  134   void InitBitstreamConverter(); | 
|  132  |  135  | 
|  133   FFmpegDemuxer* demuxer_; |  136   FFmpegDemuxer* demuxer_; | 
|  134   scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |  137   scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 
|  135   AVStream* stream_; |  138   AVStream* stream_; | 
|  136   AudioDecoderConfig audio_config_; |  139   AudioDecoderConfig audio_config_; | 
|  137   VideoDecoderConfig video_config_; |  140   VideoDecoderConfig video_config_; | 
|  138   Type type_; |  141   Type type_; | 
 |  142   Liveness liveness_; | 
|  139   base::TimeDelta duration_; |  143   base::TimeDelta duration_; | 
|  140   bool end_of_stream_; |  144   bool end_of_stream_; | 
|  141   base::TimeDelta last_packet_timestamp_; |  145   base::TimeDelta last_packet_timestamp_; | 
|  142   base::TimeDelta last_packet_duration_; |  146   base::TimeDelta last_packet_duration_; | 
|  143   Ranges<base::TimeDelta> buffered_ranges_; |  147   Ranges<base::TimeDelta> buffered_ranges_; | 
|  144   VideoRotation video_rotation_; |  148   VideoRotation video_rotation_; | 
|  145  |  149  | 
|  146   DecoderBufferQueue buffer_queue_; |  150   DecoderBufferQueue buffer_queue_; | 
|  147   ReadCB read_cb_; |  151   ReadCB read_cb_; | 
|  148  |  152  | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|  166  |  170  | 
|  167   // Demuxer implementation. |  171   // Demuxer implementation. | 
|  168   void Initialize(DemuxerHost* host, |  172   void Initialize(DemuxerHost* host, | 
|  169                   const PipelineStatusCB& status_cb, |  173                   const PipelineStatusCB& status_cb, | 
|  170                   bool enable_text_tracks) override; |  174                   bool enable_text_tracks) override; | 
|  171   void Stop() override; |  175   void Stop() override; | 
|  172   void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; |  176   void Seek(base::TimeDelta time, const PipelineStatusCB& cb) override; | 
|  173   base::Time GetTimelineOffset() const override; |  177   base::Time GetTimelineOffset() const override; | 
|  174   DemuxerStream* GetStream(DemuxerStream::Type type) override; |  178   DemuxerStream* GetStream(DemuxerStream::Type type) override; | 
|  175   base::TimeDelta GetStartTime() const override; |  179   base::TimeDelta GetStartTime() const override; | 
|  176   Liveness GetLiveness() const override; |  | 
|  177  |  180  | 
|  178   // Calls |need_key_cb_| with the initialization data encountered in the file. |  181   // Calls |need_key_cb_| with the initialization data encountered in the file. | 
|  179   void FireNeedKey(const std::string& init_data_type, |  182   void FireNeedKey(const std::string& init_data_type, | 
|  180                    const std::string& encryption_key_id); |  183                    const std::string& encryption_key_id); | 
|  181  |  184  | 
|  182   // Allow FFmpegDemuxerStream to notify us when there is updated information |  185   // Allow FFmpegDemuxerStream to notify us when there is updated information | 
|  183   // about capacity and what buffered data is available. |  186   // about capacity and what buffered data is available. | 
|  184   void NotifyCapacityAvailable(); |  187   void NotifyCapacityAvailable(); | 
|  185   void NotifyBufferingChanged(); |  188   void NotifyBufferingChanged(); | 
|  186  |  189  | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  218   void OnDataSourceError(); |  221   void OnDataSourceError(); | 
|  219  |  222  | 
|  220   // Returns the stream from |streams_| that matches |type| as an |  223   // Returns the stream from |streams_| that matches |type| as an | 
|  221   // FFmpegDemuxerStream. |  224   // FFmpegDemuxerStream. | 
|  222   FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const; |  225   FFmpegDemuxerStream* GetFFmpegStream(DemuxerStream::Type type) const; | 
|  223  |  226  | 
|  224   // Called after the streams have been collected from the media, to allow |  227   // Called after the streams have been collected from the media, to allow | 
|  225   // the text renderer to bind each text stream to the cue rendering engine. |  228   // the text renderer to bind each text stream to the cue rendering engine. | 
|  226   void AddTextStreams(); |  229   void AddTextStreams(); | 
|  227  |  230  | 
 |  231   void SetLiveness(DemuxerStream::Liveness liveness); | 
 |  232  | 
|  228   DemuxerHost* host_; |  233   DemuxerHost* host_; | 
|  229  |  234  | 
|  230   scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |  235   scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 
|  231  |  236  | 
|  232   // Thread on which all blocking FFmpeg operations are executed. |  237   // Thread on which all blocking FFmpeg operations are executed. | 
|  233   base::Thread blocking_thread_; |  238   base::Thread blocking_thread_; | 
|  234  |  239  | 
|  235   // Tracks if there's an outstanding av_read_frame() operation. |  240   // Tracks if there's an outstanding av_read_frame() operation. | 
|  236   // |  241   // | 
|  237   // TODO(scherkus): Allow more than one read in flight for higher read |  242   // TODO(scherkus): Allow more than one read in flight for higher read | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  276   // point occurs after its associated start time.  Otherwise it will use |  281   // point occurs after its associated start time.  Otherwise it will use | 
|  277   // |fallback_stream_for_seeking_|. |  282   // |fallback_stream_for_seeking_|. | 
|  278   typedef std::pair<int, base::TimeDelta> StreamSeekInfo; |  283   typedef std::pair<int, base::TimeDelta> StreamSeekInfo; | 
|  279   StreamSeekInfo preferred_stream_for_seeking_; |  284   StreamSeekInfo preferred_stream_for_seeking_; | 
|  280   StreamSeekInfo fallback_stream_for_seeking_; |  285   StreamSeekInfo fallback_stream_for_seeking_; | 
|  281  |  286  | 
|  282   // The Time associated with timestamp 0. Set to a null |  287   // The Time associated with timestamp 0. Set to a null | 
|  283   // time if the file doesn't have an association to Time. |  288   // time if the file doesn't have an association to Time. | 
|  284   base::Time timeline_offset_; |  289   base::Time timeline_offset_; | 
|  285  |  290  | 
|  286   // Liveness of the stream. |  | 
|  287   Liveness liveness_; |  | 
|  288  |  | 
|  289   // Whether text streams have been enabled for this demuxer. |  291   // Whether text streams have been enabled for this demuxer. | 
|  290   bool text_enabled_; |  292   bool text_enabled_; | 
|  291  |  293  | 
|  292   // Set if we know duration of the audio stream. Used when processing end of |  294   // Set if we know duration of the audio stream. Used when processing end of | 
|  293   // stream -- at this moment we definitely know duration. |  295   // stream -- at this moment we definitely know duration. | 
|  294   bool duration_known_; |  296   bool duration_known_; | 
|  295  |  297  | 
|  296   // FFmpegURLProtocol implementation and corresponding glue bits. |  298   // FFmpegURLProtocol implementation and corresponding glue bits. | 
|  297   scoped_ptr<BlockingUrlProtocol> url_protocol_; |  299   scoped_ptr<BlockingUrlProtocol> url_protocol_; | 
|  298   scoped_ptr<FFmpegGlue> glue_; |  300   scoped_ptr<FFmpegGlue> glue_; | 
|  299  |  301  | 
|  300   const NeedKeyCB need_key_cb_; |  302   const NeedKeyCB need_key_cb_; | 
|  301  |  303  | 
|  302   // NOTE: Weak pointers must be invalidated before all other member variables. |  304   // NOTE: Weak pointers must be invalidated before all other member variables. | 
|  303   base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; |  305   base::WeakPtrFactory<FFmpegDemuxer> weak_factory_; | 
|  304  |  306  | 
|  305   DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); |  307   DISALLOW_COPY_AND_ASSIGN(FFmpegDemuxer); | 
|  306 }; |  308 }; | 
|  307  |  309  | 
|  308 }  // namespace media |  310 }  // namespace media | 
|  309  |  311  | 
|  310 #endif  // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ |  312 #endif  // MEDIA_FILTERS_FFMPEG_DEMUXER_H_ | 
| OLD | NEW |