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