Cleanup and preparations for BPrivate::media::MediaWriter, which will soon

exist.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31983 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-07-30 17:47:54 +00:00
parent b2cdb463b3
commit b8316d9f93
2 changed files with 152 additions and 142 deletions
+151 -141
View File
@@ -1,29 +1,34 @@
/*
* Copyright 2002-2009, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT license.
*/
#ifndef _MEDIA_TRACK_H #ifndef _MEDIA_TRACK_H
#define _MEDIA_TRACK_H #define _MEDIA_TRACK_H
#include <SupportDefs.h> #include <SupportDefs.h>
#include <MediaDefs.h> #include <MediaDefs.h>
#include <MediaFormats.h> #include <MediaFormats.h>
namespace BPrivate {
namespace BPrivate { namespace media {
class Decoder;
class Encoder;
class MediaExtractor;
class MediaWriter; class MediaWriter;
namespace media { } }
class MediaExtractor;
class Decoder;
class Encoder;
}
}
class BView; class BView;
class BParameterWeb; class BParameterWeb;
enum media_seek_type { enum media_seek_type {
B_MEDIA_SEEK_CLOSEST_FORWARD = 1, B_MEDIA_SEEK_CLOSEST_FORWARD = 1,
B_MEDIA_SEEK_CLOSEST_BACKWARD = 2, B_MEDIA_SEEK_CLOSEST_BACKWARD = 2,
B_MEDIA_SEEK_DIRECTION_MASK = 3 B_MEDIA_SEEK_DIRECTION_MASK = 3
}; };
//
// BMediaTrack gives access to a particular media track in a media file // BMediaTrack gives access to a particular media track in a media file
// (as represented by BMediaFile). // (as represented by BMediaFile).
// //
@@ -43,15 +48,11 @@ enum media_seek_type {
// //
// If no codec could be found for the track, it is still possible to // If no codec could be found for the track, it is still possible to
// access the encoded data using ReadChunk(). // access the encoded data using ReadChunk().
//
class BMediaTrack { class BMediaTrack {
protected: protected:
// Use BMediaFile::ReleaseTrack() instead -- or it will go away // Use BMediaFile::ReleaseTrack() instead -- or it will go away
// on its own when the MediaFile is deleted. // on its own when the MediaFile is deleted.
// virtual ~BMediaTrack();
virtual ~BMediaTrack();
public: public:
@@ -61,16 +62,16 @@ public:
// for write-only access the BMediaTrack should be instantiated // for write-only access the BMediaTrack should be instantiated
// through BMediaFile::CreateTrack() // through BMediaFile::CreateTrack()
status_t InitCheck() const; status_t InitCheck() const;
// Get information about the codec being used. // Get information about the codec being used.
status_t GetCodecInfo(media_codec_info *mci) const; status_t GetCodecInfo(media_codec_info* _codecInfo) const;
// EncodedFormat returns information about the track's // EncodedFormat returns information about the track's
// "native" encoded format. // "native" encoded format.
status_t EncodedFormat(media_format *out_format) const; status_t EncodedFormat(media_format* _format) const;
// DecodedFormat is used to negotiate the format that the codec will // DecodedFormat is used to negotiate the format that the codec will
// use when decoding the track's data. You pass in the format that // use when decoding the track's data. You pass in the format that
@@ -81,19 +82,20 @@ public:
// The data returned through ReadFrames() will be in the format that's // The data returned through ReadFrames() will be in the format that's
// returned by this function. // returned by this function.
status_t DecodedFormat(media_format *inout_format, uint32 flags = 0); status_t DecodedFormat(media_format* _inOutFormat,
uint32 flags = 0);
// CountFrames and Duration return the total number of frame and the // CountFrames and Duration return the total number of frame and the
// total duration (expressed in microseconds) of a track. // total duration (expressed in microseconds) of a track.
int64 CountFrames() const; int64 CountFrames() const;
bigtime_t Duration() const; bigtime_t Duration() const;
// CurrentFrame and CurrentTime return the current position (expressed in // CurrentFrame and CurrentTime return the current position (expressed in
// microseconds) within the track, expressed in frame index and time. // microseconds) within the track, expressed in frame index and time.
int64 CurrentFrame() const; int64 CurrentFrame() const;
bigtime_t CurrentTime() const; bigtime_t CurrentTime() const;
// ReadFrames() fills a buffer with the next frames/samples. For a video // ReadFrames() fills a buffer with the next frames/samples. For a video
// track, it decodes the next frame of video in the passed buffer. For // track, it decodes the next frame of video in the passed buffer. For
@@ -104,14 +106,16 @@ public:
// frame/samples returned, and the start time for the frame, expressed // frame/samples returned, and the start time for the frame, expressed
// in microseconds, is in the media_header structure. // in microseconds, is in the media_header structure.
status_t ReadFrames(void *out_buffer, int64 *out_frameCount, status_t ReadFrames(void* _buffer, int64* _frameCount,
media_header *mh = NULL); media_header* mediaHeader = NULL);
status_t ReadFrames(void *out_buffer, int64 *out_frameCount, status_t ReadFrames(void* _buffer, int64* _frameCount,
media_header *mh, media_decode_info *info); media_header* mediaHeader,
media_decode_info* info);
status_t ReplaceFrames(const void *in_buffer, int64 *io_frameCount, status_t ReplaceFrames(const void* buffer,
const media_header *mh); int64* _inOutFrameCount,
const media_header* mediaHeader);
// SeekToTime and SeekToFrame are used for seeking to a particular // SeekToTime and SeekToFrame are used for seeking to a particular
@@ -124,13 +128,14 @@ public:
// If you want to explicitly seek to the nearest keyframe _before_ this // If you want to explicitly seek to the nearest keyframe _before_ this
// frame or _after_ this frame, pass B_MEDIA_SEEK_CLOSEST_FORWARD or // frame or _after_ this frame, pass B_MEDIA_SEEK_CLOSEST_FORWARD or
// B_MEDIA_SEEK_CLOSEST_BACKWARD as the flags field. // B_MEDIA_SEEK_CLOSEST_BACKWARD as the flags field.
//
status_t SeekToTime(bigtime_t *inout_time, int32 flags=0); status_t SeekToTime(bigtime_t* _inOutTime, int32 flags = 0);
status_t SeekToFrame(int64 *inout_frame, int32 flags=0); status_t SeekToFrame(int64* _inOutFrame, int32 flags = 0);
status_t FindKeyFrameForTime(bigtime_t *inout_time, int32 flags=0) const; status_t FindKeyFrameForTime(bigtime_t* _inOutTime,
status_t FindKeyFrameForFrame(int64 *inout_frame, int32 flags=0) const; int32 flags = 0) const;
status_t FindKeyFrameForFrame(int64* _inOutFrame,
int32 flags = 0) const;
// ReadChunk returns, in out_buffer, the next out_size bytes of // ReadChunk returns, in out_buffer, the next out_size bytes of
// data from the track. The data is not decoded -- it will be // data from the track. The data is not decoded -- it will be
@@ -139,162 +144,167 @@ public:
// you access the track raw (i.e. with ReadChunk) or you access // you access the track raw (i.e. with ReadChunk) or you access
// it with ReadFrames. // it with ReadFrames.
status_t ReadChunk(char **out_buffer, int32 *out_size, status_t ReadChunk(char** _buffer, int32* _size,
media_header *mh = NULL); media_header* mediaHeader = NULL);
// //
// Write-only Functions // Write-only Functions
// //
status_t AddCopyright(const char *data); status_t AddCopyright(const char* copyright);
status_t AddTrackInfo(uint32 code, const void *data, size_t size, status_t AddTrackInfo(uint32 code, const void* data,
uint32 flags = 0); size_t size, uint32 flags = 0);
//
// Write num_frames of data to the track. This data is passed // Write num_frames of data to the track. This data is passed
// through the encoder that was specified when the MediaTrack // through the encoder that was specified when the MediaTrack
// was constructed. // was constructed.
// Pass B_MEDIA_KEY_FRAME for flags if it is. // Pass B_MEDIA_KEY_FRAME for flags if it is.
//
status_t WriteFrames(const void *data, int32 num_frames,
int32 flags = 0);
status_t WriteFrames(const void *data, int64 num_frames,
media_encode_info *info);
// status_t WriteFrames(const void* data, int32 frameCount,
int32 flags = 0);
status_t WriteFrames(const void* data, int64 frameCount,
media_encode_info* info);
// Write a raw chunk of (presumably already encoded data) to // Write a raw chunk of (presumably already encoded data) to
// the file. // the file.
// Pass B_MEDIA_KEY_FRAME for flags if it is. // Pass B_MEDIA_KEY_FRAME for flags if it is.
//
status_t WriteChunk(const void *data, size_t size, status_t WriteChunk(const void* data, size_t size,
uint32 flags = 0); uint32 flags = 0);
status_t WriteChunk(const void *data, size_t size, status_t WriteChunk(const void* data, size_t size,
media_encode_info *info); media_encode_info* info);
// Flush all buffered encoded datas to disk. You should call it after // Flush all buffered encoded datas to disk. You should call it after
// writing the last frame to be sure all datas are flushed at the right // writing the last frame to be sure all datas are flushed at the right
// offset into the file. // offset into the file.
status_t Flush(); status_t Flush();
// These are for controlling the underlying encoder and track parameters // These are for controlling the underlying encoder and track parameters
// returns a copy of the parameter web // returns a copy of the parameter web
status_t GetParameterWeb(BParameterWeb** outWeb); status_t GetParameterWeb(BParameterWeb** _web);
status_t GetParameterValue(int32 id, void *valu, size_t *size); status_t GetParameterValue(int32 id, void* _value,
status_t SetParameterValue(int32 id, const void *valu, size_t size); size_t* size);
BView *GetParameterView(); status_t SetParameterValue(int32 id, const void* _value,
size_t size);
BView* GetParameterView();
// This is a simplified control API, only one parameter low=0.0, high=1.0 // This is a simplified control API, only one parameter low=0.0, high=1.0
// Return B_ERROR if it's not supported by the current encoder. // Return B_ERROR if it's not supported by the current encoder.
status_t GetQuality(float *quality); status_t GetQuality(float* _quality);
status_t SetQuality(float quality); status_t SetQuality(float quality);
status_t GetEncodeParameters(encode_parameters *parameters) const; status_t GetEncodeParameters(
status_t SetEncodeParameters(encode_parameters *parameters); encode_parameters* parameters) const;
status_t SetEncodeParameters(encode_parameters* parameters);
virtual status_t Perform(int32 selector, void * data); virtual status_t Perform(int32 code, void* data);
private: private:
friend class BMediaFile; friend class BMediaFile;
// deprecated, but for BeOS R5 compatibility // deprecated, but for BeOS R5 compatibility
BParameterWeb *Web(); BParameterWeb* Web();
// Does nothing, returns B_ERROR, for Zeta compatiblity only // Does nothing, returns B_ERROR, for Zeta compatiblity only
status_t ControlCodec(int32 selector, void *io_data, size_t size); status_t ControlCodec(int32 selector, void* _inOutData,
size_t size);
// for read-only access to a track // For read-only access to a BMediaTrack
BMediaTrack(BPrivate::media::MediaExtractor *extractor, int32 stream); BMediaTrack(
BPrivate::media::MediaExtractor* extractor,
int32 streamIndex);
// for write-only access to a BMediaTrack // For write-only access to a BMediaTrack
BMediaTrack(BPrivate::MediaWriter *writer, BMediaTrack(BPrivate::media::MediaWriter* writer,
int32 stream_num, int32 streamIndex, media_format* format,
media_format *in_format, BPrivate::media::Encoder* encoder,
BPrivate::media::Encoder *encoder, media_codec_info* codecInfo);
media_codec_info *mci);
void SetupWorkaround(); void SetupWorkaround();
bool SetupFormatTranslation(const media_format &from, media_format *to); bool SetupFormatTranslation(const media_format& from,
media_format* _to);
status_t fErr; private:
BPrivate::media::Decoder *fDecoder; status_t fErr;
BPrivate::media::Decoder *fRawDecoder; BPrivate::media::Decoder* fDecoder;
BPrivate::media::MediaExtractor *fExtractor; BPrivate::media::Decoder* fRawDecoder;
BPrivate::media::MediaExtractor* fExtractor;
int32 fStream; int32 fStream;
int64 fCurFrame; int64 fCurFrame;
bigtime_t fCurTime; bigtime_t fCurTime;
media_codec_info fMCI; media_codec_info fMCI;
BPrivate::media::Encoder *fEncoder; BPrivate::media::Encoder* fEncoder;
int32 fEncoderID; int32 fEncoderID;
BPrivate::MediaWriter *fWriter; BPrivate::media::MediaWriter* fWriter;
media_format fWriterFormat; media_format fWriterFormat;
uint32 fWorkaroundFlags; uint32 fWorkaroundFlags;
protected: protected:
int32 EncoderID() { return fEncoderID; }; int32 EncoderID() { return fEncoderID; };
private: private:
BMediaTrack(); BMediaTrack();
BMediaTrack(const BMediaTrack&); BMediaTrack(const BMediaTrack&);
BMediaTrack& operator=(const BMediaTrack&); BMediaTrack& operator=(const BMediaTrack&);
/* fbc data and virtuals */
uint32 _reserved_BMediaTrack_[31]; // FBC data and virtuals
uint32 _reserved_BMediaTrack_[31];
virtual status_t _Reserved_BMediaTrack_0(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_0(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_1(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_1(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_2(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_2(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_3(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_3(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_4(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_4(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_5(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_5(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_6(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_6(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_7(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_7(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_8(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_8(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_9(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_9(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_10(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_10(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_11(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_11(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_12(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_12(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_13(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_13(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_14(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_14(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_15(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_15(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_16(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_16(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_17(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_17(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_18(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_18(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_19(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_19(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_20(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_20(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_21(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_21(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_22(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_22(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_23(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_23(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_24(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_24(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_25(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_25(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_26(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_26(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_27(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_27(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_28(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_28(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_29(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_29(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_30(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_30(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_31(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_31(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_32(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_32(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_33(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_33(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_34(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_34(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_35(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_35(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_36(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_36(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_37(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_37(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_38(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_38(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_39(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_39(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_40(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_40(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_41(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_41(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_42(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_42(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_43(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_43(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_44(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_44(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_45(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_45(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_46(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_46(int32 arg, ...);
virtual status_t _Reserved_BMediaTrack_47(int32 arg, ...); virtual status_t _Reserved_BMediaTrack_47(int32 arg, ...);
}; };
#endif #endif
+1 -1
View File
@@ -728,7 +728,7 @@ BMediaTrack::BMediaTrack(BPrivate::media::MediaExtractor *extractor,
} }
BMediaTrack::BMediaTrack(BPrivate::MediaWriter *writer, BMediaTrack::BMediaTrack(BPrivate::media::MediaWriter* writer,
int32 stream_num, int32 stream_num,
media_format *in_format, media_format *in_format,
BPrivate::media::Encoder *encoder, BPrivate::media::Encoder *encoder,