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" | |
35 | 34 |
36 namespace media { | 35 namespace media { |
37 | 36 |
38 class MEDIA_EXPORT FFmpegURLProtocol { | 37 class FFmpegURLProtocol { |
39 public: | 38 public: |
40 FFmpegURLProtocol() { | 39 FFmpegURLProtocol() { |
41 } | 40 } |
42 | 41 |
43 virtual ~FFmpegURLProtocol() { | 42 virtual ~FFmpegURLProtocol() { |
44 } | 43 } |
45 | 44 |
46 // Read the given amount of bytes into data, returns the number of bytes read | 45 // Read the given amount of bytes into data, returns the number of bytes read |
47 // if successful, kReadError otherwise. | 46 // if successful, kReadError otherwise. |
48 virtual int Read(int size, uint8* data) = 0; | 47 virtual int Read(int size, uint8* data) = 0; |
49 | 48 |
50 // Returns true and the current file position for this file, false if the | 49 // Returns true and the current file position for this file, false if the |
51 // file position could not be retrieved. | 50 // file position could not be retrieved. |
52 virtual bool GetPosition(int64* position_out) = 0; | 51 virtual bool GetPosition(int64* position_out) = 0; |
53 | 52 |
54 // Returns true if the file position could be set, false otherwise. | 53 // Returns true if the file position could be set, false otherwise. |
55 virtual bool SetPosition(int64 position) = 0; | 54 virtual bool SetPosition(int64 position) = 0; |
56 | 55 |
57 // Returns true and the file size, false if the file size could not be | 56 // Returns true and the file size, false if the file size could not be |
58 // retrieved. | 57 // retrieved. |
59 virtual bool GetSize(int64* size_out) = 0; | 58 virtual bool GetSize(int64* size_out) = 0; |
60 | 59 |
61 // Returns false if this protocol supports random seeking. | 60 // Returns false if this protocol supports random seeking. |
62 virtual bool IsStreaming() = 0; | 61 virtual bool IsStreaming() = 0; |
63 | 62 |
64 private: | 63 private: |
65 DISALLOW_COPY_AND_ASSIGN(FFmpegURLProtocol); | 64 DISALLOW_COPY_AND_ASSIGN(FFmpegURLProtocol); |
66 }; | 65 }; |
67 | 66 |
68 class MEDIA_EXPORT FFmpegGlue { | 67 class FFmpegGlue { |
69 public: | 68 public: |
70 // Returns the singleton instance. | 69 // Returns the singleton instance. |
71 static FFmpegGlue* GetInstance(); | 70 static FFmpegGlue* GetInstance(); |
72 | 71 |
73 // Adds a FFmpegProtocol to the FFmpeg glue layer and returns a unique string | 72 // Adds a FFmpegProtocol to the FFmpeg glue layer and returns a unique string |
74 // that can be passed to FFmpeg to identify the data source. | 73 // that can be passed to FFmpeg to identify the data source. |
75 std::string AddProtocol(FFmpegURLProtocol* protocol); | 74 std::string AddProtocol(FFmpegURLProtocol* protocol); |
76 | 75 |
77 // Removes a FFmpegProtocol from the FFmpeg glue layer. Using strings from | 76 // Removes a FFmpegProtocol from the FFmpeg glue layer. Using strings from |
78 // previously added FFmpegProtocols will no longer work. | 77 // previously added FFmpegProtocols will no longer work. |
(...skipping 20 matching lines...) Expand all Loading... |
99 // Map between keys and FFmpegProtocol references. | 98 // Map between keys and FFmpegProtocol references. |
100 typedef std::map<std::string, FFmpegURLProtocol*> ProtocolMap; | 99 typedef std::map<std::string, FFmpegURLProtocol*> ProtocolMap; |
101 ProtocolMap protocols_; | 100 ProtocolMap protocols_; |
102 | 101 |
103 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); | 102 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); |
104 }; | 103 }; |
105 | 104 |
106 } // namespace media | 105 } // namespace media |
107 | 106 |
108 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ | 107 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ |
OLD | NEW |