-/*****************************************************************************
- VCDPlay: set up internal structures so seeking/reading places an item.
- itemid: the thing to play.
- user_entry: true if itemid is a user selection (rather than internally-
- generated selection such as via PBC) in which case we may have to adjust
- for differences in numbering.
- *****************************************************************************/
-int
-VCDPlay( access_t *p_access, vcdinfo_itemid_t itemid )
-{
- if (!p_access || !p_access->p_sys) return VLC_EGENERIC;
-
- {
-
- vcdplayer_t *p_vcd= (vcdplayer_t *)p_access->p_sys;
-#if 0
- const vlc_bool_t b_was_still = p_vcd->in_still;
-#endif
-
- dbg_print(INPUT_DBG_CALL, "itemid.num: %d, itemid.type: %d\n",
- itemid.num, itemid.type);
-
- switch (itemid.type) {
- case VCDINFO_ITEM_TYPE_TRACK:
-
- {
- track_t i_track = itemid.num;
- unsigned int i_entry =
- vcdinfo_track_get_entry( p_vcd->vcd, i_track);
-
- /* Valid MPEG tracks go from 1...i_tracks. */
-
- if (i_track == 0 || i_track > p_vcd->i_tracks) {
- LOG_ERR ("Invalid track number %d", i_track );
- return VLC_EGENERIC;
- }
- p_vcd->in_still = VLC_FALSE;
- VCDSetOrigin( p_access,
- vcdinfo_get_entry_lba(p_vcd->vcd, i_entry),
- i_track, &itemid );
- break;
- }
-
- case VCDINFO_ITEM_TYPE_SEGMENT:
- {
- int i_seg = itemid.num;
-
- /* Valid segments go from 0...i_segments-1. */
- if (itemid.num >= p_vcd->i_segments) {
- LOG_ERR ( "Invalid segment number: %d", i_seg );
- return VLC_EGENERIC;
- } else {
- vcdinfo_video_segment_type_t segtype =
- vcdinfo_get_video_type(p_vcd->vcd, i_seg);
-
- dbg_print(INPUT_DBG_PBC, "%s (%d), seg_num: %d",
- vcdinfo_video_type2str(p_vcd->vcd, i_seg),
- (int) segtype, itemid.num);
-
- switch (segtype)
- {
- case VCDINFO_FILES_VIDEO_NTSC_STILL:
- case VCDINFO_FILES_VIDEO_NTSC_STILL2:
- case VCDINFO_FILES_VIDEO_PAL_STILL:
- case VCDINFO_FILES_VIDEO_PAL_STILL2:
- p_vcd->in_still = VLC_TRUE;
- break;
- default:
- p_vcd->in_still = VLC_FALSE;
- }
- VCDSetOrigin( p_access, p_vcd->p_segments[i_seg],
- 0, &itemid );
- }
-
- }
- break;
-
- case VCDINFO_ITEM_TYPE_LID:
- /* LIDs go from 1..i_lids. */
- if (itemid.num == 0 || itemid.num > p_vcd->i_lids) {
- LOG_ERR ( "Invalid LID number: %d", itemid.num );
- return VLC_EGENERIC;
- } else {
- p_vcd->i_lid = itemid.num;
- vcdinfo_lid_get_pxd(p_vcd->vcd, &(p_vcd->pxd), itemid.num);
-
- switch (p_vcd->pxd.descriptor_type) {
-
- case PSD_TYPE_SELECTION_LIST:
- case PSD_TYPE_EXT_SELECTION_LIST: {
- vcdinfo_itemid_t trans_itemid;
- uint16_t trans_itemid_num;
-
- if (p_vcd->pxd.psd == NULL) return VLC_EGENERIC;
- trans_itemid_num = vcdinf_psd_get_itemid(p_vcd->pxd.psd);
- vcdinfo_classify_itemid(trans_itemid_num, &trans_itemid);
- p_vcd->loop_count = 1;
- p_vcd->loop_item = trans_itemid;
- return VCDPlay( p_access, trans_itemid );
- break;
- }
-
- case PSD_TYPE_PLAY_LIST: {
- if (p_vcd->pxd.pld == NULL) return VLC_EGENERIC;
- p_vcd->pdi = -1;
- return vcdplayer_inc_play_item(p_access)
- ? VLC_SUCCESS : VLC_EGENERIC;
- break;
- }
-
- case PSD_TYPE_END_LIST:
- case PSD_TYPE_COMMAND_LIST:
-
- default:
- ;
- }
- }
- return VLC_EGENERIC;
- case VCDINFO_ITEM_TYPE_ENTRY:
- {
- int i_entry = itemid.num;
-
- /* Entries go from 0..i_entries-1. */
- if (itemid.num >= p_vcd->i_entries) {
- LOG_ERR ("Invalid entry number: %d", i_entry );
- return VLC_EGENERIC;
- } else {
- track_t i_track = vcdinfo_get_track(p_vcd->vcd, i_entry);
- p_vcd->in_still = VLC_FALSE;
- VCDSetOrigin( p_access,
- vcdinfo_get_entry_lba(p_vcd->vcd, i_entry),
- i_track, &itemid );
- }
- break;
- }
-
- default:
- LOG_ERR ("unknown entry type" );
- return VLC_EGENERIC;
- }
-
- p_vcd->play_item = itemid;
-
- }
-
-
- return VLC_SUCCESS;
-}
-