Hello, Here is a first attempt at integrating the RTSP layer from ffmpeg. It does so by adding an access demuxer to the VLC scaffolding for libavformat.
All the major transports are working (udp, tcp, rtsp-http). I have not yet looked at features like auth or muxing, but I can do that once I know this patch is on the right track. Josh
From 519230d9ae69ac93a0f89b9e26aeb88ac1954369 Mon Sep 17 00:00:00 2001 From: Josh Allmann <[email protected]> Date: Fri, 11 Jun 2010 22:17:31 -0700 Subject: [PATCH] Integrated FFmpeg RTSP. --- modules/demux/avformat/avformat.c | 29 ++++++++++++++++++++++++++++ modules/demux/avformat/demux.c | 38 +++++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/modules/demux/avformat/avformat.c b/modules/demux/avformat/avformat.c index b5974a4..6c835a7 100644 --- a/modules/demux/avformat/avformat.c +++ b/modules/demux/avformat/avformat.c @@ -22,6 +22,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ +#define CACHING_TEXT N_("Caching value (ms)") +#define CACHING_LONGTEXT N_( \ + "Allows you to modify the default caching value for RTSP streams. This " \ + "value should be set in millisecond units." ) + + #ifndef MERGE_FFMPEG #ifdef HAVE_CONFIG_H # include "config.h" @@ -42,6 +48,29 @@ vlc_module_begin () set_capability( "demux", 2 ) set_callbacks( OpenDemux, CloseDemux ) + add_submodule() + set_description( N_("RTSP/RTP access and demux (FFmpeg)") ) + add_shortcut( "ffmpeg" ) + add_shortcut( "rtsp" ) + add_shortcut( "sdp" ) + set_capability( "access_demux", 0 ) + set_callbacks( OpenDemux, CloseDemux ) + add_integer("rtsp-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL, + CACHING_TEXT, CACHING_LONGTEXT, true ) + change_safe() + add_bool( "rtsp-tcp", false, NULL, + N_("Use RTP over RTSP (TCP)"), + N_("Use RTP over RTSP (TCP)"), true ) + change_safe() + add_bool( "rtsp-http", false, NULL, + N_("Tunnel RTSP and RTP over HTTP"), + N_("Tunnel RTSP and RTP over HTTP"), true ) + change_safe() + add_bool( "rtsp-udp", false, NULL, + N_("Use RTP and RTSP over UDP (default)"), + N_("Use RTP and RTSP over UDP (default)"), true ) + change_safe() + #ifdef ENABLE_SOUT /* mux submodule */ add_submodule () diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c index 3b5454b..1cfad1f 100644 --- a/modules/demux/avformat/demux.c +++ b/modules/demux/avformat/demux.c @@ -41,8 +41,10 @@ /* ffmpeg header */ #if defined(HAVE_LIBAVFORMAT_AVFORMAT_H) # include <libavformat/avformat.h> +# include <libavutil/avstring.h> #elif defined(HAVE_FFMPEG_AVFORMAT_H) # include <ffmpeg/avformat.h> +# include <libavutil/avstring.h> #endif #include "../../codec/avcodec/avcodec.h" @@ -117,10 +119,33 @@ int OpenDemux( vlc_object_t *p_this ) unsigned int i; int64_t i_start_time = -1; bool b_can_seek; + char filename[128] = "", opts[8] = ""; + int filename_len = 0; + + if( var_CreateGetBool( p_demux, "rtsp-tcp" ) ) + strcpy(opts, "?tcp"); + else if( var_CreateGetBool( p_demux, "rtsp-http" ) ) + strcpy(opts, "?http"); + else if( var_CreateGetBool( p_demux, "rtsp-udp" ) ) + strcpy(opts, "?udp"); + + /* build the filename string */ + if( p_demux->psz_access ) + { + filename_len += av_strlcatf( filename + filename_len, + sizeof(filename) - filename_len, + "%s://", p_demux->psz_access); + } + filename_len += av_strlcpy( filename + filename_len, + p_demux->psz_path, + sizeof(filename) - filename_len ); + filename_len += av_strlcpy( filename + filename_len, + opts, + sizeof(filename) - filename_len ); /* Init Probe data */ - pd.filename = p_demux->psz_path; - if( ( pd.buf_size = stream_Peek( p_demux->s, &pd.buf, 2048 + 213 ) ) <= 0 ) + pd.filename = filename; + if( p_demux->s && ( pd.buf_size = stream_Peek( p_demux->s, &pd.buf, 2048 + 213 ) ) <= 0 ) { msg_Warn( p_demux, "cannot peek" ); return VLC_EGENERIC; @@ -131,7 +156,7 @@ int OpenDemux( vlc_object_t *p_this ) vlc_avcodec_unlock(); /* Guess format */ - if( !( fmt = av_probe_input_format( &pd, 1 ) ) ) + if( !( fmt = av_probe_input_format( &pd, p_demux->s ? 1 : 0 ) ) ) { msg_Dbg( p_demux, "couldn't guess format" ); return VLC_EGENERIC; @@ -171,6 +196,7 @@ int OpenDemux( vlc_object_t *p_this ) msg_Dbg( p_demux, "detected format: %s", fmt->name ); /* Fill p_demux fields */ + var_Create( p_demux, "rtsp-caching", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); p_demux->pf_demux = Demux; p_demux->pf_control = Control; p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); @@ -214,7 +240,7 @@ int OpenDemux( vlc_object_t *p_this ) /* Open it */ - if( av_open_input_stream( &p_sys->ic, &p_sys->io, p_demux->psz_path, + if( av_open_input_stream( &p_sys->ic, &p_sys->io, filename, p_sys->fmt, NULL ) ) { msg_Err( p_demux, "av_open_input_stream failed" ); @@ -819,6 +845,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) } + case DEMUX_GET_PTS_DELAY: + pi64 = (int64_t*)va_arg( args, int64_t * ); + *pi64 = (int64_t)var_GetInteger( p_demux, "rtsp-caching" ) * 1000; + return VLC_SUCCESS; default: return VLC_EGENERIC; } -- 1.7.0.4
_______________________________________________ FFmpeg-soc mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc
