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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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
OLDNEW
1 // Copyright (c) 2012 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 interface between FFmpeg and Chrome used to proxy FFmpeg's 5 // FFmpegGlue is an interface between FFmpeg and Chrome used to proxy FFmpeg's
6 // read and seek requests to Chrome's internal data structures. The glue works 6 // read and seek requests to Chrome's internal data structures. The glue works
7 // through the AVIO interface provided by FFmpeg. 7 // through the AVIO interface provided by FFmpeg.
8 // 8 //
9 // AVIO works through a special AVIOContext created through avio_alloc_context() 9 // AVIO works through a special AVIOContext created through avio_alloc_context()
10 // which is attached to the AVFormatContext used for demuxing. The AVIO context 10 // which is attached to the AVFormatContext used for demuxing. The AVIO context
11 // is initialized with read and seek methods which FFmpeg calls when necessary. 11 // is initialized with read and seek methods which FFmpeg calls when necessary.
12 // 12 //
13 // During OpenContext() FFmpegGlue will tell FFmpeg to use Chrome's AVIO context 13 // During OpenContext() FFmpegGlue will tell FFmpeg to use Chrome's AVIO context
14 // by passing NULL in for the filename parameter to avformat_open_input(). All 14 // by passing NULL in for the filename parameter to avformat_open_input(). All
15 // FFmpeg operations using the configured AVFormatContext will then redirect 15 // FFmpeg operations using the configured AVFormatContext will then redirect
16 // reads and seeks through the glue. 16 // reads and seeks through the glue.
17 // 17 //
18 // The glue in turn processes those read and seek requests using the 18 // The glue in turn processes those read and seek requests using the
19 // FFmpegURLProtocol provided during construction. 19 // FFmpegURLProtocol provided during construction.
20 // 20 //
21 // FFmpegGlue is also responsible for initializing FFmpeg, which is done once 21 // FFmpegGlue is also responsible for initializing FFmpeg, which is done once
22 // per process. Initialization includes: turning off log messages, registering 22 // per process. Initialization includes: turning off log messages, registering
23 // a lock manager, and finally registering all demuxers and codecs. 23 // a lock manager, and finally registering all demuxers and codecs.
24 24
25 #ifndef MEDIA_FILTERS_FFMPEG_GLUE_H_ 25 #ifndef MEDIA_FILTERS_FFMPEG_GLUE_H_
26 #define MEDIA_FILTERS_FFMPEG_GLUE_H_ 26 #define MEDIA_FILTERS_FFMPEG_GLUE_H_
27 27
28 #include "base/basictypes.h"
29 #include "base/memory/scoped_ptr.h" 28 #include "base/memory/scoped_ptr.h"
30 #include "media/base/media_export.h" 29 #include "media/base/media_export.h"
31 #include "media/ffmpeg/ffmpeg_deleters.h" 30 #include "media/ffmpeg/ffmpeg_deleters.h"
32 31
33 struct AVFormatContext; 32 struct AVFormatContext;
34 struct AVIOContext; 33 struct AVIOContext;
35 34
36 namespace media { 35 namespace media {
37 36
38 class MEDIA_EXPORT FFmpegURLProtocol { 37 class MEDIA_EXPORT FFmpegURLProtocol {
39 public: 38 public:
40 // Read the given amount of bytes into data, returns the number of bytes read 39 // Read the given amount of bytes into data, returns the number of bytes read
41 // if successful, kReadError otherwise. 40 // if successful, kReadError otherwise.
42 virtual int Read(int size, uint8* data) = 0; 41 virtual int Read(int size, uint8_t* data) = 0;
43 42
44 // Returns true and the current file position for this file, false if the 43 // Returns true and the current file position for this file, false if the
45 // file position could not be retrieved. 44 // file position could not be retrieved.
46 virtual bool GetPosition(int64* position_out) = 0; 45 virtual bool GetPosition(int64_t* position_out) = 0;
47 46
48 // Returns true if the file position could be set, false otherwise. 47 // Returns true if the file position could be set, false otherwise.
49 virtual bool SetPosition(int64 position) = 0; 48 virtual bool SetPosition(int64_t position) = 0;
50 49
51 // Returns true and the file size, false if the file size could not be 50 // Returns true and the file size, false if the file size could not be
52 // retrieved. 51 // retrieved.
53 virtual bool GetSize(int64* size_out) = 0; 52 virtual bool GetSize(int64_t* size_out) = 0;
54 53
55 // Returns false if this protocol supports random seeking. 54 // Returns false if this protocol supports random seeking.
56 virtual bool IsStreaming() = 0; 55 virtual bool IsStreaming() = 0;
57 }; 56 };
58 57
59 class MEDIA_EXPORT FFmpegGlue { 58 class MEDIA_EXPORT FFmpegGlue {
60 public: 59 public:
61 static void InitializeFFmpeg(); 60 static void InitializeFFmpeg();
62 61
63 // See file documentation for usage. |protocol| must outlive FFmpegGlue. 62 // See file documentation for usage. |protocol| must outlive FFmpegGlue.
64 explicit FFmpegGlue(FFmpegURLProtocol* protocol); 63 explicit FFmpegGlue(FFmpegURLProtocol* protocol);
65 ~FFmpegGlue(); 64 ~FFmpegGlue();
66 65
67 // Opens an AVFormatContext specially prepared to process reads and seeks 66 // Opens an AVFormatContext specially prepared to process reads and seeks
68 // through the FFmpegURLProtocol provided during construction. 67 // through the FFmpegURLProtocol provided during construction.
69 bool OpenContext(); 68 bool OpenContext();
70 AVFormatContext* format_context() { return format_context_; } 69 AVFormatContext* format_context() { return format_context_; }
71 70
72 private: 71 private:
73 bool open_called_; 72 bool open_called_;
74 AVFormatContext* format_context_; 73 AVFormatContext* format_context_;
75 scoped_ptr<AVIOContext, ScopedPtrAVFree> avio_context_; 74 scoped_ptr<AVIOContext, ScopedPtrAVFree> avio_context_;
76 75
77 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue); 76 DISALLOW_COPY_AND_ASSIGN(FFmpegGlue);
78 }; 77 };
79 78
80 } // namespace media 79 } // namespace media
81 80
82 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_ 81 #endif // MEDIA_FILTERS_FFMPEG_GLUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698