Commit cefad26a authored by Gildas Bazin's avatar Gildas Bazin

* modules/access/dvd*.c: implemented DEMUX_GET_TIME/DEMUX_GET_LENGTH based on the MPEG mux rate.

parent fb820b48
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
#define CACHING_TEXT N_("caching value in ms") #define CACHING_TEXT N_("Caching value in ms")
#define CACHING_LONGTEXT N_( \ #define CACHING_LONGTEXT N_( \
"Allows you to modify the default caching value for DVDnav streams. This "\ "Allows you to modify the default caching value for DVDnav streams. This "\
"value should be set in millisecond units." ) "value should be set in millisecond units." )
...@@ -90,6 +90,7 @@ struct demux_sys_t ...@@ -90,6 +90,7 @@ struct demux_sys_t
/* track */ /* track */
ps_track_t tk[PS_TK_COUNT]; ps_track_t tk[PS_TK_COUNT];
int i_mux_rate;
/* for spu variables */ /* for spu variables */
input_thread_t *p_input; input_thread_t *p_input;
...@@ -165,6 +166,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -165,6 +166,7 @@ static int Open( vlc_object_t *p_this )
ps_track_init( p_sys->tk ); ps_track_init( p_sys->tk );
p_sys->i_aspect = -1; p_sys->i_aspect = -1;
p_sys->b_es_out_ok = VLC_FALSE; p_sys->b_es_out_ok = VLC_FALSE;
p_sys->i_mux_rate = 0;
if( 1 ) if( 1 )
{ {
...@@ -320,28 +322,27 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -320,28 +322,27 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
switch( i_query ) switch( i_query )
{ {
case DEMUX_SET_POSITION:
case DEMUX_GET_POSITION: case DEMUX_GET_POSITION:
case DEMUX_GET_TIME:
case DEMUX_GET_LENGTH:
{ {
uint32_t pos, len; uint32_t pos, len;
pf = (double*) va_arg( args, double* ); if( dvdnav_get_position( p_sys->dvdnav, &pos, &len ) !=
if( dvdnav_get_position( p_sys->dvdnav, &pos, &len ) == DVDNAV_STATUS_OK || len == 0 )
DVDNAV_STATUS_OK && len > 0 )
{ {
*pf = (double)pos / (double)len; return VLC_EGENERIC;
} }
else
if( i_query == DEMUX_GET_POSITION )
{ {
*pf = 0.0; pf = (double*)va_arg( args, double* );
*pf = (double)pos / (double)len;
return VLC_SUCCESS;
} }
return VLC_SUCCESS; else if( i_query == DEMUX_SET_POSITION )
}
case DEMUX_SET_POSITION:
{
uint32_t pos, len;
f = (double)va_arg( args, double );
if( dvdnav_get_position( p_sys->dvdnav, &pos, &len ) ==
DVDNAV_STATUS_OK && len > 0 )
{ {
f = (double)va_arg( args, double );
pos = f * len; pos = f * len;
if( dvdnav_sector_search( p_sys->dvdnav, pos, SEEK_SET ) == if( dvdnav_sector_search( p_sys->dvdnav, pos, SEEK_SET ) ==
DVDNAV_STATUS_OK ) DVDNAV_STATUS_OK )
...@@ -349,6 +350,26 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -349,6 +350,26 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
} }
else if( i_query == DEMUX_GET_TIME )
{
pi64 = (int64_t*)va_arg( args, int64_t * );
if( p_sys->i_mux_rate > 0 )
{
*pi64 = (int64_t)1000000 * 2048 * pos / 50 /
p_sys->i_mux_rate;
return VLC_SUCCESS;
}
}
else if( i_query == DEMUX_GET_LENGTH )
{
pi64 = (int64_t*)va_arg( args, int64_t * );
if( p_sys->i_mux_rate > 0 )
{
*pi64 = (int64_t)1000000 * len * 2048 / 50 /
p_sys->i_mux_rate;
return VLC_SUCCESS;
}
}
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -986,6 +1007,7 @@ static int DemuxBlock( demux_t *p_demux, uint8_t *pkt, int i_pkt ) ...@@ -986,6 +1007,7 @@ static int DemuxBlock( demux_t *p_demux, uint8_t *pkt, int i_pkt )
if( !ps_pkt_parse_pack( p_pkt, &i_scr, &i_mux_rate ) ) if( !ps_pkt_parse_pack( p_pkt, &i_scr, &i_mux_rate ) )
{ {
es_out_Control( p_demux->out, ES_OUT_SET_PCR, i_scr ); es_out_Control( p_demux->out, ES_OUT_SET_PCR, i_scr );
if( i_mux_rate > 0 ) p_sys->i_mux_rate = i_mux_rate;
} }
block_Release( p_pkt ); block_Release( p_pkt );
break; break;
...@@ -1142,7 +1164,6 @@ static int EventThread( vlc_object_t *p_this ) ...@@ -1142,7 +1164,6 @@ static int EventThread( vlc_object_t *p_this )
p_ev->b_moved = VLC_FALSE; p_ev->b_moved = VLC_FALSE;
p_ev->b_clicked = VLC_FALSE; p_ev->b_clicked = VLC_FALSE;
p_ev->b_key = VLC_FALSE; p_ev->b_key = VLC_FALSE;
p_ev->b_still = VLC_FALSE; p_ev->b_still = VLC_FALSE;
/* catch all key event */ /* catch all key event */
...@@ -1200,7 +1221,7 @@ static int EventThread( vlc_object_t *p_this ) ...@@ -1200,7 +1221,7 @@ static int EventThread( vlc_object_t *p_this )
/* VOUT part */ /* VOUT part */
if( p_vout && ( p_ev->b_moved || p_ev->b_clicked ) ) if( p_vout && ( p_ev->b_moved || p_ev->b_clicked ) )
{ {
pci_t *pci = dvdnav_get_current_nav_pci( p_sys->dvdnav ); pci_t *pci = dvdnav_get_current_nav_pci( p_sys->dvdnav );
vlc_value_t valx, valy; vlc_value_t valx, valy;
vlc_mutex_lock( &p_ev->lock ); vlc_mutex_lock( &p_ev->lock );
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
#define CACHING_TEXT N_("caching value in ms") #define CACHING_TEXT N_("Caching value in ms")
#define CACHING_LONGTEXT N_( \ #define CACHING_LONGTEXT N_( \
"Allows you to modify the default caching value for DVDread streams. " \ "Allows you to modify the default caching value for DVDread streams. " \
"This value should be set in millisecond units." ) "This value should be set in millisecond units." )
...@@ -138,6 +138,7 @@ struct demux_sys_t ...@@ -138,6 +138,7 @@ struct demux_sys_t
/* Track */ /* Track */
ps_track_t tk[PS_TK_COUNT]; ps_track_t tk[PS_TK_COUNT];
int i_mux_rate;
int i_titles; int i_titles;
input_title_t **titles; input_title_t **titles;
...@@ -230,6 +231,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -230,6 +231,7 @@ static int Open( vlc_object_t *p_this )
ps_track_init( p_sys->tk ); ps_track_init( p_sys->tk );
p_sys->i_aspect = -1; p_sys->i_aspect = -1;
p_sys->i_mux_rate = 0;
p_sys->p_dvdread = p_dvdread; p_sys->p_dvdread = p_dvdread;
p_sys->p_vmg_file = p_vmg_file; p_sys->p_vmg_file = p_vmg_file;
...@@ -312,6 +314,27 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -312,6 +314,27 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
case DEMUX_GET_TIME:
pi64 = (int64_t*)va_arg( args, int64_t * );
if( p_sys->i_mux_rate > 0 )
{
*pi64 = (int64_t)1000000 * DVD_VIDEO_LB_LEN *
p_sys->i_title_offset / 50 / p_sys->i_mux_rate;
return VLC_SUCCESS;
}
*pi64 = 0;
return VLC_EGENERIC;
case DEMUX_GET_LENGTH:
pi64 = (int64_t*)va_arg( args, int64_t * );
if( p_sys->i_mux_rate > 0 )
{
*pi64 = (int64_t)1000000 * DVD_VIDEO_LB_LEN *
p_sys->i_title_blocks / 50 / p_sys->i_mux_rate;
return VLC_SUCCESS;
}
*pi64 = 0;
return VLC_EGENERIC;
/* Special for access_demux */ /* Special for access_demux */
case DEMUX_CAN_PAUSE: case DEMUX_CAN_PAUSE:
...@@ -519,6 +542,7 @@ static int DemuxBlock( demux_t *p_demux, uint8_t *pkt, int i_pkt ) ...@@ -519,6 +542,7 @@ static int DemuxBlock( demux_t *p_demux, uint8_t *pkt, int i_pkt )
if( !ps_pkt_parse_pack( p_pkt, &i_scr, &i_mux_rate ) ) if( !ps_pkt_parse_pack( p_pkt, &i_scr, &i_mux_rate ) )
{ {
es_out_Control( p_demux->out, ES_OUT_SET_PCR, i_scr ); es_out_Control( p_demux->out, ES_OUT_SET_PCR, i_scr );
if( i_mux_rate > 0 ) p_sys->i_mux_rate = i_mux_rate;
} }
block_Release( p_pkt ); block_Release( p_pkt );
break; break;
...@@ -1126,10 +1150,6 @@ static void DvdReadFindCell( demux_t *p_demux ) ...@@ -1126,10 +1150,6 @@ static void DvdReadFindCell( demux_t *p_demux )
if( cell[p_sys->i_cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) if( cell[p_sys->i_cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK )
{ {
#if 0
p_sys->i_next_cell = p_sys->i_cur_cell + p_sys->i_angle_nb;
p_sys->i_cur_cell += p_sys->i_angle - 1;
#else
p_sys->i_cur_cell += p_sys->i_angle - 1; p_sys->i_cur_cell += p_sys->i_angle - 1;
while( cell[p_sys->i_cur_cell+i].block_mode != BLOCK_MODE_LAST_CELL ) while( cell[p_sys->i_cur_cell+i].block_mode != BLOCK_MODE_LAST_CELL )
...@@ -1137,7 +1157,6 @@ static void DvdReadFindCell( demux_t *p_demux ) ...@@ -1137,7 +1157,6 @@ static void DvdReadFindCell( demux_t *p_demux )
i++; i++;
} }
p_sys->i_next_cell = p_sys->i_cur_cell + i + 1; p_sys->i_next_cell = p_sys->i_cur_cell + i + 1;
#endif
} }
else else
{ {
......
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