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 |
(...skipping 10 matching lines...) Expand all Loading... |
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 "base/basictypes.h" | 28 #include "base/basictypes.h" |
29 #include "base/memory/scoped_ptr.h" | 29 #include "base/memory/scoped_ptr.h" |
30 #include "media/base/media_export.h" | 30 #include "media/base/media_export.h" |
| 31 #include "media/ffmpeg/ffmpeg_deleters.h" |
31 | 32 |
32 struct AVFormatContext; | 33 struct AVFormatContext; |
33 struct AVIOContext; | 34 struct AVIOContext; |
34 | 35 |
35 namespace media { | 36 namespace media { |
36 | 37 |
37 class ScopedPtrAVFree; | |
38 | |
39 class MEDIA_EXPORT FFmpegURLProtocol { | 38 class MEDIA_EXPORT FFmpegURLProtocol { |
40 public: | 39 public: |
41 // Read the given amount of bytes into data, returns the number of bytes read | 40 // Read the given amount of bytes into data, returns the number of bytes read |
42 // if successful, kReadError otherwise. | 41 // if successful, kReadError otherwise. |
43 virtual int Read(int size, uint8* data) = 0; | 42 virtual int Read(int size, uint8* data) = 0; |
44 | 43 |
45 // Returns true and the current file position for this file, false if the | 44 // Returns true and the current file position for this file, false if the |
46 // file position could not be retrieved. | 45 // file position could not be retrieved. |
47 virtual bool GetPosition(int64* position_out) = 0; | 46 virtual bool GetPosition(int64* position_out) = 0; |
48 | 47 |
(...skipping 17 matching lines...) Expand all Loading... |
66 ~FFmpegGlue(); | 65 ~FFmpegGlue(); |
67 | 66 |
68 // Opens an AVFormatContext specially prepared to process reads and seeks | 67 // Opens an AVFormatContext specially prepared to process reads and seeks |
69 // through the FFmpegURLProtocol provided during construction. | 68 // through the FFmpegURLProtocol provided during construction. |
70 bool OpenContext(); | 69 bool OpenContext(); |
71 AVFormatContext* format_context() { return format_context_; } | 70 AVFormatContext* format_context() { return format_context_; } |
72 | 71 |
73 private: | 72 private: |
74 bool open_called_; | 73 bool open_called_; |
75 AVFormatContext* format_context_; | 74 AVFormatContext* format_context_; |
76 scoped_ptr_malloc<AVIOContext, ScopedPtrAVFree> avio_context_; | 75 scoped_ptr<AVIOContext, ScopedPtrAVFree> avio_context_; |
77 | 76 |
78 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); | 77 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); |
79 }; | 78 }; |
80 | 79 |
81 } // namespace media | 80 } // namespace media |
82 | 81 |
83 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ | 82 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ |
OLD | NEW |