| 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 14 matching lines...) Expand all Loading... |
| 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 | 34 |
| 35 struct URLProtocol; | |
| 36 | |
| 37 namespace media { | 35 namespace media { |
| 38 | 36 |
| 39 class FFmpegURLProtocol { | 37 class FFmpegURLProtocol { |
| 40 public: | 38 public: |
| 41 FFmpegURLProtocol() {} | 39 FFmpegURLProtocol() { |
| 40 } |
| 42 | 41 |
| 43 virtual ~FFmpegURLProtocol() {} | 42 virtual ~FFmpegURLProtocol() { |
| 43 } |
| 44 | 44 |
| 45 // 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 |
| 46 // if successful, kReadError otherwise. | 46 // if successful, kReadError otherwise. |
| 47 virtual int Read(int size, uint8* data) = 0; | 47 virtual int Read(int size, uint8* data) = 0; |
| 48 | 48 |
| 49 // 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 |
| 50 // file position could not be retrieved. | 50 // file position could not be retrieved. |
| 51 virtual bool GetPosition(int64* position_out) = 0; | 51 virtual bool GetPosition(int64* position_out) = 0; |
| 52 | 52 |
| 53 // Returns true if the file position could be set, false otherwise. | 53 // Returns true if the file position could be set, false otherwise. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // av_open_input_file as the filename. | 92 // av_open_input_file as the filename. |
| 93 std::string GetProtocolKey(FFmpegURLProtocol* protocol); | 93 std::string GetProtocolKey(FFmpegURLProtocol* protocol); |
| 94 | 94 |
| 95 // Mutual exclusion while adding/removing items from the map. | 95 // Mutual exclusion while adding/removing items from the map. |
| 96 base::Lock lock_; | 96 base::Lock lock_; |
| 97 | 97 |
| 98 // Map between keys and FFmpegProtocol references. | 98 // Map between keys and FFmpegProtocol references. |
| 99 typedef std::map<std::string, FFmpegURLProtocol*> ProtocolMap; | 99 typedef std::map<std::string, FFmpegURLProtocol*> ProtocolMap; |
| 100 ProtocolMap protocols_; | 100 ProtocolMap protocols_; |
| 101 | 101 |
| 102 friend class FFmpegGlueTest; | |
| 103 static URLProtocol* url_protocol(); | |
| 104 | |
| 105 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); | 102 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); |
| 106 }; | 103 }; |
| 107 | 104 |
| 108 } // namespace media | 105 } // namespace media |
| 109 | 106 |
| 110 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ | 107 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ |
| OLD | NEW |