OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 adapter for FFmpeg's URLProtocol interface that allows us to | 5 // FFmpegGlue is an adapter for FFmpeg's URLProtocol interface that allows us to |
6 // use a DataSource implementation with FFmpeg. For convenience we use FFmpeg's | 6 // use a DataSource implementation with FFmpeg. For convenience we use FFmpeg's |
7 // av_open_input_file function, which analyzes the filename given to it and | 7 // av_open_input_file function, which analyzes the filename given to it and |
8 // automatically initializes the appropriate URLProtocol. | 8 // automatically initializes the appropriate URLProtocol. |
9 // | 9 // |
10 // Since the DataSource is already open by time we call av_open_input_file, we | 10 // Since the DataSource is already open by time we call av_open_input_file, we |
(...skipping 13 matching lines...) Expand all Loading... |
24 // removes the DataSource from FFmpegGlue's map. | 24 // removes the DataSource from FFmpegGlue's map. |
25 | 25 |
26 #ifndef MEDIA_FILTERS_FFMPEG_GLUE_H_ | 26 #ifndef MEDIA_FILTERS_FFMPEG_GLUE_H_ |
27 #define MEDIA_FILTERS_FFMPEG_GLUE_H_ | 27 #define MEDIA_FILTERS_FFMPEG_GLUE_H_ |
28 | 28 |
29 #include <map> | 29 #include <map> |
30 #include <string> | 30 #include <string> |
31 | 31 |
32 #include "base/memory/singleton.h" | 32 #include "base/memory/singleton.h" |
33 #include "base/synchronization/lock.h" | 33 #include "base/synchronization/lock.h" |
| 34 #include "media/base/media_export.h" |
34 | 35 |
35 namespace media { | 36 namespace media { |
36 | 37 |
37 class FFmpegURLProtocol { | 38 class MEDIA_EXPORT FFmpegURLProtocol { |
38 public: | 39 public: |
39 FFmpegURLProtocol() { | 40 FFmpegURLProtocol() { |
40 } | 41 } |
41 | 42 |
42 virtual ~FFmpegURLProtocol() { | 43 virtual ~FFmpegURLProtocol() { |
43 } | 44 } |
44 | 45 |
45 // Read the given amount of bytes into data, returns the number of bytes read | 46 // Read the given amount of bytes into data, returns the number of bytes read |
46 // if successful, kReadError otherwise. | 47 // if successful, kReadError otherwise. |
47 virtual int Read(int size, uint8* data) = 0; | 48 virtual int Read(int size, uint8* data) = 0; |
48 | 49 |
49 // Returns true and the current file position for this file, false if the | 50 // Returns true and the current file position for this file, false if the |
50 // file position could not be retrieved. | 51 // file position could not be retrieved. |
51 virtual bool GetPosition(int64* position_out) = 0; | 52 virtual bool GetPosition(int64* position_out) = 0; |
52 | 53 |
53 // Returns true if the file position could be set, false otherwise. | 54 // Returns true if the file position could be set, false otherwise. |
54 virtual bool SetPosition(int64 position) = 0; | 55 virtual bool SetPosition(int64 position) = 0; |
55 | 56 |
56 // Returns true and the file size, false if the file size could not be | 57 // Returns true and the file size, false if the file size could not be |
57 // retrieved. | 58 // retrieved. |
58 virtual bool GetSize(int64* size_out) = 0; | 59 virtual bool GetSize(int64* size_out) = 0; |
59 | 60 |
60 // Returns false if this protocol supports random seeking. | 61 // Returns false if this protocol supports random seeking. |
61 virtual bool IsStreaming() = 0; | 62 virtual bool IsStreaming() = 0; |
62 | 63 |
63 private: | 64 private: |
64 DISALLOW_COPY_AND_ASSIGN(FFmpegURLProtocol); | 65 DISALLOW_COPY_AND_ASSIGN(FFmpegURLProtocol); |
65 }; | 66 }; |
66 | 67 |
67 class FFmpegGlue { | 68 class MEDIA_EXPORT FFmpegGlue { |
68 public: | 69 public: |
69 // Returns the singleton instance. | 70 // Returns the singleton instance. |
70 static FFmpegGlue* GetInstance(); | 71 static FFmpegGlue* GetInstance(); |
71 | 72 |
72 // Adds a FFmpegProtocol to the FFmpeg glue layer and returns a unique string | 73 // Adds a FFmpegProtocol to the FFmpeg glue layer and returns a unique string |
73 // that can be passed to FFmpeg to identify the data source. | 74 // that can be passed to FFmpeg to identify the data source. |
74 std::string AddProtocol(FFmpegURLProtocol* protocol); | 75 std::string AddProtocol(FFmpegURLProtocol* protocol); |
75 | 76 |
76 // Removes a FFmpegProtocol from the FFmpeg glue layer. Using strings from | 77 // Removes a FFmpegProtocol from the FFmpeg glue layer. Using strings from |
77 // previously added FFmpegProtocols will no longer work. | 78 // previously added FFmpegProtocols will no longer work. |
(...skipping 20 matching lines...) Expand all Loading... |
98 // Map between keys and FFmpegProtocol references. | 99 // Map between keys and FFmpegProtocol references. |
99 typedef std::map<std::string, FFmpegURLProtocol*> ProtocolMap; | 100 typedef std::map<std::string, FFmpegURLProtocol*> ProtocolMap; |
100 ProtocolMap protocols_; | 101 ProtocolMap protocols_; |
101 | 102 |
102 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); | 103 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); |
103 }; | 104 }; |
104 | 105 |
105 } // namespace media | 106 } // namespace media |
106 | 107 |
107 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ | 108 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ |
OLD | NEW |