| 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 #ifndef MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
| 6 #define MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ | 6 #define MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/threading/thread_checker.h" | |
| 13 #include "media/base/video_decoder.h" | 12 #include "media/base/video_decoder.h" |
| 14 #include "media/base/video_decoder_config.h" | 13 #include "media/base/video_decoder_config.h" |
| 15 #include "media/base/video_frame_pool.h" | 14 #include "media/base/video_frame_pool.h" |
| 16 #include "media/ffmpeg/ffmpeg_deleters.h" | 15 #include "media/ffmpeg/ffmpeg_deleters.h" |
| 17 | 16 |
| 18 struct AVCodecContext; | 17 struct AVCodecContext; |
| 19 struct AVFrame; | 18 struct AVFrame; |
| 20 | 19 |
| 21 namespace base { | 20 namespace base { |
| 22 class SingleThreadTaskRunner; | 21 class SingleThreadTaskRunner; |
| 23 } | 22 } |
| 24 | 23 |
| 25 namespace media { | 24 namespace media { |
| 26 | 25 |
| 27 class DecoderBuffer; | 26 class DecoderBuffer; |
| 28 | 27 |
| 29 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { | 28 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { |
| 30 public: | 29 public: |
| 31 static bool IsCodecSupported(VideoCodec codec); | 30 static bool IsCodecSupported(VideoCodec codec); |
| 32 | 31 |
| 33 FFmpegVideoDecoder(); | 32 explicit FFmpegVideoDecoder( |
| 33 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 34 ~FFmpegVideoDecoder() override; | 34 ~FFmpegVideoDecoder() override; |
| 35 | 35 |
| 36 // Allow decoding of individual NALU. Entire frames are required by default. | 36 // Allow decoding of individual NALU. Entire frames are required by default. |
| 37 // Disables low-latency mode. Must be called before Initialize(). | 37 // Disables low-latency mode. Must be called before Initialize(). |
| 38 void set_decode_nalus(bool decode_nalus) { decode_nalus_ = decode_nalus; } | 38 void set_decode_nalus(bool decode_nalus) { decode_nalus_ = decode_nalus; } |
| 39 | 39 |
| 40 // VideoDecoder implementation. | 40 // VideoDecoder implementation. |
| 41 std::string GetDisplayName() const override; | 41 std::string GetDisplayName() const override; |
| 42 void Initialize(const VideoDecoderConfig& config, | 42 void Initialize(const VideoDecoderConfig& config, |
| 43 bool low_delay, | 43 bool low_delay, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 68 bool* has_produced_frame); | 68 bool* has_produced_frame); |
| 69 | 69 |
| 70 // Handles (re-)initializing the decoder with a (new) config. | 70 // Handles (re-)initializing the decoder with a (new) config. |
| 71 // Returns true if initialization was successful. | 71 // Returns true if initialization was successful. |
| 72 bool ConfigureDecoder(bool low_delay); | 72 bool ConfigureDecoder(bool low_delay); |
| 73 | 73 |
| 74 // Releases resources associated with |codec_context_| and |av_frame_| | 74 // Releases resources associated with |codec_context_| and |av_frame_| |
| 75 // and resets them to NULL. | 75 // and resets them to NULL. |
| 76 void ReleaseFFmpegResources(); | 76 void ReleaseFFmpegResources(); |
| 77 | 77 |
| 78 base::ThreadChecker thread_checker_; | 78 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 79 | 79 |
| 80 DecoderState state_; | 80 DecoderState state_; |
| 81 | 81 |
| 82 OutputCB output_cb_; | 82 OutputCB output_cb_; |
| 83 | 83 |
| 84 // FFmpeg structures owned by this object. | 84 // FFmpeg structures owned by this object. |
| 85 scoped_ptr<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; | 85 scoped_ptr<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; |
| 86 scoped_ptr<AVFrame, ScopedPtrAVFreeFrame> av_frame_; | 86 scoped_ptr<AVFrame, ScopedPtrAVFreeFrame> av_frame_; |
| 87 | 87 |
| 88 VideoDecoderConfig config_; | 88 VideoDecoderConfig config_; |
| 89 | 89 |
| 90 VideoFramePool frame_pool_; | 90 VideoFramePool frame_pool_; |
| 91 | 91 |
| 92 bool decode_nalus_; | 92 bool decode_nalus_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); | 94 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace media | 97 } // namespace media |
| 98 | 98 |
| 99 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ | 99 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ |
| OLD | NEW |