2009-06-07 23:35:14 +04:00
|
|
|
/*
|
2009-06-08 01:18:32 +04:00
|
|
|
* Copyright 2002-2009, Haiku, Inc. All rights reserved.
|
2009-07-31 14:46:58 +04:00
|
|
|
* Distributed under the terms of the MIT license.
|
2009-06-07 23:35:14 +04:00
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _MEDIA_FILE_H
|
|
|
|
#define _MEDIA_FILE_H
|
|
|
|
|
2009-07-31 14:46:58 +04:00
|
|
|
|
2009-06-08 01:18:32 +04:00
|
|
|
#include <image.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <List.h>
|
|
|
|
#include <MediaDefs.h>
|
|
|
|
#include <MediaFormats.h>
|
2009-06-07 23:35:14 +04:00
|
|
|
#include <StorageDefs.h>
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
2018-11-27 13:35:01 +03:00
|
|
|
namespace BCodecKit {
|
|
|
|
class BMediaExtractor;
|
|
|
|
class BMediaStreamer;
|
|
|
|
class BMediaWriter;
|
|
|
|
}
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
class _AddonManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-31 14:46:58 +04:00
|
|
|
// forward declarations
|
2002-07-09 16:24:59 +04:00
|
|
|
class BMediaTrack;
|
2010-09-17 12:04:26 +04:00
|
|
|
class BMessage;
|
2002-07-09 16:24:59 +04:00
|
|
|
class BParameterWeb;
|
2016-03-26 00:19:47 +03:00
|
|
|
class BUrl;
|
2002-07-09 16:24:59 +04:00
|
|
|
class BView;
|
|
|
|
|
|
|
|
|
|
|
|
// flags for the BMediaFile constructor
|
|
|
|
enum {
|
|
|
|
B_MEDIA_FILE_REPLACE_MODE = 0x00000001,
|
|
|
|
B_MEDIA_FILE_NO_READ_AHEAD = 0x00000002,
|
|
|
|
B_MEDIA_FILE_UNBUFFERED = 0x00000006,
|
|
|
|
B_MEDIA_FILE_BIG_BUFFERS = 0x00000008
|
|
|
|
};
|
|
|
|
|
|
|
|
// BMediaFile represents a media file (AVI, Quicktime, MPEG, AIFF, WAV, etc)
|
|
|
|
//
|
|
|
|
// To read a file you construct a BMediaFile with an entry_ref, get the
|
|
|
|
// BMediaTracks out of it and use those to read the data.
|
|
|
|
//
|
|
|
|
// To write a file you construct a BMediaFile with an entry ref and an id as
|
|
|
|
// returned by get_next_file_format(). You then CreateTrack() to create
|
|
|
|
// various audio & video tracks. Once you're done creating tracks, call
|
|
|
|
// CommitHeader(), then write data to each track and call CloseFile() when
|
|
|
|
// you're done.
|
|
|
|
//
|
|
|
|
|
|
|
|
class BMediaFile {
|
|
|
|
public:
|
2009-06-07 23:35:14 +04:00
|
|
|
// these four constructors are used for read-only access
|
2009-07-31 14:46:58 +04:00
|
|
|
BMediaFile(const entry_ref* ref);
|
2009-06-07 23:35:14 +04:00
|
|
|
BMediaFile(BDataIO* source);
|
|
|
|
// BFile is a BDataIO
|
|
|
|
BMediaFile(const entry_ref* ref, int32 flags);
|
|
|
|
BMediaFile(BDataIO* source, int32 flags);
|
|
|
|
|
|
|
|
// these three constructors are for read-write access
|
|
|
|
BMediaFile(const entry_ref* ref,
|
|
|
|
const media_file_format* mfi,
|
|
|
|
int32 flags = 0);
|
|
|
|
BMediaFile(BDataIO* destination,
|
|
|
|
const media_file_format* mfi,
|
|
|
|
int32 flags = 0);
|
|
|
|
BMediaFile(const media_file_format* mfi,
|
|
|
|
int32 flags = 0);
|
|
|
|
// set file later using SetTo()
|
|
|
|
|
2016-03-26 00:19:47 +03:00
|
|
|
// Additional constructors used to stream data from protocols
|
|
|
|
// supported by the Streamer API
|
2016-06-25 00:59:25 +03:00
|
|
|
BMediaFile(const BUrl& url);
|
|
|
|
BMediaFile(const BUrl& url, int32 flags);
|
2016-03-26 00:19:47 +03:00
|
|
|
// Read-Write streaming constructor
|
2016-10-20 03:24:33 +03:00
|
|
|
BMediaFile(const BUrl& destination,
|
2016-03-26 00:19:47 +03:00
|
|
|
const media_file_format* mfi,
|
|
|
|
int32 flags = 0);
|
|
|
|
|
2009-06-07 23:35:14 +04:00
|
|
|
virtual ~BMediaFile();
|
|
|
|
|
|
|
|
status_t SetTo(const entry_ref* ref);
|
|
|
|
status_t SetTo(BDataIO* destination);
|
2016-03-26 00:19:47 +03:00
|
|
|
// The streaming equivalent of SetTo
|
2016-06-25 00:59:25 +03:00
|
|
|
status_t SetTo(const BUrl& url);
|
2009-07-31 14:46:58 +04:00
|
|
|
|
2009-06-07 23:35:14 +04:00
|
|
|
status_t InitCheck() const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// Get info about the underlying file format.
|
2009-08-28 18:39:55 +04:00
|
|
|
status_t GetFileFormatInfo(
|
|
|
|
media_file_format* mfi) const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2010-09-17 12:04:26 +04:00
|
|
|
// Returns in _data hierarchical meta-data about the stream.
|
|
|
|
// The fields in the message shall follow a defined naming-scheme,
|
|
|
|
// such that applications can find the same information in different
|
|
|
|
// types of files.
|
|
|
|
status_t GetMetaData(BMessage* _data) const;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
//
|
2009-07-31 14:46:58 +04:00
|
|
|
// These functions are for read-only access to a media file.
|
2002-07-09 16:24:59 +04:00
|
|
|
// The data is read using the BMediaTrack object.
|
|
|
|
//
|
2009-06-07 23:35:14 +04:00
|
|
|
const char* Copyright() const;
|
|
|
|
int32 CountTracks() const;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// Can be called multiple times with the same index. You must call
|
|
|
|
// ReleaseTrack() when you're done with a track.
|
2009-06-07 23:35:14 +04:00
|
|
|
BMediaTrack* TrackAt(int32 index);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// Release the resource used by a given BMediaTrack object, to reduce
|
|
|
|
// the memory usage of your application. The specific 'track' object
|
|
|
|
// can no longer be used, but you can create another one by calling
|
|
|
|
// TrackAt() with the same track index.
|
2009-06-07 23:35:14 +04:00
|
|
|
status_t ReleaseTrack(BMediaTrack* track);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2009-06-07 23:35:14 +04:00
|
|
|
// A convenience. Deleting a BMediaFile will also call this.
|
|
|
|
status_t ReleaseAllTracks();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
|
|
|
|
// Create and add a track to the media file
|
2009-06-07 23:35:14 +04:00
|
|
|
BMediaTrack* CreateTrack(media_format* mf,
|
|
|
|
const media_codec_info* mci,
|
|
|
|
uint32 flags = 0);
|
2002-07-09 16:24:59 +04:00
|
|
|
// Create and add a raw track to the media file (it has no encoder)
|
2009-06-07 23:35:14 +04:00
|
|
|
BMediaTrack* CreateTrack(media_format* mf,
|
|
|
|
uint32 flags = 0);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// Lets you set the copyright info for the entire file
|
2009-06-07 23:35:14 +04:00
|
|
|
status_t AddCopyright(const char* data);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// Call this to add user-defined chunks to a file (if they're supported)
|
2009-06-07 23:35:14 +04:00
|
|
|
status_t AddChunk(int32 type, const void* data,
|
|
|
|
size_t size);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// After you have added all the tracks you want, call this
|
2009-06-07 23:35:14 +04:00
|
|
|
status_t CommitHeader();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// After you have written all the data to the track objects, call this
|
2009-06-07 23:35:14 +04:00
|
|
|
status_t CloseFile();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// This is for controlling file format parameters
|
2004-08-16 16:44:00 +04:00
|
|
|
|
|
|
|
// returns a copy of the parameter web
|
2009-06-07 23:35:14 +04:00
|
|
|
status_t GetParameterWeb(BParameterWeb** outWeb);
|
|
|
|
status_t GetParameterValue(int32 id, void* value,
|
|
|
|
size_t* size);
|
|
|
|
status_t SetParameterValue(int32 id, const void* value,
|
|
|
|
size_t size);
|
|
|
|
BView* GetParameterView();
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// For the future...
|
2009-06-07 23:35:14 +04:00
|
|
|
virtual status_t Perform(int32 selector, void* data);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
2004-08-16 16:44:00 +04:00
|
|
|
// deprecated, but for R5 compatibility
|
2009-06-07 23:35:14 +04:00
|
|
|
BParameterWeb* Web();
|
2004-08-16 16:44:00 +04:00
|
|
|
|
2009-07-31 14:46:58 +04:00
|
|
|
// Does nothing, returns B_ERROR, for Zeta compatiblity only
|
2009-06-07 23:35:14 +04:00
|
|
|
status_t ControlFile(int32 selector, void* ioData,
|
|
|
|
size_t size);
|
|
|
|
|
2018-11-27 13:35:01 +03:00
|
|
|
BCodecKit::BMediaExtractor* fExtractor;
|
2009-06-07 23:35:14 +04:00
|
|
|
int32 _reserved_BMediaFile_was_fExtractorID;
|
|
|
|
int32 fTrackNum;
|
|
|
|
status_t fErr;
|
|
|
|
|
|
|
|
BPrivate::_AddonManager* fEncoderMgr;
|
|
|
|
BPrivate::_AddonManager* fWriterMgr;
|
2018-11-27 13:35:01 +03:00
|
|
|
BCodecKit::BMediaWriter* fWriter;
|
2009-06-07 23:35:14 +04:00
|
|
|
int32 fWriterID;
|
|
|
|
media_file_format fMFI;
|
|
|
|
|
2018-11-27 13:35:01 +03:00
|
|
|
BCodecKit::BMediaStreamer* fStreamer;
|
2017-05-04 15:00:06 +03:00
|
|
|
|
2009-06-07 23:35:14 +04:00
|
|
|
bool fFileClosed;
|
|
|
|
bool fDeleteSource;
|
|
|
|
bool _reserved_was_fUnused[2];
|
|
|
|
BMediaTrack** fTrackList;
|
|
|
|
|
|
|
|
void _Init();
|
2009-06-07 23:43:26 +04:00
|
|
|
void _UnInit();
|
2016-06-25 00:59:25 +03:00
|
|
|
void _InitReader(BDataIO* source,
|
|
|
|
const BUrl* url = NULL,
|
2016-03-26 00:19:47 +03:00
|
|
|
int32 flags = 0);
|
2016-06-25 00:59:25 +03:00
|
|
|
void _InitWriter(BDataIO* target,
|
|
|
|
const BUrl* url,
|
2009-07-31 14:46:58 +04:00
|
|
|
const media_file_format* fileFormat,
|
|
|
|
int32 flags);
|
2017-05-04 15:00:06 +03:00
|
|
|
void _InitStreamer(const BUrl& url,
|
|
|
|
BDataIO** adapter);
|
2009-06-07 23:35:14 +04:00
|
|
|
|
|
|
|
BMediaFile();
|
|
|
|
BMediaFile(const BMediaFile&);
|
|
|
|
BMediaFile& operator=(const BMediaFile&);
|
|
|
|
|
|
|
|
BDataIO* fSource;
|
|
|
|
|
|
|
|
// FBC data and virtuals
|
|
|
|
|
2017-05-04 15:00:06 +03:00
|
|
|
uint32 _reserved_BMediaFile_[31];
|
2009-06-07 23:35:14 +04:00
|
|
|
|
|
|
|
virtual status_t _Reserved_BMediaFile_0(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_1(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_2(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_3(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_4(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_5(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_6(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_7(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_8(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_9(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_10(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_11(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_12(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_13(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_14(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_15(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_16(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_17(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_18(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_19(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_20(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_21(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_22(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_23(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_24(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_25(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_26(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_27(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_28(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_29(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_30(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_31(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_32(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_33(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_34(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_35(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_36(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_37(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_38(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_39(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_40(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_41(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_42(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_43(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_44(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_45(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_46(int32 arg, ...);
|
|
|
|
virtual status_t _Reserved_BMediaFile_47(int32 arg, ...);
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|