Make UEFI boot-platform build again
[haiku.git] / headers / os / media / MediaFile.h
blob9b105d8eb016b66043d80a8b3895eb949d777518
1 /*
2 * Copyright 2002-2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
4 */
5 #ifndef _MEDIA_FILE_H
6 #define _MEDIA_FILE_H
9 #include <image.h>
10 #include <List.h>
11 #include <MediaDefs.h>
12 #include <MediaFormats.h>
13 #include <StorageDefs.h>
16 namespace BPrivate {
17 namespace media {
18 class MediaExtractor;
19 class MediaStreamer;
20 class MediaWriter;
22 class _AddonManager;
26 // forward declarations
27 class BMediaTrack;
28 class BMessage;
29 class BParameterWeb;
30 class BUrl;
31 class BView;
34 // flags for the BMediaFile constructor
35 enum {
36 B_MEDIA_FILE_REPLACE_MODE = 0x00000001,
37 B_MEDIA_FILE_NO_READ_AHEAD = 0x00000002,
38 B_MEDIA_FILE_UNBUFFERED = 0x00000006,
39 B_MEDIA_FILE_BIG_BUFFERS = 0x00000008
42 // BMediaFile represents a media file (AVI, Quicktime, MPEG, AIFF, WAV, etc)
44 // To read a file you construct a BMediaFile with an entry_ref, get the
45 // BMediaTracks out of it and use those to read the data.
47 // To write a file you construct a BMediaFile with an entry ref and an id as
48 // returned by get_next_file_format(). You then CreateTrack() to create
49 // various audio & video tracks. Once you're done creating tracks, call
50 // CommitHeader(), then write data to each track and call CloseFile() when
51 // you're done.
54 class BMediaFile {
55 public:
56 // these four constructors are used for read-only access
57 BMediaFile(const entry_ref* ref);
58 BMediaFile(BDataIO* source);
59 // BFile is a BDataIO
60 BMediaFile(const entry_ref* ref, int32 flags);
61 BMediaFile(BDataIO* source, int32 flags);
63 // these three constructors are for read-write access
64 BMediaFile(const entry_ref* ref,
65 const media_file_format* mfi,
66 int32 flags = 0);
67 BMediaFile(BDataIO* destination,
68 const media_file_format* mfi,
69 int32 flags = 0);
70 BMediaFile(const media_file_format* mfi,
71 int32 flags = 0);
72 // set file later using SetTo()
74 // Additional constructors used to stream data from protocols
75 // supported by the Streamer API
76 BMediaFile(const BUrl& url);
77 BMediaFile(const BUrl& url, int32 flags);
78 // Read-Write streaming constructor
79 BMediaFile(const BUrl& destination,
80 const media_file_format* mfi,
81 int32 flags = 0);
83 virtual ~BMediaFile();
85 status_t SetTo(const entry_ref* ref);
86 status_t SetTo(BDataIO* destination);
87 // The streaming equivalent of SetTo
88 status_t SetTo(const BUrl& url);
90 status_t InitCheck() const;
92 // Get info about the underlying file format.
93 status_t GetFileFormatInfo(
94 media_file_format* mfi) const;
96 // Returns in _data hierarchical meta-data about the stream.
97 // The fields in the message shall follow a defined naming-scheme,
98 // such that applications can find the same information in different
99 // types of files.
100 status_t GetMetaData(BMessage* _data) const;
103 // These functions are for read-only access to a media file.
104 // The data is read using the BMediaTrack object.
106 const char* Copyright() const;
107 int32 CountTracks() const;
109 // Can be called multiple times with the same index. You must call
110 // ReleaseTrack() when you're done with a track.
111 BMediaTrack* TrackAt(int32 index);
113 // Release the resource used by a given BMediaTrack object, to reduce
114 // the memory usage of your application. The specific 'track' object
115 // can no longer be used, but you can create another one by calling
116 // TrackAt() with the same track index.
117 status_t ReleaseTrack(BMediaTrack* track);
119 // A convenience. Deleting a BMediaFile will also call this.
120 status_t ReleaseAllTracks();
123 // Create and add a track to the media file
124 BMediaTrack* CreateTrack(media_format* mf,
125 const media_codec_info* mci,
126 uint32 flags = 0);
127 // Create and add a raw track to the media file (it has no encoder)
128 BMediaTrack* CreateTrack(media_format* mf,
129 uint32 flags = 0);
131 // Lets you set the copyright info for the entire file
132 status_t AddCopyright(const char* data);
134 // Call this to add user-defined chunks to a file (if they're supported)
135 status_t AddChunk(int32 type, const void* data,
136 size_t size);
138 // After you have added all the tracks you want, call this
139 status_t CommitHeader();
141 // After you have written all the data to the track objects, call this
142 status_t CloseFile();
144 // This is for controlling file format parameters
146 // returns a copy of the parameter web
147 status_t GetParameterWeb(BParameterWeb** outWeb);
148 status_t GetParameterValue(int32 id, void* value,
149 size_t* size);
150 status_t SetParameterValue(int32 id, const void* value,
151 size_t size);
152 BView* GetParameterView();
154 // For the future...
155 virtual status_t Perform(int32 selector, void* data);
157 private:
158 // deprecated, but for R5 compatibility
159 BParameterWeb* Web();
161 // Does nothing, returns B_ERROR, for Zeta compatiblity only
162 status_t ControlFile(int32 selector, void* ioData,
163 size_t size);
165 BPrivate::media::MediaExtractor* fExtractor;
166 int32 _reserved_BMediaFile_was_fExtractorID;
167 int32 fTrackNum;
168 status_t fErr;
170 BPrivate::_AddonManager* fEncoderMgr;
171 BPrivate::_AddonManager* fWriterMgr;
172 BPrivate::media::MediaWriter* fWriter;
173 int32 fWriterID;
174 media_file_format fMFI;
176 BPrivate::media::MediaStreamer* fStreamer;
178 bool fFileClosed;
179 bool fDeleteSource;
180 bool _reserved_was_fUnused[2];
181 BMediaTrack** fTrackList;
183 void _Init();
184 void _UnInit();
185 void _InitReader(BDataIO* source,
186 const BUrl* url = NULL,
187 int32 flags = 0);
188 void _InitWriter(BDataIO* target,
189 const BUrl* url,
190 const media_file_format* fileFormat,
191 int32 flags);
192 void _InitStreamer(const BUrl& url,
193 BDataIO** adapter);
195 BMediaFile();
196 BMediaFile(const BMediaFile&);
197 BMediaFile& operator=(const BMediaFile&);
199 BDataIO* fSource;
201 // FBC data and virtuals
203 uint32 _reserved_BMediaFile_[31];
205 virtual status_t _Reserved_BMediaFile_0(int32 arg, ...);
206 virtual status_t _Reserved_BMediaFile_1(int32 arg, ...);
207 virtual status_t _Reserved_BMediaFile_2(int32 arg, ...);
208 virtual status_t _Reserved_BMediaFile_3(int32 arg, ...);
209 virtual status_t _Reserved_BMediaFile_4(int32 arg, ...);
210 virtual status_t _Reserved_BMediaFile_5(int32 arg, ...);
211 virtual status_t _Reserved_BMediaFile_6(int32 arg, ...);
212 virtual status_t _Reserved_BMediaFile_7(int32 arg, ...);
213 virtual status_t _Reserved_BMediaFile_8(int32 arg, ...);
214 virtual status_t _Reserved_BMediaFile_9(int32 arg, ...);
215 virtual status_t _Reserved_BMediaFile_10(int32 arg, ...);
216 virtual status_t _Reserved_BMediaFile_11(int32 arg, ...);
217 virtual status_t _Reserved_BMediaFile_12(int32 arg, ...);
218 virtual status_t _Reserved_BMediaFile_13(int32 arg, ...);
219 virtual status_t _Reserved_BMediaFile_14(int32 arg, ...);
220 virtual status_t _Reserved_BMediaFile_15(int32 arg, ...);
221 virtual status_t _Reserved_BMediaFile_16(int32 arg, ...);
222 virtual status_t _Reserved_BMediaFile_17(int32 arg, ...);
223 virtual status_t _Reserved_BMediaFile_18(int32 arg, ...);
224 virtual status_t _Reserved_BMediaFile_19(int32 arg, ...);
225 virtual status_t _Reserved_BMediaFile_20(int32 arg, ...);
226 virtual status_t _Reserved_BMediaFile_21(int32 arg, ...);
227 virtual status_t _Reserved_BMediaFile_22(int32 arg, ...);
228 virtual status_t _Reserved_BMediaFile_23(int32 arg, ...);
229 virtual status_t _Reserved_BMediaFile_24(int32 arg, ...);
230 virtual status_t _Reserved_BMediaFile_25(int32 arg, ...);
231 virtual status_t _Reserved_BMediaFile_26(int32 arg, ...);
232 virtual status_t _Reserved_BMediaFile_27(int32 arg, ...);
233 virtual status_t _Reserved_BMediaFile_28(int32 arg, ...);
234 virtual status_t _Reserved_BMediaFile_29(int32 arg, ...);
235 virtual status_t _Reserved_BMediaFile_30(int32 arg, ...);
236 virtual status_t _Reserved_BMediaFile_31(int32 arg, ...);
237 virtual status_t _Reserved_BMediaFile_32(int32 arg, ...);
238 virtual status_t _Reserved_BMediaFile_33(int32 arg, ...);
239 virtual status_t _Reserved_BMediaFile_34(int32 arg, ...);
240 virtual status_t _Reserved_BMediaFile_35(int32 arg, ...);
241 virtual status_t _Reserved_BMediaFile_36(int32 arg, ...);
242 virtual status_t _Reserved_BMediaFile_37(int32 arg, ...);
243 virtual status_t _Reserved_BMediaFile_38(int32 arg, ...);
244 virtual status_t _Reserved_BMediaFile_39(int32 arg, ...);
245 virtual status_t _Reserved_BMediaFile_40(int32 arg, ...);
246 virtual status_t _Reserved_BMediaFile_41(int32 arg, ...);
247 virtual status_t _Reserved_BMediaFile_42(int32 arg, ...);
248 virtual status_t _Reserved_BMediaFile_43(int32 arg, ...);
249 virtual status_t _Reserved_BMediaFile_44(int32 arg, ...);
250 virtual status_t _Reserved_BMediaFile_45(int32 arg, ...);
251 virtual status_t _Reserved_BMediaFile_46(int32 arg, ...);
252 virtual status_t _Reserved_BMediaFile_47(int32 arg, ...);
255 #endif