| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
#ifdef HAVE_CONFIG_H |
|---|
| 28 |
# include "config.h" |
|---|
| 29 |
#endif |
|---|
| 30 |
|
|---|
| 31 |
#ifndef _WIN32_WINNT |
|---|
| 32 |
# define _WIN32_WINNT 0x0500 |
|---|
| 33 |
#endif |
|---|
| 34 |
|
|---|
| 35 |
#include <vlc_common.h> |
|---|
| 36 |
#include <vlc_plugin.h> |
|---|
| 37 |
#include <vlc_sout.h> |
|---|
| 38 |
|
|---|
| 39 |
#include <vlc_network.h> |
|---|
| 40 |
#include "vlc_url.h" |
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
#define ACCESS_TEXT N_("Output access method") |
|---|
| 46 |
#define ACCESS_LONGTEXT N_( \ |
|---|
| 47 |
"Output method to use for the stream." ) |
|---|
| 48 |
#define MUX_TEXT N_("Output muxer") |
|---|
| 49 |
#define MUX_LONGTEXT N_( \ |
|---|
| 50 |
"Muxer to use for the stream." ) |
|---|
| 51 |
#define DEST_TEXT N_("Output destination") |
|---|
| 52 |
#define DEST_LONGTEXT N_( \ |
|---|
| 53 |
"Destination (URL) to use for the stream. Overrides path and bind parameters" ) |
|---|
| 54 |
#define BIND_TEXT N_("address to bind to (helper setting for dst)") |
|---|
| 55 |
#define BIND_LONGTEXT N_( \ |
|---|
| 56 |
"address:port to bind vlc to listening incoming streams "\ |
|---|
| 57 |
"helper setting for dst,dst=bind+'/'+path. dst-parameter overrides this" ) |
|---|
| 58 |
#define PATH_TEXT N_("filename for stream (helper setting for dst)") |
|---|
| 59 |
#define PATH_LONGTEXT N_( \ |
|---|
| 60 |
"Filename for stream "\ |
|---|
| 61 |
"helper setting for dst, dst=bind+'/'+path, dst-parameter overrides this" ) |
|---|
| 62 |
#define NAME_TEXT N_("Session name") |
|---|
| 63 |
#define NAME_LONGTEXT N_( \ |
|---|
| 64 |
"This is the name of the session that will be announced in the SDP " \ |
|---|
| 65 |
"(Session Descriptor)." ) |
|---|
| 66 |
|
|---|
| 67 |
#define GROUP_TEXT N_("Session groupname") |
|---|
| 68 |
#define GROUP_LONGTEXT N_( \ |
|---|
| 69 |
"This allows you to specify a group for the session, that will be announced "\ |
|---|
| 70 |
"if you choose to use SAP." ) |
|---|
| 71 |
|
|---|
| 72 |
#define DESC_TEXT N_("Session description") |
|---|
| 73 |
#define DESC_LONGTEXT N_( \ |
|---|
| 74 |
"This allows you to give a short description with details about the stream, " \ |
|---|
| 75 |
"that will be announced in the SDP (Session Descriptor)." ) |
|---|
| 76 |
#define URL_TEXT N_("Session URL") |
|---|
| 77 |
#define URL_LONGTEXT N_( \ |
|---|
| 78 |
"This allows you to give an URL with more details about the stream " \ |
|---|
| 79 |
"(often the website of the streaming organization), that will " \ |
|---|
| 80 |
"be announced in the SDP (Session Descriptor)." ) |
|---|
| 81 |
#define EMAIL_TEXT N_("Session email") |
|---|
| 82 |
#define EMAIL_LONGTEXT N_( \ |
|---|
| 83 |
"This allows you to give a contact mail address for the stream, that will " \ |
|---|
| 84 |
"be announced in the SDP (Session Descriptor)." ) |
|---|
| 85 |
#define PHONE_TEXT N_("Session phone number") |
|---|
| 86 |
#define PHONE_LONGTEXT N_( \ |
|---|
| 87 |
"This allows you to give a contact telephone number for the stream, that will " \ |
|---|
| 88 |
"be announced in the SDP (Session Descriptor)." ) |
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
#define SAP_TEXT N_("SAP announcing") |
|---|
| 92 |
#define SAP_LONGTEXT N_("Announce this session with SAP.") |
|---|
| 93 |
|
|---|
| 94 |
static int Open ( vlc_object_t * ); |
|---|
| 95 |
static void Close ( vlc_object_t * ); |
|---|
| 96 |
|
|---|
| 97 |
#define SOUT_CFG_PREFIX "sout-standard-" |
|---|
| 98 |
|
|---|
| 99 |
vlc_module_begin(); |
|---|
| 100 |
set_shortname( N_("Standard")); |
|---|
| 101 |
set_description( N_("Standard stream output") ); |
|---|
| 102 |
set_capability( "sout stream", 50 ); |
|---|
| 103 |
add_shortcut( "standard" ); |
|---|
| 104 |
add_shortcut( "std" ); |
|---|
| 105 |
set_category( CAT_SOUT ); |
|---|
| 106 |
set_subcategory( SUBCAT_SOUT_STREAM ); |
|---|
| 107 |
|
|---|
| 108 |
add_string( SOUT_CFG_PREFIX "access", "", NULL, ACCESS_TEXT, |
|---|
| 109 |
ACCESS_LONGTEXT, false ); |
|---|
| 110 |
add_string( SOUT_CFG_PREFIX "mux", "", NULL, MUX_TEXT, |
|---|
| 111 |
MUX_LONGTEXT, false ); |
|---|
| 112 |
add_string( SOUT_CFG_PREFIX "dst", "", NULL, DEST_TEXT, |
|---|
| 113 |
DEST_LONGTEXT, false ); |
|---|
| 114 |
add_string( SOUT_CFG_PREFIX "bind", "", NULL, BIND_TEXT, |
|---|
| 115 |
BIND_LONGTEXT, false ); |
|---|
| 116 |
add_string( SOUT_CFG_PREFIX "path", "", NULL, PATH_TEXT, |
|---|
| 117 |
PATH_LONGTEXT, false ); |
|---|
| 118 |
change_unsafe(); |
|---|
| 119 |
|
|---|
| 120 |
add_bool( SOUT_CFG_PREFIX "sap", false, NULL, SAP_TEXT, SAP_LONGTEXT, |
|---|
| 121 |
true ); |
|---|
| 122 |
add_string( SOUT_CFG_PREFIX "name", "", NULL, NAME_TEXT, NAME_LONGTEXT, |
|---|
| 123 |
true ); |
|---|
| 124 |
add_string( SOUT_CFG_PREFIX "group", "", NULL, GROUP_TEXT, GROUP_LONGTEXT, |
|---|
| 125 |
true ); |
|---|
| 126 |
add_string( SOUT_CFG_PREFIX "description", "", NULL, DESC_TEXT, DESC_LONGTEXT, |
|---|
| 127 |
true ); |
|---|
| 128 |
add_string( SOUT_CFG_PREFIX "url", "", NULL, URL_TEXT, URL_LONGTEXT, |
|---|
| 129 |
true ); |
|---|
| 130 |
add_string( SOUT_CFG_PREFIX "email", "", NULL, EMAIL_TEXT, EMAIL_LONGTEXT, |
|---|
| 131 |
true ); |
|---|
| 132 |
add_string( SOUT_CFG_PREFIX "phone", "", NULL, PHONE_TEXT, PHONE_LONGTEXT, |
|---|
| 133 |
true ); |
|---|
| 134 |
add_obsolete_bool( SOUT_CFG_PREFIX "sap-ipv6" ); |
|---|
| 135 |
|
|---|
| 136 |
set_callbacks( Open, Close ); |
|---|
| 137 |
vlc_module_end(); |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
static const char *const ppsz_sout_options[] = { |
|---|
| 144 |
"access", "mux", "url", "dst", |
|---|
| 145 |
"sap", "name", "group", "description", "url", "email", "phone", |
|---|
| 146 |
"bind", "path", NULL |
|---|
| 147 |
}; |
|---|
| 148 |
|
|---|
| 149 |
#define DEFAULT_PORT 1234 |
|---|
| 150 |
|
|---|
| 151 |
static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * ); |
|---|
| 152 |
static int Del ( sout_stream_t *, sout_stream_id_t * ); |
|---|
| 153 |
static int Send( sout_stream_t *, sout_stream_id_t *, block_t* ); |
|---|
| 154 |
|
|---|
| 155 |
struct sout_stream_sys_t |
|---|
| 156 |
{ |
|---|
| 157 |
sout_mux_t *p_mux; |
|---|
| 158 |
session_descriptor_t *p_session; |
|---|
| 159 |
}; |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
static int Open( vlc_object_t *p_this ) |
|---|
| 165 |
{ |
|---|
| 166 |
sout_stream_t *p_stream = (sout_stream_t*)p_this; |
|---|
| 167 |
sout_instance_t *p_sout = p_stream->p_sout; |
|---|
| 168 |
sout_stream_sys_t *p_sys; |
|---|
| 169 |
|
|---|
| 170 |
char *psz_mux; |
|---|
| 171 |
char *psz_access; |
|---|
| 172 |
char *psz_url=NULL; |
|---|
| 173 |
char *psz_bind; |
|---|
| 174 |
char *psz_path; |
|---|
| 175 |
|
|---|
| 176 |
vlc_value_t val; |
|---|
| 177 |
|
|---|
| 178 |
sout_access_out_t *p_access; |
|---|
| 179 |
sout_mux_t *p_mux; |
|---|
| 180 |
|
|---|
| 181 |
const char *psz_mux_byext = NULL; |
|---|
| 182 |
|
|---|
| 183 |
config_ChainParse( p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, |
|---|
| 184 |
p_stream->p_cfg ); |
|---|
| 185 |
|
|---|
| 186 |
var_Get( p_stream, SOUT_CFG_PREFIX "access", &val ); |
|---|
| 187 |
psz_access = *val.psz_string ? val.psz_string : NULL; |
|---|
| 188 |
if( !*val.psz_string ) free( val.psz_string ); |
|---|
| 189 |
|
|---|
| 190 |
var_Get( p_stream, SOUT_CFG_PREFIX "mux", &val ); |
|---|
| 191 |
psz_mux = *val.psz_string ? val.psz_string : NULL; |
|---|
| 192 |
if( !*val.psz_string ) free( val.psz_string ); |
|---|
| 193 |
|
|---|
| 194 |
var_Get( p_stream, SOUT_CFG_PREFIX "bind", &val ); |
|---|
| 195 |
psz_bind = *val.psz_string ? val.psz_string : NULL; |
|---|
| 196 |
if( !*val.psz_string ) free( val.psz_string); |
|---|
| 197 |
|
|---|
| 198 |
var_Get( p_stream, SOUT_CFG_PREFIX "path", &val ); |
|---|
| 199 |
psz_path = *val.psz_string ? val.psz_string : NULL; |
|---|
| 200 |
if( !*val.psz_string ) free( val.psz_string); |
|---|
| 201 |
|
|---|
| 202 |
if( psz_bind ) psz_url = psz_bind; |
|---|
| 203 |
if( psz_url && psz_path ) |
|---|
| 204 |
{ |
|---|
| 205 |
if( asprintf( &psz_url,"%s/%s",psz_url,psz_path ) == -1 ) |
|---|
| 206 |
psz_url = NULL; |
|---|
| 207 |
free( psz_path ); |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
var_Get( p_stream, SOUT_CFG_PREFIX "dst", &val ); |
|---|
| 211 |
if( *val.psz_string ) |
|---|
| 212 |
{ |
|---|
| 213 |
free( psz_url); |
|---|
| 214 |
psz_url = val.psz_string; |
|---|
| 215 |
} |
|---|
| 216 |
else |
|---|
| 217 |
free( val.psz_string ); |
|---|
| 218 |
|
|---|
| 219 |
p_sys = p_stream->p_sys = malloc( sizeof( sout_stream_sys_t) ); |
|---|
| 220 |
if( !p_sys ) |
|---|
| 221 |
{ |
|---|
| 222 |
free( psz_url ); |
|---|
| 223 |
return VLC_ENOMEM; |
|---|
| 224 |
} |
|---|
| 225 |
p_stream->p_sys->p_session = NULL; |
|---|
| 226 |
|
|---|
| 227 |
msg_Dbg( p_this, "creating `%s/%s://%s'", psz_access, psz_mux, psz_url ); |
|---|
| 228 |
|
|---|
| 229 |
|
|---|
| 230 |
if( psz_url && strrchr( psz_url, '.' ) ) |
|---|
| 231 |
{ |
|---|
| 232 |
|
|---|
| 233 |
static struct { const char ext[6]; const char mux[32]; } exttomux[] = |
|---|
| 234 |
{ |
|---|
| 235 |
{ "avi", "avi" }, |
|---|
| 236 |
{ "ogg", "ogg" }, |
|---|
| 237 |
{ "ogm", "ogg" }, |
|---|
| 238 |
{ "mp4", "mp4" }, |
|---|
| 239 |
{ "mov", "mov" }, |
|---|
| 240 |
{ "moov","mov" }, |
|---|
| 241 |
{ "asf", "asf" }, |
|---|
| 242 |
{ "wma", "asf" }, |
|---|
| 243 |
{ "wmv", "asf" }, |
|---|
| 244 |
{ "trp", "ts" }, |
|---|
| 245 |
{ "ts", "ts" }, |
|---|
| 246 |
{ "mpg", "ps" }, |
|---|
| 247 |
{ "mpeg","ps" }, |
|---|
| 248 |
{ "ps", "ps" }, |
|---|
| 249 |
{ "mpeg1","mpeg1" }, |
|---|
| 250 |
{ "wav", "wav" }, |
|---|
| 251 |
{ "flv", "ffmpeg{mux=flv}" }, |
|---|
| 252 |
{ "mkv", "ffmpeg{mux=matroska}"}, |
|---|
| 253 |
{ "", "" } |
|---|
| 254 |
}; |
|---|
| 255 |
const char *psz_ext = strrchr( psz_url, '.' ) + 1; |
|---|
| 256 |
int i; |
|---|
| 257 |
|
|---|
| 258 |
msg_Dbg( p_this, "extension is %s", psz_ext ); |
|---|
| 259 |
for( i = 0; exttomux[i].ext[0]; i++ ) |
|---|
| 260 |
{ |
|---|
| 261 |
if( !strcasecmp( psz_ext, exttomux[i].ext ) ) |
|---|
| 262 |
{ |
|---|
| 263 |
psz_mux_byext = exttomux[i].mux; |
|---|
| 264 |
break; |
|---|
| 265 |
} |
|---|
| 266 |
} |
|---|
| 267 |
msg_Dbg( p_this, "extension -> mux=%s", psz_mux_byext ); |
|---|
| 268 |
} |
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
if( !psz_access && !psz_mux ) |
|---|
| 273 |
{ |
|---|
| 274 |
if( psz_mux_byext ) |
|---|
| 275 |
{ |
|---|
| 276 |
msg_Warn( p_stream, |
|---|
| 277 |
"no access _and_ no muxer, extension gives file/%s", |
|---|
| 278 |
psz_mux_byext ); |
|---|
| 279 |
psz_access = strdup("file"); |
|---|
| 280 |
psz_mux = strdup(psz_mux_byext); |
|---|
| 281 |
} |
|---|
| 282 |
else |
|---|
| 283 |
{ |
|---|
| 284 |
msg_Err( p_stream, "no access _and_ no muxer (fatal error)" ); |
|---|
| 285 |
free( psz_url ); |
|---|
| 286 |
free( p_sys ); |
|---|
| 287 |
return VLC_EGENERIC; |
|---|
| 288 |
} |
|---|
| 289 |
} |
|---|
| 290 |
|
|---|
| 291 |
if( psz_access && !psz_mux ) |
|---|
| 292 |
{ |
|---|
| 293 |
|
|---|
| 294 |
if( !strncmp( psz_access, "mmsh", 4 ) ) |
|---|
| 295 |
{ |
|---|
| 296 |
psz_mux = strdup("asfh"); |
|---|
| 297 |
} |
|---|
| 298 |
else if (!strcmp (psz_access, "udp")) |
|---|
| 299 |
{ |
|---|
| 300 |
psz_mux = strdup("ts"); |
|---|
| 301 |
} |
|---|
| 302 |
else if( psz_mux_byext ) |
|---|
| 303 |
{ |
|---|
| 304 |
psz_mux = strdup(psz_mux_byext); |
|---|
| 305 |
} |
|---|
| 306 |
else |
|---|
| 307 |
{ |
|---|
| 308 |
msg_Err( p_stream, "no mux specified or found by extension" ); |
|---|
| 309 |
free( p_sys ); |
|---|
| 310 |
return VLC_EGENERIC; |
|---|
| 311 |
} |
|---|
| 312 |
} |
|---|
| 313 |
else if( psz_mux && !psz_access ) |
|---|
| 314 |
{ |
|---|
| 315 |
|
|---|
| 316 |
if( !strncmp( psz_mux, "asfh", 4 ) ) |
|---|
| 317 |
{ |
|---|
| 318 |
psz_access = strdup("mmsh"); |
|---|
| 319 |
} |
|---|
| 320 |
else |
|---|
| 321 |
{ |
|---|
| 322 |
|
|---|
| 323 |
psz_access = strdup("file"); |
|---|
| 324 |
} |
|---|
| 325 |
} |
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
if( !strncmp( psz_access, "mmsh", 4 ) && |
|---|
| 329 |
strncmp( psz_mux, "asfh", 4 ) ) |
|---|
| 330 |
{ |
|---|
| 331 |
char *p = strchr( psz_mux,'{' ); |
|---|
| 332 |
|
|---|
| 333 |
msg_Warn( p_stream, "fixing to mmsh/asfh" ); |
|---|
| 334 |
if( p ) |
|---|
| 335 |
{ |
|---|
| 336 |
if( asprintf( &p, "asfh%s", p ) == -1 ) |
|---|
| 337 |
p = NULL; |
|---|
| 338 |
free( psz_mux ); |
|---|
| 339 |
psz_mux = p; |
|---|
| 340 |
} |
|---|
| 341 |
else |
|---|
| 342 |
{ |
|---|
| 343 |
free( psz_mux ); |
|---|
| 344 |
psz_mux = strdup("asfh"); |
|---|
| 345 |
} |
|---|
| 346 |
} |
|---|
| 347 |
else if( !strncmp( psz_access, "udp", 3 ) ) |
|---|
| 348 |
{ |
|---|
| 349 |
if( !strncmp( psz_mux, "ffmpeg", 6 ) ) |
|---|
| 350 |
{ |
|---|
| 351 |
char *psz_ffmpeg_mux = var_CreateGetString( p_this, "ffmpeg-mux" ); |
|---|
| 352 |
if( !psz_ffmpeg_mux || strncmp( psz_ffmpeg_mux, "mpegts", 6 ) ) |
|---|
| 353 |
msg_Err( p_stream, "UDP is only valid with TS" ); |
|---|
| 354 |
free( psz_ffmpeg_mux ); |
|---|
| 355 |
} |
|---|
| 356 |
else if( strncmp( psz_mux, "ts", 2 ) ) |
|---|
| 357 |
{ |
|---|
| 358 |
msg_Err( p_stream, "UDP is only valid with TS" ); |
|---|
| 359 |
} |
|---|
| 360 |
} |
|---|
| 361 |
else if( strncmp( psz_access, "file", 4 ) && |
|---|
| 362 |
( !strncmp( psz_mux, "mov", 3 ) || |
|---|
| 363 |
!strncmp( psz_mux, "mp4", 3 ) ) ) |
|---|
| 364 |
{ |
|---|
| 365 |
msg_Err( p_stream, "mov and mp4 work only with file output" ); |
|---|
| 366 |
} |
|---|
| 367 |
|
|---|
| 368 |
msg_Dbg( p_this, "using `%s/%s://%s'", psz_access, psz_mux, psz_url ); |
|---|
| 369 |
|
|---|
| 370 |
|
|---|
| 371 |
p_access = sout_AccessOutNew( p_sout, psz_access, psz_url ); |
|---|
| 372 |
if( p_access == NULL ) |
|---|
| 373 |
{ |
|---|
| 374 |
msg_Err( p_stream, "no suitable sout access module for `%s/%s://%s'", |
|---|
| 375 |
psz_access, psz_mux, psz_url ); |
|---|
| 376 |
free( psz_access ); |
|---|
| 377 |
free( psz_mux ); |
|---|
| 378 |
free( psz_url ); |
|---|
| 379 |
free( p_sys ); |
|---|
| 380 |
return VLC_EGENERIC; |
|---|
| 381 |
} |
|---|
| 382 |
msg_Dbg( p_stream, "access opened" ); |
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 |
p_mux = sout_MuxNew( p_sout, psz_mux, p_access ); |
|---|
| 386 |
if( p_mux == NULL ) |
|---|
| 387 |
{ |
|---|
| 388 |
msg_Err( p_stream, "no suitable sout mux module for `%s/%s://%s'", |
|---|
| 389 |
psz_access, psz_mux, psz_url ); |
|---|
| 390 |
|
|---|
| 391 |
sout_AccessOutDelete( p_access ); |
|---|
| 392 |
free( psz_access ); |
|---|
| 393 |
free( psz_mux ); |
|---|
| 394 |
free( psz_url ); |
|---|
| 395 |
free( p_sys ); |
|---|
| 396 |
return VLC_EGENERIC; |
|---|
| 397 |
} |
|---|
| 398 |
msg_Dbg( p_stream, "mux opened" ); |
|---|
| 399 |
|
|---|
| 400 |
|
|---|
| 401 |
if( var_GetBool( p_stream, SOUT_CFG_PREFIX"sap" ) ) |
|---|
| 402 |
{ |
|---|
| 403 |
|
|---|
| 404 |
static const struct addrinfo hints = { |
|---|
| 405 |
.ai_family = AF_UNSPEC, |
|---|
| 406 |
.ai_socktype = SOCK_DGRAM, |
|---|
| 407 |
.ai_protocol = 0, |
|---|
| 408 |
.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV |
|---|
| 409 |
}; |
|---|
| 410 |
char *shost = var_GetNonEmptyString (p_access, "src-addr"); |
|---|
| 411 |
char *dhost = var_GetNonEmptyString (p_access, "dst-addr"); |
|---|
| 412 |
int sport = var_GetInteger (p_access, "src-port"); |
|---|
| 413 |
int dport = var_GetInteger (p_access, "dst-port"); |
|---|
| 414 |
struct sockaddr_storage src, dst; |
|---|
| 415 |
socklen_t srclen = 0, dstlen = 0; |
|---|
| 416 |
struct addrinfo *res; |
|---|
| 417 |
|
|---|
| 418 |
if ( vlc_getaddrinfo ( VLC_OBJECT(p_stream), dhost, dport, &hints, &res) == 0) |
|---|
| 419 |
{ |
|---|
| 420 |
memcpy (&dst, res->ai_addr, dstlen = res->ai_addrlen); |
|---|
| 421 |
vlc_freeaddrinfo (res); |
|---|
| 422 |
} |
|---|
| 423 |
|
|---|
| 424 |
if (vlc_getaddrinfo ( VLC_OBJECT(p_stream), shost, sport, &hints, &res) == 0) |
|---|
| 425 |
{ |
|---|
| 426 |
memcpy (&src, res->ai_addr, srclen = res->ai_addrlen); |
|---|
| 427 |
vlc_freeaddrinfo (res); |
|---|
| 428 |
} |
|---|
| 429 |
|
|---|
| 430 |
char *head = vlc_sdp_Start (VLC_OBJECT (p_stream), SOUT_CFG_PREFIX, |
|---|
| 431 |
(struct sockaddr *)&src, srclen, |
|---|
| 432 |
(struct sockaddr *)&dst, dstlen); |
|---|
| 433 |
free (shost); |
|---|
| 434 |
|
|---|
| 435 |
char *psz_sdp = NULL; |
|---|
| 436 |
if (head != NULL) |
|---|
| 437 |
{ |
|---|
| 438 |
if (asprintf (&psz_sdp, "%s" |
|---|
| 439 |
"m=video %d udp mpeg\r\n", head, dport) == -1) |
|---|
| 440 |
psz_sdp = NULL; |
|---|
| 441 |
free (head); |
|---|
| 442 |
} |
|---|
| 443 |
|
|---|
| 444 |
|
|---|
| 445 |
if (psz_sdp != NULL) |
|---|
| 446 |
{ |
|---|
| 447 |
announce_method_t *p_method = sout_SAPMethod (); |
|---|
| 448 |
msg_Dbg (p_stream, "Generated SDP:\n%s", psz_sdp); |
|---|
| 449 |
|
|---|
| 450 |
p_sys->p_session = |
|---|
| 451 |
sout_AnnounceRegisterSDP (p_sout, psz_sdp, dhost, p_method); |
|---|
| 452 |
sout_MethodRelease (p_method); |
|---|
| 453 |
free( psz_sdp ); |
|---|
| 454 |
} |
|---|
| 455 |
free (dhost); |
|---|
| 456 |
} |
|---|
| 457 |
|
|---|
| 458 |
p_stream->pf_add = Add; |
|---|
| 459 |
p_stream->pf_del = Del; |
|---|
| 460 |
p_stream->pf_send = Send; |
|---|
| 461 |
|
|---|
| 462 |
p_sys->p_mux = p_mux; |
|---|
| 463 |
|
|---|
| 464 |
free( psz_access ); |
|---|
| 465 |
free( psz_mux ); |
|---|
| 466 |
free( psz_url ); |
|---|
| 467 |
|
|---|
| 468 |
if( !sout_AccessOutCanControlPace( p_access ) ) |
|---|
| 469 |
p_sout->i_out_pace_nocontrol++; |
|---|
| 470 |
|
|---|
| 471 |
return VLC_SUCCESS; |
|---|
| 472 |
} |
|---|
| 473 |
|
|---|
| 474 |
|
|---|
| 475 |
|
|---|
| 476 |
|
|---|
| 477 |
static void Close( vlc_object_t * p_this ) |
|---|
| 478 |
{ |
|---|
| 479 |
sout_stream_t *p_stream = (sout_stream_t*)p_this; |
|---|
| 480 |
sout_stream_sys_t *p_sys = p_stream->p_sys; |
|---|
| 481 |
sout_access_out_t *p_access = p_sys->p_mux->p_access; |
|---|
| 482 |
|
|---|
| 483 |
if( p_sys->p_session != NULL ) |
|---|
| 484 |
sout_AnnounceUnRegister( p_stream->p_sout, p_sys->p_session ); |
|---|
| 485 |
|
|---|
| 486 |
sout_MuxDelete( p_sys->p_mux ); |
|---|
| 487 |
if( !sout_AccessOutCanControlPace( p_access ) ) |
|---|
| 488 |
p_stream->p_sout->i_out_pace_nocontrol--; |
|---|
| 489 |
sout_AccessOutDelete( p_access ); |
|---|
| 490 |
|
|---|
| 491 |
free( p_sys ); |
|---|
| 492 |
} |
|---|
| 493 |
|
|---|
| 494 |
struct sout_stream_id_t |
|---|
| 495 |
{ |
|---|
| 496 |
sout_input_t *p_input; |
|---|
| 497 |
}; |
|---|
| 498 |
|
|---|
| 499 |
|
|---|
| 500 |
static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) |
|---|
| 501 |
{ |
|---|
| 502 |
sout_stream_sys_t *p_sys = p_stream->p_sys; |
|---|
| 503 |
sout_stream_id_t *id; |
|---|
| 504 |
|
|---|
| 505 |
id = malloc( sizeof( sout_stream_id_t ) ); |
|---|
| 506 |
if( !id ) |
|---|
| 507 |
return NULL; |
|---|
| 508 |
|
|---|
| 509 |
if( ( id->p_input = sout_MuxAddStream( p_sys->p_mux, p_fmt ) ) == NULL ) |
|---|
| 510 |
{ |
|---|
| 511 |
free( id ); |
|---|
| 512 |
return NULL; |
|---|
| 513 |
} |
|---|
| 514 |
|
|---|
| 515 |
return id; |
|---|
| 516 |
} |
|---|
| 517 |
|
|---|
| 518 |
static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) |
|---|
| 519 |
{ |
|---|
| 520 |
sout_stream_sys_t *p_sys = p_stream->p_sys; |
|---|
| 521 |
|
|---|
| 522 |
sout_MuxDeleteStream( p_sys->p_mux, id->p_input ); |
|---|
| 523 |
|
|---|
| 524 |
free( id ); |
|---|
| 525 |
|
|---|
| 526 |
return VLC_SUCCESS; |
|---|
| 527 |
} |
|---|
| 528 |
|
|---|
| 529 |
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, |
|---|
| 530 |
block_t *p_buffer ) |
|---|
| 531 |
{ |
|---|
| 532 |
sout_stream_sys_t *p_sys = p_stream->p_sys; |
|---|
| 533 |
|
|---|
| 534 |
sout_MuxSendBuffer( p_sys->p_mux, id->p_input, p_buffer ); |
|---|
| 535 |
|
|---|
| 536 |
return VLC_SUCCESS; |
|---|
| 537 |
} |
|---|