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