2 * Copyright 2002-2009, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT license.
11 #include <MediaDefs.h>
12 #include <MediaFormats.h>
13 #include <StorageDefs.h>
26 // forward declarations
34 // flags for the BMediaFile constructor
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
56 // these four constructors are used for read-only access
57 BMediaFile(const entry_ref
* ref
);
58 BMediaFile(BDataIO
* source
);
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
,
67 BMediaFile(BDataIO
* destination
,
68 const media_file_format
* mfi
,
70 BMediaFile(const media_file_format
* mfi
,
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
,
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
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
,
127 // Create and add a raw track to the media file (it has no encoder)
128 BMediaTrack
* CreateTrack(media_format
* mf
,
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
,
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
,
150 status_t
SetParameterValue(int32 id
, const void* value
,
152 BView
* GetParameterView();
155 virtual status_t
Perform(int32 selector
, void* data
);
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
,
165 BPrivate::media::MediaExtractor
* fExtractor
;
166 int32 _reserved_BMediaFile_was_fExtractorID
;
170 BPrivate::_AddonManager
* fEncoderMgr
;
171 BPrivate::_AddonManager
* fWriterMgr
;
172 BPrivate::media::MediaWriter
* fWriter
;
174 media_file_format fMFI
;
176 BPrivate::media::MediaStreamer
* fStreamer
;
180 bool _reserved_was_fUnused
[2];
181 BMediaTrack
** fTrackList
;
185 void _InitReader(BDataIO
* source
,
186 const BUrl
* url
= NULL
,
188 void _InitWriter(BDataIO
* target
,
190 const media_file_format
* fileFormat
,
192 void _InitStreamer(const BUrl
& url
,
196 BMediaFile(const BMediaFile
&);
197 BMediaFile
& operator=(const BMediaFile
&);
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
, ...);