* ./src/libvlc.c: updated usage info to include STRING_FROM_LIST

    configuration items.
  * rest: new input info subsystem.

Have a look in plugins/mpeg_system/mpeg_audio.c to see how to add info.
Have a look in plugins/text/rc.c to see how to read info.


Sigmund
parent 3b00aed7
...@@ -175,7 +175,7 @@ VLC := vlc ...@@ -175,7 +175,7 @@ VLC := vlc
LIBVLC := libvlc LIBVLC := libvlc
INTERFACE := interface intf_eject INTERFACE := interface intf_eject
PLAYLIST := playlist PLAYLIST := playlist
INPUT := input input_ext-plugins input_ext-dec input_ext-intf input_dec input_programs input_clock mpeg_system INPUT := input input_ext-plugins input_ext-dec input_ext-intf input_dec input_programs input_clock mpeg_system input_info
VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures
AUDIO_OUTPUT := audio_output aout_ext-dec aout_pcm aout_spdif AUDIO_OUTPUT := audio_output aout_ext-dec aout_pcm aout_spdif
MISC := mtime modules threads cpu configuration netutils iso_lang messages objects extras MISC := mtime modules threads cpu configuration netutils iso_lang messages objects extras
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpeg_audio.c : mpeg_audio Stream input module for vlc * mpeg_audio.c : mpeg_audio Stream input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: mpeg_audio.c,v 1.11 2002/07/11 18:57:08 fenrir Exp $ * $Id: mpeg_audio.c,v 1.12 2002/07/21 18:57:02 sigmunau Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -451,6 +451,7 @@ static int MPEGAudioInit( input_thread_t * p_input ) ...@@ -451,6 +451,7 @@ static int MPEGAudioInit( input_thread_t * p_input )
es_descriptor_t * p_es; es_descriptor_t * p_es;
int i_pos; int i_pos;
int b_forced; int b_forced;
input_info_category_t * p_category;
/* XXX: i don't know what it's supposed to do, copied from ESInit */ /* XXX: i don't know what it's supposed to do, copied from ESInit */
/* Initialize access plug-in structures. */ /* Initialize access plug-in structures. */
...@@ -562,13 +563,25 @@ static int MPEGAudioInit( input_thread_t * p_input ) ...@@ -562,13 +563,25 @@ static int MPEGAudioInit( input_thread_t * p_input )
/* all is ok :)) */ /* all is ok :)) */
msg_Dbg( p_input, "audio MPEG-%d layer %d %s %dHz %dKb/s %s", msg_Dbg( p_input, "audio MPEG-%d layer %d %s %dHz %dKb/s %s",
mpeg.i_version + 1, mpeg.i_version + 1,
mpeg.i_layer +1 , mpeg.i_layer + 1,
mpegaudio_mode[mpeg.i_mode], mpegaudio_mode[mpeg.i_mode],
mpeg.i_samplingfreq, mpeg.i_samplingfreq,
p_mpegaudio->xingheader.i_avgbitrate / 1000, p_mpegaudio->xingheader.i_avgbitrate / 1000,
p_mpegaudio->xingheader.i_flags ? p_mpegaudio->xingheader.i_flags ?
"VBR (Xing)" : "" "VBR (Xing)" : ""
); );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_category = input_InfoCategory( p_input, "mpeg" );
input_AddInfo( p_category, "input type", "audio MPEG-%d",
mpeg.i_version +1 );
input_AddInfo( p_category, "layer", "%d", mpeg.i_layer + 1 );
input_AddInfo( p_category, "mode", mpegaudio_mode[mpeg.i_mode] );
input_AddInfo( p_category, "sample rate", "%dHz", mpeg.i_samplingfreq );
input_AddInfo( p_category, "average bitrate", "%dKb/s",
p_mpegaudio->xingheader.i_avgbitrate / 1000 );
vlc_mutex_unlock( &p_input->stream.stream_lock );
return( 0 ); return( 0 );
} }
...@@ -595,7 +608,6 @@ static int MPEGAudioDemux( input_thread_t * p_input ) ...@@ -595,7 +608,6 @@ static int MPEGAudioDemux( input_thread_t * p_input )
mpegaudio_format_t mpeg; mpegaudio_format_t mpeg;
demux_data_mpegaudio_t *p_mpegaudio = demux_data_mpegaudio_t *p_mpegaudio =
(demux_data_mpegaudio_t*) p_input->p_demux_data; (demux_data_mpegaudio_t*) p_input->p_demux_data;
/* look for a frame */ /* look for a frame */
if( !MPEGAudio_FindFrame( p_input, &i_pos, &mpeg, 4096 ) ) if( !MPEGAudio_FindFrame( p_input, &i_pos, &mpeg, 4096 ) )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* rc.c : remote control stdin/stdout plugin for vlc * rc.c : remote control stdin/stdout plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: rc.c,v 1.22 2002/07/20 18:01:43 sam Exp $ * $Id: rc.c,v 1.23 2002/07/21 18:57:02 sigmunau Exp $
* *
* Authors: Peter Surda <shurdeek@panorama.sth.ac.at> * Authors: Peter Surda <shurdeek@panorama.sth.ac.at>
* *
...@@ -151,6 +151,8 @@ static void intf_Run( intf_thread_t *p_intf ) ...@@ -151,6 +151,8 @@ static void intf_Run( intf_thread_t *p_intf )
{ {
char p_buffer[ MAX_LINE_LENGTH + 1 ]; char p_buffer[ MAX_LINE_LENGTH + 1 ];
vlc_bool_t b_complete = 0; vlc_bool_t b_complete = 0;
input_info_category_t * p_category;
input_info_t * p_info;
int i_dummy; int i_dummy;
off_t i_oldpos = 0; off_t i_oldpos = 0;
...@@ -159,6 +161,10 @@ static void intf_Run( intf_thread_t *p_intf ) ...@@ -159,6 +161,10 @@ static void intf_Run( intf_thread_t *p_intf )
struct timeval tv; /* how long to wait */ struct timeval tv; /* how long to wait */
double f_ratio = 1; double f_ratio = 1;
char psz_dashes[81];
memset(psz_dashes, '-', 80);
psz_dashes[80] = '\0';
p_intf->p_sys->p_input = NULL; p_intf->p_sys->p_input = NULL;
...@@ -325,7 +331,30 @@ static void intf_Run( intf_thread_t *p_intf ) ...@@ -325,7 +331,30 @@ static void intf_Run( intf_thread_t *p_intf )
printf( "q . . . . . . . . . . . . . . . . . . . . . quit\n" ); printf( "q . . . . . . . . . . . . . . . . . . . . . quit\n" );
printf( "end of help\n" ); printf( "end of help\n" );
break; break;
case 'i':
case 'I':
printf( "Dumping stream info\n" );
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
p_category = p_intf->p_sys->p_input->stream.p_info;
while ( p_category )
{
psz_dashes[72 - strlen(p_category->psz_name) ] = '\0';
printf( "+--| %s |%s+\n", p_category->psz_name, psz_dashes);
psz_dashes[72 - strlen(p_category->psz_name) ] = '-';
p_info = p_category->p_info;
while ( p_info )
{
printf( "| %s: %s\n", p_info->psz_name,
p_info->psz_value );
p_info = p_info->p_next;
}
printf("|\n");
p_category = p_category->p_next;
}
psz_dashes[78] = '\0';
printf( "+%s+\n", psz_dashes );
vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
break;
default: default:
printf( "unknown command `%s'\n", p_cmd ); printf( "unknown command `%s'\n", p_cmd );
break; break;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: input.c,v 1.205 2002/06/27 19:05:17 sam Exp $ * $Id: input.c,v 1.206 2002/07/21 18:57:02 sigmunau Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -71,6 +71,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, ...@@ -71,6 +71,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
playlist_item_t *p_item, int *pi_status ) playlist_item_t *p_item, int *pi_status )
{ {
input_thread_t * p_input; /* thread descriptor */ input_thread_t * p_input; /* thread descriptor */
input_info_category_t * p_info;
/* Allocate descriptor */ /* Allocate descriptor */
p_input = vlc_object_create( p_parent, VLC_OBJECT_INPUT ); p_input = vlc_object_create( p_parent, VLC_OBJECT_INPUT );
...@@ -148,8 +149,28 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, ...@@ -148,8 +149,28 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
p_input->stream.control.b_grayscale = config_GetInt( p_input, "grayscale" ); p_input->stream.control.b_grayscale = config_GetInt( p_input, "grayscale" );
p_input->stream.control.i_smp = config_GetInt( p_input, "vdec-smp" ); p_input->stream.control.i_smp = config_GetInt( p_input, "vdec-smp" );
/* Initialize input info */
p_input->stream.p_info = malloc( sizeof( input_info_category_t ) );
if( !p_input->stream.p_info )
{
msg_Err( p_input, "No memory!" );
return NULL;
}
p_input->stream.p_info->psz_name = strdup("General") ;
p_input->stream.p_info->p_info = NULL;
p_input->stream.p_info->p_next = NULL;
/* test code */
msg_Dbg( p_input, "finding category \"hepp\"");
p_info = input_InfoCategory( p_input, "hepp" );
msg_Dbg( p_input, "adding testkey/testval");
input_AddInfo( p_info, "testkey", "testval");
/* end test code */
msg_Info( p_input, "playlist item `%s'", p_input->psz_source ); msg_Info( p_input, "playlist item `%s'", p_input->psz_source );
p_info = input_InfoCategory( p_input, "General");
input_AddInfo( p_info, "Playlist item", p_input->psz_source );
vlc_object_attach( p_input, p_parent ); vlc_object_attach( p_input, p_parent );
/* Create thread and wait for its readiness. */ /* Create thread and wait for its readiness. */
...@@ -545,6 +566,10 @@ static void EndThread( input_thread_t * p_input ) ...@@ -545,6 +566,10 @@ static void EndThread( input_thread_t * p_input )
msg_Dbg( p_input, "%d loops", p_input->c_loops ); msg_Dbg( p_input, "%d loops", p_input->c_loops );
#endif #endif
/* Free info structures */
msg_Dbg( p_input, "freeing info structures...");
input_DelInfo( p_input );
input_DumpStream( p_input ); input_DumpStream( p_input );
/* Tell we're dead */ /* Tell we're dead */
......
/*****************************************************************************
* input_info.c: Convenient functions to handle the input info structures
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_info.c,v 1.1 2002/07/21 18:57:02 sigmunau Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <sys/types.h>
#include <vlc/vlc.h>
#include <string.h>
#include <errno.h>
#include "stream_control.h"
#include "input_ext-intf.h"
#include "interface.h"
input_info_category_t * input_InfoCategory( input_thread_t * p_this,
char * psz_name)
{
input_info_category_t * p_category, * p_prev;
p_prev = NULL;
msg_Dbg( p_this, "searching for category");
for ( p_category = p_this->stream.p_info;
(p_category != NULL) && strcmp( p_category->psz_name, psz_name );
p_category = p_category->p_next)
{
p_prev = p_category;
}
if ( p_category )
{
msg_Dbg(p_this, "found category at %p, with name %s", p_category
,p_category->psz_name);
return p_category;
}
else
{
msg_Dbg( p_this, "creating new input category");
p_category = malloc( sizeof( input_info_category_t ) );
if ( !p_category )
{
msg_Err( p_this, "No mem" );
return 0;
}
p_category->psz_name = strdup( psz_name );
p_category->p_next = NULL;
p_category->p_info = NULL;
p_prev->p_next = p_category;
return p_category;
}
}
int input_AddInfo( input_info_category_t * p_category, char * psz_name,
char * psz_format, ...)
{
input_info_t * p_info, * p_prev;
char * psz_str;
va_list args;
p_prev = NULL;
if ( !p_category )
{
return -1;
}
va_start( args, psz_format );
/*
* Convert message to string
*/
#ifdef HAVE_VASPRINTF
vasprintf( &psz_str, psz_format, args );
#else
psz_str = (char*) malloc( strlen(psz_format) + INTF_MAX_MSG_SIZE );
#endif
if( psz_str == NULL )
{
// fprintf( stderr, "main warning: can't store message (%s): ",
// strerror(errno) );
// vfprintf( stderr, psz_format, args );
// fprintf( stderr, "\n" );
return -1;
}
#ifndef HAVE_VASPRINTF
# ifdef WIN32
psz_temp = ConvertPrintfFormatString( psz_format );
if( !psz_temp )
{
//fprintf( stderr, "main warning: couldn't print message\n" );
return -1;
}
vsprintf( psz_str, psz_temp, args );
free( psz_temp );
# else
vsprintf( psz_str, psz_format, args );
# endif
#endif
va_end( args );
p_info = p_category->p_info;
while ( p_info )
{
p_prev = p_info;
p_info = p_info->p_next;
}
p_info = malloc( sizeof( input_info_t ) );
if( !p_info )
{
return -1;
}
p_info->psz_name = strdup( psz_name );
p_info->psz_value = psz_str;
p_info->p_next = NULL;
if ( p_prev )
{
p_prev->p_next = p_info;
}
else
{
p_category->p_info = p_info;
}
return 0;
}
int input_DelInfo( input_thread_t * p_input )
{
input_info_category_t * p_category, * p_prev_category;
input_info_t * p_info, * p_prev_info;
p_category = p_input->stream.p_info;
while ( p_category )
{
p_info = p_category->p_info;
while ( p_info )
{
if ( p_info->psz_name )
{
free( p_info->psz_name );
}
if ( p_info->psz_value )
{
free( p_info->psz_value );
}
p_prev_info = p_info;
p_info = p_info->p_next;
free( p_prev_info );
}
if ( p_category->psz_name )
{
free( p_category->psz_name );
}
p_prev_category = p_category;
p_category = p_category->p_next;
free( p_prev_category );
}
return 0;
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* and spawns threads. * and spawns threads.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: libvlc.c,v 1.17 2002/07/20 18:01:43 sam Exp $ * $Id: libvlc.c,v 1.18 2002/07/21 18:57:02 sigmunau Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -971,8 +971,25 @@ static void Usage( vlc_t *p_this, const char *psz_module_name ) ...@@ -971,8 +971,25 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_FILE: case CONFIG_ITEM_FILE:
case CONFIG_ITEM_MODULE: /* We could also have "=<" here */ case CONFIG_ITEM_MODULE: /* We could also have "=<" here */
if( !p_item->ppsz_list )
{
psz_bra = " <"; psz_type = _("string"); psz_ket = ">"; psz_bra = " <"; psz_type = _("string"); psz_ket = ">";
break; break;
}
else
{
psz_bra = " [";
psz_type = malloc( 1000 );
memset( psz_type, 0, 1000 );
for( i=0; p_item->ppsz_list[i]; i++ )
{
strcat( psz_type, p_item->ppsz_list[i] );
strcat( psz_type, "|" );
}
psz_type[ strlen( psz_type ) - 1 ] = '\0';
psz_ket = "]";
break;
}
case CONFIG_ITEM_INTEGER: case CONFIG_ITEM_INTEGER:
psz_bra = " <"; psz_type = _("integer"); psz_ket = ">"; psz_bra = " <"; psz_type = _("integer"); psz_ket = ">";
break; break;
...@@ -1058,6 +1075,10 @@ static void Usage( vlc_t *p_this, const char *psz_module_name ) ...@@ -1058,6 +1075,10 @@ static void Usage( vlc_t *p_this, const char *psz_module_name )
p_item->psz_text, psz_suf ); p_item->psz_text, psz_suf );
} }
psz_spaces[i] = ' '; psz_spaces[i] = ' ';
if ( p_item->ppsz_list )
{
free( psz_type );
}
} }
} }
......
...@@ -229,6 +229,8 @@ static inline const char * module_error( char *psz_buffer ) ...@@ -229,6 +229,8 @@ static inline const char * module_error( char *psz_buffer )
(p_symbols)->input_ClockManageControl_inner = input_ClockManageControl; \ (p_symbols)->input_ClockManageControl_inner = input_ClockManageControl; \
(p_symbols)->input_ClockManageRef_inner = input_ClockManageRef; \ (p_symbols)->input_ClockManageRef_inner = input_ClockManageRef; \
(p_symbols)->input_ClockGetTS_inner = input_ClockGetTS; \ (p_symbols)->input_ClockGetTS_inner = input_ClockGetTS; \
(p_symbols)->input_InfoCategory_inner = input_InfoCategory; \
(p_symbols)->input_AddInfo_inner = input_AddInfo; \
(p_symbols)->input_BuffersEnd_inner = input_BuffersEnd; \ (p_symbols)->input_BuffersEnd_inner = input_BuffersEnd; \
(p_symbols)->input_NewBuffer_inner = input_NewBuffer; \ (p_symbols)->input_NewBuffer_inner = input_NewBuffer; \
(p_symbols)->input_ReleaseBuffer_inner = input_ReleaseBuffer; \ (p_symbols)->input_ReleaseBuffer_inner = input_ReleaseBuffer; \
......
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