00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <vlc/vlc.h>
00025 #include <vlc/input.h>
00026
00027 #include "vcd.h"
00028 #include <vlc_playlist.h>
00029 #include "vlc_keys.h"
00030 #include "info.h"
00031
00032 #include <cdio/cdio.h>
00033 #include <cdio/cd_types.h>
00034 #include <cdio/logging.h>
00035 #include <cdio/util.h>
00036 #include <libvcd/info.h>
00037 #include <libvcd/logging.h>
00038
00039 static inline void
00040 MetaInfoAddStr(access_t *p_access, char *psz_cat,
00041 char *title, const char *psz)
00042 {
00043 vcdplayer_t *p_vcdplayer = (vcdplayer_t *) p_access->p_sys;
00044 if ( psz ) {
00045 dbg_print( INPUT_DBG_META, "cat %s, field: %s: %s", psz_cat, title, psz);
00046 input_Control( p_vcdplayer->p_input, INPUT_ADD_INFO, psz_cat, title, "%s",
00047 psz);
00048 }
00049 }
00050
00051
00052 static inline void
00053 MetaInfoAddNum(access_t *p_access, char *psz_cat, char *title, int num)
00054 {
00055 vcdplayer_t *p_vcdplayer = (vcdplayer_t *) p_access->p_sys;
00056 dbg_print( INPUT_DBG_META, "cat %s, field %s: %d", psz_cat, title, num);
00057 input_Control( p_vcdplayer->p_input, INPUT_ADD_INFO, psz_cat, title,
00058 "%d", num );
00059 }
00060
00061 static inline void
00062 MetaInfoAddHex(access_t *p_access, char *psz_cat, char *title, int hex)
00063 {
00064 vcdplayer_t *p_vcdplayer = (vcdplayer_t *) p_access->p_sys;
00065 dbg_print( INPUT_DBG_META, "cat %s, field %s: %d", psz_cat, title, hex);
00066 input_Control( p_vcdplayer->p_input, INPUT_ADD_INFO, psz_cat, title,
00067 "%x", hex );
00068 }
00069
00070 #define addstr(title, str) \
00071 MetaInfoAddStr( p_access, psz_cat, title, str );
00072
00073 #define addnum(title, num) \
00074 MetaInfoAddNum( p_access, psz_cat, title, num );
00075
00076 #define addhex(title, hex) \
00077 MetaInfoAddHex( p_access, psz_cat, title, hex );
00078
00079 void
00080 VCDMetaInfo( access_t *p_access, char *psz_mrl )
00081 {
00082 vcdplayer_t *p_vcdplayer = (vcdplayer_t *) p_access->p_sys;
00083 unsigned int i_entries = vcdinfo_get_num_entries(p_vcdplayer->vcd);
00084 unsigned int last_entry = 0;
00085 char *psz_cat;
00086 track_t i_track;
00087
00088 psz_cat = _("Disc");
00089
00090 addstr( _("VCD Format"), vcdinfo_get_format_version_str(p_vcdplayer->vcd) );
00091 addstr( _("Album"), vcdinfo_get_album_id(p_vcdplayer->vcd));
00092 addstr( _("Application"), vcdinfo_get_application_id(p_vcdplayer->vcd) );
00093 addstr( _("Preparer"), vcdinfo_get_preparer_id(p_vcdplayer->vcd) );
00094 addnum( _("Vol #"), vcdinfo_get_volume_num(p_vcdplayer->vcd) );
00095 addnum( _("Vol max #"), vcdinfo_get_volume_count(p_vcdplayer->vcd) );
00096 addstr( _("Volume Set"), vcdinfo_get_volumeset_id(p_vcdplayer->vcd) );
00097 addstr( _("Volume"), vcdinfo_get_volume_id(p_vcdplayer->vcd) );
00098 addstr( _("Publisher"), vcdinfo_get_publisher_id(p_vcdplayer->vcd) );
00099 addstr( _("System Id"), vcdinfo_get_system_id(p_vcdplayer->vcd) );
00100 addnum( "LIDs", vcdinfo_get_num_LIDs(p_vcdplayer->vcd) );
00101 addnum( _("Entries"), vcdinfo_get_num_entries(p_vcdplayer->vcd) );
00102 addnum( _("Segments"), vcdinfo_get_num_segments(p_vcdplayer->vcd) );
00103 addnum( _("Tracks"), vcdinfo_get_num_tracks(p_vcdplayer->vcd) );
00104
00105
00106
00107
00108
00109 #define TITLE_MAX 30
00110 for( i_track = 1 ; i_track < p_vcdplayer->i_tracks ; i_track++ ) {
00111 char psz_cat[20];
00112 unsigned int audio_type = vcdinfo_get_track_audio_type(p_vcdplayer->vcd,
00113 i_track);
00114 uint32_t i_secsize = vcdinfo_get_track_sect_count(p_vcdplayer->vcd, i_track);
00115
00116 snprintf(psz_cat, sizeof(psz_cat), "Track %d", i_track);
00117 if (p_vcdplayer->b_svd) {
00118 addnum(_("Audio Channels"),
00119 vcdinfo_audio_type_num_channels(p_vcdplayer->vcd, audio_type) );
00120 }
00121
00122 addnum(_("First Entry Point"), last_entry );
00123 for ( ; last_entry < i_entries
00124 && vcdinfo_get_track(p_vcdplayer->vcd, last_entry) == i_track;
00125 last_entry++ ) ;
00126 addnum(_("Last Entry Point"), last_entry-1 );
00127 addnum(_("Track size (in sectors)"), i_secsize );
00128 }
00129
00130 {
00131 lid_t i_lid;
00132 for( i_lid = 1 ; i_lid <= p_vcdplayer->i_lids ; i_lid++ ) {
00133 PsdListDescriptor_t pxd;
00134 char psz_cat[20];
00135 snprintf(psz_cat, sizeof(psz_cat), "LID %d", i_lid);
00136 if (vcdinfo_lid_get_pxd(p_vcdplayer->vcd, &pxd, i_lid)) {
00137 switch (pxd.descriptor_type) {
00138 case PSD_TYPE_END_LIST:
00139 addstr(_("type"), _("end"));
00140 break;
00141 case PSD_TYPE_PLAY_LIST:
00142 addstr(_("type"), _("play list"));
00143 addnum("items", vcdinf_pld_get_noi(pxd.pld));
00144 addhex("next", vcdinf_pld_get_next_offset(pxd.pld));
00145 addhex("previous", vcdinf_pld_get_prev_offset(pxd.pld));
00146 addhex("return", vcdinf_pld_get_return_offset(pxd.pld));
00147 addnum("wait time", vcdinf_get_wait_time(pxd.pld));
00148 break;
00149 case PSD_TYPE_SELECTION_LIST:
00150 case PSD_TYPE_EXT_SELECTION_LIST:
00151 addstr(_("type"),
00152 PSD_TYPE_SELECTION_LIST == pxd.descriptor_type
00153 ? _("extended selection list")
00154 : _("selection list")
00155 );
00156 addhex("default", vcdinf_psd_get_default_offset(pxd.psd));
00157 addhex("loop count", vcdinf_get_loop_count(pxd.psd));
00158 addhex("next", vcdinf_psd_get_next_offset(pxd.psd));
00159 addhex("previous", vcdinf_psd_get_prev_offset(pxd.psd));
00160 addhex("return", vcdinf_psd_get_return_offset(pxd.psd));
00161 addhex("rejected", vcdinf_psd_get_lid_rejected(pxd.psd));
00162 addhex("time-out offset", vcdinf_get_timeout_offset(pxd.psd));
00163 addnum("time-out time", vcdinf_get_timeout_time(pxd.psd));
00164 break;
00165 default:
00166 addstr(_("type"), _("unknown type"));
00167 break;
00168 }
00169 }
00170 }
00171 }
00172
00173 if ( CDIO_INVALID_TRACK != i_track )
00174 {
00175 char *psz_name =
00176 VCDFormatStr( p_access, p_vcdplayer,
00177 config_GetPsz( p_access, MODULE_STRING "-title-format" ),
00178 psz_mrl, &(p_vcdplayer->play_item) );
00179
00180 input_Control( p_vcdplayer->p_input, INPUT_SET_NAME, psz_name );
00181 }
00182
00183 }
00184
00185 #define add_format_str_info(val) \
00186 { \
00187 const char *str = strdup(val); \
00188 unsigned int len; \
00189 if (val != NULL) { \
00190 len=strlen(str); \
00191 if (len != 0) { \
00192 strncat(tp, str, TEMP_STR_LEN-(tp-temp_str)); \
00193 tp += len; \
00194 } \
00195 saw_control_prefix = VLC_FALSE; \
00196 } \
00197 }
00198
00199 #define add_format_num_info( val, fmt ) \
00200 { \
00201 char num_str[10]; \
00202 unsigned int len; \
00203 sprintf(num_str, fmt, val); \
00204 len = strlen(num_str); \
00205 if( len != 0 ) \
00206 { \
00207 strncat(tp, num_str, TEMP_STR_LEN-(tp-temp_str)); \
00208 tp += len; \
00209 } \
00210 saw_control_prefix = VLC_FALSE; \
00211 }
00212
00235 char *
00236 VCDFormatStr(const access_t *p_access, vcdplayer_t *p_vcdplayer,
00237 const char format_str[], const char *mrl,
00238 const vcdinfo_itemid_t *itemid)
00239 {
00240 #define TEMP_STR_SIZE 256
00241 #define TEMP_STR_LEN (TEMP_STR_SIZE-1)
00242 static char temp_str[TEMP_STR_SIZE];
00243 size_t i;
00244 char * tp = temp_str;
00245 vlc_bool_t saw_control_prefix = VLC_FALSE;
00246 size_t format_len = strlen(format_str);
00247
00248 memset(temp_str, 0, TEMP_STR_SIZE);
00249
00250 for (i=0; i<format_len; i++) {
00251
00252 if (!saw_control_prefix && format_str[i] != '%') {
00253 *tp++ = format_str[i];
00254 saw_control_prefix = VLC_FALSE;
00255 continue;
00256 }
00257
00258 switch(format_str[i]) {
00259 case '%':
00260 if (saw_control_prefix) {
00261 *tp++ = '%';
00262 }
00263 saw_control_prefix = !saw_control_prefix;
00264 break;
00265 case 'A':
00266 add_format_str_info(vcdinfo_strip_trail(vcdinfo_get_album_id(p_vcdplayer->vcd),
00267 MAX_ALBUM_LEN));
00268 break;
00269
00270 case 'c':
00271 add_format_num_info(vcdinfo_get_volume_num(p_vcdplayer->vcd), "%d");
00272 break;
00273
00274 case 'C':
00275 add_format_num_info(vcdinfo_get_volume_count(p_vcdplayer->vcd), "%d");
00276 break;
00277
00278 case 'F':
00279 add_format_str_info(vcdinfo_get_format_version_str(p_vcdplayer->vcd));
00280 break;
00281
00282 case 'I':
00283 {
00284 switch (itemid->type) {
00285 case VCDINFO_ITEM_TYPE_TRACK:
00286 strncat(tp, _("Track"), TEMP_STR_LEN-(tp-temp_str));
00287 tp += strlen(_("Track"));
00288 break;
00289 case VCDINFO_ITEM_TYPE_ENTRY:
00290 strncat(tp, _("Entry"), TEMP_STR_LEN-(tp-temp_str));
00291 tp += strlen(_("Entry"));
00292 break;
00293 case VCDINFO_ITEM_TYPE_SEGMENT:
00294 strncat(tp, _("Segment"), TEMP_STR_LEN-(tp-temp_str));
00295 tp += strlen(_("Segment"));
00296 break;
00297 case VCDINFO_ITEM_TYPE_LID:
00298 strncat(tp, _("List ID"), TEMP_STR_LEN-(tp-temp_str));
00299 tp += strlen(_("List ID"));
00300 break;
00301 case VCDINFO_ITEM_TYPE_SPAREID2:
00302 strncat(tp, _("Navigation"), TEMP_STR_LEN-(tp-temp_str));
00303 tp += strlen(_("Navigation"));
00304 break;
00305 default:
00306
00307 ;
00308 }
00309 saw_control_prefix = VLC_FALSE;
00310 }
00311 break;
00312
00313 case 'L':
00314 if (vcdplayer_pbc_is_on(p_vcdplayer)) {
00315 char num_str[40];
00316 sprintf(num_str, "%s %d", _("List ID"), p_vcdplayer->i_lid);
00317 strncat(tp, num_str, TEMP_STR_LEN-(tp-temp_str));
00318 tp += strlen(num_str);
00319 }
00320 saw_control_prefix = VLC_FALSE;
00321 break;
00322
00323 case 'M':
00324 add_format_str_info(mrl);
00325 break;
00326
00327 case 'N':
00328 add_format_num_info(itemid->num, "%d");
00329 break;
00330
00331 case 'p':
00332 add_format_str_info(vcdinfo_get_preparer_id(p_vcdplayer->vcd));
00333 break;
00334
00335 case 'P':
00336 add_format_str_info(vcdinfo_get_publisher_id(p_vcdplayer->vcd));
00337 break;
00338
00339 case 'S':
00340 if ( VCDINFO_ITEM_TYPE_SEGMENT==itemid->type ) {
00341 char seg_type_str[30];
00342
00343 sprintf(seg_type_str, " %s",
00344 vcdinfo_video_type2str(p_vcdplayer->vcd, itemid->num));
00345 strncat(tp, seg_type_str, TEMP_STR_LEN-(tp-temp_str));
00346 tp += strlen(seg_type_str);
00347 }
00348 saw_control_prefix = VLC_FALSE;
00349 break;
00350
00351 case 'T':
00352 add_format_num_info(p_vcdplayer->i_track, "%d");
00353 break;
00354
00355 case 'V':
00356 add_format_str_info(vcdinfo_get_volumeset_id(p_vcdplayer->vcd));
00357 break;
00358
00359 case 'v':
00360 add_format_str_info(vcdinfo_get_volume_id(p_vcdplayer->vcd));
00361 break;
00362
00363 default:
00364 *tp++ = '%';
00365 *tp++ = format_str[i];
00366 saw_control_prefix = VLC_FALSE;
00367 }
00368 }
00369 return strdup(temp_str);
00370 }
00371
00372 void
00373 VCDUpdateTitle( access_t *p_access )
00374 {
00375
00376 vcdplayer_t *p_vcdplayer= (vcdplayer_t *)p_access->p_sys;
00377
00378 unsigned int psz_mrl_max = strlen(VCD_MRL_PREFIX)
00379 + strlen(p_vcdplayer->psz_source) + sizeof("@E999")+3;
00380 char *psz_mrl = malloc( psz_mrl_max );
00381
00382 if( psz_mrl )
00383 {
00384 char *psz_name;
00385 snprintf(psz_mrl, psz_mrl_max, "%s%s",
00386 VCD_MRL_PREFIX, p_vcdplayer->psz_source);
00387 psz_name = VCDFormatStr( p_access, p_vcdplayer,
00388 config_GetPsz( p_access, MODULE_STRING
00389 "-title-format" ),
00390 psz_mrl, &(p_vcdplayer->play_item) );
00391 input_Control( p_vcdplayer->p_input, INPUT_SET_NAME, psz_name );
00392 free(psz_mrl);
00393 }
00394 }
00395