1 /* 2 * Copyright 2009, Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _BUFFER_CONSUMER_H 6 #define _BUFFER_CONSUMER_H 7 8 9 #include <MediaDefs.h> 10 #include <MediaNode.h> 11 12 13 class BBuffer; 14 class BBufferGroup; 15 class BRegion; 16 17 namespace BPrivate { 18 class BufferCache; 19 namespace media { 20 class BMediaRosterEx; 21 } 22 } 23 24 25 class BBufferConsumer : public virtual BMediaNode { 26 protected: 27 virtual ~BBufferConsumer(); 28 29 public: 30 media_type ConsumerType(); 31 32 static status_t RegionToClipData(const BRegion* region, 33 int32* format, int32* size, void* data); 34 35 protected: 36 explicit BBufferConsumer(media_type type); 37 38 static void NotifyLateProducer( 39 const media_source& whatSource, 40 bigtime_t howMuch, 41 bigtime_t performanceTime); 42 status_t SetVideoClippingFor(const media_source& output, 43 const media_destination& destination, 44 const int16* shorts, int32 shortCount, 45 const media_video_display_info& display, 46 void* userData, int32* changeTag, 47 void* _reserved = NULL); 48 status_t SetOutputEnabled(const media_source& source, 49 const media_destination& destination, 50 bool enabled, void* userData, 51 int32* changeTag, void* _reserved = NULL); 52 status_t RequestFormatChange(const media_source& source, 53 const media_destination& destination, 54 const media_format& toFormat, 55 void* userData, int32* changeTag, 56 void* _reserved = NULL); 57 status_t RequestAdditionalBuffer( 58 const media_source& source, 59 BBuffer* previousBuffer, 60 void* _reserved = NULL); 61 status_t RequestAdditionalBuffer( 62 const media_source& source, 63 bigtime_t startTime, 64 void* _reserved = NULL); 65 status_t SetOutputBuffersFor(const media_source& source, 66 const media_destination& destination, 67 BBufferGroup* group, void* userData, 68 int32* changeTag, bool willReclaim = false, 69 void* _reserved = NULL); 70 status_t SendLatencyChange(const media_source& source, 71 const media_destination& destination, 72 bigtime_t newLatency, uint32 flags = 0); 73 74 protected: 75 virtual status_t HandleMessage(int32 message, const void* data, 76 size_t size); 77 78 virtual status_t AcceptFormat( 79 const media_destination& destination, 80 media_format* format) = 0; 81 virtual status_t GetNextInput(int32* cookie, 82 media_input* _input) = 0; 83 virtual void DisposeInputCookie(int32 cookie) = 0; 84 virtual void BufferReceived(BBuffer* buffer) = 0; 85 virtual void ProducerDataStatus( 86 const media_destination& forWhom, 87 int32 status, 88 bigtime_t atPerformanceTime) = 0; 89 virtual status_t GetLatencyFor(const media_destination& forWhom, 90 bigtime_t* _latency, 91 media_node_id* _timesource) = 0; 92 virtual status_t Connected(const media_source& producer, 93 const media_destination& where, 94 const media_format& withFormat, 95 media_input* _input) = 0; 96 virtual void Disconnected(const media_source& producer, 97 const media_destination& where) = 0; 98 virtual status_t FormatChanged(const media_source& producer, 99 const media_destination& consumer, 100 int32 changeTag, 101 const media_format& format) = 0; 102 103 virtual status_t SeekTagRequested( 104 const media_destination& destination, 105 bigtime_t targetTime, uint32 flags, 106 media_seek_tag* _seekTag, 107 bigtime_t* _taggedTime, uint32* _flags); 108 109 private: 110 friend class BMediaNode; 111 friend class BBufferProducer; 112 friend class BMediaRoster; 113 friend class BPrivate::media::BMediaRosterEx; 114 115 BBufferConsumer(); 116 BBufferConsumer(const BBufferConsumer& other); 117 BBufferConsumer& operator=(const BBufferConsumer& other); 118 119 // deprecated methods following 120 static status_t SetVideoClippingFor(const media_source& output, 121 const int16* shorts, int32 shortCount, 122 const media_video_display_info& display, 123 int32* changeTag); 124 static status_t RequestFormatChange(const media_source& source, 125 const media_destination& destination, 126 media_format* toFormat, int32* changeTag); 127 static status_t SetOutputEnabled(const media_source& source, 128 bool enabled, int32* changeTag); 129 130 status_t _Reserved_BufferConsumer_0(void*); 131 // used for SeekTagRequested() 132 virtual status_t _Reserved_BufferConsumer_1(void*); 133 virtual status_t _Reserved_BufferConsumer_2(void*); 134 virtual status_t _Reserved_BufferConsumer_3(void*); 135 virtual status_t _Reserved_BufferConsumer_4(void*); 136 virtual status_t _Reserved_BufferConsumer_5(void*); 137 virtual status_t _Reserved_BufferConsumer_6(void*); 138 virtual status_t _Reserved_BufferConsumer_7(void*); 139 virtual status_t _Reserved_BufferConsumer_8(void*); 140 virtual status_t _Reserved_BufferConsumer_9(void*); 141 virtual status_t _Reserved_BufferConsumer_10(void*); 142 virtual status_t _Reserved_BufferConsumer_11(void*); 143 virtual status_t _Reserved_BufferConsumer_12(void*); 144 virtual status_t _Reserved_BufferConsumer_13(void*); 145 virtual status_t _Reserved_BufferConsumer_14(void*); 146 virtual status_t _Reserved_BufferConsumer_15(void*); 147 148 private: 149 media_type fConsumerType; 150 BPrivate::BufferCache* fBufferCache; 151 BBufferGroup* fDeleteBufferGroup; 152 uint32 _reserved[14]; 153 }; 154 155 156 #endif // _BUFFER_CONSUMER_H 157