Commit 39a7f7e6 authored by Rocky Bernstein's avatar Rocky Bernstein

Slightly better handling of stills and toggling pause by using the

different threads better.

Still has stream still/to MPEG bug and duplicate video window bug though.
(And could use lots of cleanup.)
parent 3e505864
SOURCES_vcdx = \ SOURCES_vcdx = \
access.c \
cdrom.c \
cdrom.h \
demux.c \
intf.c \ intf.c \
intf.h \ intf.h \
vcd.c \ vcd.c \
vcd.h \ vcd.h \
vcdplayer.h \ vcdplayer.h \
vcdplayer.c \ vcdplayer.c \
cdrom.c \
cdrom.h \
demux.c \
access.c \
$(NULL) $(NULL)
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* to go here. * to go here.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000,2003 VideoLAN * Copyright (C) 2000,2003 VideoLAN
* $Id: access.c,v 1.7 2003/12/03 21:55:33 rocky Exp $ * $Id: access.c,v 1.8 2003/12/05 04:24:47 rocky Exp $
* *
* Authors: Rocky Bernstein <rocky@panix.com> * Authors: Rocky Bernstein <rocky@panix.com>
* Johan Bilien <jobi@via.ecp.fr> * Johan Bilien <jobi@via.ecp.fr>
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h> #include <vlc/input.h>
#include <vlc_interface.h> #include <vlc/intf.h>
#include "../../demux/mpeg/system.h" #include "../../demux/mpeg/system.h"
#include "vcd.h" #include "vcd.h"
#include "intf.h"
#include "vcdplayer.h" #include "vcdplayer.h"
#include "intf.h"
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include <cdio/cd_types.h> #include <cdio/cd_types.h>
...@@ -50,6 +50,8 @@ ...@@ -50,6 +50,8 @@
#define VCD_BLOCKS_ONCE 20 #define VCD_BLOCKS_ONCE 20
#define VCD_DATA_ONCE (VCD_BLOCKS_ONCE * M2F2_SECTOR_SIZE) #define VCD_DATA_ONCE (VCD_BLOCKS_ONCE * M2F2_SECTOR_SIZE)
#define VCD_MRL_PREFIX "vcdx://"
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
...@@ -193,9 +195,9 @@ VCDRead( input_thread_t * p_input, byte_t * p_buffer, size_t i_len ) ...@@ -193,9 +195,9 @@ VCDRead( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
memset(p_buf, 0, M2F2_SECTOR_SIZE); memset(p_buf, 0, M2F2_SECTOR_SIZE);
p_buf += 2; p_buf += 2;
*p_buf = 0x01; *p_buf = 0x01;
dbg_print(INPUT_DBG_STILL, "Handled still event\n"); dbg_print(INPUT_DBG_STILL, "Handled still event");
/* p_vcd->p_intf->b_end_of_cell = true; */ p_vcd->p_intf->p_sys->b_still = 1;
input_SetStatus( p_input, INPUT_STATUS_PAUSE ); input_SetStatus( p_input, INPUT_STATUS_PAUSE );
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
...@@ -205,7 +207,9 @@ VCDRead( input_thread_t * p_input, byte_t * p_buffer, size_t i_len ) ...@@ -205,7 +207,9 @@ VCDRead( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
dbg_print(INPUT_DBG_STILL, "Clock manage");
input_ClockManageControl( p_input, p_pgrm, 0 ); input_ClockManageControl( p_input, p_pgrm, 0 );
dbg_print(INPUT_DBG_STILL, "Clock manage done");
return i_read + M2F2_SECTOR_SIZE; return i_read + M2F2_SECTOR_SIZE;
} }
...@@ -977,6 +981,92 @@ static void InformationCreate( input_thread_t *p_input ) ...@@ -977,6 +981,92 @@ static void InformationCreate( input_thread_t *p_input )
} }
#if FINISHED_PLAYLIST
static void
VCDCreatePlayListItem(const input_thread_t *p_input,
thread_vcd_data_t *p_vcd,
playlist_t *p_playlist, unsigned int i_track,
char *psz_mrl, int psz_mrl_max,
const char *psz_source, int playlist_operation,
unsigned int i_pos)
{
mtime_t i_duration =
(vcdinfo_get_track_size(p_vcd->vcd, i_track) * 8 * 10000000)
/ (400 * p_input->stream.control.i_rate) ;
char *p_title;
char *config_varname = MODULE_STRING "-title-format";
snprintf(psz_mrl, psz_mrl_max, "%s%s@T%u",
VCD_MRL_PREFIX, psz_source, i_track);
#if 0
p_title = VCDFormatStr(p_input, p_vcd,
config_GetPsz( p_input, config_varname ),
psz_mrl, i_track);
#else
p_title = psz_mrl;
#endif
playlist_AddExt( p_playlist, psz_mrl, p_title, i_duration,
0, 0, playlist_operation, i_pos );
}
static int
VCDFixupPlayList( input_thread_t *p_input, thread_vcd_data_t *p_vcd,
const char *psz_source )
{
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_input, "out of memory" );
return -1;
}
p_playlist = (playlist_t *) vlc_object_find( p_input, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Warn( p_input, "can't find playlist" );
free(psz_mrl);
return -1;
}
if ( config_GetInt( p_input, MODULE_STRING "-PBC" ) ) {
/* May fill out more information when the playlist user interface becomes
more mature.
*/
VCDCreatePlayListItem(p_input, p_vcd, p_playlist, p_vcd->cur_track,
psz_mrl, psz_mrl_max, psz_source, PLAYLIST_REPLACE,
p_playlist->i_index);
} else {
playlist_Delete( p_playlist, p_playlist->i_index);
for( i = 1 ; i < p_vcd->num_tracks ; i++ )
{
VCDCreatePlayListItem(p_input, p_vcd, p_playlist, i, psz_mrl,
psz_mrl_max, psz_source, PLAYLIST_APPEND,
PLAYLIST_END);
}
playlist_Command( p_playlist, PLAYLIST_GOTO, 0 );
}
vlc_object_release( p_playlist );
free(psz_mrl);
return 0;
}
#endif
/***************************************************************************** /*****************************************************************************
* Public routines. * Public routines.
*****************************************************************************/ *****************************************************************************/
...@@ -1061,16 +1151,13 @@ E_(Open) ( vlc_object_t *p_this ) ...@@ -1061,16 +1151,13 @@ E_(Open) ( vlc_object_t *p_this )
if( !(p_vcd->vcd = vcd_Open( p_this, psz_source )) ) if( !(p_vcd->vcd = vcd_Open( p_this, psz_source )) )
{ {
msg_Warn( p_input, "could not open %s", psz_source ); msg_Warn( p_input, "could not open %s", psz_source );
free( psz_source ); goto err_exit;
free( p_vcd );
return VLC_EGENERIC;
} }
/* Get track information. */ /* Get track information. */
p_vcd->num_tracks = ioctl_GetTracksMap( VLC_OBJECT(p_input), p_vcd->num_tracks = ioctl_GetTracksMap( VLC_OBJECT(p_input),
vcdinfo_get_cd_image(p_vcd->vcd), vcdinfo_get_cd_image(p_vcd->vcd),
&p_vcd->p_sectors ); &p_vcd->p_sectors );
free( psz_source );
if( p_vcd->num_tracks < 0 ) if( p_vcd->num_tracks < 0 )
LOG_ERR ("unable to count tracks" ); LOG_ERR ("unable to count tracks" );
else if( p_vcd->num_tracks <= 1 ) else if( p_vcd->num_tracks <= 1 )
...@@ -1078,8 +1165,7 @@ E_(Open) ( vlc_object_t *p_this ) ...@@ -1078,8 +1165,7 @@ E_(Open) ( vlc_object_t *p_this )
if( p_vcd->num_tracks <= 1) if( p_vcd->num_tracks <= 1)
{ {
vcdinfo_close( p_vcd->vcd ); vcdinfo_close( p_vcd->vcd );
free( p_vcd ); goto err_exit;
return VLC_EGENERIC;
} }
/* Set stream and area data */ /* Set stream and area data */
...@@ -1117,8 +1203,7 @@ E_(Open) ( vlc_object_t *p_this ) ...@@ -1117,8 +1203,7 @@ E_(Open) ( vlc_object_t *p_this )
if ( ! b_play_ok ) { if ( ! b_play_ok ) {
vcdinfo_close( p_vcd->vcd ); vcdinfo_close( p_vcd->vcd );
free( p_vcd ); goto err_exit;
return VLC_EGENERIC;
} }
if( !p_input->psz_demux || !*p_input->psz_demux ) if( !p_input->psz_demux || !*p_input->psz_demux )
...@@ -1136,7 +1221,17 @@ E_(Open) ( vlc_object_t *p_this ) ...@@ -1136,7 +1221,17 @@ E_(Open) ( vlc_object_t *p_this )
InformationCreate( p_input ); InformationCreate( p_input );
#if FINISHED_PLAYLIST
VCDFixupPlayList( p_input, p_vcd, psz_source );
#endif
free( psz_source );
return VLC_SUCCESS; return VLC_SUCCESS;
err_exit:
free( psz_source );
free( p_vcd );
return VLC_EGENERIC;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* demux.c: demux functions for dvdplay. * demux.c: demux functions for dvdplay.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: demux.c,v 1.2 2003/11/09 00:52:32 rocky Exp $ * $Id: demux.c,v 1.3 2003/12/05 04:24:47 rocky Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#endif #endif
#include "vcd.h" #include "vcd.h"
#include "vcdplayer.h"
#include "intf.h" #include "intf.h"
/* how many packets vcdx_Demux will read in each loop */ /* how many packets vcdx_Demux will read in each loop */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf.c: Video CD interface to handle user interaction and still time * intf.c: Video CD interface to handle user interaction and still time
***************************************************************************** *****************************************************************************
* Copyright (C) 2002,2003 VideoLAN * Copyright (C) 2002,2003 VideoLAN
* $Id: intf.c,v 1.9 2003/11/26 01:45:03 rocky Exp $ * $Id: intf.c,v 1.10 2003/12/05 04:24:47 rocky Exp $
* *
* Authors: Rocky Bernstein <rocky@panix.com> * Authors: Rocky Bernstein <rocky@panix.com>
* from DVD code by Stphane Borel <stef@via.ecp.fr> * from DVD code by Stphane Borel <stef@via.ecp.fr>
...@@ -35,33 +35,12 @@ ...@@ -35,33 +35,12 @@
#include "vcd.h" #include "vcd.h"
#include "vcdplayer.h" #include "vcdplayer.h"
#include "intf.h"
/*****************************************************************************
* intf_sys_t: description and status of interface
*****************************************************************************/
struct intf_sys_t
{
input_thread_t * p_input;
thread_vcd_data_t * p_vcd;
vlc_bool_t b_still;
vlc_bool_t b_inf_still;
mtime_t m_still_time;
#if FINISHED
vcdplay_ctrl_t control;
#else
int control;
#endif
vlc_bool_t b_click, b_move, b_key_pressed;
};
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
*****************************************************************************/ *****************************************************************************/
static int InitThread ( intf_thread_t *p_intf ); static int InitThread ( intf_thread_t *p_intf );
static int MouseEvent ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int KeyEvent ( vlc_object_t *, char const *, static int KeyEvent ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
...@@ -100,6 +79,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this ) ...@@ -100,6 +79,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
void E_(CloseIntf) ( vlc_object_t *p_this ) void E_(CloseIntf) ( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = (intf_thread_t *)p_this;
var_DelCallback( p_intf->p_vlc, "key-pressed", KeyEvent, p_intf );
/* Destroy structure */ /* Destroy structure */
free( p_intf->p_sys ); free( p_intf->p_sys );
...@@ -112,6 +92,8 @@ void E_(CloseIntf) ( vlc_object_t *p_this ) ...@@ -112,6 +92,8 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
static void RunIntf( intf_thread_t *p_intf ) static void RunIntf( intf_thread_t *p_intf )
{ {
vlc_object_t * p_vout = NULL; vlc_object_t * p_vout = NULL;
mtime_t mtime = 0;
mtime_t mlast = 0;
thread_vcd_data_t * p_vcd; thread_vcd_data_t * p_vcd;
input_thread_t * p_input; input_thread_t * p_input;
...@@ -136,6 +118,35 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -136,6 +118,35 @@ static void RunIntf( intf_thread_t *p_intf )
{ {
vlc_mutex_lock( &p_intf->change_lock ); vlc_mutex_lock( &p_intf->change_lock );
/*
* still images
*/
if( p_intf->p_sys->b_still && !p_intf->p_sys->b_inf_still )
{
if( p_intf->p_sys->m_still_time > 0 )
{
/* update remaining still time */
dbg_print(INPUT_DBG_STILL, "updating still time");
mtime = mdate();
if( mlast )
{
p_intf->p_sys->m_still_time -= mtime - mlast;
}
mlast = mtime;
}
else
{
/* still time elasped */
dbg_print(INPUT_DBG_STILL, "wait time done - setting play");
input_SetStatus( p_intf->p_sys->p_input,
INPUT_STATUS_PLAY );
p_intf->p_sys->m_still_time = 0;
p_intf->p_sys->b_still = 0;
mlast = 0;
}
}
/* /*
* keyboard event * keyboard event
*/ */
...@@ -215,6 +226,18 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -215,6 +226,18 @@ static void RunIntf( intf_thread_t *p_intf )
} }
} }
number_addend = 0; number_addend = 0;
/* we can safely interact with the VCD player
* with the stream lock */
if( p_intf->p_sys->b_still )
{
dbg_print(INPUT_DBG_STILL, "Playing still after activate");
input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );
p_intf->p_sys->b_still = 0;
p_intf->p_sys->b_inf_still = 0;
p_intf->p_sys->m_still_time = 0;
}
} else { } else {
unsigned int digit_entered=0; unsigned int digit_entered=0;
...@@ -259,8 +282,6 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -259,8 +282,6 @@ static void RunIntf( intf_thread_t *p_intf )
VLC_OBJECT_VOUT, FIND_CHILD ); VLC_OBJECT_VOUT, FIND_CHILD );
if( p_vout ) if( p_vout )
{ {
var_AddCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
var_AddCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
var_AddCallback( p_vout, "key-pressed", KeyEvent, p_intf ); var_AddCallback( p_vout, "key-pressed", KeyEvent, p_intf );
} }
} }
...@@ -272,8 +293,6 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -272,8 +293,6 @@ static void RunIntf( intf_thread_t *p_intf )
if( p_vout ) if( p_vout )
{ {
var_DelCallback( p_vout, "mouse-moved", MouseEvent, p_intf );
var_DelCallback( p_vout, "mouse-clicked", MouseEvent, p_intf );
var_DelCallback( p_vout, "key-pressed", KeyEvent, p_intf ); var_DelCallback( p_vout, "key-pressed", KeyEvent, p_intf );
vlc_object_release( p_vout ); vlc_object_release( p_vout );
} }
...@@ -317,30 +336,6 @@ static int InitThread( intf_thread_t * p_intf ) ...@@ -317,30 +336,6 @@ static int InitThread( intf_thread_t * p_intf )
} }
} }
/*****************************************************************************
* MouseEvent: callback for mouse events
*****************************************************************************/
static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
intf_thread_t *p_intf = (intf_thread_t *)p_data;
vlc_mutex_lock( &p_intf->change_lock );
if( psz_var[6] == 'c' ) /* "mouse-clicked" */
{
p_intf->p_sys->b_click = VLC_TRUE;
}
else if( psz_var[6] == 'm' ) /* "mouse-moved" */
{
p_intf->p_sys->b_move = VLC_TRUE;
}
vlc_mutex_unlock( &p_intf->change_lock );
return VLC_SUCCESS;
}
/***************************************************************************** /*****************************************************************************
* KeyEvent: callback for keyboard events * KeyEvent: callback for keyboard events
*****************************************************************************/ *****************************************************************************/
...@@ -358,7 +353,7 @@ static int KeyEvent( vlc_object_t *p_this, char const *psz_var, ...@@ -358,7 +353,7 @@ static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
} }
/***************************************************************************** /*****************************************************************************
* dvdIntfStillTime: function provided to demux plugin to request * vcdIntfStillTime: function provided to demux plugin to request
* still images * still images
*****************************************************************************/ *****************************************************************************/
int vcdIntfStillTime( intf_thread_t *p_intf, int i_sec ) int vcdIntfStillTime( intf_thread_t *p_intf, int i_sec )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf.h: send info to intf. * intf.h: send info to intf.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: intf.h,v 1.1 2003/10/04 18:55:13 gbazin Exp $ * $Id: intf.h,v 1.2 2003/12/05 04:24:47 rocky Exp $
* *
* Author: Stéphane Borel <stef@via.ecp.fr> * Author: Stéphane Borel <stef@via.ecp.fr>
* *
...@@ -21,6 +21,26 @@ ...@@ -21,6 +21,26 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
/*****************************************************************************
* intf_sys_t: description and status of interface
*****************************************************************************/
struct intf_sys_t
{
input_thread_t * p_input;
thread_vcd_data_t * p_vcd;
vlc_bool_t b_still;
vlc_bool_t b_inf_still;
mtime_t m_still_time;
#if FINISHED
vcdplay_ctrl_t control;
#else
int control;
#endif
vlc_bool_t b_click, b_move, b_key_pressed;
};
int vcdIntfStillTime( struct intf_thread_t *, int ); int vcdIntfStillTime( struct intf_thread_t *, int );
int vcdIntfResetStillTime( intf_thread_t *p_intf ); int vcdIntfResetStillTime( intf_thread_t *p_intf );
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* using libcdio, libvcd and libvcdinfo * using libcdio, libvcd and libvcdinfo
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> * Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
* $Id: vcdplayer.c,v 1.5 2003/11/24 03:30:36 rocky Exp $ * $Id: vcdplayer.c,v 1.6 2003/12/05 04:24:47 rocky Exp $
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -31,9 +31,11 @@ ...@@ -31,9 +31,11 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h> #include <vlc/input.h>
#include <vlc/intf.h>
#include "vcd.h" #include "vcd.h"
#include "vcdplayer.h" #include "vcdplayer.h"
#include "intf.h"
#include <string.h> #include <string.h>
...@@ -183,9 +185,13 @@ vcdplayer_pbc_nav ( input_thread_t * p_input ) ...@@ -183,9 +185,13 @@ vcdplayer_pbc_nav ( input_thread_t * p_input )
if (wait_time != 0) { if (wait_time != 0) {
/* FIXME */ /* FIXME */
p_vcd->in_still = wait_time - 1; p_vcd->in_still = wait_time - 1;
SLEEP_1_SEC_AND_HANDLE_EVENTS ; p_vcd->p_intf->p_sys->m_still_time = (wait_time - 1) * 1000000;
return READ_STILL_FRAME; return READ_STILL_FRAME;
} else {
p_vcd->p_intf->p_sys->m_still_time = 0;
p_vcd->p_intf->p_sys->b_inf_still = 1;
} }
} }
vcdplayer_update_entry( p_input, vcdplayer_update_entry( p_input,
vcdinf_pld_get_next_offset(p_vcd->pxd.pld), vcdinf_pld_get_next_offset(p_vcd->pxd.pld),
...@@ -208,8 +214,15 @@ vcdplayer_pbc_nav ( input_thread_t * p_input ) ...@@ -208,8 +214,15 @@ vcdplayer_pbc_nav ( input_thread_t * p_input )
/* Handle any wait time given */ /* Handle any wait time given */
if (-5 == p_vcd->in_still) { if (-5 == p_vcd->in_still) {
if (wait_time != 0) {
/* FIXME */
p_vcd->in_still = wait_time - 1; p_vcd->in_still = wait_time - 1;
SLEEP_1_SEC_AND_HANDLE_EVENTS ; p_vcd->p_intf->p_sys->m_still_time = (wait_time - 1) * 1000000;
return READ_STILL_FRAME;
} else {
p_vcd->p_intf->p_sys->m_still_time = 0;
p_vcd->p_intf->p_sys->b_inf_still = 1;
}
return READ_STILL_FRAME; return READ_STILL_FRAME;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment