1 // AbstractFileInterfaceNode.h
3 // Andrew Bachmann, 2002
5 // The AbstractFileInterfaceNode class implements
6 // the common functionality between MediaReader
9 #if !defined(_ABSTRACT_FILE_INTERFACE_NODE_H)
10 #define _ABSTRACT_FILE_INTERFACE_NODE_H
12 #include <BufferGroup.h>
13 #include <Controllable.h>
16 #include <FileInterface.h>
17 #include <MediaAddOn.h>
18 #include <MediaDefs.h>
19 #include <MediaNode.h>
20 #include <MediaEventLooper.h>
22 class AbstractFileInterfaceNode
:
23 public BFileInterface
,
25 public BMediaEventLooper
28 virtual ~AbstractFileInterfaceNode(void);
32 explicit AbstractFileInterfaceNode(
33 size_t defaultChunkSize
= 8192, // chunk size = 8 KB
34 float defaultBitRate
= 800000, // bit rate = 100.000 KB/sec = 5.85 MB/minute
35 const flavor_info
* info
= 0, // buffer period = 80 milliseconds
36 BMessage
* config
= 0,
37 BMediaAddOn
* addOn
= 0);
39 virtual status_t
InitCheck(void) const;
41 // see BMediaAddOn::GetConfigurationFor
42 virtual status_t
GetConfigurationFor(
43 BMessage
* into_message
);
45 /*************************/
46 /* begin from BMediaNode */
48 // /* this port is what a media node listens to for commands */
49 // virtual port_id ControlPort(void) const;
51 virtual BMediaAddOn
* AddOn(
52 int32
* internal_id
) const; /* Who instantiated you -- or NULL for app class */
55 /* These don't return errors; instead, they use the global error condition reporter. */
56 /* A node is required to have a queue of at least one pending command (plus TimeWarp) */
57 /* and is recommended to allow for at least one pending command of each type. */
58 /* Allowing an arbitrary number of outstanding commands might be nice, but apps */
59 /* cannot depend on that happening. */
61 bigtime_t performance_time
);
63 bigtime_t performance_time
,
67 bigtime_t performance_time
);
68 virtual void SetRunMode(
70 virtual void TimeWarp(
71 bigtime_t at_real_time
,
72 bigtime_t to_performance_time
);
73 virtual void Preroll(void);
74 virtual void SetTimeSource(
75 BTimeSource
* time_source
);
78 virtual status_t
HandleMessage(
84 /* Called when requests have completed, or failed. */
85 virtual status_t
RequestCompleted( /* reserved 0 */
86 const media_request_info
& info
);
89 virtual status_t
DeleteHook(BMediaNode
* node
); /* reserved 1 */
91 virtual void NodeRegistered(void); /* reserved 2 */
95 /* fill out your attributes in the provided array, returning however many you have. */
96 virtual status_t
GetNodeAttributes( /* reserved 3 */
97 media_node_attribute
* outAttributes
,
100 virtual status_t
AddTimer(
101 bigtime_t at_performance_time
,
104 /* end from BMediaNode */
105 /***********************/
108 virtual BParameterWeb
* MakeParameterWeb(void);
110 /*****************************/
111 /* begin from BFileInterface */
113 //included from BMediaNode
114 //virtual status_t HandleMessage(
116 // const void * data,
119 virtual status_t
GetNextFileFormat(
121 media_file_format
* out_format
);
122 virtual void DisposeFileFormatCookie(
125 virtual status_t
GetDuration(
126 bigtime_t
* out_time
);
128 virtual status_t
SniffRef(
129 const entry_ref
& file
,
130 char * out_mime_type
, /* 256 bytes */
131 float * out_quality
);
133 virtual status_t
SetRef(
134 const entry_ref
& file
,
136 bigtime_t
* out_time
) = 0;
138 virtual status_t
SetRef(
139 const entry_ref
& file
,
142 bigtime_t
* out_time
);
144 virtual status_t
GetRef(
146 char * out_mime_type
);
148 /* end from BFileInterface */
149 /***************************/
151 // provided for BAbstractFileInterfaceNodeAddOn
153 static status_t
StaticSniffRef(
154 const entry_ref
& file
,
155 char * out_mime_type
, /* 256 bytes */
156 float * out_quality
);
158 /****************************/
159 /* begin from BControllable */
161 //included from BMediaNode
162 //virtual status_t HandleMessage(
164 // const void * data,
167 /* These are alternate methods of accomplishing the same thing as */
168 /* connecting to control information source/destinations would. */
169 virtual status_t
GetParameterValue(
171 bigtime_t
* last_change
,
174 virtual void SetParameterValue(
179 virtual status_t
StartControlPanel(
180 BMessenger
* out_messenger
);
182 /* end from BControllable */
183 /**************************/
186 // these three are related:
187 // DEFAULT_CHUNK_SIZE = (DEFAULT_BIT_RATE * 1024) * (DEFAULT_BUFFER_PERIOD / 8000000)
188 static const int32 DEFAULT_CHUNK_SIZE_PARAM
; // in bytes
189 static const int32 DEFAULT_BIT_RATE_PARAM
; // in 1000*kilobits/sec
190 static const int32 DEFAULT_BUFFER_PERIOD_PARAM
; // milliseconds
193 size_t fDefaultChunkSizeParam
;
194 bigtime_t fDefaultChunkSizeParamChangeTime
;
195 float fDefaultBitRateParam
;
196 bigtime_t fDefaultBitRateParamChangeTime
;
197 int32 fDefaultBufferPeriodParam
;
198 bigtime_t fDefaultBufferPeriodParamChangeTime
;
200 // This is used to figure out which parameter to compute
201 // when enforcing the above constraint relating the three params
202 int32 fLastUpdatedParameter
;
203 int32 fLeastRecentlyUpdatedParameter
;
205 /********************************/
206 /* start from BMediaEventLooper */
209 /* you must override to handle your events! */
210 /* you should not call HandleEvent directly */
211 virtual void HandleEvent( const media_timed_event
*event
,
213 bool realTimeEvent
= false);
215 /* override to clean up custom events you have added to your queue */
216 virtual void CleanUpEvent(const media_timed_event
*event
);
218 /* called from Offline mode to determine the current time of the node */
219 /* update your internal information whenever it changes */
220 virtual bigtime_t
OfflineTime();
222 /* override only if you know what you are doing! */
223 /* otherwise much badness could occur */
224 /* the actual control loop function: */
225 /* waits for messages, Pops events off the queue and calls DispatchEvent */
226 virtual void ControlLoop();
228 /* end from BMediaEventLooper */
229 /******************************/
233 virtual status_t
HandleStart(
234 const media_timed_event
*event
,
236 bool realTimeEvent
= false);
237 virtual status_t
HandleSeek(
238 const media_timed_event
*event
,
240 bool realTimeEvent
= false);
241 virtual status_t
HandleWarp(
242 const media_timed_event
*event
,
244 bool realTimeEvent
= false);
245 virtual status_t
HandleStop(
246 const media_timed_event
*event
,
248 bool realTimeEvent
= false);
249 virtual status_t
HandleBuffer(
250 const media_timed_event
*event
,
252 bool realTimeEvent
= false) = 0;
253 virtual status_t
HandleDataStatus(
254 const media_timed_event
*event
,
256 bool realTimeEvent
= false) = 0;
257 virtual status_t
HandleParameter(
258 const media_timed_event
*event
,
260 bool realTimeEvent
= false);
264 static void GetFlavor(flavor_info
* outInfo
, int32 id
);
265 static void GetFormat(media_format
* outFormat
);
266 static void GetFileFormat(media_file_format
* outFileFormat
);
270 virtual status_t
AddRequirements(media_format
* format
);
271 virtual status_t
ResolveWildcards(media_format
* format
);
275 inline BFile
* GetCurrentFile() { return fCurrentFile
; }
279 AbstractFileInterfaceNode( /* private unimplemented */
280 const AbstractFileInterfaceNode
& clone
);
281 AbstractFileInterfaceNode
& operator=(
282 const AbstractFileInterfaceNode
& clone
);
284 status_t fInitCheckStatus
;
286 BMediaAddOn
* fAddOn
;
288 BFile
* fCurrentFile
;
289 entry_ref f_current_ref
;
290 char f_current_mime_type
[B_MIME_TYPE_LENGTH
+1];
292 /* Mmmh, stuffing! */
293 virtual status_t
_Reserved_AbstractFileInterfaceNode_0(void *);
294 virtual status_t
_Reserved_AbstractFileInterfaceNode_1(void *);
295 virtual status_t
_Reserved_AbstractFileInterfaceNode_2(void *);
296 virtual status_t
_Reserved_AbstractFileInterfaceNode_3(void *);
297 virtual status_t
_Reserved_AbstractFileInterfaceNode_4(void *);
298 virtual status_t
_Reserved_AbstractFileInterfaceNode_5(void *);
299 virtual status_t
_Reserved_AbstractFileInterfaceNode_6(void *);
300 virtual status_t
_Reserved_AbstractFileInterfaceNode_7(void *);
301 virtual status_t
_Reserved_AbstractFileInterfaceNode_8(void *);
302 virtual status_t
_Reserved_AbstractFileInterfaceNode_9(void *);
303 virtual status_t
_Reserved_AbstractFileInterfaceNode_10(void *);
304 virtual status_t
_Reserved_AbstractFileInterfaceNode_11(void *);
305 virtual status_t
_Reserved_AbstractFileInterfaceNode_12(void *);
306 virtual status_t
_Reserved_AbstractFileInterfaceNode_13(void *);
307 virtual status_t
_Reserved_AbstractFileInterfaceNode_14(void *);
308 virtual status_t
_Reserved_AbstractFileInterfaceNode_15(void *);
310 uint32 _reserved_abstract_file_interface_node_
[16];
314 #endif /* _ABSTRACT_FILE_INTERFACE_NODE_H */