1 /*****************************************************************************
2 * qtl.c: QuickTime Media Link Importer
3 *****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea -@t- videolan -Dot- org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
26 http://developer.apple.com/documentation/QuickTime/QT6WhatsNew/Chap1/chapter_1_section_54.html
28 http://developer.apple.com/documentation/QuickTime/WhatsNewQT5/QT5NewChapt1/chapter_1_section_39.html
31 controller - true/false
32 fullscreen - normal/double/half/current/full
34 kioskmode - true/false
35 loop - true/false/palindrome
38 playeveryframe - true/false
40 quitwhendone - true/false
43 volume - 0 (mute) - 100 (max)
47 /*****************************************************************************
49 *****************************************************************************/
55 #include <vlc_common.h>
56 #include <vlc_demux.h>
61 typedef enum { FULLSCREEN_NORMAL,
65 FULLSCREEN_FULL } qtl_fullscreen_t;
66 const char* ppsz_fullscreen[] = { "normal", "double", "half", "current", "full" };
67 typedef enum { LOOP_TRUE,
69 LOOP_PALINDROME } qtl_loop_t;
70 const char* ppsz_loop[] = { "true", "false", "palindrome" };
72 /*****************************************************************************
74 *****************************************************************************/
75 static int Demux( demux_t *p_demux);
76 static int Control( demux_t *p_demux, int i_query, va_list args );
78 /*****************************************************************************
79 * Import_QTL: main import function
80 *****************************************************************************/
81 int Import_QTL( vlc_object_t *p_this )
83 demux_t *p_demux = (demux_t *)p_this;
85 if( !demux_IsPathExtension( p_demux, ".qtl" ) )
88 p_demux->pf_demux = Demux;
89 p_demux->pf_control = Control;
90 msg_Dbg( p_demux, "using QuickTime Media Link reader" );
95 static int Demux( demux_t *p_demux )
97 xml_reader_t *p_xml_reader;
99 input_item_t *p_input;
102 /* List of all possible attributes. The only required one is "src" */
103 bool b_autoplay = false;
104 bool b_controler = true;
105 qtl_fullscreen_t fullscreen = false;
106 char *psz_href = NULL;
107 bool b_kioskmode = false;
108 qtl_loop_t loop = LOOP_FALSE;
110 char *psz_moviename = NULL;
111 bool b_playeveryframe = false;
112 char *psz_qtnext = NULL;
113 bool b_quitwhendone = false;
114 char *psz_src = NULL;
115 char *psz_mimetype = NULL;
118 input_item_t *p_current_input = GetCurrentItem(p_demux);
120 p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
124 /* check root node */
125 if( xml_ReaderNextNode( p_xml_reader, &node ) != XML_READER_STARTELEM
126 || strcmp( node, "embed" ) )
128 msg_Err( p_demux, "invalid root node <%s>", node );
130 /* second line has <?quicktime tag ... so we try to skip it */
131 msg_Dbg( p_demux, "trying to read one more node" );
132 if( xml_ReaderNextNode( p_xml_reader, &node ) != XML_READER_STARTELEM
133 || strcmp( node, "embed" ) )
135 msg_Err( p_demux, "invalid root node <%s>", node );
140 const char *attrname, *value;
141 while( (attrname = xml_ReaderNextAttr( p_xml_reader, &value )) != NULL )
143 if( !strcmp( attrname, "autoplay" ) )
144 b_autoplay = !strcmp( value, "true" );
145 else if( !strcmp( attrname, "controler" ) )
146 b_controler = !strcmp( attrname, "false" );
147 else if( !strcmp( attrname, "fullscreen" ) )
149 if( !strcmp( value, "double" ) )
150 fullscreen = FULLSCREEN_DOUBLE;
151 else if( !strcmp( value, "half" ) )
152 fullscreen = FULLSCREEN_HALF;
153 else if( !strcmp( value, "current" ) )
154 fullscreen = FULLSCREEN_CURRENT;
155 else if( !strcmp( value, "full" ) )
156 fullscreen = FULLSCREEN_FULL;
158 fullscreen = FULLSCREEN_NORMAL;
160 else if( !strcmp( attrname, "href" ) )
163 psz_href = strdup( value );
165 else if( !strcmp( attrname, "kioskmode" ) )
166 b_kioskmode = !strcmp( value, "true" );
167 else if( !strcmp( attrname, "loop" ) )
169 if( !strcmp( value, "true" ) )
171 else if( !strcmp( value, "palindrome" ) )
172 loop = LOOP_PALINDROME;
176 else if( !strcmp( attrname, "movieid" ) )
177 i_movieid = atoi( value );
178 else if( !strcmp( attrname, "moviename" ) )
180 free( psz_moviename );
181 psz_moviename = strdup( value );
183 else if( !strcmp( attrname, "playeveryframe" ) )
184 b_playeveryframe = !strcmp( value, "true" );
185 else if( !strcmp( attrname, "qtnext" ) )
188 psz_qtnext = strdup( value );
190 else if( !strcmp( attrname, "quitwhendone" ) )
191 b_quitwhendone = !strcmp( value, "true" );
192 else if( !strcmp( attrname, "src" ) )
195 psz_src = strdup( value );
197 else if( !strcmp( attrname, "mimetype" ) )
199 free( psz_mimetype );
200 psz_mimetype = strdup( value );
202 else if( !strcmp( attrname, "volume" ) )
203 i_volume = atoi( value );
205 msg_Dbg( p_demux, "Attribute %s with value %s isn't valid",
209 msg_Dbg( p_demux, "autoplay: %s (unused by VLC)",
210 b_autoplay ? "true": "false" );
211 msg_Dbg( p_demux, "controler: %s (unused by VLC)",
212 b_controler ? "true": "false" );
213 msg_Dbg( p_demux, "fullscreen: %s (unused by VLC)",
214 ppsz_fullscreen[fullscreen] );
215 msg_Dbg( p_demux, "href: %s", psz_href );
216 msg_Dbg( p_demux, "kioskmode: %s (unused by VLC)",
217 b_kioskmode ? "true":"false" );
218 msg_Dbg( p_demux, "loop: %s (unused by VLC)", ppsz_loop[loop] );
219 msg_Dbg( p_demux, "movieid: %d (unused by VLC)", i_movieid );
220 msg_Dbg( p_demux, "moviename: %s", psz_moviename );
221 msg_Dbg( p_demux, "playeverframe: %s (unused by VLC)",
222 b_playeveryframe ? "true":"false" );
223 msg_Dbg( p_demux, "qtnext: %s", psz_qtnext );
224 msg_Dbg( p_demux, "quitwhendone: %s (unused by VLC)",
225 b_quitwhendone ? "true":"false" );
226 msg_Dbg( p_demux, "src: %s", psz_src );
227 msg_Dbg( p_demux, "mimetype: %s", psz_mimetype );
228 msg_Dbg( p_demux, "volume: %d (unused by VLC)", i_volume );
233 msg_Err( p_demux, "Mandatory attribute 'src' not found" );
237 input_item_node_t *p_subitems = input_item_node_Create( p_current_input );
238 p_input = input_item_New( psz_src, psz_moviename );
239 #define SADD_INFO( type, field ) if( field ) { input_item_AddInfo( \
240 p_input, "QuickTime Media Link", type, "%s", field ) ; }
241 SADD_INFO( "href", psz_href );
242 SADD_INFO( _("Mime"), psz_mimetype );
243 input_item_node_AppendItem( p_subitems, p_input );
244 vlc_gc_decref( p_input );
247 p_input = input_item_New( psz_qtnext, NULL );
248 input_item_node_AppendItem( p_subitems, p_input );
249 vlc_gc_decref( p_input );
251 input_item_node_PostAndDelete( p_subitems );
254 i_ret = 0; /* Needed for correct operation of go back */
258 xml_ReaderDelete( p_xml_reader );
260 vlc_gc_decref(p_current_input);
263 free( psz_moviename );
266 free( psz_mimetype );
270 static int Control( demux_t *p_demux, int i_query, va_list args )
272 VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args);