| 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 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
#ifdef HAVE_CONFIG_H |
|---|
| 102 |
# include "config.h" |
|---|
| 103 |
#endif |
|---|
| 104 |
|
|---|
| 105 |
#include <vlc_common.h> |
|---|
| 106 |
#include <vlc_demux.h> |
|---|
| 107 |
#include "playlist.h" |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
#define MAX_LINE 1024 |
|---|
| 113 |
|
|---|
| 114 |
struct demux_sys_t |
|---|
| 115 |
{ |
|---|
| 116 |
char *psz_uri; |
|---|
| 117 |
char *psz_server; |
|---|
| 118 |
char *psz_location; |
|---|
| 119 |
char *psz_name; |
|---|
| 120 |
char *psz_user; |
|---|
| 121 |
char *psz_password; |
|---|
| 122 |
char *psz_mcast_ip; |
|---|
| 123 |
int i_mcast_port; |
|---|
| 124 |
int i_packet_size; |
|---|
| 125 |
mtime_t i_duration; |
|---|
| 126 |
int i_port; |
|---|
| 127 |
int i_sid; |
|---|
| 128 |
bool b_concert; |
|---|
| 129 |
bool b_rtsp_kasenna; |
|---|
| 130 |
}; |
|---|
| 131 |
|
|---|
| 132 |
static int Demux ( demux_t *p_demux ); |
|---|
| 133 |
static int Control( demux_t *p_demux, int i_query, va_list args ); |
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
int Import_SGIMB( vlc_object_t * p_this ) |
|---|
| 139 |
{ |
|---|
| 140 |
demux_t *p_demux = (demux_t *)p_this; |
|---|
| 141 |
const uint8_t *p_peek; |
|---|
| 142 |
int i_size; |
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
i_size = stream_Peek( p_demux->s, &p_peek, MAX_LINE ); |
|---|
| 146 |
i_size -= sizeof("sgiNameServerHost=") - 1; |
|---|
| 147 |
if ( i_size > 0 ) |
|---|
| 148 |
{ |
|---|
| 149 |
unsigned int i_len = sizeof("sgiNameServerHost=") - 1; |
|---|
| 150 |
while ( i_size && strncasecmp( (char *)p_peek, "sgiNameServerHost=", i_len ) ) |
|---|
| 151 |
{ |
|---|
| 152 |
p_peek++; |
|---|
| 153 |
i_size--; |
|---|
| 154 |
} |
|---|
| 155 |
if ( !strncasecmp( (char *)p_peek, "sgiNameServerHost=", i_len ) ) |
|---|
| 156 |
{ |
|---|
| 157 |
STANDARD_DEMUX_INIT_MSG( "using SGIMB playlist reader" ); |
|---|
| 158 |
p_demux->p_sys->psz_uri = NULL; |
|---|
| 159 |
p_demux->p_sys->psz_server = NULL; |
|---|
| 160 |
p_demux->p_sys->psz_location = NULL; |
|---|
| 161 |
p_demux->p_sys->psz_name = NULL; |
|---|
| 162 |
p_demux->p_sys->psz_user = NULL; |
|---|
| 163 |
p_demux->p_sys->psz_password = NULL; |
|---|
| 164 |
p_demux->p_sys->psz_mcast_ip = NULL; |
|---|
| 165 |
p_demux->p_sys->i_mcast_port = 0; |
|---|
| 166 |
p_demux->p_sys->i_packet_size = 0; |
|---|
| 167 |
p_demux->p_sys->i_duration = 0; |
|---|
| 168 |
p_demux->p_sys->i_port = 0; |
|---|
| 169 |
p_demux->p_sys->i_sid = 0; |
|---|
| 170 |
p_demux->p_sys->b_rtsp_kasenna = false; |
|---|
| 171 |
p_demux->p_sys->b_concert = false; |
|---|
| 172 |
|
|---|
| 173 |
return VLC_SUCCESS; |
|---|
| 174 |
} |
|---|
| 175 |
} |
|---|
| 176 |
return VLC_EGENERIC; |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
void Close_SGIMB( vlc_object_t *p_this ) |
|---|
| 183 |
{ |
|---|
| 184 |
demux_t *p_demux = (demux_t*)p_this; |
|---|
| 185 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 186 |
free( p_sys->psz_uri ); |
|---|
| 187 |
free( p_sys->psz_server ); |
|---|
| 188 |
free( p_sys->psz_location ); |
|---|
| 189 |
free( p_sys->psz_name ); |
|---|
| 190 |
free( p_sys->psz_user ); |
|---|
| 191 |
free( p_sys->psz_password ); |
|---|
| 192 |
free( p_sys->psz_mcast_ip ); |
|---|
| 193 |
free( p_demux->p_sys ); |
|---|
| 194 |
return; |
|---|
| 195 |
} |
|---|
| 196 |
|
|---|
| 197 |
static int ParseLine ( demux_t *p_demux, char *psz_line ) |
|---|
| 198 |
{ |
|---|
| 199 |
char *psz_bol; |
|---|
| 200 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 201 |
|
|---|
| 202 |
psz_bol = psz_line; |
|---|
| 203 |
|
|---|
| 204 |
|
|---|
| 205 |
while( *psz_bol == ' ' || *psz_bol == '\t' || |
|---|
| 206 |
*psz_bol == '\n' || *psz_bol == '\r' ) |
|---|
| 207 |
{ |
|---|
| 208 |
psz_bol++; |
|---|
| 209 |
} |
|---|
| 210 |
|
|---|
| 211 |
if( !strncasecmp( psz_bol, "rtsp://", sizeof("rtsp://") - 1 ) ) |
|---|
| 212 |
{ |
|---|
| 213 |
|
|---|
| 214 |
p_sys->psz_uri = strdup( psz_bol ); |
|---|
| 215 |
} |
|---|
| 216 |
else if( !strncasecmp( psz_bol, "Stream=\"", sizeof("Stream=\"") - 1 ) ) |
|---|
| 217 |
{ |
|---|
| 218 |
psz_bol += sizeof("Stream=\"") - 1; |
|---|
| 219 |
if ( !psz_bol ) |
|---|
| 220 |
return 0; |
|---|
| 221 |
strrchr( psz_bol, '"' )[0] = '\0'; |
|---|
| 222 |
|
|---|
| 223 |
if( !strncasecmp( psz_bol, "xdma://", sizeof("xdma://") - 1 ) ) |
|---|
| 224 |
{ |
|---|
| 225 |
psz_bol[0] = 'r'; |
|---|
| 226 |
psz_bol[1] = 't'; |
|---|
| 227 |
psz_bol[2] = 's'; |
|---|
| 228 |
psz_bol[3] = 'p'; |
|---|
| 229 |
} |
|---|
| 230 |
p_sys->psz_uri = strdup( psz_bol ); |
|---|
| 231 |
} |
|---|
| 232 |
else if( !strncasecmp( psz_bol, "sgiNameServerHost=", sizeof("sgiNameServerHost=") - 1 ) ) |
|---|
| 233 |
{ |
|---|
| 234 |
psz_bol += sizeof("sgiNameServerHost=") - 1; |
|---|
| 235 |
p_sys->psz_server = strdup( psz_bol ); |
|---|
| 236 |
} |
|---|
| 237 |
else if( !strncasecmp( psz_bol, "sgiMovieName=", sizeof("sgiMovieName=") - 1 ) ) |
|---|
| 238 |
{ |
|---|
| 239 |
psz_bol += sizeof("sgiMovieName=") - 1; |
|---|
| 240 |
p_sys->psz_location = strdup( psz_bol ); |
|---|
| 241 |
} |
|---|
| 242 |
else if( !strncasecmp( psz_bol, "sgiUserAccount=", sizeof("sgiUserAccount=") - 1 ) ) |
|---|
| 243 |
{ |
|---|
| 244 |
psz_bol += sizeof("sgiUserAccount=") - 1; |
|---|
| 245 |
p_sys->psz_user = strdup( psz_bol ); |
|---|
| 246 |
} |
|---|
| 247 |
else if( !strncasecmp( psz_bol, "sgiUserPassword=", sizeof("sgiUserPassword=") - 1 ) ) |
|---|
| 248 |
{ |
|---|
| 249 |
psz_bol += sizeof("sgiUserPassword=") - 1; |
|---|
| 250 |
p_sys->psz_password = strdup( psz_bol ); |
|---|
| 251 |
} |
|---|
| 252 |
else if( !strncasecmp( psz_bol, "sgiShowingName=", sizeof("sgiShowingName=") - 1 ) ) |
|---|
| 253 |
{ |
|---|
| 254 |
psz_bol += sizeof("sgiShowingName=") - 1; |
|---|
| 255 |
p_sys->psz_name = strdup( psz_bol ); |
|---|
| 256 |
} |
|---|
| 257 |
else if( !strncasecmp( psz_bol, "sgiFormatName=", sizeof("sgiFormatName=") - 1 ) ) |
|---|
| 258 |
{ |
|---|
| 259 |
psz_bol += sizeof("sgiFormatName=") - 1; |
|---|
| 260 |
if( strcasestr( psz_bol, "MPEG-4") == NULL ) |
|---|
| 261 |
p_sys->b_rtsp_kasenna = true; |
|---|
| 262 |
} |
|---|
| 263 |
else if( !strncasecmp( psz_bol, "sgiMulticastAddress=", sizeof("sgiMulticastAddress=") - 1 ) ) |
|---|
| 264 |
{ |
|---|
| 265 |
psz_bol += sizeof("sgiMulticastAddress=") - 1; |
|---|
| 266 |
p_sys->psz_mcast_ip = strdup( psz_bol ); |
|---|
| 267 |
} |
|---|
| 268 |
else if( !strncasecmp( psz_bol, "sgiMulticastPort=", sizeof("sgiMulticastPort=") - 1 ) ) |
|---|
| 269 |
{ |
|---|
| 270 |
psz_bol += sizeof("sgiMulticastPort=") - 1; |
|---|
| 271 |
p_sys->i_mcast_port = (int) strtol( psz_bol, NULL, 0 ); |
|---|
| 272 |
} |
|---|
| 273 |
else if( !strncasecmp( psz_bol, "sgiPacketSize=", sizeof("sgiPacketSize=") - 1 ) ) |
|---|
| 274 |
{ |
|---|
| 275 |
psz_bol += sizeof("sgiPacketSize=") - 1; |
|---|
| 276 |
p_sys->i_packet_size = (int) strtol( psz_bol, NULL, 0 ); |
|---|
| 277 |
} |
|---|
| 278 |
else if( !strncasecmp( psz_bol, "sgiDuration=", sizeof("sgiDuration=") - 1 ) ) |
|---|
| 279 |
{ |
|---|
| 280 |
psz_bol += sizeof("sgiDuration=") - 1; |
|---|
| 281 |
p_sys->i_duration = (mtime_t) strtol( psz_bol, NULL, 0 ); |
|---|
| 282 |
} |
|---|
| 283 |
else if( !strncasecmp( psz_bol, "sgiRtspPort=", sizeof("sgiRtspPort=") - 1 ) ) |
|---|
| 284 |
{ |
|---|
| 285 |
psz_bol += sizeof("sgiRtspPort=") - 1; |
|---|
| 286 |
p_sys->i_port = (int) strtol( psz_bol, NULL, 0 ); |
|---|
| 287 |
} |
|---|
| 288 |
else if( !strncasecmp( psz_bol, "sgiSid=", sizeof("sgiSid=") - 1 ) ) |
|---|
| 289 |
{ |
|---|
| 290 |
psz_bol += sizeof("sgiSid=") - 1; |
|---|
| 291 |
p_sys->i_sid = (int) strtol( psz_bol, NULL, 0 ); |
|---|
| 292 |
} |
|---|
| 293 |
else if( !strncasecmp( psz_bol, "DeliveryService=cds", sizeof("DeliveryService=cds") - 1 ) ) |
|---|
| 294 |
{ |
|---|
| 295 |
p_sys->b_concert = true; |
|---|
| 296 |
} |
|---|
| 297 |
else |
|---|
| 298 |
{ |
|---|
| 299 |
|
|---|
| 300 |
return 0; |
|---|
| 301 |
} |
|---|
| 302 |
return VLC_SUCCESS; |
|---|
| 303 |
} |
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 |
static int Demux ( demux_t *p_demux ) |
|---|
| 311 |
{ |
|---|
| 312 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 313 |
input_item_t *p_child = NULL; |
|---|
| 314 |
char *psz_line; |
|---|
| 315 |
|
|---|
| 316 |
INIT_PLAYLIST_STUFF; |
|---|
| 317 |
|
|---|
| 318 |
while( ( psz_line = stream_ReadLine( p_demux->s ) ) ) |
|---|
| 319 |
{ |
|---|
| 320 |
ParseLine( p_demux, psz_line ); |
|---|
| 321 |
free( psz_line ); |
|---|
| 322 |
} |
|---|
| 323 |
|
|---|
| 324 |
if( p_sys->psz_mcast_ip ) |
|---|
| 325 |
{ |
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
free( p_sys->psz_uri ); |
|---|
| 329 |
if( asprintf( &p_sys->psz_uri, "udp://@" "%s:%i", p_sys->psz_mcast_ip, p_sys->i_mcast_port ) == -1 ) |
|---|
| 330 |
{ |
|---|
| 331 |
p_sys->psz_uri = NULL; |
|---|
| 332 |
return -1; |
|---|
| 333 |
} |
|---|
| 334 |
} |
|---|
| 335 |
|
|---|
| 336 |
if( p_sys->psz_uri == NULL ) |
|---|
| 337 |
{ |
|---|
| 338 |
if( p_sys->psz_server && p_sys->psz_location ) |
|---|
| 339 |
{ |
|---|
| 340 |
if( asprintf( &p_sys->psz_uri, "rtsp://" "%s:%i%s", |
|---|
| 341 |
p_sys->psz_server, p_sys->i_port > 0 ? p_sys->i_port : 554, p_sys->psz_location ) == -1 ) |
|---|
| 342 |
{ |
|---|
| 343 |
p_sys->psz_uri = NULL; |
|---|
| 344 |
return -1; |
|---|
| 345 |
} |
|---|
| 346 |
} |
|---|
| 347 |
} |
|---|
| 348 |
|
|---|
| 349 |
if( p_sys->b_concert ) |
|---|
| 350 |
{ |
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 |
if( p_sys->psz_uri == NULL ) |
|---|
| 354 |
{ |
|---|
| 355 |
msg_Err( p_demux, "no URI was found" ); |
|---|
| 356 |
return -1; |
|---|
| 357 |
} |
|---|
| 358 |
|
|---|
| 359 |
free( p_sys->psz_uri ); |
|---|
| 360 |
if( asprintf( &p_sys->psz_uri, "%s%%3FMeDiAbAsEshowingId=%d%%26MeDiAbAsEconcert%%3FMeDiAbAsE", |
|---|
| 361 |
p_sys->psz_uri, p_sys->i_sid ) == -1 ) |
|---|
| 362 |
{ |
|---|
| 363 |
p_sys->psz_uri = NULL; |
|---|
| 364 |
return -1; |
|---|
| 365 |
} |
|---|
| 366 |
} |
|---|
| 367 |
|
|---|
| 368 |
p_child = input_item_NewWithType( VLC_OBJECT(p_demux), p_sys->psz_uri, |
|---|
| 369 |
p_sys->psz_name ? p_sys->psz_name : p_sys->psz_uri, |
|---|
| 370 |
0, NULL, p_sys->i_duration, ITEM_TYPE_NET ); |
|---|
| 371 |
|
|---|
| 372 |
if( !p_child ) |
|---|
| 373 |
{ |
|---|
| 374 |
msg_Err( p_demux, "A valid playlistitem could not be created" ); |
|---|
| 375 |
return -1; |
|---|
| 376 |
} |
|---|
| 377 |
|
|---|
| 378 |
input_item_CopyOptions( p_current_input, p_child ); |
|---|
| 379 |
if( p_sys->i_packet_size && p_sys->psz_mcast_ip ) |
|---|
| 380 |
{ |
|---|
| 381 |
char *psz_option; |
|---|
| 382 |
p_sys->i_packet_size += 1000; |
|---|
| 383 |
if( asprintf( &psz_option, "mtu=%i", p_sys->i_packet_size ) != -1 ) |
|---|
| 384 |
{ |
|---|
| 385 |
input_item_AddOption( p_child, psz_option ); |
|---|
| 386 |
free( psz_option ); |
|---|
| 387 |
} |
|---|
| 388 |
} |
|---|
| 389 |
if( !p_sys->psz_mcast_ip ) |
|---|
| 390 |
{ |
|---|
| 391 |
char *psz_option; |
|---|
| 392 |
if( asprintf( &psz_option, "rtsp-caching=5000" ) != -1 ) |
|---|
| 393 |
{ |
|---|
| 394 |
input_item_AddOption( p_child, psz_option ); |
|---|
| 395 |
free( psz_option ); |
|---|
| 396 |
} |
|---|
| 397 |
} |
|---|
| 398 |
if( !p_sys->psz_mcast_ip && p_sys->b_rtsp_kasenna ) |
|---|
| 399 |
{ |
|---|
| 400 |
char *psz_option; |
|---|
| 401 |
if( asprintf( &psz_option, "rtsp-kasenna" ) != -1 ) |
|---|
| 402 |
{ |
|---|
| 403 |
input_item_AddOption( p_child, psz_option ); |
|---|
| 404 |
free( psz_option ); |
|---|
| 405 |
} |
|---|
| 406 |
} |
|---|
| 407 |
|
|---|
| 408 |
input_item_AddSubItem( p_current_input, p_child ); |
|---|
| 409 |
vlc_gc_decref( p_child ); |
|---|
| 410 |
HANDLE_PLAY_AND_RELEASE |
|---|
| 411 |
return 0; |
|---|
| 412 |
} |
|---|
| 413 |
|
|---|
| 414 |
static int Control( demux_t *p_demux, int i_query, va_list args ) |
|---|
| 415 |
{ |
|---|
| 416 |
VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args); |
|---|
| 417 |
return VLC_EGENERIC; |
|---|
| 418 |
} |
|---|
| 419 |
|
|---|