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