Rewrote header.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32751 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-08-27 13:13:54 +00:00
parent 2a452b95b1
commit 2089178aac
+134 -156
View File
@@ -1,54 +1,47 @@
/******************************************************************************* /*
/ * Copyright 2009, Haiku, Inc. All rights reserved.
/ File: BBufferProducer.h * Distributed under the terms of the MIT License.
/ */
/ Description: A BBufferProducer is any source of media buffers in the Media Kit #ifndef _BUFFER_PRODUCER_H
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
#if !defined(_BUFFER_PRODUCER_H)
#define _BUFFER_PRODUCER_H #define _BUFFER_PRODUCER_H
#include <MediaDefs.h>
#include <MediaNode.h> #include <MediaNode.h>
class BBuffer; class BBuffer;
class BBufferGroup; class BBufferGroup;
class BRegion; class BRegion;
namespace BPrivate { namespace media {
namespace BPrivate {
namespace media {
class BMediaRosterEx; class BMediaRosterEx;
}} }
}
class BBufferProducer : class BBufferProducer : public virtual BMediaNode {
public virtual BMediaNode
{
protected: protected:
/* this has to be at the top to force a vtable */ // NOTE: This has to be at the top to force a vtable.
virtual ~BBufferProducer(); virtual ~BBufferProducer();
public: public:
/* Supported formats for low-level clipping data */ // Supported formats for low-level clipping data
enum { enum {
B_CLIP_SHORT_RUNS = 1 B_CLIP_SHORT_RUNS = 1
}; };
/* Handy conversion functions for dealing with clip information */ // Handy conversion function for dealing with clip information.
static status_t ClipDataToRegion( static status_t ClipDataToRegion(int32 format, int32 size,
int32 format, const void* data, BRegion* region);
int32 size,
const void * data,
BRegion * region);
media_type ProducerType(); media_type ProducerType();
protected: protected:
explicit BBufferProducer( explicit BBufferProducer(media_type producer_type
media_type producer_type /* = B_MEDIA_UNKNOWN_TYPE */); /* = B_MEDIA_UNKNOWN_TYPE */);
enum suggestion_quality { enum suggestion_quality {
B_ANY_QUALITY = 0, B_ANY_QUALITY = 0,
@@ -57,160 +50,144 @@ explicit BBufferProducer(
B_HIGH_QUALITY = 100 B_HIGH_QUALITY = 100
}; };
/* functionality of BBufferProducer */ // BBufferProducer interface
virtual status_t FormatSuggestionRequested( virtual status_t FormatSuggestionRequested(media_type type,
media_type type, int32 quality, media_format* format) = 0;
int32 quality, virtual status_t FormatProposal(const media_source& output,
media_format * format) = 0;
virtual status_t FormatProposal(
const media_source & output,
media_format* ioFormat) = 0; media_format* ioFormat) = 0;
/* If the format isn't good, put a good format into *io_format and return error */
/* If format has wildcard, specialize to what you can do (and change). */ // If the format isn't good, put a good format into ioFormat and
/* If you can change the format, return OK. */ // return error.
/* The request comes from your destination sychronously, so you cannot ask it */ // If format has wildcard, specialize to what you can do (and change).
/* whether it likes it -- you should assume it will since it asked. */ // If you can change the format, return OK.
// The request comes from your destination sychronously, so you cannot ask
// it whether it likes it -- you should assume it will since it asked.
virtual status_t FormatChangeRequested( virtual status_t FormatChangeRequested(
const media_source& source, const media_source& source,
const media_destination& destination, const media_destination& destination,
media_format * io_format, media_format* ioFormat,
int32* _deprecated_) = 0; int32* _deprecated_) = 0;
virtual status_t GetNextOutput( /* cookie starts as 0 */ virtual status_t GetNextOutput(
int32 * cookie, int32* ioCookie,
media_output * out_output) = 0; media_output* _output) = 0;
virtual status_t DisposeOutputCookie( virtual status_t DisposeOutputCookie(int32 cookie) = 0;
int32 cookie) = 0;
/* In this function, you should either pass on the group to your upstream guy, */ // In this function, you should either pass on the group to your upstream
/* or delete your current group and hang on to this group. Deleting the previous */ // guy, or delete your current group and hang on to this group. Deleting
/* group (unless you passed it on with the reclaim flag set to false) is very */ // the previous group (unless you passed it on with the reclaim flag set
/* important, else you will 1) leak memory and 2) block someone who may want */ // to false) is very important, else you will 1) leak memory and 2) block
/* to reclaim the buffers living in that group. */ // someone who may want to reclaim the buffers living in that group.
virtual status_t SetBufferGroup( virtual status_t SetBufferGroup(const media_source& forSource,
const media_source & for_source,
BBufferGroup* group) = 0; BBufferGroup* group) = 0;
/* Format of clipping is (as int16-s): <from line> <npairs> <startclip> <endclip>. */
/* Repeat for each line where the clipping is different from the previous line. */ // Format of clipping is (as int16-s): <from line> <npairs> <startclip>
/* If <npairs> is negative, use the data from line -<npairs> (there are 0 pairs after */ // <endclip>. Repeat for each line where the clipping is different from
/* a negative <npairs>. Yes, we only support 32k*32k frame buffers for clipping. */ // the previous line. If <npairs> is negative, use the data from line
/* Any non-0 field of 'display' means that that field changed, and if you don't support */ // -<npairs> (there are 0 pairs after a negative <npairs>. Yes, we only
/* that change, you should return an error and ignore the request. Note that the buffer */ // support 32k*32k frame buffers for clipping. Any non-0 field of
/* offset values do not have wildcards; 0 (or -1, or whatever) are real values and must */ // 'display' means that that field changed, and if you don't support that
/* be adhered to. */ // change, you should return an error and ignore the request. Note that
// the buffer offset values do not have wildcards; 0 (or -1, or whatever)
// are real values and must be adhered to.
virtual status_t VideoClippingChanged( virtual status_t VideoClippingChanged(
const media_source & for_source, const media_source& forSource,
int16 num_shorts, int16 numShorts,
int16 * clip_data, int16* clipData,
const media_video_display_info& display, const media_video_display_info& display,
int32 * _deprecated_); int32 * _deprecated_);
/* Iterates over all outputs and maxes the latency found */
virtual status_t GetLatency( // Iterates over all outputs and maxes the latency found
bigtime_t * out_lantency); virtual status_t GetLatency(bigtime_t* _lantency);
virtual status_t PrepareToConnect(
const media_source & what, virtual status_t PrepareToConnect(const media_source& what,
const media_destination& where, const media_destination& where,
media_format* format, media_format* format,
media_source * out_source, media_source* _source,
char * out_name) = 0; char* _name) = 0;
virtual void Connect( virtual void Connect(status_t error,
status_t error,
const media_source& source, const media_source& source,
const media_destination& destination, const media_destination& destination,
const media_format& format, const media_format& format,
char * io_name) = 0; char* ioName) = 0;
virtual void Disconnect( virtual void Disconnect(const media_source& what,
const media_source & what,
const media_destination& where) = 0; const media_destination& where) = 0;
virtual void LateNoticeReceived(
const media_source & what,
bigtime_t how_much,
bigtime_t performance_time) = 0;
virtual void EnableOutput(
const media_source & what,
bool enabled,
int32 * _deprecated_) = 0;
virtual status_t SetPlayRate(
int32 numer,
int32 denom);
virtual status_t HandleMessage( /* call this from the thread that listens to the port */ virtual void LateNoticeReceived(const media_source& what,
int32 message, bigtime_t howMuch,
const void * data, bigtime_t performanceTime) = 0;
virtual void EnableOutput(const media_source& what,
bool enabled, int32* _deprecated_) = 0;
virtual status_t SetPlayRate(int32 numer, int32 denom);
// NOTE: Call this from the thread that listens to the port!
virtual status_t HandleMessage(int32 message, const void* data,
size_t size); size_t size);
virtual void AdditionalBufferRequested( // used to be Reserved 0 virtual void AdditionalBufferRequested(
const media_source& source, const media_source& source,
media_buffer_id prev_buffer, media_buffer_id previousBuffer,
bigtime_t prev_time, bigtime_t previousTime,
const media_seek_tag * prev_tag); // may be NULL const media_seek_tag* previousTag
/* = NULL */);
virtual void LatencyChanged( // used to be Reserved 1 virtual void LatencyChanged(const media_source& source,
const media_source & source,
const media_destination& destination, const media_destination& destination,
bigtime_t new_latency, bigtime_t newLatency, uint32 flags);
uint32 flags);
/* Use this function in BBufferProducer to pass on the buffer. */ // NOTE: Use this function to pass on the buffer on to the BBufferConsumer.
status_t SendBuffer( status_t SendBuffer(BBuffer* buffer,
BBuffer * buffer,
const media_destination& destination); const media_destination& destination);
status_t SendDataStatus( status_t SendDataStatus(int32 status,
int32 status,
const media_destination& destination, const media_destination& destination,
bigtime_t at_time); bigtime_t atTime);
/* Check in advance if a target is prepared to accept a format. You may */ // Check in advance if a target is prepared to accept a format. You may
/* want to call this from Connect(), although that's not required. */ // want to call this from Connect(), although that's not required.
status_t ProposeFormatChange( status_t ProposeFormatChange(media_format* format,
media_format * format, const media_destination& forDestination);
const media_destination & for_destination);
/* Tell consumer to accept a proposed format change */ // Tell consumer to accept a proposed format change
/* YOU MUST NOT CALL BROADCAST_BUFFER WHILE THIS CALL IS OUTSTANDING! */ // NOTE: You must not call SendBuffer while this call is pending!
status_t ChangeFormat( status_t ChangeFormat(const media_source& forSource,
const media_source & for_source, const media_destination& forDestination,
const media_destination & for_destination,
media_format* format); media_format* format);
/* Check how much latency the down-stream graph introduces */
// Check how much latency the down-stream graph introduces.
status_t FindLatencyFor( status_t FindLatencyFor(
const media_destination & for_destination, const media_destination& forDestination,
bigtime_t * out_latency, bigtime_t* _latency,
media_node_id * out_timesource); media_node_id* _timesource);
/* Find the tag of a previously seen buffer to expedite seeking */ // Find the tag of a previously seen buffer to expedite seeking
status_t FindSeekTag( status_t FindSeekTag(
const media_destination & for_destination, const media_destination& forDestination,
bigtime_t in_target_time, bigtime_t inTargetTime,
media_seek_tag * out_tag, media_seek_tag* _tag,
bigtime_t * out_tagged_time, bigtime_t* _taggedTime, uint32* _flags = 0,
uint32 * out_flags = 0, uint32 flags = 0);
uint32 in_flags = 0);
/* Set the initial latency, which is the maximum additional latency */ // Set the initial latency, which is the maximum additional latency
/* that will be imposed while starting/syncing to a signal (such as */ // that will be imposed while starting/syncing to a signal (such as
/* starting a TV capture card in the middle of a field). Most nodes */ // starting a TV capture card in the middle of a field). Most nodes
/* have this at 0 (the default); only TV input Nodes need it currently */ // have this at 0 (the default); only TV input Nodes need it currently
/* because they slave to a low-resolution (59.94 Hz) clock that arrives */ // because they slave to a low-resolution (59.94 Hz) clock that arrives
/* from the outside world. Call this from the constructor if you need it. */ // from the outside world. Call this from the constructor if you need it.
void SetInitialLatency( void SetInitialLatency(bigtime_t inInitialLatency,
bigtime_t inInitialLatency,
uint32 flags = 0); uint32 flags = 0);
private: private:
// FBC padding and forbidden methods
BBufferProducer();
BBufferProducer(const BBufferProducer& other);
BBufferProducer& operator=(const BBufferProducer& other);
friend class BBufferConsumer; status_t _Reserved_BufferProducer_0(void*);
friend class BMediaNode; // was AdditionalBufferRequested()
friend class BMediaRoster; status_t _Reserved_BufferProducer_1(void*);
friend class BPrivate::media::BMediaRosterEx; // was LatencyChanged()
BBufferProducer(); /* private unimplemented */
BBufferProducer(
const BBufferProducer & clone);
BBufferProducer & operator=(
const BBufferProducer & clone);
/* Mmmh, stuffing! */
status_t _Reserved_BufferProducer_0(void *); /* AdditionalBufferRequested() */
status_t _Reserved_BufferProducer_1(void *); /* LatencyChanged() */
virtual status_t _Reserved_BufferProducer_2(void*); virtual status_t _Reserved_BufferProducer_2(void*);
virtual status_t _Reserved_BufferProducer_3(void*); virtual status_t _Reserved_BufferProducer_3(void*);
virtual status_t _Reserved_BufferProducer_4(void*); virtual status_t _Reserved_BufferProducer_4(void*);
@@ -226,22 +203,23 @@ virtual status_t _Reserved_BufferProducer_13(void *);
virtual status_t _Reserved_BufferProducer_14(void*); virtual status_t _Reserved_BufferProducer_14(void*);
virtual status_t _Reserved_BufferProducer_15(void*); virtual status_t _Reserved_BufferProducer_15(void*);
private:
friend class BBufferConsumer;
friend class BMediaNode;
friend class BMediaRoster;
friend class BPrivate::media::BMediaRosterEx;
static status_t clip_shorts_to_region(const int16* data,
int count, BRegion* output);
static status_t clip_region_to_shorts(const BRegion* input,
int16* data, int maxCount, int* _count);
private:
media_type fProducerType; media_type fProducerType;
bigtime_t fInitialLatency; bigtime_t fInitialLatency;
uint32 fInitialFlags; uint32 fInitialFlags;
bigtime_t fDelay; bigtime_t fDelay;
static status_t clip_shorts_to_region(
const int16 * data,
int count,
BRegion * output);
static status_t clip_region_to_shorts(
const BRegion * input,
int16 * data,
int max_count,
int * out_count);
uint32 _reserved_buffer_producer_[12]; uint32 _reserved_buffer_producer_[12];
}; };