]> git.sesse.net Git - vlc/blob - plugins/dvd/dvd_summary.c
* Another FreeBSD compilation fix.
[vlc] / plugins / dvd / dvd_summary.c
1 /*****************************************************************************
2  * dvd_summary.c: set of functions to print options of selected title
3  * found in .ifo.
4  *****************************************************************************
5  * Copyright (C) 1998-2001 VideoLAN
6  * $Id: dvd_summary.c,v 1.4 2001/06/07 22:25:42 sam Exp $
7  *
8  * Author: Stéphane Borel <stef@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include "defs.h"
29
30 #ifdef HAVE_CSS
31 #define MODULE_NAME dvd
32 #else /* HAVE_CSS */
33 #define MODULE_NAME dvdnocss
34 #endif /* HAVE_CSS */
35 #include "modules_inner.h"
36
37 #include <stdio.h>
38 #include <stdlib.h>
39
40 #ifdef HAVE_UNISTD_H
41 #include <unistd.h>
42 #endif
43
44 #if !defined( WIN32 )
45 #include <netinet/in.h>
46 #endif
47
48 #include <fcntl.h>
49 #include <sys/types.h>
50
51 #include <string.h>
52 #ifdef STRNCASECMP_IN_STRINGS_H
53 #   include <strings.h>
54 #endif
55 #include <errno.h>
56
57 #include "config.h"
58 #include "common.h"
59 #include "threads.h"
60 #include "mtime.h"
61 #include "tests.h"
62
63 #include "intf_msg.h"
64
65 #include "main.h"
66
67 #include "input_dvd.h"
68 #include "dvd_ifo.h"
69
70 #include "debug.h"
71
72 #include "modules.h"
73 #include "modules_export.h"
74
75 /*****************************************************************************
76  * Local tables
77  *****************************************************************************/
78 static struct
79 {
80     char    p_code[3];
81     char    p_lang_long[20];
82 }
83
84 lang_tbl[] =
85 {
86     /* The ISO 639 language codes.
87      * Language names with * prefix are not spelled in their own language 
88      */
89     { "  ", "Not Specified" },
90     { "aa", "*Afar" },
91     { "ab", "*Abkhazian" },
92     { "af", "*Afrikaans" },
93     { "am", "*Amharic" },
94     { "ar", "*Arabic" },
95     { "as", "*Assamese" },
96     { "ay", "*Aymara" },
97     { "az", "*Azerbaijani" },
98     { "ba", "*Bashkir" },
99     { "be", "*Byelorussian" },
100     { "bg", "*Bulgarian" },
101     { "bh", "*Bihari" },
102     { "bi", "*Bislama" },
103     { "bn", "*Bengali; Bangla" },
104     { "bo", "*Tibetan" },
105     { "br", "*Breton" },
106     { "ca", "*Catalan" },
107     { "co", "*Corsican" },
108     { "cs", "*Czech(Ceske)" },
109     { "cy", "*Welsh" },
110     { "da", "Dansk" },
111     { "de", "Deutsch" },
112     { "dz", "*Bhutani" },
113     { "el", "*Greek" },
114     { "en", "English" },
115     { "eo", "*Esperanto" },
116     { "es", "Espanol" },
117     { "et", "*Estonian" },
118     { "eu", "*Basque" },
119     { "fa", "*Persian" },
120     { "fi", "Suomi" },
121     { "fj", "*Fiji" },
122     { "fo", "*Faroese" },
123     { "fr", "Francais" },
124     { "fy", "*Frisian" },
125     { "ga", "*Irish" },
126     { "gd", "*Scots Gaelic" },
127     { "gl", "*Galician" },
128     { "gn", "*Guarani" },
129     { "gu", "*Gujarati" },
130     { "ha", "*Hausa" },
131     { "he", "*Hebrew" },                                      /* formerly iw */
132     { "hi", "*Hindi" },
133     { "hr", "Hrvatski" },                                        /* Croatian */
134     { "hu", "Magyar" },
135     { "hy", "*Armenian" },
136     { "ia", "*Interlingua" },
137     { "id", "*Indonesian" },                                  /* formerly in */
138     { "ie", "*Interlingue" },
139     { "ik", "*Inupiak" },
140     { "in", "*Indonesian" },                               /* replaced by id */
141     { "is", "Islenska" },
142     { "it", "Italiano" },
143     { "iu", "*Inuktitut" },
144     { "iw", "*Hebrew" },                                   /* replaced by he */
145     { "ja", "*Japanese" },
146     { "ji", "*Yiddish" },                                  /* replaced by yi */
147     { "jw", "*Javanese" },
148     { "ka", "*Georgian" },
149     { "kk", "*Kazakh" },
150     { "kl", "*Greenlandic" },
151     { "km", "*Cambodian" },
152     { "kn", "*Kannada" },
153     { "ko", "*Korean" },
154     { "ks", "*Kashmiri" },
155     { "ku", "*Kurdish" },
156     { "ky", "*Kirghiz" },
157     { "la", "*Latin" },
158     { "ln", "*Lingala" },
159     { "lo", "*Laothian" },
160     { "lt", "*Lithuanian" },
161     { "lv", "*Latvian, Lettish" },
162     { "mg", "*Malagasy" },
163     { "mi", "*Maori" },
164     { "mk", "*Macedonian" },
165     { "ml", "*Malayalam" },
166     { "mn", "*Mongolian" },
167     { "mo", "*Moldavian" },
168     { "mr", "*Marathi" },
169     { "ms", "*Malay" },
170     { "mt", "*Maltese" },
171     { "my", "*Burmese" },
172     { "na", "*Nauru" },
173     { "ne", "*Nepali" },
174     { "nl", "Nederlands" },
175     { "no", "Norsk" },
176     { "oc", "*Occitan" },
177     { "om", "*(Afan) Oromo" },
178     { "or", "*Oriya" },
179     { "pa", "*Punjabi" },
180     { "pl", "*Polish" },
181     { "ps", "*Pashto, Pushto" },
182     { "pt", "Portugues" },
183     { "qu", "*Quechua" },
184     { "rm", "*Rhaeto-Romance" },
185     { "rn", "*Kirundi" },
186     { "ro", "*Romanian"  },
187     { "ru", "*Russian" },
188     { "rw", "*Kinyarwanda" },
189     { "sa", "*Sanskrit" },
190     { "sd", "*Sindhi" },
191     { "sg", "*Sangho" },
192     { "sh", "*Serbo-Croatian" },
193     { "si", "*Sinhalese" },
194     { "sk", "*Slovak" },
195     { "sl", "*Slovenian" },
196     { "sm", "*Samoan" },
197     { "sn", "*Shona"  },
198     { "so", "*Somali" },
199     { "sq", "*Albanian" },
200     { "sr", "*Serbian" },
201     { "ss", "*Siswati" },
202     { "st", "*Sesotho" },
203     { "su", "*Sundanese" },
204     { "sv", "Svenska" },
205     { "sw", "*Swahili" },
206     { "ta", "*Tamil" },
207     { "te", "*Telugu" },
208     { "tg", "*Tajik" },
209     { "th", "*Thai" },
210     { "ti", "*Tigrinya" },
211     { "tk", "*Turkmen" },
212     { "tl", "*Tagalog" },
213     { "tn", "*Setswana" },
214     { "to", "*Tonga" },
215     { "tr", "*Turkish" },
216     { "ts", "*Tsonga" },
217     { "tt", "*Tatar" },
218     { "tw", "*Twi" },
219     { "ug", "*Uighur" },
220     { "uk", "*Ukrainian" },
221     { "ur", "*Urdu" },
222     { "uz", "*Uzbek" },
223     { "vi", "*Vietnamese" },
224     { "vo", "*Volapuk" },
225     { "wo", "*Wolof" },
226     { "xh", "*Xhosa" },
227     { "yi", "*Yiddish" },                                     /* formerly ji */
228     { "yo", "*Yoruba" },
229     { "za", "*Zhuang" },
230     { "zh", "*Chinese" },
231     { "zu", "*Zulu" },
232     { "\0", "" }
233 };
234
235 /*
236  * Local tools to decode some data in ifo
237  */
238
239 /*****************************************************************************
240  * IfoLanguage: gives the long language name from the two-letters
241  *              ISO-639 code
242  *****************************************************************************/
243 char * IfoLanguage( u16 i_code )
244 {
245     int     i = 0;
246
247     while( memcmp( lang_tbl[i].p_code, &i_code, 2 ) &&
248            lang_tbl[i].p_lang_long[0] )
249     {
250         i++;
251     }
252
253     return lang_tbl[i].p_lang_long;
254 }
255
256
257 /****************************************************************************
258  * IfoPrintTitle
259  ****************************************************************************/
260 void IfoPrintTitle( thread_dvd_data_t * p_dvd )
261 {
262     intf_WarnMsg( 5, "***************************************************" );
263     intf_WarnMsg( 5, "dvd info: title: %d", p_dvd->i_title );
264     intf_WarnMsg( 5, "    vobstart at: %lld", p_dvd->i_start );
265     intf_WarnMsg( 5, "    stream size: %lld", p_dvd->i_size );
266     intf_WarnMsg( 5, "    number of chapters: %d", p_dvd->i_chapter_nb );
267     intf_WarnMsg( 5, "    number of angles: %d", p_dvd->i_angle_nb );
268     intf_WarnMsg( 5, "***************************************************\n" );
269 }
270
271 /****************************************************************************
272  * IfoPrintVideo
273  ****************************************************************************/
274 #define video p_dvd->p_ifo->vts.manager_inf.video_attr
275 void IfoPrintVideo( thread_dvd_data_t * p_dvd )
276 {
277     char     psz_ratio[12];
278     char     psz_perm_displ[4][23] =
279              {
280                 "pan-scan & letterboxed",
281                 "pan-scan",
282                 "letterboxed",
283                 "not specified"
284              };
285     char     psz_source_res[4][28] =
286              {
287                 "720x480 ntsc or 720x576 pal",
288                 "704x480 ntsc or 704x576 pal",
289                 "352x480 ntsc or 352x576 pal",
290                 "352x240 ntsc or 352x288 pal"
291              };
292
293  
294     switch( video.i_ratio )
295     {
296     case 0:
297         sprintf( psz_ratio, "4:3" );
298         break;
299     case 3:
300         sprintf( psz_ratio, "16:9" );
301         break;
302     default:
303         sprintf( psz_ratio, "undef" );
304         break;
305     }
306
307     intf_WarnMsg( 5, "***********************************************" );
308     intf_WarnMsg( 5, "dvd info: video" );
309     intf_WarnMsg( 5, "    compression: mpeg-%d", video.i_compression+1 );
310     intf_WarnMsg( 5, "    tv system: %s Hz",
311                      video.i_system ? "pal 625/50" : "ntsc 525/60" );
312     intf_WarnMsg( 5, "    aspect ratio: %s", psz_ratio );
313     intf_WarnMsg( 5, "    display mode: %s",
314                      psz_perm_displ[video.i_perm_displ] );
315     intf_WarnMsg( 5, "    line21-1: %s",
316                      video.i_line21_1 ? "data present in GOP" : "" );
317     intf_WarnMsg( 5, "    line21-2: %s",
318                      video.i_line21_2 ? "data present in GOP" : "" );
319     intf_WarnMsg( 5, "    source res: %s",
320                      psz_source_res[video.i_source_res] );
321     intf_WarnMsg( 5, "    letterboxed: %s",
322                      video.i_letterboxed ? "yes" : "no" );
323     intf_WarnMsg( 5, "    mode: %s",
324                      video.i_mode ? "film (625/50 only)" : "camera");
325     intf_WarnMsg( 5, "***********************************************\n" );
326 }
327 #undef video
328
329 /****************************************************************************
330  * IfoPrintAudio
331  ****************************************************************************/
332 #define audio p_dvd->p_ifo->vts.manager_inf.p_audio_attr[i-1]
333 #define audio_status \
334     p_dvd->p_ifo->vts.title_unit.p_title[p_dvd->i_title_id-1].title.pi_audio_status[i-1]
335 void IfoPrintAudio( thread_dvd_data_t * p_dvd, int i )
336 {
337
338     if( audio_status.i_available )
339     {
340         char    ppsz_mode[7][9] =
341                 { "ac3", "unknown", "mpeg-1", "mpeg-2", "lpcm", "sdds", "dts" };
342         char    ppsz_appl_mode[3][15] =
343                 { "not specified", "karaoke", "surround sound" };
344         char    psz_caption[25];
345         char    ppsz_quant[4][10] =
346                 { "16 bits", "20 bits", "24 bits", "drc" };
347     
348         intf_WarnMsg( 5, "***********************************************" );
349         intf_WarnMsg( 5, "dvd info: audio %d" , i );
350         intf_WarnMsg( 5, "    language: %s", 
351                          IfoLanguage( hton16( audio.i_lang_code ) ) );
352         intf_WarnMsg( 5, "    mode: %s", ppsz_mode[audio.i_coding_mode & 0x7] );
353         intf_WarnMsg( 5, "    channel(s): %d %s",
354                          audio.i_num_channels + 1,
355                          audio.i_multichannel_extension ? "ext." : "" );
356         intf_WarnMsg( 5, "    sampling: %d Hz",
357                          audio.i_sample_freq ? 96000 : 48000 );
358         intf_WarnMsg( 5, "    appl_mode: %s",
359                          ppsz_appl_mode[audio.i_appl_mode & 0x2] );
360         switch( audio.i_caption )
361         {
362         case 1:
363             sprintf( psz_caption, "normal caption" );
364             break;
365         case 3:
366             sprintf( psz_caption, "directors comments" );
367             break;
368         default:
369             sprintf( psz_caption, " " );
370             break;
371         }
372         intf_WarnMsg( 5, "    caption: %s", psz_caption );
373         intf_WarnMsg( 5, "    quantization: %s",
374                          ppsz_quant[audio.i_quantization & 0x3] );
375     
376         intf_WarnMsg( 5, "    status: %x", audio_status.i_position );
377         intf_WarnMsg( 5, "***********************************************\n" );
378     }
379
380
381 }
382 #undef audio_status
383 #undef audio
384
385 /****************************************************************************
386  * IfoPrintSpu
387  ****************************************************************************/
388 #define spu p_dvd->p_ifo->vts.manager_inf.p_spu_attr[i-1]
389 #define spu_status \
390     p_dvd->p_ifo->vts.title_unit.p_title[p_dvd->i_title_id-1].title.pi_spu_status[i-1]
391
392 void IfoPrintSpu( thread_dvd_data_t * p_dvd, int i )
393 {
394     if( spu_status.i_available )
395     {
396         intf_WarnMsg( 5, "***********************************************" );
397         intf_WarnMsg( 5, "dvd info: spu %d", i );
398         intf_WarnMsg( 5, "    caption: %d", spu.i_caption );
399         intf_WarnMsg( 5, "    language: %s",
400                          IfoLanguage( hton16( spu.i_lang_code ) ) );
401         intf_WarnMsg( 5, "    prefix: %x", spu.i_prefix );
402
403         intf_WarnMsg( 5, "    status: 4:3 %x wide %x letter %x pan %x",
404             spu_status.i_position_43,
405             spu_status.i_position_wide,
406             spu_status.i_position_letter,
407             spu_status.i_position_pan );
408         intf_WarnMsg( 5, "***********************************************\n" );
409     }
410
411 }
412 #undef spu_status
413 #undef spu