[vlc-devel] [PATCH 10/11] access: dvdnav: handle angles
Francois Cartegnie
fcvlcdev at free.fr
Tue May 5 17:57:08 CEST 2020
---
modules/access/dvdnav.c | 45 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 42 insertions(+), 3 deletions(-)
diff --git a/modules/access/dvdnav.c b/modules/access/dvdnav.c
index 0200871bdf..ff032c4cc2 100644
--- a/modules/access/dvdnav.c
+++ b/modules/access/dvdnav.c
@@ -161,6 +161,7 @@ typedef struct
input_title_t **title;
int cur_title;
int cur_seekpoint;
+ int32_t cur_angle;
unsigned updates;
/* length of program group chain */
@@ -261,7 +262,6 @@ static int CommonOpen( vlc_object_t *p_this,
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
- int i_angle;
char *psz_code;
assert( p_dvdnav );
@@ -354,8 +354,10 @@ static int CommonOpen( vlc_object_t *p_this,
msg_Warn( p_demux, "cannot go to dvd menu" );
}
- i_angle = var_CreateGetInteger( p_demux, "dvdnav-angle" );
- if( i_angle <= 0 ) i_angle = 1;
+ p_sys->cur_angle = 1 + var_CreateGetInteger( p_demux, "dvdnav-angle" );
+ if( p_sys->cur_angle <= 0 ||
+ !dvdnav_angle_change( p_sys->dvdnav, p_sys->cur_angle ) )
+ p_sys->cur_angle = 1;
p_sys->still.b_enabled = false;
vlc_mutex_init( &p_sys->still.lock );
@@ -596,6 +598,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
demux_sys_t *p_sys = p_demux->p_sys;
input_title_t ***ppp_title;
int i;
+ unsigned u;
switch( i_query )
{
@@ -739,6 +742,20 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
RandomAccessCleanup( p_sys );
return VLC_SUCCESS;
+ case DEMUX_SET_ANGLE:
+ {
+ u = va_arg( args, unsigned );
+ if( u > INT32_MAX - 1 ||
+ dvdnav_angle_change( p_sys->dvdnav, u + 1 ) != DVDNAV_STATUS_OK )
+ {
+ msg_Err(p_demux,"Can't change angle to %u", u);
+ return VLC_EGENERIC;
+ }
+ p_sys->cur_angle = u + 1;
+ msg_Err(p_demux,"angle to %u", u);
+ break;
+ }
+
case DEMUX_TEST_AND_CLEAR_FLAGS:
{
unsigned *restrict flags = va_arg(args, unsigned *);
@@ -755,6 +772,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
*va_arg( args, int * ) = p_sys->cur_seekpoint;
break;
+ case DEMUX_GET_ANGLE:
+ {
+ *va_arg( args, unsigned * ) = p_sys->cur_angle - 1;
+ break;
+ }
+
case DEMUX_GET_PTS_DELAY:
*va_arg( args, vlc_tick_t * ) =
VLC_TICK_FROM_MS( var_InheritInteger( p_demux, "disc-caching" ) );
@@ -1066,6 +1089,7 @@ static int Demux( demux_t *p_demux )
p_sys->cur_title = i_title;
}
}
+ p_sys->updates |= INPUT_UPDATE_ANGLE;
break;
}
@@ -1118,6 +1142,7 @@ static int Demux( demux_t *p_demux )
p_sys->updates |= INPUT_UPDATE_TITLE;
if( i_seekpoint != p_sys->cur_seekpoint )
p_sys->updates |= INPUT_UPDATE_SEEKPOINT;
+ p_sys->updates |= INPUT_UPDATE_ANGLE;
}
break;
}
@@ -1146,6 +1171,15 @@ static int Demux( demux_t *p_demux )
p_sys->i_vobu_flush = p_dsi_gi->vobu_1stref_ea;
}
+ int32_t current_angle, angle_count;
+ if( dvdnav_get_angle_info( p_sys->dvdnav, ¤t_angle, &angle_count ) &&
+ current_angle != p_sys->cur_angle && current_angle > 0 )
+ {
+ p_sys->cur_angle = current_angle;
+ msg_Dbg(p_demux,"angle changed to %"PRId32, current_angle);
+ p_sys->updates |= INPUT_UPDATE_ANGLE;
+ }
+
#ifdef DVDNAV_DEBUG
msg_Dbg( p_demux, "DVDNAV_NAV_PACKET" );
#endif
@@ -1289,6 +1323,10 @@ static void DemuxTitles( demux_t *p_demux )
uint64_t i_title_length;
uint64_t *p_chapters_time;
+ int32_t angles;
+ if(!dvdnav_get_number_of_angles(p_sys->dvdnav, i, &angles) || angles < 1)
+ angles = 1;
+
int32_t i_chapters = dvdnav_describe_title_chapters( p_sys->dvdnav, i,
&p_chapters_time,
&i_title_length );
@@ -1299,6 +1337,7 @@ static void DemuxTitles( demux_t *p_demux )
}
t = vlc_input_title_New();
t->i_length = FROM_SCALE_NZ(i_title_length);
+ t->i_additional_angles = angles - 1;
for( int j = 0; j < __MAX( i_chapters, 1 ); j++ )
{
s = vlc_seekpoint_New();
--
2.25.4
More information about the vlc-devel
mailing list