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

Unified Diff: media/filters/ffmpeg_glue.h

Issue 10912080: Switch to AVIO instead of a custom FFmpeg URLProtocol handler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: AVIO! Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/ffmpeg_glue.h
diff --git a/media/filters/ffmpeg_glue.h b/media/filters/ffmpeg_glue.h
index c5aa15c2ad8220dc0e3dfd2a3fcfda9b3ae70edc..8946f85151a72e311efa48d928c400020b8f4d3b 100644
--- a/media/filters/ffmpeg_glue.h
+++ b/media/filters/ffmpeg_glue.h
@@ -26,24 +26,22 @@
#ifndef MEDIA_FILTERS_FFMPEG_GLUE_H_
#define MEDIA_FILTERS_FFMPEG_GLUE_H_
-#include <map>
-#include <string>
-
-#include "base/memory/singleton.h"
-#include "base/synchronization/lock.h"
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
#include "media/base/media_export.h"
-struct URLProtocol;
+struct AVFormatContext;
+struct AVIOContext;
namespace media {
+class ScopedPtrAVFree;
+
class MEDIA_EXPORT FFmpegURLProtocol {
Ami GONE FROM CHROMIUM 2012/09/27 03:24:45 wants renaming?
public:
- FFmpegURLProtocol() {}
-
// Read the given amount of bytes into data, returns the number of bytes read
// if successful, kReadError otherwise.
- virtual size_t Read(size_t size, uint8* data) = 0;
+ virtual int Read(int size, uint8* data) = 0;
// Returns true and the current file position for this file, false if the
// file position could not be retrieved.
@@ -58,53 +56,22 @@ class MEDIA_EXPORT FFmpegURLProtocol {
// Returns false if this protocol supports random seeking.
virtual bool IsStreaming() = 0;
-
- protected:
- virtual ~FFmpegURLProtocol() {}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FFmpegURLProtocol);
};
class MEDIA_EXPORT FFmpegGlue {
public:
- // Returns the singleton instance.
- static FFmpegGlue* GetInstance();
-
- // Adds a FFmpegProtocol to the FFmpeg glue layer and returns a unique string
- // that can be passed to FFmpeg to identify the data source.
- std::string AddProtocol(FFmpegURLProtocol* protocol);
+ static void InitializeFFmpeg();
- // Removes a FFmpegProtocol from the FFmpeg glue layer. Using strings from
- // previously added FFmpegProtocols will no longer work.
- void RemoveProtocol(FFmpegURLProtocol* protocol);
-
- // Assigns the FFmpegProtocol identified with by the given key to
- // |protocol|, or assigns NULL if no such FFmpegProtocol could be found.
- void GetProtocol(const std::string& key,
- FFmpegURLProtocol** protocol);
-
- private:
- // Only allow Singleton to create and delete FFmpegGlue.
- friend struct DefaultSingletonTraits<FFmpegGlue>;
- FFmpegGlue();
+ explicit FFmpegGlue(FFmpegURLProtocol* protocol);
virtual ~FFmpegGlue();
Ami GONE FROM CHROMIUM 2012/09/27 03:24:45 why virtual?
DaleCurtis 2012/10/02 01:24:23 Done.
- // Returns the unique key for this data source, which can be passed to
- // avformat_open_input() as the filename.
- std::string GetProtocolKey(FFmpegURLProtocol* protocol);
-
- // Mutual exclusion while adding/removing items from the map.
- base::Lock lock_;
+ int OpenContext();
Ami GONE FROM CHROMIUM 2012/09/27 03:24:45 why not return a bool for success? (here and elsew
DaleCurtis 2012/10/02 01:24:23 Done.
+ AVFormatContext* format_context() { return format_context_; }
- // Map between keys and FFmpegProtocol references.
- typedef std::map<std::string, FFmpegURLProtocol*> ProtocolMap;
- ProtocolMap protocols_;
-
- friend class FFmpegGlueTest;
- static URLProtocol* url_protocol();
-
- DISALLOW_COPY_AND_ASSIGN(FFmpegGlue);
+ private:
+ bool open_called_;
+ AVFormatContext* format_context_;
+ scoped_ptr_malloc<AVIOContext, ScopedPtrAVFree> avio_context_;
};
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698