diff --git a/headers/os/media/MediaFile.h b/headers/os/media/MediaFile.h index 4624aa8d82..e0ef377409 100644 --- a/headers/os/media/MediaFile.h +++ b/headers/os/media/MediaFile.h @@ -55,14 +55,19 @@ public: BMediaFile( BDataIO * source, int32 flags); // BFile is a BDataIO - // these two constructors are for read-write access + // these three constructors are for read-write access BMediaFile(const entry_ref *ref, // these two are write-only const media_file_format * mfi, int32 flags=0); BMediaFile(BDataIO *destination, // BFile is a BDataIO const media_file_format * mfi, int32 flags=0); - + BMediaFile(const media_file_format * mfi, // set file later using SetTo() + int32 flags=0); + + status_t SetTo(const entry_ref *ref); + status_t SetTo(BDataIO *destination); // BFile is a BDataIO + virtual ~BMediaFile(); status_t InitCheck() const; @@ -92,9 +97,9 @@ public: // Create and add a track to the media file - BMediaTrack *CreateTrack(media_format *mf, const media_codec_info *mci); + BMediaTrack *CreateTrack(media_format *mf, const media_codec_info *mci, uint32 flags=0); // Create and add a raw track to the media file (it has no encoder) - BMediaTrack *CreateTrack(media_format *mf); + BMediaTrack *CreateTrack(media_format *mf, uint32 flags=0); // Lets you set the copyright info for the entire file status_t AddCopyright(const char *data); @@ -109,16 +114,23 @@ public: status_t CloseFile(void); // This is for controlling file format parameters - BParameterWeb *Web(); + + // returns a copy of the parameter web + status_t GetParameterWeb(BParameterWeb** outWeb); status_t GetParameterValue(int32 id, void *valu, size_t *size); status_t SetParameterValue(int32 id, const void *valu, size_t size); BView *GetParameterView(); - // For the future... virtual status_t Perform(int32 selector, void * data); private: + // deprecated, but for R5 compatibility + BParameterWeb *Web(); + + // Does nothing, returns B_ERROR, for Zeta compatiblity only + status_t ControlFile(int32 selector, void * io_data, size_t size); + BPrivate::media::MediaExtractor *fExtractor; int32 _reserved_BMediaFile_was_fExtractorID; int32 fTrackNum; diff --git a/headers/os/media/MediaTrack.h b/headers/os/media/MediaTrack.h index cf9fa4e502..19b1909c92 100644 --- a/headers/os/media/MediaTrack.h +++ b/headers/os/media/MediaTrack.h @@ -81,7 +81,7 @@ public: // The data returned through ReadFrames() will be in the format that's // returned by this function. - status_t DecodedFormat(media_format *inout_format, int32 flags = 0); + status_t DecodedFormat(media_format *inout_format, uint32 flags = 0); // CountFrames and Duration return the total number of frame and the // total duration (expressed in microseconds) of a track. @@ -177,7 +177,8 @@ public: status_t Flush(); // These are for controlling the underlying encoder and track parameters - BParameterWeb *Web(); + // returns a copy of the parameter web + status_t GetParameterWeb(BParameterWeb** outWeb); status_t GetParameterValue(int32 id, void *valu, size_t *size); status_t SetParameterValue(int32 id, const void *valu, size_t size); BView *GetParameterView(); @@ -196,6 +197,12 @@ virtual status_t Perform(int32 selector, void * data); private: friend class BMediaFile; + // deprecated, but for BeOS R5 compatibility + BParameterWeb *Web(); + + // Does nothing, returns B_ERROR, for Zeta compatiblity only + status_t ControlCodec(int32 selector, void *io_data, size_t size); + // for read-only access to a track BMediaTrack(BPrivate::media::MediaExtractor *extractor, int32 stream); @@ -206,10 +213,6 @@ private: BPrivate::media::Encoder *encoder, media_codec_info *mci); -#ifdef __BUILDING_MEDIA_TRACK_CPP - status_t DecodedFormat(media_format *inout_format); -#endif - void SetupWorkaround(); bool SetupFormatTranslation(const media_format &from, media_format *to); diff --git a/src/kits/media/MediaFile.cpp b/src/kits/media/MediaFile.cpp index c9fcfd2be3..c339fb80a0 100644 --- a/src/kits/media/MediaFile.cpp +++ b/src/kits/media/MediaFile.cpp @@ -1,8 +1,28 @@ -/*********************************************************************** - * AUTHOR: Marcus Overhagen - * FILE: MediaFile.cpp - * DESCR: - ***********************************************************************/ +/* + * Copyright (c) 2002-2004, Marcus Overhagen + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + #include #include #include @@ -15,6 +35,7 @@ * public BMediaFile *************************************************************/ + BMediaFile::BMediaFile(const entry_ref *ref) { CALLED(); @@ -23,6 +44,7 @@ BMediaFile::BMediaFile(const entry_ref *ref) InitReader(new BFile(ref, O_RDONLY)); } + BMediaFile::BMediaFile(BDataIO * source) { CALLED(); @@ -30,6 +52,7 @@ BMediaFile::BMediaFile(BDataIO * source) InitReader(source); } + BMediaFile::BMediaFile(const entry_ref * ref, int32 flags) { @@ -39,6 +62,7 @@ BMediaFile::BMediaFile(const entry_ref * ref, InitReader(new BFile(ref, O_RDONLY), flags); } + BMediaFile::BMediaFile(BDataIO * source, int32 flags) { @@ -47,6 +71,7 @@ BMediaFile::BMediaFile(BDataIO * source, InitReader(source, flags); } + BMediaFile::BMediaFile(const entry_ref *ref, const media_file_format * mfi, int32 flags) @@ -56,6 +81,7 @@ BMediaFile::BMediaFile(const entry_ref *ref, fDeleteSource = true; InitWriter(new BFile(ref, O_WRONLY), mfi, flags); } + BMediaFile::BMediaFile(BDataIO *destination, const media_file_format * mfi, @@ -66,6 +92,29 @@ BMediaFile::BMediaFile(BDataIO *destination, InitWriter(destination, mfi, flags); } + +// File will be set later by SetTo() +BMediaFile::BMediaFile(const media_file_format * mfi, + int32 flags) +{ + debugger("BMediaFile::BMediaFile not implemented"); +} + + +status_t +BMediaFile::SetTo(const entry_ref *ref) +{ + debugger("BMediaFile::SetTo not implemented"); +} + + +status_t +BMediaFile::SetTo(BDataIO *destination) +{ + debugger("BMediaFile::SetTo not implemented"); +} + + /* virtual */ BMediaFile::~BMediaFile() { @@ -78,6 +127,7 @@ BMediaFile::~BMediaFile() delete fSource; } + status_t BMediaFile::InitCheck() const { @@ -85,6 +135,7 @@ BMediaFile::InitCheck() const return fErr; } + // Get info about the underlying file format. status_t BMediaFile::GetFileFormatInfo(media_file_format *mfi) const @@ -96,6 +147,7 @@ BMediaFile::GetFileFormatInfo(media_file_format *mfi) const return B_OK; } + const char * BMediaFile::Copyright(void) const { @@ -103,6 +155,7 @@ BMediaFile::Copyright(void) const return ""; } + int32 BMediaFile::CountTracks() const { @@ -149,6 +202,7 @@ BMediaFile::ReleaseTrack(BMediaTrack *track) return B_ERROR; } + status_t BMediaFile::ReleaseAllTracks(void) { @@ -165,21 +219,48 @@ BMediaFile::ReleaseAllTracks(void) return B_OK; } + // Create and add a track to the media file BMediaTrack * BMediaFile::CreateTrack(media_format *mf, - const media_codec_info *mci) + const media_codec_info *mci, + uint32 flags) { UNIMPLEMENTED(); return 0; } + // Create and add a raw track to the media file (it has no encoder) BMediaTrack * -BMediaFile::CreateTrack(media_format *mf) +BMediaFile::CreateTrack(media_format *mf, uint32 flags) { - UNIMPLEMENTED(); - return 0; + return CreateTrack(mf, NULL, flags); +} + + +// For BeOS R5 compatibility +extern "C" BMediaTrack * CreateTrack__10BMediaFileP12media_formatPC16media_codec_info( + BMediaFile *self, media_format *mf, const media_codec_info *mci); +BMediaTrack * +CreateTrack__10BMediaFileP12media_formatPC16media_codec_info( + BMediaFile *self, + media_format *mf, + const media_codec_info *mci) +{ + return self->CreateTrack(mf, mci, 0); +} + + +// For BeOS R5 compatibility +extern "C" BMediaTrack * CreateTrack__10BMediaFileP12media_format( + BMediaFile *self, media_format *mf); +BMediaTrack * +CreateTrack__10BMediaFileP12media_format( + BMediaFile *self, + media_format *mf) +{ + return self->CreateTrack(mf, NULL, 0); } @@ -218,8 +299,18 @@ BMediaFile::CloseFile(void) return B_OK; } - // This is for controlling file format parameters + +// returns a copy of the parameter web +status_t +BMediaFile::GetParameterWeb(BParameterWeb** outWeb) +{ + UNIMPLEMENTED(); + return B_ERROR; +} + + +// deprecated BeOS R5 API BParameterWeb * BMediaFile::Web() { @@ -227,6 +318,7 @@ BMediaFile::Web() return 0; } + status_t BMediaFile::GetParameterValue(int32 id, void *valu, size_t *size) { @@ -234,6 +326,7 @@ BMediaFile::GetParameterValue(int32 id, void *valu, size_t *size) return B_OK; } + status_t BMediaFile::SetParameterValue(int32 id, const void *valu, size_t size) { @@ -249,6 +342,7 @@ BMediaFile::GetParameterView() return 0; } + /* virtual */ status_t BMediaFile::Perform(int32 selector, void * data) { @@ -257,10 +351,19 @@ BMediaFile::Perform(int32 selector, void * data) } +status_t +BMediaFile::ControlFile(int32 selector, void * io_data, size_t size) +{ + UNIMPLEMENTED(); + return B_ERROR; +} + + /************************************************************* * private BMediaFile *************************************************************/ + void BMediaFile::Init() { @@ -280,6 +383,7 @@ BMediaFile::Init() fFileClosed = 0; } + void BMediaFile::InitReader(BDataIO *source, int32 flags) { @@ -298,6 +402,7 @@ BMediaFile::InitReader(BDataIO *source, int32 flags) memset(fTrackList, 0, fTrackNum * sizeof(BMediaTrack *)); } + void BMediaFile::InitWriter(BDataIO *source, const media_file_format * mfi, int32 flags) { diff --git a/src/kits/media/MediaTrack.cpp b/src/kits/media/MediaTrack.cpp index cbfa01aa1c..048ab11736 100644 --- a/src/kits/media/MediaTrack.cpp +++ b/src/kits/media/MediaTrack.cpp @@ -1,11 +1,28 @@ -/*********************************************************************** - * AUTHOR: Marcus Overhagen - * FILE: MediaTrack.cpp - * DESCR: - ***********************************************************************/ +/* + * Copyright (c) 2002-2004, Marcus Overhagen + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ -#define __BUILDING_MEDIA_TRACK_CPP - #include #include #include @@ -104,15 +121,17 @@ BMediaTrack::EncodedFormat(media_format *out_format) const } -status_t -BMediaTrack::DecodedFormat(media_format *inout_format) +// for BeOS R5 compatibilitly +extern "C" status_t DecodedFormat__11BMediaTrackP12media_format(BMediaTrack *self, media_format *inout_format); +status_t DecodedFormat__11BMediaTrackP12media_format(BMediaTrack *self, + media_format *inout_format) { - return DecodedFormat(inout_format, 0); + return self->DecodedFormat(inout_format, 0); } status_t -BMediaTrack::DecodedFormat(media_format *inout_format, int32 flags) +BMediaTrack::DecodedFormat(media_format *inout_format, uint32 flags) { CALLED(); if (!inout_format) @@ -513,6 +532,7 @@ BMediaTrack::Flush() } +// deprecated BeOS R5 API BParameterWeb * BMediaTrack::Web() { @@ -521,6 +541,13 @@ BMediaTrack::Web() } +// returns a copy of the parameter web +status_t +BMediaTrack::GetParameterWeb(BParameterWeb** outWeb) +{ +} + + status_t BMediaTrack::GetParameterValue(int32 id, void *valu, @@ -638,6 +665,15 @@ BMediaTrack::BMediaTrack(BPrivate::MediaWriter *writer, UNIMPLEMENTED(); } + +// Does nothing, returns B_ERROR, for Zeta compatiblity only +status_t +BMediaTrack::ControlCodec(int32 selector, void *io_data, size_t size) +{ + return B_ERROR; +} + + void BMediaTrack::SetupWorkaround() {