| 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 // FFmpegGlue is an interface between FFmpeg and Chrome used to proxy FFmpeg's | 5 // FFmpegGlue is an interface between FFmpeg and Chrome used to proxy FFmpeg's |
| 6 // read and seek requests to Chrome's internal data structures. The glue works | 6 // read and seek requests to Chrome's internal data structures. The glue works |
| 7 // through the AVIO interface provided by FFmpeg. | 7 // through the AVIO interface provided by FFmpeg. |
| 8 // | 8 // |
| 9 // AVIO works through a special AVIOContext created through avio_alloc_context() | 9 // AVIO works through a special AVIOContext created through avio_alloc_context() |
| 10 // which is attached to the AVFormatContext used for demuxing. The AVIO context | 10 // which is attached to the AVFormatContext used for demuxing. The AVIO context |
| 11 // is initialized with read and seek methods which FFmpeg calls when necessary. | 11 // is initialized with read and seek methods which FFmpeg calls when necessary. |
| 12 // | 12 // |
| 13 // During OpenContext() FFmpegGlue will tell FFmpeg to use Chrome's AVIO context | 13 // During OpenContext() FFmpegGlue will tell FFmpeg to use Chrome's AVIO context |
| 14 // by passing NULL in for the filename parameter to avformat_open_input(). All | 14 // by passing NULL in for the filename parameter to avformat_open_input(). All |
| 15 // FFmpeg operations using the configured AVFormatContext will then redirect | 15 // FFmpeg operations using the configured AVFormatContext will then redirect |
| 16 // reads and seeks through the glue. | 16 // reads and seeks through the glue. |
| 17 // | 17 // |
| 18 // The glue in turn processes those read and seek requests using the | 18 // The glue in turn processes those read and seek requests using the |
| 19 // FFmpegURLProtocol provided during construction. | 19 // FFmpegURLProtocol provided during construction. |
| 20 // | 20 // |
| 21 // FFmpegGlue is also responsible for initializing FFmpeg, which is done once | 21 // FFmpegGlue is also responsible for initializing FFmpeg, which is done once |
| 22 // per process. Initialization includes: turning off log messages, registering | 22 // per process. Initialization includes: turning off log messages, registering |
| 23 // a lock manager, and finally registering all demuxers and codecs. | 23 // a lock manager, and finally registering all demuxers and codecs. |
| 24 | 24 |
| 25 #ifndef MEDIA_FILTERS_FFMPEG_GLUE_H_ | 25 #ifndef MEDIA_FILTERS_FFMPEG_GLUE_H_ |
| 26 #define MEDIA_FILTERS_FFMPEG_GLUE_H_ | 26 #define MEDIA_FILTERS_FFMPEG_GLUE_H_ |
| 27 | 27 |
| 28 #include <stdint.h> | 28 #include <stdint.h> |
| 29 | 29 |
| 30 #include <memory> |
| 31 |
| 30 #include "base/macros.h" | 32 #include "base/macros.h" |
| 31 #include "base/memory/scoped_ptr.h" | |
| 32 #include "media/base/media_export.h" | 33 #include "media/base/media_export.h" |
| 33 #include "media/ffmpeg/ffmpeg_deleters.h" | 34 #include "media/ffmpeg/ffmpeg_deleters.h" |
| 34 | 35 |
| 35 struct AVFormatContext; | 36 struct AVFormatContext; |
| 36 struct AVIOContext; | 37 struct AVIOContext; |
| 37 | 38 |
| 38 namespace media { | 39 namespace media { |
| 39 | 40 |
| 40 class MEDIA_EXPORT FFmpegURLProtocol { | 41 class MEDIA_EXPORT FFmpegURLProtocol { |
| 41 public: | 42 public: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 67 ~FFmpegGlue(); | 68 ~FFmpegGlue(); |
| 68 | 69 |
| 69 // Opens an AVFormatContext specially prepared to process reads and seeks | 70 // Opens an AVFormatContext specially prepared to process reads and seeks |
| 70 // through the FFmpegURLProtocol provided during construction. | 71 // through the FFmpegURLProtocol provided during construction. |
| 71 bool OpenContext(); | 72 bool OpenContext(); |
| 72 AVFormatContext* format_context() { return format_context_; } | 73 AVFormatContext* format_context() { return format_context_; } |
| 73 | 74 |
| 74 private: | 75 private: |
| 75 bool open_called_; | 76 bool open_called_; |
| 76 AVFormatContext* format_context_; | 77 AVFormatContext* format_context_; |
| 77 scoped_ptr<AVIOContext, ScopedPtrAVFree> avio_context_; | 78 std::unique_ptr<AVIOContext, ScopedPtrAVFree> avio_context_; |
| 78 | 79 |
| 79 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); | 80 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 } // namespace media | 83 } // namespace media |
| 83 | 84 |
| 84 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ | 85 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ |
| OLD | NEW |