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