Commit acf4606c authored by Christophe Massiot's avatar Christophe Massiot

* modules/stream_out/switcher.c: New module allowing to replace an MPEG2

  video by a fixed panel (format .uyvy). Specify panel files with
  --sout-switcher-files=toto.uyvy,tata.uyvy,titi.uyvy and the size of
  pictures with --sout-switcher-sizes=720x576,720x576,480x576.
  --sout-switcher-port=4242 opens up a UDP port. echo 1 | nc -u localhost 4242
  switches to panel #1 (0 is the live video, -1 disables all output).
  The audio is blanked out when a panel is active. --sout-switcher-command
  specifies the first command to run on start-up.
* modules/access/fake.c: Fake video input simulating a video at x fps.
  Use it to switch between fixed panels with the switcher when you have
  no video.
parent 9cb4d58c
......@@ -984,7 +984,7 @@ VLC_ADD_PLUGINS([trivial_channel_mixer trivial_mixer])
VLC_ADD_PLUGINS([id3 playlist export sgimb m3u xtag])
VLC_ADD_PLUGINS([i420_rgb rawvideo blend scale image logo])
VLC_ADD_PLUGINS([wav araw subtitle vobsub adpcm a52sys dtssys au voc xa])
VLC_ADD_PLUGINS([access_directory access_file access_udp access_tcp])
VLC_ADD_PLUGINS([access_directory access_file access_udp access_tcp access_fake])
VLC_ADD_PLUGINS([access_http access_mms access_ftp ipv4])
VLC_ADD_PLUGINS([packetizer_mpegvideo packetizer_h264])
VLC_ADD_PLUGINS([packetizer_mpeg4video packetizer_mpeg4audio])
......@@ -1995,8 +1995,8 @@ then
then
AC_CHECK_HEADERS(ffmpeg/avcodec.h)
AC_CHECK_HEADERS(postproc/postprocess.h)
VLC_ADD_PLUGINS([ffmpeg])
VLC_ADD_CFLAGS([ffmpeg],[`${FFMPEG_CONFIG} --cflags`])
VLC_ADD_PLUGINS([ffmpeg stream_out_switcher])
VLC_ADD_CFLAGS([ffmpeg stream_out_switcher],[`${FFMPEG_CONFIG} --cflags`])
VLC_ADD_LDFLAGS([ffmpeg],[`${FFMPEG_CONFIG} --plugin-libs avcodec avformat postproc`])
else
AC_ARG_WITH(ffmpeg-mp3lame,
......@@ -2031,7 +2031,7 @@ then
AC_CHECK_HEADERS(ffmpeg/avcodec.h, [], [AC_MSG_ERROR([Missing header file ffmpeg/avcodec.h.])] )
AC_CHECK_HEADERS(postproc/postprocess.h, [], [AC_MSG_ERROR([Missing header file postproc/postprocess.h.])] )
AC_CHECK_LIB(avcodec, avcodec_init, [
VLC_ADD_BUILTINS([ffmpeg])
VLC_ADD_BUILTINS([ffmpeg stream_out_switcher])
VLC_ADD_LDFLAGS([ffmpeg],[-lavcodec])],
[ AC_MSG_ERROR([Could not find ffmpeg on your system: you may get it from http://ffmpeg.sf.net/ (cvs version is recommended). Alternatively you can use --disable-ffmpeg to disable the ffmpeg plugins.]) ])
AC_CHECK_LIB(avformat, av_open_input_stream, [
......@@ -2096,14 +2096,14 @@ then
VLC_ADD_LDFLAGS([ffmpeg],[-lxvidcore])
fi
VLC_ADD_BUILTINS([ffmpeg])
VLC_ADD_BUILTINS([ffmpeg stream_out_switcher])
VLC_ADD_LDFLAGS([ffmpeg],[-L${real_ffmpeg_tree}/libavcodec ${real_ffmpeg_tree}/libavcodec/libavcodec.a])
VLC_ADD_CPPFLAGS([ffmpeg],[-I${real_ffmpeg_tree}/libavcodec])
VLC_ADD_CPPFLAGS([ffmpeg stream_out_switcher],[-I${real_ffmpeg_tree}/libavcodec])
if test -f "${real_ffmpeg_tree}/libavformat/libavformat.a"; then
AC_DEFINE(HAVE_LIBAVFORMAT, 1, [Define if you have ffmpeg's libavformat.])
VLC_ADD_LDFLAGS([ffmpeg],[-L${real_ffmpeg_tree}/libavformat ${real_ffmpeg_tree}/libavformat/libavformat.a])
VLC_ADD_CPPFLAGS([ffmpeg],[-I${real_ffmpeg_tree}/libavformat])
VLC_ADD_CPPFLAGS([ffmpeg stream_out_switcher],[-I${real_ffmpeg_tree}/libavformat])
fi
fi
fi
......@@ -2146,6 +2146,8 @@ then
VLC_ADD_LDFLAGS([ffmpegaltivec],[-L${real_ffmpeg_tree}/libavformat -lavformataltivec -lz])
VLC_ADD_CPPFLAGS([ffmpegaltivec],[-I${real_ffmpeg_tree}/libavformat])
fi
VLC_ADD_LDFLAGS([stream_out_switcher],[-L${real_ffmpeg_tree}/libavcodec])
VLC_ADD_CPPFLAGS([stream_out_switcher],[-I${real_ffmpeg_tree}/libavcodec -I${real_ffmpeg_tree}/libavformat])
fi
fi
......
......@@ -8,6 +8,7 @@ SOURCES_access_smb = smb.c
SOURCES_dvdnav = dvdnav.c
SOURCES_dvdread = dvdread.c
SOURCES_slp = slp.c
SOURCES_access_fake = fake.c
SOURCES_cdda = \
cdda.c \
vcd/cdrom.c \
......
/*****************************************************************************
* fake.c : Fake video input for VLC
*****************************************************************************
* Copyright (C) 2005 VideoLAN
* $Id$
*
* Author: Christophe Massiot <massiot@via.ecp.fr>
*
* 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 <stdio.h>
#include <string.h>
#include <vlc/vlc.h>
#include <vlc/input.h>
/*****************************************************************************
* Module descriptior
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
#define CACHING_TEXT N_("Caching value in ms")
#define CACHING_LONGTEXT N_( \
"Allows you to modify the default caching value for fake streams. This " \
"value should be set in millisecond units." )
#define FPS_TEXT N_("Framerate")
#define FPS_LONGTEXT N_( \
"Specify the number of frames per second (eg. 24, 25, 29.997, 30).")
vlc_module_begin();
set_shortname( _("Fake") );
set_description( _("Fake input") );
set_category( CAT_INPUT );
set_subcategory( SUBCAT_INPUT_ACCESS );
add_integer( "fake-caching", DEFAULT_PTS_DELAY / 1000, NULL,
CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
add_float( "fake-fps", 25.0, NULL, FPS_TEXT, FPS_LONGTEXT, VLC_TRUE );
add_shortcut( "fake" );
set_capability( "access_demux", 0 );
set_callbacks( Open, Close );
vlc_module_end();
/*****************************************************************************
* Access: local prototypes
*****************************************************************************/
static int Demux ( demux_t * );
static int Control( demux_t *, int, va_list );
struct demux_sys_t
{
float f_fps;
mtime_t i_last_pts; /* only used when f_fps > 0 */
es_out_id_t *p_es_video;
};
/*****************************************************************************
* Open: opens fake device
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
vlc_value_t val;
es_format_t fmt;
/* Only when selected */
if( *p_demux->psz_access == '\0' )
return VLC_EGENERIC;
/* Set up p_demux */
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->info.i_update = 0;
p_demux->info.i_title = 0;
p_demux->info.i_seekpoint = 0;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
memset( p_sys, 0, sizeof( demux_sys_t ) );
var_Create( p_demux, "fake-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
var_Get( p_demux, "fake-fps", &val );
p_sys->f_fps = val.f_float;
p_sys->i_last_pts = 0;
/* Declare elementary stream */
es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC('f', 'a', 'k', 'e') );
p_sys->p_es_video = es_out_Add( p_demux->out, &fmt );
/* Update default_pts to a suitable value for access */
var_Create( p_demux, "fake-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
return VLC_SUCCESS;
}
/*****************************************************************************
* Close: close device, free resources
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
free( p_sys );
}
/*****************************************************************************
* Control:
*****************************************************************************/
static int Control( demux_t *p_demux, int i_query, va_list args )
{
demux_sys_t *p_sys = p_demux->p_sys;
vlc_bool_t *pb;
int64_t *pi64;
switch( i_query )
{
/* Special for access_demux */
case DEMUX_CAN_PAUSE:
case DEMUX_SET_PAUSE_STATE:
case DEMUX_CAN_CONTROL_PACE:
pb = (vlc_bool_t*)va_arg( args, vlc_bool_t * );
*pb = VLC_FALSE;
return VLC_SUCCESS;
case DEMUX_GET_PTS_DELAY:
pi64 = (int64_t*)va_arg( args, int64_t * );
*pi64 = (int64_t)var_GetInteger( p_demux, "fake-caching" ) * 1000;
return VLC_SUCCESS;
case DEMUX_GET_TIME:
pi64 = (int64_t*)va_arg( args, int64_t * );
*pi64 = p_sys->i_last_pts;
return VLC_SUCCESS;
/* TODO implement others */
default:
return VLC_EGENERIC;
}
return VLC_EGENERIC;
}
/*****************************************************************************
* Demux:
*****************************************************************************/
static int Demux( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
block_t *p_block = block_New( p_demux, 1 );
if ( !p_sys->i_last_pts )
{
p_sys->i_last_pts = mdate();
}
else
{
p_sys->i_last_pts += I64C(1000000) / p_sys->f_fps;
mwait( p_sys->i_last_pts );
}
p_block->i_flags |= BLOCK_FLAG_TYPE_I;
p_block->i_dts = p_block->i_pts = p_sys->i_last_pts;
es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
es_out_Send( p_demux->out, p_sys->p_es_video, p_block );
return 1;
}
......@@ -9,3 +9,4 @@ SOURCES_stream_out_es = es.c
SOURCES_stream_out_display = display.c
SOURCES_stream_out_gather = gather.c
SOURCES_stream_out_rtp = rtp.c
SOURCES_stream_out_switcher = switcher.c
This diff is collapsed.
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