Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: media/filters/ffmpeg_glue.h

Issue 9317096: Fix media code to work with new ffmpeg. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix years. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | media/filters/ffmpeg_glue.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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 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 // avformat_open_input() 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 avformat_open_input(),
11 // need a way for av_open_input_file to find the correct DataSource instance. 11 // we need a way for avformat_open_input() to find the correct DataSource
12 // The solution is to maintain a map of "filenames" to DataSource instances, 12 // instance. The solution is to maintain a map of "filenames" to DataSource
13 // where filenames are actually just a unique identifier. For simplicity, 13 // instances, where filenames are actually just a unique identifier. For
14 // FFmpegGlue is registered as an HTTP handler and generates filenames based on 14 // simplicity, FFmpegGlue is registered as an HTTP handler and generates
15 // the memory address of the DataSource, i.e., http://0xc0bf4870. Since there 15 // filenames based on the memory address of the DataSource, i.e.,
16 // may be multiple FFmpegDemuxers active at one time, FFmpegGlue is a 16 // http://0xc0bf4870. Since there may be multiple FFmpegDemuxers active at one
17 // thread-safe singleton. 17 // time, FFmpegGlue is a thread-safe singleton.
18 // 18 //
19 // Usage: FFmpegDemuxer adds the DataSource to FFmpegGlue's map and is given a 19 // Usage: FFmpegDemuxer adds the DataSource to FFmpegGlue's map and is given a
20 // filename to pass to av_open_input_file. FFmpegDemuxer calls 20 // filename to pass to avformat_open_input(). FFmpegDemuxer calls
21 // av_open_input_file with the filename, which results in FFmpegGlue returning 21 // avformat_open_input() with the filename, which results in FFmpegGlue
22 // the DataSource as a URLProtocol instance to FFmpeg. Since FFmpegGlue is only 22 // returning the DataSource as a URLProtocol instance to FFmpeg. Since
23 // needed for opening files, when av_open_input_file returns FFmpegDemuxer 23 // FFmpegGlue is only needed for opening files, when avformat_open_input()
24 // removes the DataSource from FFmpegGlue's map. 24 // returns FFmpegDemuxer 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 #include "media/base/media_export.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 void GetProtocol(const std::string& key, 83 void GetProtocol(const std::string& key,
84 FFmpegURLProtocol** protocol); 84 FFmpegURLProtocol** protocol);
85 85
86 private: 86 private:
87 // Only allow Singleton to create and delete FFmpegGlue. 87 // Only allow Singleton to create and delete FFmpegGlue.
88 friend struct DefaultSingletonTraits<FFmpegGlue>; 88 friend struct DefaultSingletonTraits<FFmpegGlue>;
89 FFmpegGlue(); 89 FFmpegGlue();
90 virtual ~FFmpegGlue(); 90 virtual ~FFmpegGlue();
91 91
92 // Returns the unique key for this data source, which can be passed to 92 // Returns the unique key for this data source, which can be passed to
93 // av_open_input_file as the filename. 93 // avformat_open_input() as the filename.
94 std::string GetProtocolKey(FFmpegURLProtocol* protocol); 94 std::string GetProtocolKey(FFmpegURLProtocol* protocol);
95 95
96 // Mutual exclusion while adding/removing items from the map. 96 // Mutual exclusion while adding/removing items from the map.
97 base::Lock lock_; 97 base::Lock lock_;
98 98
99 // Map between keys and FFmpegProtocol references. 99 // Map between keys and FFmpegProtocol references.
100 typedef std::map<std::string, FFmpegURLProtocol*> ProtocolMap; 100 typedef std::map<std::string, FFmpegURLProtocol*> ProtocolMap;
101 ProtocolMap protocols_; 101 ProtocolMap protocols_;
102 102
103 friend class FFmpegGlueTest; 103 friend class FFmpegGlueTest;
104 static URLProtocol* url_protocol(); 104 static URLProtocol* url_protocol();
105 105
106 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); 106 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue);
107 }; 107 };
108 108
109 } // namespace media 109 } // namespace media
110 110
111 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ 111 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | media/filters/ffmpeg_glue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698