1// A MediaFileProducer is a node that
2// implements FileInterface and BBufferProducer.
3// it produces one output, a multistream
4
5#if !defined(_MEDIA_FILE_PRODUCER_H)
6#define _MEDIA_FILE_PRODUCER_H
7
8#include <MediaDefs.h>
9#include <MediaNode.h>
10#include <FileInterface.h>
11#include <BufferProducer.h>
12
13class MediaFileProducer :
14    public BFileInterface,
15    public BBufferProducer
16{
17protected:
18MediaFileProducer();
19virtual ~MediaFileProducer();
20
21/*************************/
22/* begin from BMediaNode */
23public:
24	/* this port is what a media node listens to for commands */
25virtual port_id ControlPort() const;
26
27virtual	BMediaAddOn* AddOn(
28				int32 * internal_id) const = 0;	/* Who instantiated you -- or NULL for app class */
29
30protected:
31		/* These don't return errors; instead, they use the global error condition reporter. */
32		/* A node is required to have a queue of at least one pending command (plus TimeWarp) */
33		/* and is recommended to allow for at least one pending command of each type. */
34		/* Allowing an arbitrary number of outstanding commands might be nice, but apps */
35		/* cannot depend on that happening. */
36virtual	void Start(
37				bigtime_t performance_time);
38virtual	void Stop(
39				bigtime_t performance_time,
40				bool immediate);
41virtual	void Seek(
42				bigtime_t media_time,
43				bigtime_t performance_time);
44virtual	void SetRunMode(
45				run_mode mode);
46virtual	void TimeWarp(
47				bigtime_t at_real_time,
48				bigtime_t to_performance_time);
49virtual	void Preroll();
50virtual	void SetTimeSource(
51				BTimeSource * time_source);
52
53public:
54virtual	status_t HandleMessage(
55				int32 message,
56				const void * data,
57				size_t size);
58
59protected:
60		/* Called when requests have completed, or failed. */
61virtual	status_t RequestCompleted(	/* reserved 0 */
62				const media_request_info & info);
63
64protected:
65virtual		status_t DeleteHook(BMediaNode * node);		/* reserved 1 */
66
67virtual		void NodeRegistered();	/* reserved 2 */
68
69public:
70
71		/* fill out your attributes in the provided array, returning however many you have. */
72virtual		status_t GetNodeAttributes(	/* reserved 3 */
73					media_node_attribute * outAttributes,
74					size_t inMaxCount);
75
76virtual		status_t AddTimer(
77					bigtime_t at_performance_time,
78					int32 cookie);
79
80/* end from BMediaNode */
81/***********************/
82
83/*****************************/
84/* begin from BFileInterface */
85protected:
86//included from BMediaNode
87//virtual	status_t HandleMessage(
88//                int32 message,
89//				const void * data,
90//				size_t size);
91
92virtual	status_t GetNextFileFormat(
93				int32 * cookie,
94				media_file_format * out_format) = 0;
95virtual	void DisposeFileFormatCookie(
96				int32 cookie) = 0;
97
98virtual	status_t GetDuration(
99				bigtime_t * out_time) = 0;
100virtual	status_t SniffRef(
101				const entry_ref & file,
102				char * out_mime_type,	/* 256 bytes */
103				float * out_quality) = 0;
104virtual	status_t SetRef(
105				const entry_ref & file,
106				bool create,
107				bigtime_t * out_time) = 0;
108virtual	status_t GetRef(
109				entry_ref * out_ref,
110				char * out_mime_type) = 0;
111/* end from BFileInterface */
112/***************************/
113
114/******************************/
115/* begin from BBufferProducer */
116protected:
117	/* functionality of BBufferProducer */
118virtual	status_t FormatSuggestionRequested(
119				media_type type,
120				int32 quality,
121				media_format * format) = 0;
122virtual	status_t FormatProposal(
123				const media_source & output,
124				media_format * format) = 0;
125	/* If the format isn't good, put a good format into *io_format and return error */
126	/* If format has wildcard, specialize to what you can do (and change). */
127	/* If you can change the format, return OK. */
128	/* The request comes from your destination sychronously, so you cannot ask it */
129	/* whether it likes it -- you should assume it will since it asked. */
130virtual	status_t FormatChangeRequested(
131				const media_source & source,
132				const media_destination & destination,
133				media_format * io_format,
134				int32 * _deprecated_) = 0;
135virtual	status_t GetNextOutput(	/* cookie starts as 0 */
136				int32 * cookie,
137				media_output * out_output) = 0;
138virtual	status_t DisposeOutputCookie(
139				int32 cookie) = 0;
140	/* In this function, you should either pass on the group to your upstream guy, */
141	/* or delete your current group and hang on to this group. Deleting the previous */
142	/* group (unless you passed it on with the reclaim flag set to false) is very */
143	/* important, else you will 1) leak memory and 2) block someone who may want */
144	/* to reclaim the buffers living in that group. */
145virtual	status_t SetBufferGroup(
146				const media_source & for_source,
147				BBufferGroup * group) = 0;
148	/* Format of clipping is (as int16-s): <from line> <npairs> <startclip> <endclip>. */
149	/* Repeat for each line where the clipping is different from the previous line. */
150	/* If <npairs> is negative, use the data from line -<npairs> (there are 0 pairs after */
151	/* a negative <npairs>. Yes, we only support 32k*32k frame buffers for clipping. */
152	/* Any non-0 field of 'display' means that that field changed, and if you don't support */
153	/* that change, you should return an error and ignore the request. Note that the buffer */
154	/* offset values do not have wildcards; 0 (or -1, or whatever) are real values and must */
155	/* be adhered to. */
156virtual	status_t VideoClippingChanged(
157				const media_source & for_source,
158				int16 num_shorts,
159				int16 * clip_data,
160				const media_video_display_info & display,
161				int32 * _deprecated_);
162	/* Iterates over all outputs and maxes the latency found */
163virtual	status_t GetLatency(
164				bigtime_t * out_lantency);
165virtual	status_t PrepareToConnect(
166				const media_source & what,
167				const media_destination & where,
168				media_format * format,
169				media_source * out_source,
170				char * out_name) = 0;
171virtual	void Connect(
172				status_t error,
173				const media_source & source,
174				const media_destination & destination,
175				const media_format & format,
176				char * io_name) = 0;
177virtual	void Disconnect(
178				const media_source & what,
179				const media_destination & where) = 0;
180virtual	void LateNoticeReceived(
181				const media_source & what,
182				bigtime_t how_much,
183				bigtime_t performance_time) = 0;
184virtual	void EnableOutput(
185				const media_source & what,
186				bool enabled,
187				int32 * _deprecated_) = 0;
188virtual	status_t SetPlayRate(
189				int32 numer,
190				int32 denom);
191
192virtual	status_t HandleMessage(	/* call this from the thread that listens to the port */
193				int32 message,
194				const void * data,
195				size_t size);
196
197virtual	void AdditionalBufferRequested(			//	used to be Reserved 0
198				const media_source & source,
199				media_buffer_id prev_buffer,
200				bigtime_t prev_time,
201				const media_seek_tag * prev_tag);	//	may be NULL
202
203virtual	void LatencyChanged(					//	used to be Reserved 1
204				const media_source & source,
205				const media_destination & destination,
206				bigtime_t new_latency,
207				uint32 flags);
208
209/* end from BBufferProducer */
210/****************************/
211
212private:
213
214		MediaFileProducer(	/* private unimplemented */
215				const MediaFileProducer & clone);
216		MediaFileProducer & operator=(
217				const MediaFileProducer & clone);
218
219		/* Mmmh, stuffing! */
220virtual		status_t _Reserved_MediaFileProducer_0(void *);
221virtual		status_t _Reserved_MediaFileProducer_1(void *);
222virtual		status_t _Reserved_MediaFileProducer_2(void *);
223virtual		status_t _Reserved_MediaFileProducer_3(void *);
224virtual		status_t _Reserved_MediaFileProducer_4(void *);
225virtual		status_t _Reserved_MediaFileProducer_5(void *);
226virtual		status_t _Reserved_MediaFileProducer_6(void *);
227virtual		status_t _Reserved_MediaFileProducer_7(void *);
228virtual		status_t _Reserved_MediaFileProducer_8(void *);
229virtual		status_t _Reserved_MediaFileProducer_9(void *);
230virtual		status_t _Reserved_MediaFileProducer_10(void *);
231virtual		status_t _Reserved_MediaFileProducer_11(void *);
232virtual		status_t _Reserved_MediaFileProducer_12(void *);
233virtual		status_t _Reserved_MediaFileProducer_13(void *);
234virtual		status_t _Reserved_MediaFileProducer_14(void *);
235virtual		status_t _Reserved_MediaFileProducer_15(void *);
236
237		uint32 _reserved_media_file_node_[16];
238
239};
240
241#endif /* _MEDIA_FILE_PRODUCER_H */
242