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
+185 -207
View File
@@ -1,248 +1,226 @@
/******************************************************************************* /*
/ * 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 {
class BMediaRosterEx; namespace BPrivate {
}} namespace media {
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,
B_LOW_QUALITY = 10, B_LOW_QUALITY = 10,
B_MEDIUM_QUALITY = 50, B_MEDIUM_QUALITY = 50,
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; media_format* ioFormat) = 0;
virtual status_t FormatProposal(
const media_source & output,
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 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(
const media_source & source,
const media_destination & destination,
media_format * io_format,
int32 * _deprecated_) = 0;
virtual status_t GetNextOutput( /* cookie starts as 0 */
int32 * cookie,
media_output * out_output) = 0;
virtual status_t DisposeOutputCookie(
int32 cookie) = 0;
/* In this function, you should either pass on the group to your upstream guy, */
/* or delete your current group and hang on to this group. Deleting the previous */
/* group (unless you passed it on with the reclaim flag set to false) is very */
/* important, else you will 1) leak memory and 2) block someone who may want */
/* to reclaim the buffers living in that group. */
virtual status_t SetBufferGroup(
const media_source & for_source,
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. */
/* If <npairs> is negative, use the data from line -<npairs> (there are 0 pairs after */
/* a negative <npairs>. Yes, we only support 32k*32k frame buffers for clipping. */
/* Any non-0 field of 'display' means that that field changed, and if you don't support */
/* that 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(
const media_source & for_source,
int16 num_shorts,
int16 * clip_data,
const media_video_display_info & display,
int32 * _deprecated_);
/* Iterates over all outputs and maxes the latency found */
virtual status_t GetLatency(
bigtime_t * out_lantency);
virtual status_t PrepareToConnect(
const media_source & what,
const media_destination & where,
media_format * format,
media_source * out_source,
char * out_name) = 0;
virtual void Connect(
status_t error,
const media_source & source,
const media_destination & destination,
const media_format & format,
char * io_name) = 0;
virtual void Disconnect(
const media_source & what,
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 */ // If the format isn't good, put a good format into ioFormat and
int32 message, // return error.
const void * data, // If format has wildcard, specialize to what you can do (and change).
size_t size); // 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(
const media_source& source,
const media_destination& destination,
media_format* ioFormat,
int32* _deprecated_) = 0;
virtual status_t GetNextOutput(
int32* ioCookie,
media_output* _output) = 0;
virtual status_t DisposeOutputCookie(int32 cookie) = 0;
virtual void AdditionalBufferRequested( // used to be Reserved 0 // In this function, you should either pass on the group to your upstream
const media_source & source, // guy, or delete your current group and hang on to this group. Deleting
media_buffer_id prev_buffer, // the previous group (unless you passed it on with the reclaim flag set
bigtime_t prev_time, // to false) is very important, else you will 1) leak memory and 2) block
const media_seek_tag * prev_tag); // may be NULL // someone who may want to reclaim the buffers living in that group.
virtual status_t SetBufferGroup(const media_source& forSource,
BBufferGroup* group) = 0;
virtual void LatencyChanged( // used to be Reserved 1 // Format of clipping is (as int16-s): <from line> <npairs> <startclip>
const media_source & source, // <endclip>. Repeat for each line where the clipping is different from
const media_destination & destination, // the previous line. If <npairs> is negative, use the data from line
bigtime_t new_latency, // -<npairs> (there are 0 pairs after a negative <npairs>. Yes, we only
uint32 flags); // support 32k*32k frame buffers for clipping. Any non-0 field of
// 'display' means that that field changed, and if you don't support that
// 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(
const media_source& forSource,
int16 numShorts,
int16* clipData,
const media_video_display_info& display,
int32 * _deprecated_);
/* Use this function in BBufferProducer to pass on the buffer. */ // Iterates over all outputs and maxes the latency found
status_t SendBuffer( virtual status_t GetLatency(bigtime_t* _lantency);
BBuffer * buffer,
const media_destination & destination);
status_t SendDataStatus( virtual status_t PrepareToConnect(const media_source& what,
int32 status, const media_destination& where,
const media_destination & destination, media_format* format,
bigtime_t at_time); media_source* _source,
char* _name) = 0;
virtual void Connect(status_t error,
const media_source& source,
const media_destination& destination,
const media_format& format,
char* ioName) = 0;
virtual void Disconnect(const media_source& what,
const media_destination& where) = 0;
/* Check in advance if a target is prepared to accept a format. You may */ virtual void LateNoticeReceived(const media_source& what,
/* want to call this from Connect(), although that's not required. */ bigtime_t howMuch,
status_t ProposeFormatChange( bigtime_t performanceTime) = 0;
media_format * format,
const media_destination & for_destination);
/* Tell consumer to accept a proposed format change */
/* YOU MUST NOT CALL BROADCAST_BUFFER WHILE THIS CALL IS OUTSTANDING! */
status_t ChangeFormat(
const media_source & for_source,
const media_destination & for_destination,
media_format * format);
/* Check how much latency the down-stream graph introduces */
status_t FindLatencyFor(
const media_destination & for_destination,
bigtime_t * out_latency,
media_node_id * out_timesource);
/* Find the tag of a previously seen buffer to expedite seeking */ virtual void EnableOutput(const media_source& what,
status_t FindSeekTag( bool enabled, int32* _deprecated_) = 0;
const media_destination & for_destination,
bigtime_t in_target_time,
media_seek_tag * out_tag,
bigtime_t * out_tagged_time,
uint32 * out_flags = 0,
uint32 in_flags = 0);
/* Set the initial latency, which is the maximum additional latency */ virtual status_t SetPlayRate(int32 numer, int32 denom);
/* 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 */ // NOTE: Call this from the thread that listens to the port!
/* have this at 0 (the default); only TV input Nodes need it currently */ virtual status_t HandleMessage(int32 message, const void* data,
/* because they slave to a low-resolution (59.94 Hz) clock that arrives */ size_t size);
/* from the outside world. Call this from the constructor if you need it. */
void SetInitialLatency( virtual void AdditionalBufferRequested(
bigtime_t inInitialLatency, const media_source& source,
uint32 flags = 0); media_buffer_id previousBuffer,
bigtime_t previousTime,
const media_seek_tag* previousTag
/* = NULL */);
virtual void LatencyChanged(const media_source& source,
const media_destination& destination,
bigtime_t newLatency, uint32 flags);
// NOTE: Use this function to pass on the buffer on to the BBufferConsumer.
status_t SendBuffer(BBuffer* buffer,
const media_destination& destination);
status_t SendDataStatus(int32 status,
const media_destination& destination,
bigtime_t atTime);
// 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.
status_t ProposeFormatChange(media_format* format,
const media_destination& forDestination);
// Tell consumer to accept a proposed format change
// NOTE: You must not call SendBuffer while this call is pending!
status_t ChangeFormat(const media_source& forSource,
const media_destination& forDestination,
media_format* format);
// Check how much latency the down-stream graph introduces.
status_t FindLatencyFor(
const media_destination& forDestination,
bigtime_t* _latency,
media_node_id* _timesource);
// Find the tag of a previously seen buffer to expedite seeking
status_t FindSeekTag(
const media_destination& forDestination,
bigtime_t inTargetTime,
media_seek_tag* _tag,
bigtime_t* _taggedTime, uint32* _flags = 0,
uint32 flags = 0);
// Set the initial latency, which is the maximum additional latency
// 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
// 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
// from the outside world. Call this from the constructor if you need it.
void SetInitialLatency(bigtime_t inInitialLatency,
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()
virtual status_t _Reserved_BufferProducer_2(void*);
virtual status_t _Reserved_BufferProducer_3(void*);
virtual status_t _Reserved_BufferProducer_4(void*);
virtual status_t _Reserved_BufferProducer_5(void*);
virtual status_t _Reserved_BufferProducer_6(void*);
virtual status_t _Reserved_BufferProducer_7(void*);
virtual status_t _Reserved_BufferProducer_8(void*);
virtual status_t _Reserved_BufferProducer_9(void*);
virtual status_t _Reserved_BufferProducer_10(void*);
virtual status_t _Reserved_BufferProducer_11(void*);
virtual status_t _Reserved_BufferProducer_12(void*);
virtual status_t _Reserved_BufferProducer_13(void*);
virtual status_t _Reserved_BufferProducer_14(void*);
virtual status_t _Reserved_BufferProducer_15(void*);
BBufferProducer(); /* private unimplemented */ private:
BBufferProducer( friend class BBufferConsumer;
const BBufferProducer & clone); friend class BMediaNode;
BBufferProducer & operator=( friend class BMediaRoster;
const BBufferProducer & clone); friend class BPrivate::media::BMediaRosterEx;
/* 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_3(void *);
virtual status_t _Reserved_BufferProducer_4(void *);
virtual status_t _Reserved_BufferProducer_5(void *);
virtual status_t _Reserved_BufferProducer_6(void *);
virtual status_t _Reserved_BufferProducer_7(void *);
virtual status_t _Reserved_BufferProducer_8(void *);
virtual status_t _Reserved_BufferProducer_9(void *);
virtual status_t _Reserved_BufferProducer_10(void *);
virtual status_t _Reserved_BufferProducer_11(void *);
virtual status_t _Reserved_BufferProducer_12(void *);
virtual status_t _Reserved_BufferProducer_13(void *);
virtual status_t _Reserved_BufferProducer_14(void *);
virtual status_t _Reserved_BufferProducer_15(void *);
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);
media_type fProducerType; private:
bigtime_t fInitialLatency; media_type fProducerType;
uint32 fInitialFlags; bigtime_t fInitialLatency;
bigtime_t fDelay; uint32 fInitialFlags;
bigtime_t fDelay;
static status_t clip_shorts_to_region( uint32 _reserved_buffer_producer_[12];
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];
}; };
#endif /* _BUFFER_PRODUCER_H */ #endif /* _BUFFER_PRODUCER_H */