Commit 0e5f99c2 authored by Rocky Bernstein's avatar Rocky Bernstein

info.c: Add LID info in stream and media info.

vcdplayer.{c,h}, since this tries to be platform independent use bool
rather than VLC_BOOL.

Some segment play back improvments. (I hope).
parent 6bafce69
SOURCES_vcdx = \
access.c \
intf.c \
intf.h \
vcd.c \
vcd.h \
vcdplayer.h \
......
......@@ -32,10 +32,6 @@
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/input.h>
#include "vcd.h"
#include "info.h"
#include "intf.h"
#include "vlc_keys.h"
#include <cdio/cdio.h>
......@@ -44,6 +40,9 @@
#include <cdio/util.h>
#include <libvcd/info.h>
#include <libvcd/logging.h>
#include "vcd.h"
#include "info.h"
#include "intf.h"
#define FREE_AND_NULL(ptr) if (NULL != ptr) free(ptr); ptr = NULL;
......@@ -147,6 +146,7 @@ VCDReadBlock( access_t * p_access )
block_t *p_block;
const int i_blocks = p_vcd->i_blocks_per_read;
int i_read;
uint8_t * p_buf;
i_read = 0;
......@@ -162,16 +162,42 @@ VCDReadBlock( access_t * p_access )
return NULL;
}
p_buf = (uint8_t *) p_block->p_buffer;
for ( i_read = 0 ; i_read < i_blocks ; i_read++ )
{
const lsn_t old_lsn = p_vcd->i_lsn;
vcdplayer_read_status_t read_status = vcdplayer_read(p_access, p_buf);
p_access->info.i_pos += M2F2_SECTOR_SIZE;
switch ( vcdplayer_read(p_access, (byte_t *) p_block->p_buffer
+ (i_read*M2F2_SECTOR_SIZE)) ) {
switch ( read_status ) {
case READ_END:
/* End reached. Return NULL to indicated this. */
/* We also set the postion to the end so the higher level
(demux?) doesn't try to keep reading. If everything works out
right this shouldn't have to happen.
*/
#if 0
if ( p_access->info.i_pos != p_access->info.i_size ) {
msg_Warn( p_access,
"At end but pos (%llu) is not size (%llu). Adjusting.",
p_access->info.i_pos, p_access->info.i_size );
p_access->info.i_pos = p_access->info.i_size;
}
#endif
#if 1
block_Release( p_block );
return NULL;
#else
{
memset(p_buf, 0, M2F2_SECTOR_SIZE);
p_buf += 2;
*p_buf = 0x01;
printf("++++hacked\n");
return p_block;
}
#endif
case READ_ERROR:
/* Some sort of error. Should we increment lsn? to skip block?
*/
......@@ -179,20 +205,26 @@ VCDReadBlock( access_t * p_access )
return NULL;
case READ_STILL_FRAME:
{
dbg_print(INPUT_DBG_STILL, "Handled still event\n");
/* Reached the end of a still frame. */
byte_t * p_buf = (byte_t *) p_block->p_buffer;
p_buf += (i_read*M2F2_SECTOR_SIZE);
/* FIXME The below should be done in an event thread.
Until then...
*/
#if 0
msleep( MILLISECONDS_PER_SEC * *p_buf );
p_vcd->in_still = VLC_FALSE;
dbg_print(INPUT_DBG_STILL, "still wait time done");
#else
vcdIntfStillTime(p_vcd->p_intf, *p_buf);
#endif
#if 1
block_Release( p_block );
return NULL;
#else
memset(p_buf, 0, M2F2_SECTOR_SIZE);
p_buf += 2;
*p_buf = 0x01;
dbg_print(INPUT_DBG_STILL, "Handled still event");
p_vcd->in_still = VLC_TRUE;
var_SetInteger( p_access, "state", PAUSE_S );
return p_block;
#endif
}
default:
......@@ -201,14 +233,13 @@ VCDReadBlock( access_t * p_access )
;
}
p_access->info.i_pos += (p_vcd->i_lsn - old_lsn) * M2F2_SECTOR_SIZE;
p_buf += M2F2_SECTOR_SIZE;
/* Update seekpoint */
if ( VCDINFO_ITEM_TYPE_ENTRY == p_vcd->play_item.type )
{
unsigned int i_entry = p_vcd->play_item.num+1;
lsn_t i_lsn = vcdinfo_get_entry_lba(p_vcd->vcd, i_entry);
if (p_vcd->i_lsn >= i_lsn )
if ( p_vcd->i_lsn >= i_lsn && i_lsn != VCDINFO_NULL_LBA )
{
const track_t i_track = p_vcd->i_track;
p_vcd->play_item.num = i_entry;
......@@ -742,7 +773,7 @@ vcd_Open( vlc_object_t *p_this, const char *psz_dev )
p_vcd->track[i].size =
vcdinfo_get_track_sect_count(p_vcdobj, track_num);
p_vcd->track[i].start_LSN =
vcdinfo_get_track_lsn(p_vcdobj, track_num);
vcdinfo_get_track_lba(p_vcdobj, track_num);
}
} else
p_vcd->track = NULL;
......@@ -810,7 +841,7 @@ VCDUpdateVar( access_t *p_access, int i_num, int i_action,
and VLC_EGENERIC for some other error.
*****************************************************************************/
int
E_(VCDOpen) ( vlc_object_t *p_this )
VCDOpen ( vlc_object_t *p_this )
{
access_t *p_access = (access_t *)p_this;
vcdplayer_t *p_vcd;
......@@ -865,6 +896,8 @@ E_(VCDOpen) ( vlc_object_t *p_this )
p_vcd->play_item.type = VCDINFO_ITEM_TYPE_NOTFOUND;
p_vcd->p_input = vlc_object_find( p_access, VLC_OBJECT_INPUT,
FIND_PARENT );
p_vcd->p_demux = vlc_object_find( p_access, VLC_OBJECT_DEMUX,
FIND_PARENT );
p_vcd->p_meta = vlc_meta_New();
p_vcd->p_segments = NULL;
p_vcd->p_entries = NULL;
......@@ -917,18 +950,19 @@ E_(VCDOpen) ( vlc_object_t *p_this )
p_access->psz_demux = strdup( "ps" );
#if FIXED
p_vcd->p_intf = intf_Create( p_access, "vcdx" );
p_vcd->p_intf->b_block = VLC_FALSE;
intf_RunThread( p_vcd->p_intf );
#endif
#if FIXED
if (play_single_item)
VCDFixupPlayList( p_access, p_vcd, psz_source, &itemid,
play_single_item );
#endif
p_vcd->p_intf = intf_Create( p_access, "vcdx" );
p_vcd->p_intf->b_block = VLC_FALSE;
p_vcd->p_access = p_access;
#ifdef FIXED
intf_RunThread( p_vcd->p_intf );
#endif
free( psz_source );
......@@ -943,7 +977,7 @@ E_(VCDOpen) ( vlc_object_t *p_this )
* VCDClose: closes VCD releasing allocated memory.
*****************************************************************************/
void
E_(VCDClose) ( vlc_object_t *p_this )
VCDClose ( vlc_object_t *p_this )
{
access_t *p_access = (access_t *)p_this;
vcdplayer_t *p_vcd = (vcdplayer_t *)p_access->p_sys;
......
......@@ -37,13 +37,13 @@
#include <libvcd/logging.h>
static inline void
MetaInfoAddStr(access_t *p_access, char *p_cat,
char *title, const char *str)
MetaInfoAddStr(access_t *p_access, char *psz_cat,
char *title, const char *psz)
{
vcdplayer_t *p_vcd = (vcdplayer_t *) p_access->p_sys;
if ( str ) {
dbg_print( INPUT_DBG_META, "field: %s: %s", title, str);
input_Control( p_vcd->p_input, INPUT_ADD_INFO, p_cat, title, "%s", str);
if ( psz ) {
dbg_print( INPUT_DBG_META, "cat %s, field: %s: %s", psz_cat, title, psz);
input_Control( p_vcd->p_input, INPUT_ADD_INFO, psz_cat, title, "%s", psz);
}
}
......@@ -52,16 +52,27 @@ static inline void
MetaInfoAddNum(access_t *p_access, char *psz_cat, char *title, int num)
{
vcdplayer_t *p_vcd = (vcdplayer_t *) p_access->p_sys;
dbg_print( INPUT_DBG_META, "field %s: %d", title, num);
dbg_print( INPUT_DBG_META, "cat %s, field %s: %d", psz_cat, title, num);
input_Control( p_vcd->p_input, INPUT_ADD_INFO, psz_cat, title, "%d", num );
}
static inline void
MetaInfoAddHex(access_t *p_access, char *psz_cat, char *title, int hex)
{
vcdplayer_t *p_vcd = (vcdplayer_t *) p_access->p_sys;
dbg_print( INPUT_DBG_META, "cat %s, field %s: %d", psz_cat, title, hex);
input_Control( p_vcd->p_input, INPUT_ADD_INFO, psz_cat, title, "%x", hex );
}
#define addstr(title, str) \
MetaInfoAddStr( p_access, psz_cat, title, str );
#define addnum(title, num) \
MetaInfoAddNum( p_access, psz_cat, title, num );
#define addhex(title, hex) \
MetaInfoAddHex( p_access, psz_cat, title, hex );
void
VCDMetaInfo( access_t *p_access, /*const*/ char *psz_mrl )
{
......@@ -110,6 +121,49 @@ VCDMetaInfo( access_t *p_access, /*const*/ char *psz_mrl )
addnum(_("Last Entry Point"), last_entry-1 );
addnum(_("Track size (in sectors)"), i_secsize );
}
{
lid_t i_lid;
for( i_lid = 1 ; i_lid <= p_vcd->i_lids ; i_lid++ ) {
PsdListDescriptor_t pxd;
char psz_cat[20];
snprintf(psz_cat, sizeof(psz_cat), "LID %d", i_lid);
if (vcdinfo_lid_get_pxd(p_vcd->vcd, &pxd, i_lid)) {
switch (pxd.descriptor_type) {
case PSD_TYPE_END_LIST:
addstr(_("type"), _("end"));
break;
case PSD_TYPE_PLAY_LIST:
addstr(_("type"), _("play list"));
addnum("items", vcdinf_pld_get_noi(pxd.pld));
addhex("next", vcdinf_pld_get_next_offset(pxd.pld));
addhex("previous", vcdinf_pld_get_prev_offset(pxd.pld));
addhex("return", vcdinf_pld_get_return_offset(pxd.pld));
addnum("wait time", vcdinf_get_wait_time(pxd.pld));
break;
case PSD_TYPE_SELECTION_LIST:
case PSD_TYPE_EXT_SELECTION_LIST:
addstr(_("type"),
PSD_TYPE_SELECTION_LIST == pxd.descriptor_type
? _("extended selection list")
: _("selection list")
);
addhex("default", vcdinf_psd_get_default_offset(pxd.psd));
addhex("loop count", vcdinf_get_loop_count(pxd.psd));
addhex("next", vcdinf_psd_get_next_offset(pxd.psd));
addhex("previous", vcdinf_psd_get_prev_offset(pxd.psd));
addhex("return", vcdinf_psd_get_return_offset(pxd.psd));
addhex("rejected", vcdinf_psd_get_lid_rejected(pxd.psd));
addhex("time-out offset", vcdinf_get_timeout_offset(pxd.psd));
addnum("time-out time", vcdinf_get_timeout_time(pxd.psd));
break;
default:
addstr(_("type"), _("unknown type"));
break;
}
}
}
}
if ( CDIO_INVALID_TRACK != i_track )
{
......@@ -310,110 +364,6 @@ VCDFormatStr(const access_t *p_access, vcdplayer_t *p_vcd,
return strdup(temp_str);
}
static void
VCDCreatePlayListItem(const access_t *p_access,
vcdplayer_t *p_vcd,
playlist_t *p_playlist,
const vcdinfo_itemid_t *itemid,
char *psz_mrl, int psz_mrl_max,
const char *psz_source, int playlist_operation,
int i_pos)
{
char *p_author;
char *p_title;
char c_type;
switch(itemid->type) {
case VCDINFO_ITEM_TYPE_TRACK:
c_type='T';
break;
case VCDINFO_ITEM_TYPE_SEGMENT:
c_type='S';
break;
case VCDINFO_ITEM_TYPE_LID:
c_type='P';
break;
case VCDINFO_ITEM_TYPE_ENTRY:
c_type='E';
break;
default:
c_type='?';
break;
}
snprintf(psz_mrl, psz_mrl_max, "%s%s@%c%3u", VCD_MRL_PREFIX, psz_source,
c_type, itemid->num);
p_title =
VCDFormatStr( p_access, p_vcd,
config_GetPsz( p_access, MODULE_STRING "-title-format" ),
psz_mrl, itemid );
playlist_Add( p_playlist, psz_mrl, p_title, playlist_operation, i_pos );
p_author =
VCDFormatStr( p_access, p_vcd,
config_GetPsz( p_access, MODULE_STRING "-author-format" ),
psz_mrl, itemid );
if( i_pos == PLAYLIST_END ) i_pos = p_playlist->i_size - 1;
playlist_AddInfo(p_playlist, i_pos, _("General"), _("Author"), "%s",
p_author);
}
int
VCDFixupPlayList( access_t *p_access, vcdplayer_t *p_vcd,
const char *psz_source, vcdinfo_itemid_t *itemid,
vlc_bool_t b_single_item )
{
unsigned int i;
playlist_t * p_playlist;
char * psz_mrl;
unsigned int psz_mrl_max = strlen(VCD_MRL_PREFIX) + strlen(psz_source) +
strlen("@T") + strlen("100") + 1;
psz_mrl = malloc( psz_mrl_max );
if( psz_mrl == NULL )
{
msg_Warn( p_access, "out of memory" );
return -1;
}
p_playlist = (playlist_t *) vlc_object_find( p_access, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Warn( p_access, "can't find playlist" );
free(psz_mrl);
return -1;
}
{
vcdinfo_itemid_t list_itemid;
list_itemid.type=VCDINFO_ITEM_TYPE_ENTRY;
playlist_LockDelete( p_playlist, p_playlist->i_index);
for( i = 0 ; i < p_vcd->i_entries ; i++ )
{
list_itemid.num=i;
VCDCreatePlayListItem(p_access, p_vcd, p_playlist, &list_itemid,
psz_mrl, psz_mrl_max, psz_source,
PLAYLIST_APPEND, PLAYLIST_END);
}
#if LOOKED_OVER
playlist_Command( p_playlist, PLAYLIST_GOTO, 0 );
#endif
}
vlc_object_release( p_playlist );
free(psz_mrl);
return 0;
}
void
VCDUpdateTitle( access_t *p_access )
{
......
......@@ -26,13 +26,6 @@
#include "vcdplayer.h"
/*
Fills out playlist information.
*/
int VCDFixupPlayList( access_t *p_access, vcdplayer_t *p_vcd,
const char *psz_source, vcdinfo_itemid_t *itemid,
vlc_bool_t b_single_track );
/*
Sets VCD meta information and navigation/playlist entries.
*/
......
......@@ -27,10 +27,8 @@
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/input.h>
#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
#include "vlc_keys.h"
#include "vcd.h"
......@@ -50,7 +48,7 @@ static void RunIntf ( intf_thread_t *p_intf );
/*****************************************************************************
* OpenIntf: initialize dummy interface
*****************************************************************************/
int E_(OpenIntf) ( vlc_object_t *p_this )
int VCDOpenIntf ( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
......@@ -60,23 +58,23 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
p_intf->p_sys = malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
{
return( 1 );
return( VLC_EGENERIC );
};
p_intf->pf_run = RunIntf;
var_AddCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
p_intf->p_sys->m_still_time = 0;
p_intf->p_sys->b_inf_still = 0;
p_intf->p_sys->b_infinite_still = 0;
p_intf->p_sys->b_still = 0;
return( 0 );
return( VLC_SUCCESS );
}
/*****************************************************************************
* CloseIntf: destroy dummy interface
*****************************************************************************/
void E_(CloseIntf) ( vlc_object_t *p_this )
void VCDCloseIntf ( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
var_DelCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
......@@ -89,13 +87,15 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
/*****************************************************************************
* RunIntf: main loop
*****************************************************************************/
static void RunIntf( intf_thread_t *p_intf )
static void
RunIntf( intf_thread_t *p_intf )
{
vlc_object_t * p_vout = NULL;
mtime_t mtime = 0;
mtime_t mlast = 0;
thread_vcd_data_t * p_vcd;
vcdplayer_t * p_vcd;
input_thread_t * p_input;
access_t * p_access;
/* What you add to the last input number entry. It accumulates all of
the 10_ADD keypresses */
......@@ -108,8 +108,14 @@ static void RunIntf( intf_thread_t *p_intf )
}
p_input = p_intf->p_sys->p_input;
p_vcd = p_intf->p_sys->p_vcd =
(thread_vcd_data_t *) p_input->p_access_data;
while ( !p_intf->p_sys->p_vcd )
{
msleep( INTF_IDLE_SLEEP );
}
p_vcd = p_intf->p_sys->p_vcd;
p_access = p_vcd->p_access;
dbg_print( INPUT_DBG_CALL, "intf initialized" );
......@@ -121,7 +127,7 @@ static void RunIntf( intf_thread_t *p_intf )
/*
* Have we timed-out in showing a still frame?
*/
if( p_intf->p_sys->b_still && !p_intf->p_sys->b_inf_still )
if( p_intf->p_sys->b_still && !p_intf->p_sys->b_infinite_still )
{
if( p_intf->p_sys->m_still_time > 0 )
{
......@@ -137,7 +143,7 @@ static void RunIntf( intf_thread_t *p_intf )
}
else
{
/* Still time has elasped; set to continue playing. */
/* Still time has elapsed; set to continue playing. */
dbg_print(INPUT_DBG_STILL, "wait time done - setting play");
var_SetInteger( p_intf->p_sys->p_input, "state", PLAYING_S );
p_intf->p_sys->m_still_time = 0;
......@@ -177,7 +183,7 @@ static void RunIntf( intf_thread_t *p_intf )
dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_LEFT - prev (%d)",
number_addend );
do {
vcdplayer_play_prev( p_input );
vcdplayer_play_prev( p_access );
} while (number_addend-- > 0);
break;
......@@ -185,20 +191,20 @@ static void RunIntf( intf_thread_t *p_intf )
dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_RIGHT - next (%d)",
number_addend );
do {
vcdplayer_play_next( p_input );
vcdplayer_play_next( p_access );
} while (number_addend-- > 0);
break;
case ACTIONID_NAV_UP:
dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_UP - return" );
do {
vcdplayer_play_return( p_input );
vcdplayer_play_return( p_access );
} while (number_addend-- > 0);
break;
case ACTIONID_NAV_DOWN:
dbg_print( INPUT_DBG_EVENT, "ACTIONID_NAV_DOWN - default" );
vcdplayer_play_default( p_input );
vcdplayer_play_default( p_access );
break;
case ACTIONID_NAV_ACTIVATE:
......@@ -210,16 +216,16 @@ static void RunIntf( intf_thread_t *p_intf )
if ( vcdplayer_pbc_is_on( p_vcd ) && number_addend != 0 ) {
lid_t next_num=vcdinfo_selection_get_lid(p_vcd->vcd,
p_vcd->cur_lid,
p_vcd->i_lid,
number_addend);
if (VCDINFO_INVALID_LID != next_num) {
itemid.num = next_num;
itemid.type = VCDINFO_ITEM_TYPE_LID;
VCDPlay( p_input, itemid );
vcdplayer_play( p_access, itemid );
}
} else {
itemid.num = number_addend;
VCDPlay( p_input, itemid );
vcdplayer_play( p_access, itemid );
}
break;
}
......@@ -234,7 +240,7 @@ static void RunIntf( intf_thread_t *p_intf )
dbg_print(INPUT_DBG_STILL, "Playing still after activate");
var_SetInteger( p_intf->p_sys->p_input, "state", PLAYING_S );
p_intf->p_sys->b_still = 0;
p_intf->p_sys->b_inf_still = 0;
p_intf->p_sys->b_infinite_still = 0;
p_intf->p_sys->m_still_time = 0;
}
......@@ -321,8 +327,9 @@ static int InitThread( intf_thread_t * p_intf )
vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_sys->p_input = p_input;
p_intf->p_sys->p_vcd = NULL;
p_intf->p_sys->b_move = VLC_FALSE;
p_intf->p_sys->b_move = VLC_FALSE;
p_intf->p_sys->b_click = VLC_FALSE;
p_intf->p_sys->b_key_pressed = VLC_FALSE;
......@@ -356,19 +363,18 @@ static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
* vcdIntfStillTime: function provided to demux plugin to request
* still images
*****************************************************************************/
int vcdIntfStillTime( intf_thread_t *p_intf, int i_sec )
int vcdIntfStillTime( intf_thread_t *p_intf, uint8_t i_sec )
{
vlc_mutex_lock( &p_intf->change_lock );
if( i_sec == -1 )
p_intf->p_sys->b_still = 1;
if( 255 == i_sec )
{
p_intf->p_sys->b_still = 1;
p_intf->p_sys->b_inf_still = 1;
p_intf->p_sys->b_infinite_still = VLC_TRUE;
}
else if( i_sec > 0 )
else
{
p_intf->p_sys->b_still = 1;
p_intf->p_sys->m_still_time = 1000000 * i_sec;
p_intf->p_sys->m_still_time = MILLISECONDS_PER_SEC * i_sec;
}
vlc_mutex_unlock( &p_intf->change_lock );
......
......@@ -29,11 +29,11 @@ struct intf_sys_t
input_thread_t *p_input;
vcdplayer_t *p_vcd;
vlc_bool_t b_still; /* True if we are in a still frame */
vlc_bool_t b_inf_still; /* True if still wait time is infinite */
mtime_t m_still_time; /* Time in microseconds remaining
vlc_bool_t b_still; /* True if we are in a still frame */
vlc_bool_t b_infinite_still; /* True if still wait time is infinite */
mtime_t m_still_time; /* Time in microseconds remaining
to wait in still frame.
*/
*/
#if FINISHED
vcdplay_ctrl_t control;
#else
......@@ -42,6 +42,6 @@ struct intf_sys_t
vlc_bool_t b_click, b_move, b_key_pressed;
};
int vcdIntfStillTime( struct intf_thread_t *, int );
int vcdIntfStillTime( struct intf_thread_t * p_intf, uint8_t wait_time);
int vcdIntfResetStillTime( intf_thread_t *p_intf );
......@@ -34,12 +34,12 @@
/*****************************************************************************
* Exported prototypes
*****************************************************************************/
int E_(VCDOpen) ( vlc_object_t * );
void E_(VCDClose) ( vlc_object_t * );
int E_(OpenIntf) ( vlc_object_t * );
void E_(CloseIntf) ( vlc_object_t * );
int E_(VCDInit) ( vlc_object_t * );
void E_(VCDEnd) ( vlc_object_t * );
int VCDOpen ( vlc_object_t * );
void VCDClose ( vlc_object_t * );