Commit 11e8ae92 authored by Yoann Peronneau's avatar Yoann Peronneau

* src/video_output/vout_subpictures.c : New OSD channels

When you want to use OSD, you have to register an OSD channel, by calling
vout_RegisterOSDChannel, then pass it to vout_CreateSubPicture.
There is a particular channel, DEFAULT_CHANNEL that can be used for
general purpose.
See modules/control/hotkeys.c for an example.
parent 6dcbb0a9
......@@ -126,8 +126,9 @@ and <function> vout_DatePicture </function> upon necessary.
<listitem> <para> <type> subpicture_t * </type> <function>
vout_CreateSubPicture </function> <parameter> ( vout_thread_t *p_vout,
int i_type, int i_size ) </parameter> :
Returns an allocated subpicture buffer. <parameter> i_type
int i_channel, int i_type ) </parameter> :
Returns an allocated subpicture buffer. <parameter> i_channel
</parameter> is the ID of the subpicture channel, <parameter> i_type
</parameter> is <constant> DVD_SUBPICTURE </constant> or
<constant> TEXT_SUBPICTURE</constant>, <parameter> i_size
</parameter> is the length in bytes of the packet.
......
......@@ -65,4 +65,4 @@ VLC_EXPORT( void, __vout_OSDMessage, ( vlc_object_t *, int, char *, ... ) );
# define vout_OSDMessage __vout_OSDMessage
#endif
VLC_EXPORT( void, vout_OSDSlider, ( vlc_object_t *, int, int , short ) );
VLC_EXPORT( void, vout_OSDIcon, ( vlc_object_t *, short ) );
VLC_EXPORT( void, vout_OSDIcon, ( vlc_object_t *, int, short ) );
......@@ -125,6 +125,10 @@ struct vout_thread_t
/* Picture and subpicture heaps */
picture_t p_picture[2*VOUT_MAX_PICTURES]; /**< pictures */
subpicture_t p_subpicture[VOUT_MAX_PICTURES]; /**< subpictures */
subpicture_t *p_default_channel; /**< subpicture in the default
channel */
int i_channel_count; /**< index of last subpicture
channel registered */
/* Statistics */
count_t c_loops;
......@@ -256,9 +260,11 @@ enum output_query_e
* \addtogroup subpicture
* @{
*/
VLC_EXPORT( subpicture_t *, vout_CreateSubPicture, ( vout_thread_t *, int, int, int ) );
VLC_EXPORT( subpicture_t *, vout_CreateSubPicture, ( vout_thread_t *, int, int ) );
VLC_EXPORT( void, vout_DestroySubPicture, ( vout_thread_t *, subpicture_t * ) );
VLC_EXPORT( void, vout_DisplaySubPicture, ( vout_thread_t *, subpicture_t * ) );
VLC_EXPORT( int, vout_RegisterOSDChannel, ( vout_thread_t * ) );
VLC_EXPORT( void, vout_ClearOSDChannel, ( vout_thread_t *, int ) );
subpicture_t * vout_SortSubPictures ( vout_thread_t *, mtime_t );
void vout_RenderSubPictures ( vout_thread_t *, picture_t *,
......
......@@ -193,10 +193,9 @@ struct picture_heap_t
*/
struct subpicture_t
{
/** \name Channel and content type */
/** \name Channel ID */
/**@{*/
int i_channel; /**< subpicture channel */
int i_content; /**< content type */
int i_channel; /**< subpicture channel ID */
/**@}*/
/** \name Type and flags
......@@ -241,24 +240,14 @@ struct subpicture_t
#define EMPTY_SUBPICTURE 0 /* subtitle slot is empty and available */
#define MEMORY_SUBPICTURE 100 /* subpicture stored in memory */
/* Default subpicture channel ID */
#define DEFAULT_CHAN 1
/* Subpicture status */
#define FREE_SUBPICTURE 0 /* free and not allocated */
#define RESERVED_SUBPICTURE 1 /* allocated and reserved */
#define READY_SUBPICTURE 2 /* ready for display */
/* Subpicture channel */
#define SUBT1_CHAN 1
#define SUBT2_CHAN 2
#define BEGIN_EXCLUSIVE_CHAN 3 /* exclusive subpic-channels list */
#define POSITION_CHAN 3
#define VOLUME_CHAN 4
#define SOLO_CHAN 5
#define END_EXCLUSIVE_CHAN 5 /*end of list */
/* Subpicture content type */
#define TEXT_CONTENT 0
#define GRAPH_CONTENT 1 /* used for OSD icon, slider... */
/*****************************************************************************
* Prototypes
*****************************************************************************/
......
......@@ -843,7 +843,7 @@ static int DisplayAnchor( intf_thread_t *p_intf,
/* TODO: p_subpicture doesn't have the proper i_x and i_y
* coordinates. Need to look at the subpicture display system to
* work out why. */
if ( vout_ShowTextAbsolute( p_vout, SOLO_CHAN,
if ( vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN,
psz_anchor_description, p_style, OSD_ALIGN_BOTTOM,
i_margin_h, i_margin_v, i_now, 0 ) == VLC_SUCCESS )
{
......
......@@ -175,6 +175,7 @@ typedef struct
dvbsub_page_t* p_page;
dvbsub_object_t* p_objects;
subpicture_t* p_spu[16];
int i_subpic_channel;
} dvbsub_all_t;
......@@ -295,6 +296,7 @@ static void Decode( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_block;
vout_thread_t *p_last_vout;
if( pp_block == NULL || *pp_block == NULL )
{
......@@ -311,6 +313,7 @@ static void Decode( decoder_t *p_dec, block_t **pp_block )
return;
}
p_last_vout = p_sys->p_vout;
if( ( p_sys->p_vout = FindVout( p_dec ) ) )
{
int i_data_identifier;
......@@ -332,6 +335,12 @@ static void Decode( decoder_t *p_dec, block_t **pp_block )
}
i_end_data_marker = bs_read( &p_sys->bs, 8 );
if( p_last_vout != p_sys->p_vout )
{
p_sys->dvbsub.i_subpic_channel =
vout_RegisterOSDChannel( p_sys->p_vout );
}
/* Check if the page is to be displayed */
if( p_sys->dvbsub.p_page && p_sys->dvbsub.p_objects )
{
......@@ -1258,7 +1267,7 @@ static void render( dvbsub_all_t *dvbsub, vout_thread_t *p_vout )
/* Allocate the subpicture internal data. */
dvbsub->p_spu[j] =
vout_CreateSubPicture( p_vout, SUBT1_CHAN, TEXT_CONTENT,
vout_CreateSubPicture( p_vout, dvbsub->i_subpic_channel,
MEMORY_SUBPICTURE );
if( dvbsub->p_spu[j] == NULL )
{
......
......@@ -48,7 +48,7 @@ vlc_module_begin();
set_callbacks( VCDSubOpen, VCDSubClose );
add_integer ( MODULE_STRING "-debug", 0, NULL,
DEBUG_TEXT, DEBUG_LONGTEXT, VLC_TRUE );
DEBUG_TEXT, DEBUG_LONGTEXT, VLC_TRUE );
add_integer ( MODULE_STRING "-horizontal-correct", 0, NULL,
HORIZONTAL_CORRECT, HORIZONTAL_CORRECT_LONGTEXT, VLC_FALSE );
......@@ -57,12 +57,12 @@ vlc_module_begin();
VERTICAL_CORRECT, VERTICAL_CORRECT_LONGTEXT, VLC_FALSE );
add_string( MODULE_STRING "-aspect-ratio", "", NULL,
SUB_ASPECT_RATIO_TEXT, SUB_ASPECT_RATIO_LONGTEXT,
VLC_TRUE );
SUB_ASPECT_RATIO_TEXT, SUB_ASPECT_RATIO_LONGTEXT,
VLC_TRUE );
add_integer( MODULE_STRING "-duration-scaling", 3, NULL,
DURATION_SCALE_TEXT, DURATION_SCALE_LONGTEXT,
VLC_TRUE );
DURATION_SCALE_TEXT, DURATION_SCALE_LONGTEXT,
VLC_TRUE );
add_submodule();
set_description( _("Chaoji VCD subtitle packetizer") );
......@@ -145,6 +145,7 @@ Decode ( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_spu = Reassemble( p_dec, pp_block );
vout_thread_t *p_last_vout = p_dec->p_sys->p_vout;
dbg_print( (DECODE_DBG_CALL) , "");
......@@ -156,6 +157,12 @@ Decode ( decoder_t *p_dec, block_t **pp_block )
if( ( p_sys->p_vout = VCDSubFindVout( p_dec ) ) )
{
if( p_last_vout != p_sys->p_vout )
{
p_sys->i_subpic_channel =
vout_RegisterOSDChannel( p_sys->p_vout );
}
/* Parse and decode */
E_(ParsePacket)( p_dec );
......@@ -229,36 +236,37 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
p_buffer = p_block->p_buffer;
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_PACKET),
"header: 0x%02x 0x%02x 0x%02x 0x%02x, 0x%02x, 0x%02x, size: %i",
p_buffer[1], p_buffer[2], p_buffer[3], p_buffer[4],
p_buffer[5], p_buffer[6],
p_block->i_buffer);
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_PACKET),
"header: 0x%02x 0x%02x 0x%02x 0x%02x, 0x%02x, 0x%02x, size: %i",
p_buffer[1], p_buffer[2], p_buffer[3], p_buffer[4],
p_buffer[5], p_buffer[6],
p_block->i_buffer);
/* Attach to our input thread and see if subtitle is selected. */
{
vlc_object_t * p_input;
vlc_value_t val;
p_input = vlc_object_find( p_dec, VLC_OBJECT_INPUT, FIND_PARENT );
if( !p_input ) return NULL;
p_input = vlc_object_find( p_dec, VLC_OBJECT_INPUT, FIND_PARENT );
if( !p_input ) return NULL;
if( var_Get( p_input, "spu-channel", &val ) )
{
vlc_object_release( p_input );
return NULL;
}
if( var_Get( p_input, "spu-channel", &val ) ) {
vlc_object_release( p_input );
return NULL;
}
vlc_object_release( p_input );
/* Number could be 0bd, 1bd, 2bd, 3bd for 0..3. If so
reduce it to 0..3.
*/
if ( (val.i_int & 0xff) == 0xbd ) val.i_int >>= 8;
if( val.i_int == -1 || val.i_int != p_buffer[0] )
return NULL;
/* Number could be 0bd, 1bd, 2bd, 3bd for 0..3. If so
reduce it to 0..3.
*/
if ( (val.i_int & 0xff) == 0xbd ) val.i_int >>= 8;
if( val.i_int == -1 || val.i_int != p_buffer[0] )
return NULL;
}
......@@ -268,8 +276,8 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
image don't. */
if ( p_sys->state == SUBTITLE_BLOCK_EMPTY && p_block->i_pts == 0 ) {
msg_Warn( p_dec,
"first packet expected but no PTS present -- skipped\n");
msg_Warn( p_dec,
"first packet expected but no PTS present -- skipped\n");
return NULL;
}
......@@ -280,8 +288,8 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
}
/* FIXME - remove append_data and use chainappend */
VCDSubAppendData( p_dec, p_buffer + SPU_HEADER_LEN,
p_block->i_buffer - SPU_HEADER_LEN );
VCDSubAppendData( p_dec, p_buffer + SPU_HEADER_LEN,
p_block->i_buffer - SPU_HEADER_LEN );
block_ChainAppend( &p_sys->p_block, p_block );
......@@ -295,6 +303,5 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
p_sys->state = SUBTITLE_BLOCK_PARTIAL;
}
return NULL;
}
......@@ -292,7 +292,7 @@ E_(ParsePacket)( decoder_t *p_dec)
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_EXT) , "");
/* Allocate the subpicture internal data. */
p_spu = vout_CreateSubPicture( p_sys->p_vout, SUBT1_CHAN, TEXT_CONTENT,
p_spu = vout_CreateSubPicture( p_sys->p_vout, p_sys->i_subpic_channel,
MEMORY_SUBPICTURE );
if( p_spu == NULL )
{
......
......@@ -48,7 +48,7 @@ vlc_module_begin();
set_callbacks( VCDSubOpen, VCDSubClose );
add_integer ( MODULE_STRING "-debug", 0, NULL,
DEBUG_TEXT, DEBUG_LONGTEXT, VLC_TRUE );
DEBUG_TEXT, DEBUG_LONGTEXT, VLC_TRUE );
add_integer ( MODULE_STRING "-horizontal-correct", 0, NULL,
HORIZONTAL_CORRECT, HORIZONTAL_CORRECT_LONGTEXT, VLC_FALSE );
......@@ -57,12 +57,10 @@ vlc_module_begin();
VERTICAL_CORRECT, VERTICAL_CORRECT_LONGTEXT, VLC_FALSE );
add_string( MODULE_STRING "-aspect-ratio", "", NULL,
SUB_ASPECT_RATIO_TEXT, SUB_ASPECT_RATIO_LONGTEXT,
VLC_TRUE );
SUB_ASPECT_RATIO_TEXT, SUB_ASPECT_RATIO_LONGTEXT, VLC_TRUE );
add_integer( MODULE_STRING "-duration-scaling", 9, NULL,
DURATION_SCALE_TEXT, DURATION_SCALE_LONGTEXT,
VLC_TRUE );
DURATION_SCALE_TEXT, DURATION_SCALE_LONGTEXT, VLC_TRUE );
add_submodule();
set_description( _("Philips OGT (SVCD subtitle) packetizer") );
......@@ -145,6 +143,7 @@ Decode ( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_spu = Reassemble( p_dec, pp_block );
vout_thread_t *p_last_vout = p_dec->p_sys->p_vout;
dbg_print( (DECODE_DBG_CALL) , "");
......@@ -156,6 +155,12 @@ Decode ( decoder_t *p_dec, block_t **pp_block )
if( ( p_sys->p_vout = VCDSubFindVout( p_dec ) ) )
{
if( p_last_vout != p_sys->p_vout )
{
p_sys->i_subpic_channel =
vout_RegisterOSDChannel( p_sys->p_vout );
}
/* Parse and decode */
E_(ParsePacket)( p_dec );
......@@ -239,34 +244,36 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
p_buffer = p_block->p_buffer;
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_PACKET),
"header: 0x%02x 0x%02x 0x%02x 0x%02x, size: %i",
p_buffer[1], p_buffer[2], p_buffer[3], p_buffer[4],
p_block->i_buffer);
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_PACKET),
"header: 0x%02x 0x%02x 0x%02x 0x%02x, size: %i",
p_buffer[1], p_buffer[2], p_buffer[3], p_buffer[4],
p_block->i_buffer);
/* Attach to our input thread and see if subtitle is selected. */
{
vlc_object_t * p_input;
vlc_value_t val;
p_input = vlc_object_find( p_dec, VLC_OBJECT_INPUT, FIND_PARENT );
if( !p_input ) return NULL;
p_input = vlc_object_find( p_dec, VLC_OBJECT_INPUT, FIND_PARENT );
if( !p_input ) return NULL;
if( var_Get( p_input, "spu-channel", &val ) ) {
vlc_object_release( p_input );
if( var_Get( p_input, "spu-channel", &val ) )
{
vlc_object_release( p_input );
return NULL;
}
vlc_object_release( p_input );
dbg_print( (DECODE_DBG_PACKET),
dbg_print( (DECODE_DBG_PACKET),
"val.i_int %x p_buffer[i] %x", val.i_int, p_buffer[1]);
/* The dummy ES that the menu selection uses has an 0x70 at
the head which we need to strip off. */
if( val.i_int == -1 || (val.i_int & 0x03) != p_buffer[1] ) {
dbg_print( DECODE_DBG_PACKET, "subtitle not for us.\n");
return NULL;
if( val.i_int == -1 || (val.i_int & 0x03) != p_buffer[1] )
{
dbg_print( DECODE_DBG_PACKET, "subtitle not for us.\n");
return NULL;
}
}
......@@ -332,7 +339,7 @@ Reassemble( decoder_t *p_dec, block_t **pp_block )
}
/*
/*
* Local variables:
* c-file-style: "gnu"
* tab-width: 8
......
......@@ -165,7 +165,7 @@ E_(ParsePacket)( decoder_t *p_dec)
dbg_print( (DECODE_DBG_CALL|DECODE_DBG_EXT) , "");
/* Allocate the subpicture internal data. */
p_spu = vout_CreateSubPicture( p_sys->p_vout, SUBT1_CHAN, TEXT_CONTENT,
p_spu = vout_CreateSubPicture( p_sys->p_vout, p_sys->i_subpic_channel,
MEMORY_SUBPICTURE );
if( p_spu == NULL )
{
......
......@@ -35,7 +35,7 @@
#define DECODE_DBG_PNG 64 /* Extract subtitles to PNG files. */
#define DECODE_DBG_INFO 128
#define DEBUG_TEXT N_( \
#define DEBUG_TEXT N_( \
"If nonzero, this gives additional debug information." \
)
......@@ -51,7 +51,7 @@
"misc info 128\n" )
#define SUB_ASPECT_RATIO_TEXT N_("Subtitle aspect-ratio correction")
#define SUB_ASPECT_RATIO_LONGTEXT N_( \
#define SUB_ASPECT_RATIO_LONGTEXT N_( \
"Use this to force the subtitle aspect ratio. If you give a null string " \
"the right value will be determined automatically. Usually this is what " \
"you want. For OGT and CVD subtitles this undoes the effect " \
......@@ -66,26 +66,26 @@
)
#define DURATION_SCALE_TEXT N_("Factor to increase subtitle display interval")
#define DURATION_SCALE_LONGTEXT N_( \
#define DURATION_SCALE_LONGTEXT N_( \
"If you find you need extra time for reading subtitles, " \
"you can set this higher and it will multiply the display " \
"time by that amount. Use 0 to mean until the next " \
"you can set this higher and it will multiply the display " \
"time by that amount. Use 0 to mean until the next " \
"subtitle.")
#define HORIZONTAL_CORRECT \
N_("Add this to starting horizontal position of subtitle.")
#define HORIZONTAL_CORRECT_LONGTEXT N_( \
#define HORIZONTAL_CORRECT_LONGTEXT N_( \
"If you need to adjust the subtitle starting position horizontally, " \
"set this. Negative values shift left and positive values right. 0 would " \
"be no deviation from where the position specified in the subtitle." \
"be no deviation from where the position specified in the subtitle." \
)
#define VERTICAL_CORRECT \
N_("Add this to starting vertical position of subtitle.")
#define VERTICAL_CORRECT_LONGTEXT N_( \
#define VERTICAL_CORRECT_LONGTEXT N_( \
"If you need to adjust the subtitle starting position vertically, " \
"set this. Negative values shift up, positive values down. 0 would " \
"be no deviation from where the position specified in the subtitle." \
"set this. Negative values shift up, positive values down. 0 would " \
"be no deviation from where the position specified in the subtitle." \
)
#define DECODE_DEBUG 1
......@@ -107,7 +107,7 @@
/* The number of color palette entries allowed in a subtitle. */
#define NUM_SUBTITLE_COLORS 4
#define NUM_SUBTITLE_COLORS 4
typedef enum {
SUBTITLE_BLOCK_EMPTY,
......@@ -118,7 +118,7 @@ typedef enum {
/* The byte storage used by one pixel */
#define PIXEL_SIZE 4
/* Size in bytes of YUV portion above. */
/* Size in bytes of YUV portion above. */
#define YUV_SIZE 3
......@@ -133,50 +133,52 @@ struct decoder_sys_t
int i_spu;
packet_state_t state; /* data-gathering state for this subtitle */
uint16_t i_image; /* image number in the subtitle stream; 0 is the
first one. */
uint8_t i_packet;/* packet number for above image number; 0 is the
first one. */
uint16_t i_image; /* image number in the subtitle stream; 0 is the
first one. */
uint8_t i_packet;/* packet number for above image number; 0 is the
first one. */
block_t *p_block;/* Bytes of the packet. */
uint8_t buffer[65536 + 20 ]; /* we will never overflow more than 11
bytes if I'm right */
bytes if I'm right */
int b_packetizer;
int i_spu_size; /* goal for subtitle_data_pos while gathering,
size of used subtitle_data later */
int i_spu_size; /* goal for subtitle_data_pos while gathering,
size of used subtitle_data later */
vout_thread_t *p_vout;
int i_subpic_channel; /* Subpicture channel in which subtitles will
be written */
/* FIXME: Remove this? */
uint8_t *subtitle_data; /* buffer used to accumulate data from
successive packets in the same subtitle */
int subtitle_data_size; /* size of the allocated subtitle_data */
uint8_t *subtitle_data; /* buffer used to accumulate data from
successive packets in the same subtitle */
int subtitle_data_size; /* size of the allocated subtitle_data */
/* Move into subpicture_sys_t? */
uint16_t i_image_offset; /* offset from subtitle_data to compressed
image data */
int i_image_length; /* size of the compressed image data */
uint16_t i_image_offset; /* offset from subtitle_data to compressed
image data */
int i_image_length; /* size of the compressed image data */
int first_field_offset; /* offset of even raster lines. Used
only for CVD.
*/
only for CVD. */
int second_field_offset; /* offset of odd raster lines */
int metadata_offset; /* offset to data describing the image */
int metadata_length; /* length of metadata */
int subtitle_data_pos; /* where to write next chunk */
int subtitle_data_pos; /* where to write next chunk */
mtime_t i_duration; /* how long to display the image, 0 stands
for "until next subtitle" */
mtime_t i_duration; /* how long to display the image, 0 stands
for "until next subtitle" */
uint16_t i_x_start, i_y_start; /* position of top leftmost pixel of
image when displayed */
uint16_t i_width, i_height; /* dimensions in pixels of image */
image when displayed */
uint16_t i_width, i_height; /* dimensions in pixels of image */
ogt_yuvt_t p_palette[NUM_SUBTITLE_COLORS]; /* Palette of colors used
in subtitle */
in subtitle */
ogt_yuvt_t p_palette_highlight[NUM_SUBTITLE_COLORS]; /* Only used
for CVD */
for CVD */
uint8_t i_options;
uint8_t i_options2;
......@@ -194,7 +196,7 @@ struct subpicture_sys_t
/* Link to our input */
vlc_object_t * p_input;
/* Cropping properties */
vlc_mutex_t lock;
vlc_bool_t b_crop;
......@@ -202,6 +204,6 @@ struct subpicture_sys_t
/* This is only used for color palette Chromas like RGB2. */
ogt_yuvt_t p_palette[NUM_SUBTITLE_COLORS]; /* Palette of colors used
in subtitle */
in subtitle */
};
......@@ -70,9 +70,10 @@ void E_(ParsePacket)( decoder_t *p_dec)
decoder_sys_t *p_sys = p_dec->p_sys;
subpicture_t *p_spu;
int i_spu_channel;
/* Allocate the subpicture internal data. */
p_spu = vout_CreateSubPicture( p_sys->p_vout, SUBT1_CHAN, TEXT_CONTENT,
p_spu = vout_CreateSubPicture( p_sys->p_vout, p_sys->i_subpic_channel,
MEMORY_SUBPICTURE );
if( p_spu == NULL )
{
......
......@@ -2,7 +2,7 @@
* spudec.c : SPU decoder thread
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: spudec.c,v 1.33 2004/01/30 16:50:26 fenrir Exp $
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Laurent Aimar <fenrir@via.ecp.fr>
......@@ -153,10 +153,11 @@ static void Close( vlc_object_t *p_this )
/*****************************************************************************
* Decode:
*****************************************************************************/
static void Decode ( decoder_t *p_dec, block_t **pp_block )
static void Decode( decoder_t *p_dec, block_t **pp_block )
{
decoder_sys_t *p_sys = p_dec->p_sys;
block_t *p_spu = Reassemble( p_dec, pp_block );
vout_thread_t *p_last_vout = p_dec->p_sys->p_vout;
if( p_spu )
{
......@@ -166,6 +167,12 @@ static void Decode ( decoder_t *p_dec, block_t **pp_block )
if( ( p_sys->p_vout = FindVout( p_dec ) ) )
{
if( p_last_vout != p_sys->p_vout )
{
p_sys->i_subpic_channel =
vout_RegisterOSDChannel( p_sys->p_vout );
}
/* Parse and decode */
E_(ParsePacket)( p_dec );
......
......@@ -2,7 +2,7 @@
* spudec.h : sub picture unit decoder thread interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: spudec.h,v 1.8 2003/11/22 19:55:47 fenrir Exp $
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -30,6 +30,8 @@ struct decoder_sys_t
int i_rle_size;
int i_spu;
int i_subpic_channel;
block_t *p_block;
uint8_t buffer[65536 + 20 ]; /* we will never overflow more than 11 bytes if I'm right */
......
......@@ -43,6 +43,9 @@
struct decoder_sys_t
{
int i_align; /* Subtitles alignment on the vout */
int i_subpic_channel; /* Subpic channel for subtitles */
vout_thread_t *p_vout; /* last vout used */
#if defined(HAVE_ICONV)
iconv_t iconv_handle; /* handle to iconv instance */
......@@ -182,6 +185,8 @@ static int OpenDecoder( vlc_object_t *p_this )
msg_Dbg( p_dec, "no iconv support available" );
#endif
p_dec->p_sys->p_vout = NULL;
return VLC_SUCCESS;
}
......@@ -204,6 +209,10 @@ static void DecodeBlock( decoder_t *p_dec, block_t **pp_block )
p_vout = vlc_object_find( p_dec, VLC_OBJECT_VOUT, FIND_ANYWHERE );
if( p_vout )
{
if( p_dec->p_sys->p_vout != p_vout )
{
p_dec->p_sys->i_subpic_channel = vout_RegisterOSDChannel( p_vout );
}
ParseText( p_dec, *pp_block, p_vout );
vlc_object_release( p_vout );
}
......@@ -211,6 +220,7 @@ static void DecodeBlock( decoder_t *p_dec, block_t **pp_block )
{
msg_Warn( p_dec, "couldn't find a video output, trashing subtitle" );
}
p_dec->p_sys->p_vout = p_vout;
block_Release( *pp_block );
*pp_block = NULL;
......@@ -271,7 +281,7 @@ static void ParseText( decoder_t *p_dec, block_t *p_block,
msg_Warn( p_dec, "subtitle without a date" );
return;
}
/* Check validity of packet data */
if( p_block->i_buffer <= 1 || p_block->p_buffer[0] == '\0' )
{
......@@ -281,7 +291,7 @@ static void ParseText( decoder_t *p_dec, block_t *p_block,
/* Should be resiliant against bad subtitles */
psz_subtitle = strndup( p_block->p_buffer, p_block->i_buffer );
i_align_h = p_sys->i_align ? 20 : 0;
i_align_v = 10;
......@@ -371,7 +381,7 @@ static void ParseText( decoder_t *p_dec, block_t *p_block,
}
}
StripTags( psz_subtitle );
vout_ShowTextAbsolute( p_vout, SUBT1_CHAN, psz_subtitle, NULL,
vout_ShowTextAbsolute( p_vout, p_sys->i_subpic_channel, psz_subtitle, NULL,
OSD_ALIGN_BOTTOM | p_sys->i_align, i_align_h,
i_align_v, p_block->i_pts,
p_block->i_length ? p_block->i_pts + p_block->i_length : 0 );
......@@ -421,4 +431,3 @@ static void StripTags( char *psz_text )
}
psz_text[ i - i_left_moves ] = '\0';
}
......@@ -742,8 +742,8 @@ mediacontrol_display_text( mediacontrol_Instance *self,
mediacontrol_MediaTime,
end->value );
vout_ShowTextRelative( p_vout, SUBT1_CHAN, ( char* ) message, NULL,
OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 20, 20,
vout_ShowTextRelative( p_vout, DEFAULT_CHAN, ( char* ) message, NULL,
OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 20, 20,
i_duration );
}
else
......@@ -768,9 +768,9 @@ mediacontrol_display_text( mediacontrol_Instance *self,
( mediacontrol_Position * ) end );
i_fin += i_now;
vout_ShowTextAbsolute( p_vout, SUBT1_CHAN, ( char* )message, NULL,
OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 20, 20,
i_debut, i_fin );
vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN, ( char* ) message, NULL,
OSD_ALIGN_BOTTOM | OSD_ALIGN_LEFT, 20, 20,
i_debut, i_fin );
}
vlc_object_release( p_vout );
......
This diff is collapsed.
......@@ -45,6 +45,8 @@ struct intf_sys_t
struct lirc_config *config;
vlc_mutex_t change_lock;
int i_osd_channel;
input_thread_t * p_input;
vout_thread_t * p_vout;
};
......@@ -189,21 +191,21 @@ static void Run( intf_thread_t *p_intf )
if( !strcmp( c, "QUIT" ) )
{
p_intf->p_vlc->b_die = VLC_TRUE;
vout_OSDMessage( p_intf, SOLO_CHAN, _("Quit" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Quit" ) );
continue;
}
else if( !strcmp( c, "VOL_UP" ) )
{
audio_volume_t i_newvol;
aout_VolumeUp( p_intf, 1, &i_newvol );
vout_OSDMessage( p_intf, SOLO_CHAN, _("Vol %%%d"),
vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %%%d"),
i_newvol * 100 / AOUT_VOLUME_MAX );
}
else if( !strcmp( c, "VOL_DOWN" ) )
{
audio_volume_t i_newvol;
aout_VolumeDown( p_intf, 1, &i_newvol );
vout_OSDMessage( p_intf, SOLO_CHAN, _("Vol %%%d"),
vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %%%d"),
i_newvol * 100 / AOUT_VOLUME_MAX );
}
else if( !strcmp( c, "MUTE" ) )
......@@ -212,11 +214,11 @@ static void Run( intf_thread_t *p_intf )
aout_VolumeMute( p_intf, &i_newvol );
if( i_newvol == 0 )
{
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Mute" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Mute" ) );
}
else
{
vout_OSDMessage( p_intf, SOLO_CHAN, _("Vol %d%%"),
vout_OSDMessage( p_intf, DEFAULT_CHAN, _("Vol %d%%"),
i_newvol * 100 / AOUT_VOLUME_MAX );
}
}
......@@ -305,7 +307,7 @@ static void Run( intf_thread_t *p_intf )
}
if( p_input && val.i_int != PAUSE_S )
{
vout_OSDMessage( VLC_OBJECT(p_intf), SOLO_CHAN,
vout_OSDMessage( VLC_OBJECT(p_intf), DEFAULT_CHAN,
_( "Pause" ) );
val.i_int = PAUSE_S;
var_Set( p_input, "state", val );
......@@ -320,7 +322,7 @@ static void Run( intf_thread_t *p_intf )
if( p_playlist->i_size )
{
vlc_mutex_unlock( &p_playlist->object_lock );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Play" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Play" ) );
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
......@@ -367,7 +369,7 @@ static void Run( intf_thread_t *p_intf )
list.p_list->p_values[i+1] );
i++;
}
vout_OSDMessage( VLC_OBJECT(p_input), SOLO_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
_("Audio track: %s"),
list2.p_list->p_values[i].psz_string );
}
......@@ -403,14 +405,14 @@ static void Run( intf_thread_t *p_intf )
var_Set( p_input, "spu-es", list.p_list->p_values[i+1] );
i = i + 1;
}
vout_OSDMessage( VLC_OBJECT(p_input), SOLO_CHAN,
vout_OSDMessage( VLC_OBJECT(p_input), DEFAULT_CHAN,
_("Subtitle track: %s"),
list2.p_list->p_values[i].psz_string );
}
else if( !strcmp( c, "PAUSE" ) )
{
vlc_value_t val;
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Pause" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Pause" ) );
val.i_int = PAUSE_S;
var_Set( p_input, "state", val );
}
......
......@@ -56,7 +56,7 @@
}
if( p_input && val.i_int != PAUSE_S )
{
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Pause" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Pause" ) );
val.i_int = PAUSE_S;
var_Set( p_input, "state", val );
}
......@@ -70,7 +70,7 @@
if( p_playlist->i_size )
{
vlc_mutex_unlock( &p_playlist->object_lock );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Play" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Play" ) );
playlist_Play( p_playlist );
vlc_object_release( p_playlist );
}
......@@ -92,7 +92,7 @@
FIND_ANYWHERE );
if( p_playlist != NULL )
{
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Stop" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Stop" ) );
playlist_Stop( p_playlist );
vlc_object_release( p_playlist );
}
......@@ -108,7 +108,7 @@
vlc_value_t val; val.b_bool = VLC_TRUE;
var_Set( p_input, "rate-faster", val );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Faster" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Faster" ) );
vlc_object_release( p_input );
}
}
......@@ -123,7 +123,7 @@
vlc_value_t val; val.b_bool = VLC_TRUE;
var_Set( p_input, "rate-slower", val );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Slower" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Slower" ) );
vlc_object_release( p_input );
}
}
......@@ -137,7 +137,7 @@
{
playlist_Prev( p_playlist );
vlc_object_release( p_playlist );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Previous" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Previous" ) );
}
}
......@@ -150,7 +150,7 @@
{
playlist_Next( p_playlist );
vlc_object_release( p_playlist );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Next" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Next" ) );
}
}
......@@ -170,11 +170,11 @@
var_Set( p_playlist, "random", val );
if( val.b_bool )
{
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Random On" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random On" ) );
}
else
{
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Random Off" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random Off" ) );
}
p_intf->p_sys->b_playlist_update = VLC_TRUE;
......@@ -202,11 +202,11 @@
var_Set( p_playlist, "repeat", val );
if( val.b_bool )
{
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Repeat All" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
}
else
{
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Repeat Off" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
}
p_intf->p_sys->b_playlist_update = VLC_TRUE;
......@@ -234,11 +234,11 @@
var_Set( p_playlist, "loop", val );
if( val.b_bool )
{
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Repeat One" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
}
else
{
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Repeat Off" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
}
p_intf->p_sys->b_playlist_update = VLC_TRUE;
......@@ -256,7 +256,7 @@
vlc_value_t time;
time.i_time = 10 * 1000000;
var_Set( p_input, "time-offset", time );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Jump +10 Seconds" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Jump +10 Seconds" ) );
vlc_object_release( p_input );
}
}
......@@ -271,7 +271,7 @@
vlc_value_t time;
time.i_time = -10 * 1000000;
var_Set( p_input, "time-offset", time );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Jump -10 Seconds" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Jump -10 Seconds" ) );
vlc_object_release( p_input );
}
}
......@@ -333,7 +333,7 @@
[o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)];
vout_OSDMessage( p_intf, SOLO_CHAN, "Vol %d%%",
vout_OSDMessage( p_intf, DEFAULT_CHAN, "Vol %d%%",
i_volume*100/AOUT_VOLUME_MAX );
}
......
......@@ -545,7 +545,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
var_Set( p_playlist, "loop", val1 );
val1.b_bool = 1;
var_Set( p_playlist, "repeat", val1 );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Repeat One" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
break;
case 2:
......@@ -553,7 +553,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
var_Set( p_playlist, "repeat", val1 );
val1.b_bool = 1;
var_Set( p_playlist, "loop", val1 );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Repeat All" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
break;
default:
......@@ -564,7 +564,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
val1.b_bool = 0;
var_Set( p_playlist, "repeat", val1 );
var_Set( p_playlist, "loop", val1 );
vout_OSDMessage( p_intf, SOLO_CHAN, _( "Repeat Off" ) );
vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
}
break;
}
......
......@@ -706,8 +706,7 @@ static subpicture_t *AddText ( vout_thread_t *p_vout, int i_channel,
p_subpic = 0;
/* Create and initialize a subpicture */
p_subpic = vout_CreateSubPicture( p_vout, i_channel, TEXT_CONTENT,
MEMORY_SUBPICTURE );
p_subpic = vout_CreateSubPicture( p_vout, i_channel, MEMORY_SUBPICTURE );
if ( p_subpic == NULL )
{
return NULL;
......
......@@ -253,6 +253,10 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent,
/* No images in the heap */
p_vout->i_heap_size = 0;
/* Register the default subpicture channel */
p_vout->p_default_channel = NULL;
p_vout->i_channel_count = 1;
/* Initialize the rendering heap */
I_RENDERPICTURES = 0;
p_vout->render.i_width = i_width;
......
......@@ -382,8 +382,7 @@ subpicture_t *vout_CreateWidget( vout_thread_t *p_vout, int i_channel )
p_widget = 0;
/* Create and initialize a subpicture */
p_subpic = vout_CreateSubPicture( p_vout, i_channel, GRAPH_CONTENT,
MEMORY_SUBPICTURE );
p_subpic = vout_CreateSubPicture( p_vout, i_channel, MEMORY_SUBPICTURE );
if( p_subpic == NULL )
{
return NULL;
......@@ -493,29 +492,19 @@ void vout_OSDSlider( vlc_object_t *p_caller, int i_channel, int i_position,
* Displays an OSD icon.
* Types are: OSD_PLAY_ICON, OSD_PAUSE_ICON, OSD_SPEAKER_ICON, OSD_MUTE_ICON
*****************************************************************************/
void vout_OSDIcon( vlc_object_t *p_caller, short i_type )
void vout_OSDIcon( vlc_object_t *p_caller, int i_channel, short i_type )
{
vout_thread_t *p_vout = vlc_object_find( p_caller, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
subpicture_t *p_subpic;
subpicture_sys_t *p_widget;
int i_x_margin, i_y_margin, i_channel;
int i_x_margin, i_y_margin;
if( p_vout == NULL || !config_GetInt( p_caller, "osd" ) )
{
return;
}
switch( i_type )
{
case OSD_SPEAKER_ICON:
i_channel = VOLUME_CHAN;
break;
default:
i_channel = SOLO_CHAN;
break;
}
p_subpic = vout_CreateWidget( p_vout, i_channel );
if( p_subpic == NULL )
{
......
......@@ -42,7 +42,7 @@
* \param p_vout the video output this subpicture should be displayed on
* \param p_subpic the subpicture to display
*/
void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
{
int i_margin;
......@@ -83,44 +83,20 @@ void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
* \return NULL on error, a reserved subpicture otherwise
*/
subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_channel,
int i_content, int i_type )
int i_type )
{
int i_subpic; /* subpicture index */
subpicture_t * p_subpic = NULL; /* first free subpicture */
/* Get lock */
vlc_mutex_lock( &p_vout->subpicture_lock );
/*
* Destroy all subpics which are not in the correct channel and
* subpics which are in the right channel and have the same content type
* (only concerns exclusive channels)
*/
if( i_channel >= BEGIN_EXCLUSIVE_CHAN )
/* Clear the default channel before writing into it */
if( i_channel == DEFAULT_CHAN )
{
for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
{
p_subpic = &p_vout->p_subpicture[i_subpic];
if( p_subpic->i_status == FREE_SUBPICTURE
|| ( p_subpic->i_status != RESERVED_SUBPICTURE
&& p_subpic->i_status != READY_SUBPICTURE ) )
{
continue;
}
if( ( p_subpic->i_channel != i_channel
&& p_subpic->i_channel >= BEGIN_EXCLUSIVE_CHAN )
|| ( p_subpic->i_channel == i_channel
&& p_subpic->i_content == i_content ) )
{
if( p_subpic->pf_destroy )
{
p_subpic->pf_destroy( p_subpic );
}
p_subpic->i_status = FREE_SUBPICTURE;
}
}
vout_ClearOSDChannel( p_vout, DEFAULT_CHAN );
}
/* Get lock */
vlc_mutex_lock( &p_vout->subpicture_lock );
/*
* Look for an empty place
*/
......@@ -146,8 +122,6 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_channel,
/* Copy subpicture information, set some default values */
p_subpic->i_channel = i_channel;
p_subpic->i_content = i_content;
p_subpic->i_type = i_type;
p_subpic->i_status = RESERVED_SUBPICTURE;
......@@ -160,6 +134,12 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_channel,
p_subpic->i_width = 0;
p_subpic->i_height = 0;
/* Remain last subpicture displayed in DEFAULT_CHAN */
if( i_channel == DEFAULT_CHAN )
{
p_vout->p_default_channel = p_subpic;
}
vlc_mutex_unlock( &p_vout->subpicture_lock );
return p_subpic;
......@@ -337,3 +317,58 @@ subpicture_t *vout_SortSubPictures( vout_thread_t *p_vout,
return p_subpic;
}
/*****************************************************************************
* vout_RegisterOSDChannel: register an OSD channel
*****************************************************************************
* This function affects an ID to an OSD channel
*****************************************************************************/
int vout_RegisterOSDChannel( vout_thread_t *p_vout )
{
msg_Dbg( p_vout, "Registering OSD channel, ID: %i", p_vout->i_channel_count + 1 );
return ++p_vout->i_channel_count;
}
/*****************************************************************************
* vout_ClearOSDChannel: clear an OSD channel
*****************************************************************************
* This function destroys the subpictures which belong to the OSD channel
* corresponding to i_channel_id.
*****************************************************************************/
void vout_ClearOSDChannel( vout_thread_t *p_vout, int i_channel )
{
int i_subpic; /* subpicture index */
subpicture_t * p_subpic = NULL; /* first free subpicture */
if( i_channel == DEFAULT_CHAN )
{
if( p_vout->p_default_channel != NULL )
{
vout_DestroySubPicture( p_vout, p_vout->p_default_channel );
}
p_vout->p_default_channel = NULL;
return;
}
vlc_mutex_lock( &p_vout->subpicture_lock );
for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
{
p_subpic = &p_vout->p_subpicture[i_subpic];
if( p_subpic->i_status == FREE_SUBPICTURE
|| ( p_subpic->i_status != RESERVED_SUBPICTURE
&& p_subpic->i_status != READY_SUBPICTURE ) )
{
continue;
}
if( p_subpic->i_channel == i_channel )
{
if( p_subpic->pf_destroy )
{
p_subpic->pf_destroy( p_subpic );
}
p_subpic->i_status = FREE_SUBPICTURE;
}
}
vlc_mutex_unlock( &p_vout->subpicture_lock );
}
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