OSDN Git Service

add tstools.
[rec10/rec10-git.git] / tstools / DtsEdit / src / gpac / mediaobject.h
1 /*\r
2  *                      GPAC - Multimedia Framework C SDK\r
3  *\r
4  *                      Copyright (c) Jean Le Feuvre 2000-2005 \r
5  *                                      All rights reserved\r
6  *\r
7  *  This file is part of GPAC / Stream Management sub-project\r
8  *\r
9  *  GPAC is free software; you can redistribute it and/or modify\r
10  *  it under the terms of the GNU Lesser General Public License as published by\r
11  *  the Free Software Foundation; either version 2, or (at your option)\r
12  *  any later version.\r
13  *   \r
14  *  GPAC is distributed in the hope that it will be useful,\r
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  *  GNU Lesser General Public License for more details.\r
18  *   \r
19  *  You should have received a copy of the GNU Lesser General Public\r
20  *  License along with this library; see the file COPYING.  If not, write to\r
21  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
22  *\r
23  */\r
24 \r
25 \r
26 \r
27 #ifndef _GF_MEDIA_OBJECT_H_\r
28 #define _GF_MEDIA_OBJECT_H_\r
29 \r
30 #ifdef __cplusplus\r
31 extern "C" {\r
32 #endif\r
33 \r
34 #include <gpac/scenegraph_vrml.h>\r
35 \r
36 \r
37 /*\r
38                 Media Object\r
39 \r
40   opaque handler for all natural media objects (audio, video, image) so that compositor and systems engine\r
41 are not too tied up. \r
42         NOTE: the media object location relies on the node parent graph (this is to deal with namespaces in OD framework)\r
43 therefore it is the task of the media management app to setup clear links between the scene graph and its ressources\r
44 (but this is not mandatory, cf URLs in VRML )\r
45 \r
46         TODO - add interface for shape coding positioning in mediaObject and in the decoder API\r
47 */\r
48 \r
49 typedef struct _mediaobj GF_MediaObject;\r
50 \r
51 /*locate media object related to the given node - url designes the object to find - returns NULL if\r
52 URL cannot be handled - note that until the mediaObject.isInit member is true, the media object is not valid\r
53 (and could actually never be) */\r
54 GF_MediaObject *gf_mo_register(GF_Node *node, MFURL *url, Bool lock_timelines);\r
55 /*unregister the node from the media object*/\r
56 void gf_mo_unregister(GF_Node *node, GF_MediaObject *mo);\r
57 \r
58 /*opens media object*/\r
59 void gf_mo_play(GF_MediaObject *mo, Double clipBegin, Double clipEnd, Bool can_loop);\r
60 /*stops media object - video memory is not reset, last frame is kept*/\r
61 void gf_mo_stop(GF_MediaObject *mo);\r
62 /*restarts media object - shall be used for all looping media instead of stop/play for mediaControl\r
63 to restart appropriated objects*/\r
64 void gf_mo_restart(GF_MediaObject *mo);\r
65 \r
66 void gf_mo_pause(GF_MediaObject *mo);\r
67 void gf_mo_resume(GF_MediaObject *mo);\r
68 \r
69 /*\r
70         Note on mediaControl: mediaControl is the media management app responsability, therefore\r
71 is hidden from the rendering app. Since MediaControl overrides default settings of the node (speed and loop)\r
72 you must use the gf_mo_get_speed and gf_mo_get_loop in order to know whether the related field applies or not\r
73 */\r
74 \r
75 /*set speed of media - speed is not always applied, depending on media control settings.\r
76 NOTE: audio pitching is the responsability of the rendering app*/\r
77 void gf_mo_set_speed(GF_MediaObject *mo, Fixed speed);\r
78 /*returns current speed of media - in_speed is the speed of the media as set in the node (MovieTexture, \r
79 AudioClip and AudioSource) - the return value is the real speed of the media as overloaded by mediaControl if any*/\r
80 Fixed gf_mo_get_speed(GF_MediaObject *mo, Fixed in_speed);\r
81 /*returns looping flag of media - in_loop is the looping flag of the media as set in the node (MovieTexture, \r
82 AudioClip) - the return value is the real loop flag of the media as overloaded by mediaControl if any*/\r
83 Bool gf_mo_get_loop(GF_MediaObject *mo, Bool in_loop);\r
84 /*returns media object duration*/\r
85 Double gf_mo_get_duration(GF_MediaObject *mo);\r
86 /*returns whether the object should be deactivated (stop) or not - this checks object status as well as \r
87 mediaControl status */\r
88 Bool gf_mo_should_deactivate(GF_MediaObject *mo);\r
89 /*checks whether the target object is changed - you MUST use this in order to detect url changes*/\r
90 Bool gf_mo_url_changed(GF_MediaObject *mo, MFURL *url);\r
91 \r
92 \r
93 /*fetch media data \r
94 \r
95 */\r
96 char *gf_mo_fetch_data(GF_MediaObject *mo, Bool resync, Bool *eos, u32 *timestamp, u32 *size);\r
97 \r
98 /*release given amount of media data - nb_bytes is used for audio - if forceDrop is set, the unlocked frame will be \r
99 droped if all bytes are consumed, otherwise it will be droped based on object time - typically, video fetches with the resync\r
100 flag set and release without forceDrop, while audio fetches without resync but forces buffer drop. If forceDrop is set to 2, \r
101 the frame will be stated as a discraded frame*/\r
102 void gf_mo_release_data(GF_MediaObject *mo, u32 nb_bytes, s32 forceDrop);\r
103 /*get media time*/\r
104 void gf_mo_get_media_time(GF_MediaObject *mo, u32 *media_time, u32 *media_dur);\r
105 /*get object clock*/\r
106 void gf_mo_get_object_time(GF_MediaObject *mo, u32 *obj_time);\r
107 /*returns mute flag of media - if muted the media shouldn't be displayed*/\r
108 Bool gf_mo_is_muted(GF_MediaObject *mo);\r
109 /*returns end of stream state*/\r
110 Bool gf_mo_is_done(GF_MediaObject *mo);\r
111 /*resyncs clock - only audio objects are allowed to use this*/\r
112 void gf_mo_adjust_clock(GF_MediaObject *mo, s32 ms_drift);\r
113 \r
114 u32 gf_mo_get_last_frame_time(GF_MediaObject *mo);\r
115 \r
116 Bool gf_mo_get_visual_info(GF_MediaObject *mo, u32 *width, u32 *height, u32 *stride, u32 *pixel_ar, u32 *pixelFormat);\r
117 \r
118 Bool gf_mo_get_audio_info(GF_MediaObject *mo, u32 *sample_rate, u32 *bits_per_sample, u32 *num_channels, u32 *channel_config);\r
119 \r
120 /*checks if the service associated withthis object has an audio stream*/\r
121 Bool gf_mo_has_audio(GF_MediaObject *mo);\r
122 \r
123 enum\r
124 {\r
125         /*this is set to 0 by the OD manager whenever a change occur in the media (w/h change, SR change, etc) \r
126         as a hint for the compositor*/\r
127         GF_MO_IS_INIT = (1<<1),\r
128         /*used by animation stream to remove TEXT from display upon delete and URL change*/\r
129         GF_MO_DISPLAY_REMOVE = (1<<2),\r
130 };\r
131 \r
132 u32 gf_mo_get_flags(GF_MediaObject *mo);\r
133 void gf_mo_set_flag(GF_MediaObject *mo, u32 flag, Bool set_on);\r
134 \r
135 /*loads a new resource as indicated in the xlink:href attribute of the node. If this points to a fragment\r
136 of the current document, returns NULL. This will automatically trigger a play request on the resource*/\r
137 GF_MediaObject *gf_mo_load_xlink_resource(GF_Node *node, Bool primary_resource, Double clipBegin, Double clipEnd);\r
138 void gf_mo_unload_xlink_resource(GF_Node *node, GF_MediaObject *mo);\r
139 /*returns scene graph associated with a scene/document object, or NULL if wrong type or not loaded*/\r
140 GF_SceneGraph *gf_mo_get_scenegraph(GF_MediaObject *mo);\r
141 \r
142 #ifdef __cplusplus\r
143 }\r
144 #endif\r
145 \r
146 \r
147 #endif  /*_GF_MEDIA_OBJECT_H_*/\r
148 \r
149 \r