1 /******************************************************************************* 2 / 3 / File: BufferConsumer.h 4 / 5 / Description: A BBufferConsumer is anything that wants to receive buffers in the Media Kit 6 / 7 / Copyright 1997-98, Be Incorporated, All Rights Reserved 8 / 9 *******************************************************************************/ 10 11 #if !defined(_BUFFER_CONSUMER_H) 12 #define _BUFFER_CONSUMER_H 13 14 #include <MediaDefs.h> 15 #include <MediaNode.h> 16 17 class BBuffer; 18 class BBufferGroup; 19 class BRegion; 20 21 namespace BPrivate { namespace media { 22 class BMediaRosterEx; 23 }} 24 25 class _buffer_id_cache; 26 27 class BBufferConsumer : 28 public virtual BMediaNode 29 { 30 protected: 31 /* this has to be at the top to force a vtable */ 32 virtual ~BBufferConsumer(); 33 34 public: 35 36 media_type ConsumerType(); 37 38 /* for encoding a region into the format needed for clipping requests */ 39 static status_t RegionToClipData( 40 const BRegion * region, 41 int32 * format, 42 int32 * ioSize, 43 void * data); 44 45 protected: 46 explicit BBufferConsumer( 47 media_type consumer_type /* = B_MEDIA_UNKNOWN_TYPE */); 48 49 static void NotifyLateProducer( 50 const media_source & what_source, 51 bigtime_t how_much, 52 bigtime_t performance_time); 53 status_t SetVideoClippingFor( 54 const media_source & output, 55 const media_destination & destination, 56 const int16 * shorts, 57 int32 short_count, 58 const media_video_display_info & display, 59 void * user_data, 60 int32 * change_tag, 61 void * _reserved_ = 0); // change_tag value will be passed to RequestCompleted() 62 status_t SetOutputEnabled( 63 const media_source & source, 64 const media_destination & destination, 65 bool enabled, 66 void * user_data, 67 int32 * change_tag, 68 void * _reserved_ = 0); // change_tag value will be passed to RequestCompleted() 69 status_t RequestFormatChange( 70 const media_source & source, 71 const media_destination & destination, 72 const media_format & to_format, 73 void * user_data, 74 int32 * change_tag, 75 void * _reserved_ = 0); // change_tag value will be passed to RequestCompleted() 76 status_t RequestAdditionalBuffer( // new in 4.1 77 const media_source & source, 78 BBuffer * prev_buffer, 79 void * _reserved = NULL); 80 status_t RequestAdditionalBuffer( // new in 4.1 81 const media_source & source, 82 bigtime_t start_time, 83 void * _reserved = NULL); 84 status_t SetOutputBuffersFor( // new in 4.1 85 const media_source & source, 86 const media_destination & destination, 87 BBufferGroup * group, 88 void * user_data, 89 int32 * change_tag, // passed to RequestCompleted() 90 bool will_reclaim = false, 91 void * _reserved_ = 0); 92 status_t SendLatencyChange( 93 const media_source & source, 94 const media_destination & destination, 95 bigtime_t my_new_latency, 96 uint32 flags = 0); 97 98 protected: 99 100 virtual status_t HandleMessage( 101 int32 message, 102 const void * data, 103 size_t size); 104 105 /* Someone, probably the producer, is asking you about this format. Give */ 106 /* your honest opinion, possibly modifying *format. Do not ask upstream */ 107 /* producer about the format, since he's synchronously waiting for your */ 108 /* reply. */ 109 virtual status_t AcceptFormat( 110 const media_destination & dest, 111 media_format * ioFormat) = 0; 112 virtual status_t GetNextInput( 113 int32 * cookie, 114 media_input * out_input) = 0; 115 virtual void DisposeInputCookie( 116 int32 cookie) = 0; 117 virtual void BufferReceived( 118 BBuffer * buffer) = 0; 119 virtual void ProducerDataStatus( 120 const media_destination & for_whom, 121 int32 status, 122 bigtime_t at_performance_time) = 0; 123 virtual status_t GetLatencyFor( 124 const media_destination & for_whom, 125 bigtime_t * out_latency, 126 media_node_id * out_timesource) = 0; 127 virtual status_t Connected( 128 const media_source & producer, /* here's a good place to request buffer group usage */ 129 const media_destination & where, 130 const media_format & with_format, 131 media_input * out_input) = 0; 132 virtual void Disconnected( 133 const media_source & producer, 134 const media_destination & where) = 0; 135 /* The notification comes from the upstream producer, so he's already cool with */ 136 /* the format; you should not ask him about it in here. */ 137 virtual status_t FormatChanged( 138 const media_source & producer, 139 const media_destination & consumer, 140 int32 change_tag, 141 const media_format & format) = 0; 142 143 /* Given a performance time of some previous buffer, retrieve the remembered tag */ 144 /* of the closest (previous or exact) performance time. Set *out_flags to 0; the */ 145 /* idea being that flags can be added later, and the understood flags returned in */ 146 /* *out_flags. */ 147 virtual status_t SeekTagRequested( 148 const media_destination & destination, 149 bigtime_t in_target_time, 150 uint32 in_flags, 151 media_seek_tag * out_seek_tag, 152 bigtime_t * out_tagged_time, 153 uint32 * out_flags); 154 155 private: 156 157 BBufferConsumer(); /* private unimplemented */ 158 BBufferConsumer( 159 const BBufferConsumer & clone); 160 BBufferConsumer & operator=( 161 const BBufferConsumer & clone); 162 163 // these functions are deprecated from the 4.0 API 164 static status_t SetVideoClippingFor( 165 const media_source & output, 166 const int16 * shorts, 167 int32 short_count, 168 const media_video_display_info & display, 169 int32 * change_tag); // change_tag value will be passed to RequestCompleted() 170 static status_t RequestFormatChange( 171 const media_source & source, 172 const media_destination & destination, 173 media_format * io_to_format, // the "o" part is unused from 4.1 174 int32 * change_tag); // change_tag value will be passed to RequestCompleted() 175 static status_t SetOutputEnabled( 176 const media_source & source, 177 bool enabled, 178 int32 * change_tag); // change_tag value will be passed to RequestCompleted() 179 180 /* Mmmh, stuffing! */ 181 status_t _Reserved_BufferConsumer_0(void *); /* SeekTagRequested */ 182 virtual status_t _Reserved_BufferConsumer_1(void *); 183 virtual status_t _Reserved_BufferConsumer_2(void *); 184 virtual status_t _Reserved_BufferConsumer_3(void *); 185 virtual status_t _Reserved_BufferConsumer_4(void *); 186 virtual status_t _Reserved_BufferConsumer_5(void *); 187 virtual status_t _Reserved_BufferConsumer_6(void *); 188 virtual status_t _Reserved_BufferConsumer_7(void *); 189 virtual status_t _Reserved_BufferConsumer_8(void *); 190 virtual status_t _Reserved_BufferConsumer_9(void *); 191 virtual status_t _Reserved_BufferConsumer_10(void *); 192 virtual status_t _Reserved_BufferConsumer_11(void *); 193 virtual status_t _Reserved_BufferConsumer_12(void *); 194 virtual status_t _Reserved_BufferConsumer_13(void *); 195 virtual status_t _Reserved_BufferConsumer_14(void *); 196 virtual status_t _Reserved_BufferConsumer_15(void *); 197 198 friend class BMediaNode; 199 friend class BBufferProducer; 200 friend class BMediaRoster; 201 friend class BPrivate::media::BMediaRosterEx; 202 203 media_type fConsumerType; 204 _buffer_id_cache * fBufferCache; 205 BBufferGroup *fDeleteBufferGroup; 206 uint32 _reserved_buffer_consumer_[14]; 207 208 }; 209 210 211 #endif /* _BUFFER_CONSUMER_H */ 212 213