#include <vlc/vlc.h>
#include <vlc_sout.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
#include <vlc_network.h>
#include "vlc_url.h"
if( psz_url && strrchr( psz_url, '.' ) )
{
/* by extension */
- static struct { const char *ext; const char *mux; } exttomux[] =
+ static struct { const char ext[6]; const char mux[16]; } exttomux[] =
{
{ "avi", "avi" },
{ "ogg", "ogg" },
{ "mpeg","ps" },
{ "ps", "ps" },
{ "mpeg1","mpeg1" },
- { "wav","wav" },
+ { "wav", "wav" },
{ "flv", "ffmpeg{mux=flv}" },
- { NULL, NULL }
+ { "", "" }
};
const char *psz_ext = strrchr( psz_url, '.' ) + 1;
int i;
msg_Dbg( p_this, "extension is %s", psz_ext );
- for( i = 0; exttomux[i].ext != NULL; i++ )
+ for( i = 0; exttomux[i].ext[0]; i++ )
{
if( !strcasecmp( psz_ext, exttomux[i].ext ) )
{
psz_mux = strdup("asfh");
}
else if (!strcmp (psz_access, "udp")
- || !strcmp (psz_access, "rtp") || !strcmp (psz_access, "udplite")
- || !strcmp (psz_access, "tcp") || !strcmp (psz_access, "sctp")
- || !strcmp (psz_access, "dccp"))
+ || !strcmp (psz_access, "rtp"))
{
psz_mux = strdup("ts");
}
}
/* fix or warn of incompatible couple */
- if( psz_mux && psz_access )
+ if( !strncmp( psz_access, "mmsh", 4 ) &&
+ strncmp( psz_mux, "asfh", 4 ) )
{
- if( !strncmp( psz_access, "mmsh", 4 ) &&
- strncmp( psz_mux, "asfh", 4 ) )
- {
- char *p = strchr( psz_mux,'{' );
+ char *p = strchr( psz_mux,'{' );
- msg_Warn( p_stream, "fixing to mmsh/asfh" );
- if( p )
- {
- /* -> a little memleak but ... */
- psz_mux = malloc( strlen( "asfh" ) + strlen( p ) + 1);
- sprintf( psz_mux, "asfh%s", p );
- }
- else
- {
- psz_mux = strdup("asfh");
- }
- }
- else if( ( !strncmp( psz_access, "rtp", 3 ) ||
- !strncmp( psz_access, "udp", 3 ) ) &&
- strncmp( psz_mux, "ts", 2 ) )
+ msg_Warn( p_stream, "fixing to mmsh/asfh" );
+ if( p )
{
- msg_Err( p_stream, "for now udp and rtp are only valid with TS" );
+ if( asprintf( &p, "asfh%s", p ) == -1 )
+ p = NULL;
+ free( psz_mux );
+ psz_mux = p;
}
- else if( strncmp( psz_access, "file", 4 ) &&
- ( !strncmp( psz_mux, "mov", 3 ) ||
- !strncmp( psz_mux, "mp4", 3 ) ) )
+ else
{
- msg_Err( p_stream, "mov and mp4 work only with file output" );
+ free( psz_mux );
+ psz_mux = strdup("asfh");
}
}
+ else if( ( !strncmp( psz_access, "rtp", 3 ) ||
+ !strncmp( psz_access, "udp", 3 ) ) &&
+ strncmp( psz_mux, "ts", 2 ) )
+ {
+ msg_Err( p_stream, "UDP and RTP are only valid with TS" );
+ }
+ else if( strncmp( psz_access, "file", 4 ) &&
+ ( !strncmp( psz_mux, "mov", 3 ) ||
+ !strncmp( psz_mux, "mp4", 3 ) ) )
+ {
+ msg_Err( p_stream, "mov and mp4 work only with file output" );
+ }
msg_Dbg( p_this, "using `%s/%s://%s'", psz_access, psz_mux, psz_url );
{
msg_Err( p_stream, "no suitable sout access module for `%s/%s://%s'",
psz_access, psz_mux, psz_url );
- if( psz_access ) free( psz_access );
- if( psz_mux ) free( psz_mux );
+ free( psz_access );
+ free( psz_mux );
return VLC_EGENERIC;
}
msg_Dbg( p_stream, "access opened" );
psz_access, psz_mux, psz_url );
sout_AccessOutDelete( p_access );
- if( psz_access ) free( psz_access );
- if( psz_mux ) free( psz_mux );
+ free( psz_access );
+ free( psz_mux );
return VLC_EGENERIC;
}
msg_Dbg( p_stream, "mux opened" );
{
session_descriptor_t *p_session;
announce_method_t *p_method = sout_SAPMethod ();
- const int payload_type = 33;
static const struct { const char *access; const char *fmt; } fmts[] =
{
- /* TLS/DTLS variants (none implemented): */
- { "dtlslite", "UDPLite/TLS/RTP/AVP %d" },
- { "dtls", "UDP/TLS/RTP/AVP %d" },
- { "dccps", "DCCP/TLS/RTP/AVP %d" },
- { "tls", "TCP/TLS/RTP/AVP %d" },
/* Plain text: */
- { "udplite", "UDPLite/RTP/AVP %d" },
{ "udp", "udp mpeg" },
- { "rtp", "RTP/AVP %d" },
- /* Currently unsupported access outputs: */
- { "dccp", "DCCP/RTP/AVP %d" },
- { "tcp", "TCP/RTP/AVP %d" },
- /* SRTP (none implemented): */
- { "srtp", "RTP/SAVP %d" },
- { "sudplite", "UDPLite/RTP/SAVP %d" },
- { "sdccp", "DCCP/RTP/SAVP %d" },
- { "stcp", "TCP/RTP/SAVP %d" },
+ { "rtp", "RTP/AVP 33" },
{ NULL, NULL }
};
- const char *psz_sdp_fmt = NULL;
- char *fmt, *src, *dst;
+ const char *fmt = NULL;
+ char *src, *dst;
int sport, dport;
for (unsigned i = 0; fmts[i].access != NULL; i++)
if (strncasecmp (fmts[i].access, psz_access, strlen (fmts[i].access)) == 0)
{
- psz_sdp_fmt = fmts[i].fmt;
+ fmt = fmts[i].fmt;
break;
}
sport = var_GetInteger (p_access, "src-port");
dport = var_GetInteger (p_access, "dst-port");
- if ((psz_sdp_fmt == NULL)
- || (asprintf (&fmt, psz_sdp_fmt, payload_type) == -1))
- fmt = NULL;
-
msg_Dbg( p_stream, "SAP advertized format: %s", fmt);
if ((fmt == NULL) || ((src == NULL) && (dst == NULL)))
{
sout_MethodRelease (p_method);
nosap:
- free (fmt);
free (src);
free (dst);
}
p_stream->p_sys->p_mux = p_mux;
- if( psz_access ) free( psz_access );
- if( psz_mux ) free( psz_mux );
- if( psz_url ) free( psz_url );
-
+ free( psz_access );
+ free( psz_mux );
+ free( psz_url );
return VLC_SUCCESS;
}