Changeset 298f0e468edf5cbbf05d852bb58c7ef762a6a571
- Timestamp:
- 11/03/04 18:35:28 (5 years ago)
- git-parent:
- Files:
-
- modules/access_output/dummy.c (modified) (7 diffs)
- modules/access_output/file.c (modified) (9 diffs)
- modules/access_output/http.c (modified) (10 diffs)
- modules/access_output/udp.c (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/access_output/dummy.c
r7211d64 r298f0e4 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001, 2002 VideoLAN 5 * $Id : dummy.c,v 1.3 2003/03/03 14:21:08 gbazin Exp$5 * $Id$ 6 6 * 7 7 * Authors: Laurent Aimar <fenrir@via.ecp.fr> … … 27 27 *****************************************************************************/ 28 28 #include <stdlib.h> 29 #include <sys/types.h>30 #include <sys/stat.h>31 #include <string.h>32 #include <errno.h>33 #include <fcntl.h>34 29 35 30 #include <vlc/vlc.h> 36 #include <vlc/input.h>37 31 #include <vlc/sout.h> 38 39 #ifdef HAVE_UNISTD_H40 # include <unistd.h>41 #endif42 43 /*****************************************************************************44 * Exported prototypes45 *****************************************************************************/46 static int Open ( vlc_object_t * );47 static void Close ( vlc_object_t * );48 49 static int Write( sout_access_out_t *, sout_buffer_t * );50 static int Seek ( sout_access_out_t *, off_t );51 32 52 33 /***************************************************************************** 53 34 * Module descriptor 54 35 *****************************************************************************/ 36 static int Open ( vlc_object_t * ); 37 static void Close( vlc_object_t * ); 38 55 39 vlc_module_begin(); 56 40 set_description( _("Dummy stream ouput") ); … … 60 44 vlc_module_end(); 61 45 46 47 /***************************************************************************** 48 * Exported prototypes 49 *****************************************************************************/ 50 static int Write( sout_access_out_t *, block_t * ); 51 static int Seek ( sout_access_out_t *, off_t ); 62 52 63 53 /***************************************************************************** … … 72 62 p_access->pf_seek = Seek; 73 63 74 msg_ Info( p_access, "dummy stream output access launched" );64 msg_Dbg( p_access, "dummy stream output access opened" ); 75 65 return VLC_SUCCESS; 76 66 } … … 82 72 { 83 73 sout_access_out_t *p_access = (sout_access_out_t*)p_this; 84 msg_ Info( p_access, "Close" );74 msg_Dbg( p_access, "dummy stream output access closed" ); 85 75 } 86 76 … … 88 78 * Read: standard read on a file descriptor. 89 79 *****************************************************************************/ 90 static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )80 static int Write( sout_access_out_t *p_access, block_t *p_buffer ) 91 81 { 92 size_t i_write = 0; 82 int64_t i_write = 0; 83 block_t *b = p_buffer; 93 84 94 do85 while( b ) 95 86 { 96 sout_buffer_t *p_next; 97 i_write += p_buffer->i_size; 98 p_next = p_buffer->p_next; 99 sout_BufferDelete( p_access->p_sout, p_buffer ); 100 p_buffer = p_next; 101 } while( p_buffer ); 87 i_write += b->i_buffer; 102 88 103 msg_Dbg( p_access, "Dummy Skipped: len:"I64Fd, (int64_t)i_write ); 89 b = b->p_next; 90 } 104 91 105 return( i_write ); 92 block_ChainRelease( p_buffer ); 93 94 return i_write; 106 95 } 107 96 … … 111 100 static int Seek( sout_access_out_t *p_access, off_t i_pos ) 112 101 { 113 msg_Dbg( p_access, "Seek: pos:"I64Fd, (int64_t)i_pos ); 114 return( 0 ); 102 return 0; 115 103 } 116 104 modules/access_output/file.c
r5c2cf08 r298f0e4 3 3 ***************************************************************************** 4 4 * Copyright (C) 2001, 2002 VideoLAN 5 * $Id : file.c,v 1.11 2004/01/23 17:56:14 gbazin Exp$5 * $Id$ 6 6 * 7 7 * Authors: Laurent Aimar <fenrir@via.ecp.fr> … … 30 30 #include <sys/stat.h> 31 31 #include <string.h> 32 #include <fcntl.h> 32 33 #include <errno.h> 33 #include <fcntl.h>34 34 35 35 #include <vlc/vlc.h> 36 #include <vlc/input.h>37 36 #include <vlc/sout.h> 38 37 … … 55 54 56 55 /***************************************************************************** 57 * Exported prototypes58 *****************************************************************************/59 static int Open ( vlc_object_t * );60 static void Close ( vlc_object_t * );61 62 static int Write( sout_access_out_t *, sout_buffer_t * );63 static int Seek ( sout_access_out_t *, off_t );64 static int Read ( sout_access_out_t *, sout_buffer_t * );65 66 /*****************************************************************************67 56 * Module descriptor 68 57 *****************************************************************************/ 58 static int Open ( vlc_object_t * ); 59 static void Close( vlc_object_t * ); 60 69 61 vlc_module_begin(); 70 62 set_description( _("File stream ouput") ); … … 74 66 vlc_module_end(); 75 67 68 69 /***************************************************************************** 70 * Exported prototypes 71 *****************************************************************************/ 72 static int Write( sout_access_out_t *, block_t * ); 73 static int Seek ( sout_access_out_t *, off_t ); 74 static int Read ( sout_access_out_t *, block_t * ); 75 76 76 struct sout_access_out_sys_t 77 77 { 78 78 int i_handle; 79 80 79 }; 81 80 … … 126 125 p_access->pf_seek = Seek; 127 126 128 msg_ Info( p_access, "Open: name:`%s'", p_access->psz_name );127 msg_Dbg( p_access, "file access output opened (`%s')", p_access->psz_name ); 129 128 return VLC_SUCCESS; 130 129 } … … 146 145 free( p_access->p_sys ); 147 146 148 msg_ Info( p_access, "Close" );147 msg_Dbg( p_access, "file access output closed" ); 149 148 } 150 149 … … 152 151 * Read: standard read on a file descriptor. 153 152 *****************************************************************************/ 154 static int Read( sout_access_out_t *p_access, sout_buffer_t *p_buffer )153 static int Read( sout_access_out_t *p_access, block_t *p_buffer ) 155 154 { 156 155 if( strcmp( p_access->psz_name, "-" ) ) 157 156 { 158 157 return read( p_access->p_sys->i_handle, p_buffer->p_buffer, 159 p_buffer->i_size ); 160 } 161 else 162 { 163 msg_Err( p_access, "cannot seek while using stdout" ); 164 return VLC_EGENERIC; 165 } 158 p_buffer->i_buffer ); 159 } 160 161 msg_Err( p_access, "cannot read while using stdout" ); 162 return VLC_EGENERIC; 166 163 } 167 164 … … 169 166 * Write: standard write on a file descriptor. 170 167 *****************************************************************************/ 171 static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )168 static int Write( sout_access_out_t *p_access, block_t *p_buffer ) 172 169 { 173 170 size_t i_write = 0; 174 171 175 do176 { 177 sout_buffer_t *p_next;178 179 i_write += write( p_access->p_sys->i_handle, p_buffer->p_buffer,180 p_buffer-> i_size);181 p_next = p_buffer->p_next;182 sout_BufferDelete( p_access->p_sout, p_buffer ); 172 while( p_buffer ) 173 { 174 block_t *p_next = p_buffer->p_next;; 175 176 i_write += write( p_access->p_sys->i_handle, 177 p_buffer->p_buffer, p_buffer->i_buffer ); 178 block_Release( p_buffer ); 179 183 180 p_buffer = p_next; 184 185 } while( p_buffer ); 186 187 return( i_write ); 181 } 182 183 return i_write; 188 184 } 189 185 … … 193 189 static int Seek( sout_access_out_t *p_access, off_t i_pos ) 194 190 { 195 //msg_Dbg( p_access, "Seek: pos:"I64Fd, (int64_t)i_pos );196 197 191 if( strcmp( p_access->psz_name, "-" ) ) 198 192 { modules/access_output/http.c
r4c29602 r298f0e4 26 26 *****************************************************************************/ 27 27 #include <stdlib.h> 28 #include <string.h>29 #include <errno.h>30 28 31 29 #include <vlc/vlc.h> 32 #include <vlc/input.h>33 30 #include <vlc/sout.h> 34 31 … … 40 37 41 38 /***************************************************************************** 42 * Exported prototypes43 *****************************************************************************/44 static int Open ( vlc_object_t * );45 static void Close ( vlc_object_t * );46 47 static int Write( sout_access_out_t *, sout_buffer_t * );48 static int Seek ( sout_access_out_t *, off_t );49 50 /*****************************************************************************51 39 * Module descriptor 52 40 *****************************************************************************/ 41 static int Open ( vlc_object_t * ); 42 static void Close( vlc_object_t * ); 43 53 44 vlc_module_begin(); 54 45 set_description( _("HTTP stream ouput") ); … … 59 50 vlc_module_end(); 60 51 52 53 /***************************************************************************** 54 * Exported prototypes 55 *****************************************************************************/ 56 static int Write( sout_access_out_t *, block_t * ); 57 static int Seek ( sout_access_out_t *, off_t ); 58 61 59 struct sout_access_out_sys_t 62 60 { … … 74 72 }; 75 73 76 #if 077 static struct78 {79 char *psz_ext;80 char *psz_mime;81 } http_mime[] =82 {83 { ".avi", "video/avi" },84 { ".asf", "video/x-ms-asf" },85 { ".m1a", "audio/mpeg" },86 { ".m2a", "audio/mpeg" },87 { ".m1v", "video/mpeg" },88 { ".m2v", "video/mpeg" },89 { ".mp2", "audio/mpeg" },90 { ".mp3", "audio/mpeg" },91 { ".mpa", "audio/mpeg" },92 { ".mpg", "video/mpeg" },93 { ".mpeg", "video/mpeg" },94 { ".mpe", "video/mpeg" },95 { ".mov", "video/quicktime" },96 { ".moov", "video/quicktime" },97 { ".ogg", "application/ogg" },98 { ".ogm", "application/ogg" },99 { ".wma", "audio/x-ms-wma" },100 { ".wmv", "video/x-ms-wmv" },101 { ".wav", "audio/wav" },102 { NULL, NULL }103 };104 105 static char *GetMime( char *psz_name )106 {107 char *psz_ext;108 109 psz_ext = strrchr( psz_name, '.' );110 if( psz_ext )111 {112 int i;113 114 for( i = 0; http_mime[i].psz_ext != NULL ; i++ )115 {116 if( !strcmp( http_mime[i].psz_ext, psz_ext ) )117 {118 return( http_mime[i].psz_mime );119 }120 }121 }122 return( "application/octet-stream" );123 }124 #endif125 126 74 /***************************************************************************** 127 75 * Open: open the file … … 273 221 * Write: 274 222 *****************************************************************************/ 275 static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )223 static int Write( sout_access_out_t *p_access, block_t *p_buffer ) 276 224 { 277 225 sout_access_out_sys_t *p_sys = p_access->p_sys; … … 280 228 while( p_buffer ) 281 229 { 282 sout_buffer_t *p_next;283 284 if( p_buffer->i_flags & SOUT_BUFFER_FLAGS_HEADER )230 block_t *p_next; 231 232 if( p_buffer->i_flags & BLOCK_FLAG_HEADER ) 285 233 { 286 234 /* gather header */ … … 291 239 p_sys->b_header_complete = VLC_FALSE; 292 240 } 293 if( (int)(p_buffer->i_ size+ p_sys->i_header_size) >241 if( (int)(p_buffer->i_buffer + p_sys->i_header_size) > 294 242 p_sys->i_header_allocated ) 295 243 { 296 244 p_sys->i_header_allocated = 297 p_buffer->i_ size+ p_sys->i_header_size + 1024;245 p_buffer->i_buffer + p_sys->i_header_size + 1024; 298 246 p_sys->p_header = 299 247 realloc( p_sys->p_header, p_sys->i_header_allocated ); … … 301 249 memcpy( &p_sys->p_header[p_sys->i_header_size], 302 250 p_buffer->p_buffer, 303 p_buffer->i_ size);304 p_sys->i_header_size += p_buffer->i_ size;251 p_buffer->i_buffer ); 252 p_sys->i_header_size += p_buffer->i_buffer; 305 253 } 306 254 else if( !p_sys->b_header_complete ) … … 314 262 /* send data */ 315 263 i_err = httpd_StreamSend( p_sys->p_httpd_stream, p_buffer->p_buffer, 316 p_buffer->i_ size);264 p_buffer->i_buffer ); 317 265 318 266 p_next = p_buffer->p_next; 319 sout_BufferDelete( p_access->p_sout,p_buffer );267 block_Release( p_buffer ); 320 268 p_buffer = p_next; 321 269 … … 328 276 if( i_err < 0 ) 329 277 { 330 sout_buffer_t *p_next; 331 while( p_buffer ) 332 { 333 p_next = p_buffer->p_next; 334 sout_BufferDelete( p_access->p_sout, p_buffer ); 335 p_buffer = p_next; 336 } 278 block_ChainRelease( p_buffer ); 337 279 } 338 280 modules/access_output/udp.c
r53ccc56 r298f0e4 34 34 35 35 #include <vlc/vlc.h> 36 #include <vlc/input.h>37 36 #include <vlc/sout.h> 38 37 … … 53 52 #include "network.h" 54 53 55 #define DEFAULT_PORT 123456 /*****************************************************************************57 * Exported prototypes58 *****************************************************************************/59 static int Open ( vlc_object_t * );60 static void Close ( vlc_object_t * );61 62 static int Write ( sout_access_out_t *, sout_buffer_t * );63 static int WriteRaw( sout_access_out_t *, sout_buffer_t * );64 static int Seek ( sout_access_out_t *, off_t );65 66 static void ThreadWrite( vlc_object_t * );67 68 static sout_buffer_t *NewUDPPacket( sout_access_out_t *, mtime_t );69 54 70 55 /***************************************************************************** 71 56 * Module descriptor 72 57 *****************************************************************************/ 58 static int Open ( vlc_object_t * ); 59 static void Close( vlc_object_t * ); 60 73 61 #define CACHING_TEXT N_("Caching value (ms)") 74 62 #define CACHING_LONGTEXT N_( \ … … 86 74 vlc_module_end(); 87 75 76 /***************************************************************************** 77 * Exported prototypes 78 *****************************************************************************/ 79 static int Write ( sout_access_out_t *, block_t * ); 80 static int WriteRaw( sout_access_out_t *, block_t * ); 81 static int Seek ( sout_access_out_t *, off_t ); 82 83 static void ThreadWrite( vlc_object_t * ); 84 85 static block_t *NewUDPPacket( sout_access_out_t *, mtime_t ); 86 87 88 88 typedef struct sout_access_thread_t 89 89 { … … 92 92 sout_instance_t *p_sout; 93 93 94 sout_fifo_t *p_fifo;94 block_fifo_t *p_fifo; 95 95 96 96 int i_handle; … … 110 110 unsigned int i_mtu; 111 111 112 sout_buffer_t*p_buffer;112 block_t *p_buffer; 113 113 114 114 sout_access_thread_t *p_thread; 115 115 116 116 }; 117 118 #define DEFAULT_PORT 1234 117 119 118 120 /***************************************************************************** … … 192 194 p_sys->p_thread->b_die = 0; 193 195 p_sys->p_thread->b_error= 0; 194 p_sys->p_thread->p_fifo = sout_FifoCreate( p_access->p_sout);196 p_sys->p_thread->p_fifo = block_FifoNew( p_access ); 195 197 196 198 socket_desc.i_type = NETWORK_UDP; … … 267 269 p_access->pf_seek = Seek; 268 270 269 msg_ Info( p_access, "Open: addr:`%s' port:`%d'", psz_dst_addr, i_dst_port);271 msg_Dbg( p_access, "udp access output opened(%s:%d)", psz_dst_addr, i_dst_port ); 270 272 271 273 free( psz_dst_addr ); … … 289 291 for( i = 0; i < 10; i++ ) 290 292 { 291 sout_buffer_t *p_dummy; 292 293 p_dummy = sout_BufferNew( p_access->p_sout, p_sys->i_mtu ); 293 block_t *p_dummy = block_New( p_access, p_sys->i_mtu ); 294 294 p_dummy->i_dts = 0; 295 295 p_dummy->i_pts = 0; 296 296 p_dummy->i_length = 0; 297 sout_FifoPut( p_sys->p_thread->p_fifo, p_dummy );297 block_FifoPut( p_sys->p_thread->p_fifo, p_dummy ); 298 298 } 299 299 vlc_thread_join( p_sys->p_thread ); 300 300 301 sout_FifoDestroy( p_access->p_sout,p_sys->p_thread->p_fifo );301 block_FifoRelease( p_sys->p_thread->p_fifo ); 302 302 303 303 if( p_sys->p_buffer ) 304 304 { 305 sout_BufferDelete( p_access->p_sout,p_sys->p_buffer );305 block_Release( p_sys->p_buffer ); 306 306 } 307 307 … … 311 311 p_access->p_sout->i_out_pace_nocontrol--; 312 312 313 msg_Dbg( p_access, "udp access output closed" ); 313 314 free( p_sys ); 314 msg_Info( p_access, "Close" );315 315 } 316 316 … … 318 318 * Write: standard write on a file descriptor. 319 319 *****************************************************************************/ 320 static int Write( sout_access_out_t *p_access, sout_buffer_t *p_buffer )320 static int Write( sout_access_out_t *p_access, block_t *p_buffer ) 321 321 { 322 322 sout_access_out_sys_t *p_sys = p_access->p_sys; … … 325 325 while( p_buffer ) 326 326 { 327 sout_buffer_t *p_next;328 if( p_buffer->i_ size> p_sys->i_mtu )327 block_t *p_next; 328 if( p_buffer->i_buffer > p_sys->i_mtu ) 329 329 { 330 330 msg_Warn( p_access, "arggggggggggggg packet size > mtu" ); … … 333 333 else 334 334 { 335 i_write = p_buffer->i_ size;335 i_write = p_buffer->i_buffer; 336 336 } 337 337 338 338 /* if we have enough data, enque the buffer */ 339 339 if( p_sys->p_buffer && 340 p_sys->p_buffer->i_ size+ i_write > p_sys->i_mtu )341 { 342 sout_FifoPut( p_sys->p_thread->p_fifo, p_sys->p_buffer );340 p_sys->p_buffer->i_buffer + i_write > p_sys->i_mtu ) 341 { 342 block_FifoPut( p_sys->p_thread->p_fifo, p_sys->p_buffer ); 343 343 p_sys->p_buffer = NULL; 344 344 } … … 349 349 } 350 350 351 if( p_buffer->i_ size> 0 )352 { 353 memcpy( p_sys->p_buffer->p_buffer + p_sys->p_buffer->i_ size,351 if( p_buffer->i_buffer > 0 ) 352 { 353 memcpy( p_sys->p_buffer->p_buffer + p_sys->p_buffer->i_buffer, 354 354 p_buffer->p_buffer, i_write ); 355 p_sys->p_buffer->i_ size+= i_write;355 p_sys->p_buffer->i_buffer += i_write; 356 356 } 357 357 p_next = p_buffer->p_next; 358 sout_BufferDelete( p_access->p_sout,p_buffer );358 block_Release( p_buffer ); 359 359 p_buffer = p_next; 360 360 } … … 366 366 * WriteRaw: write p_buffer without trying to fill mtu 367 367 *****************************************************************************/ 368 static int WriteRaw( sout_access_out_t *p_access, sout_buffer_t *p_buffer )368 static int WriteRaw( sout_access_out_t *p_access, block_t *p_buffer ) 369 369 { 370 370 sout_access_out_sys_t *p_sys = p_access->p_sys; 371 371 372 sout_FifoPut( p_sys->p_thread->p_fifo, p_buffer );372 block_FifoPut( p_sys->p_thread->p_fifo, p_buffer ); 373 373 374 374 return( p_sys->p_thread->b_error ? -1 : 0 ); … … 381 381 { 382 382 msg_Err( p_access, "UDP sout access cannot seek" ); 383 return ( -1 );383 return -1; 384 384 } 385 385 … … 387 387 * NewUDPPacket: allocate a new UDP packet of size p_sys->i_mtu 388 388 *****************************************************************************/ 389 static sout_buffer_t *NewUDPPacket( sout_access_out_t *p_access, mtime_t i_dts)389 static block_t *NewUDPPacket( sout_access_out_t *p_access, mtime_t i_dts) 390 390 { 391 391 sout_access_out_sys_t *p_sys = p_access->p_sys; 392 sout_buffer_t *p_buffer;393 394 p_buffer = sout_BufferNew( p_access->p_sout, p_sys->i_mtu );392 block_t *p_buffer; 393 394 p_buffer = block_New( p_access->p_sout, p_sys->i_mtu ); 395 395 p_buffer->i_dts = i_dts; 396 p_buffer->i_ size= 0;396 p_buffer->i_buffer = 0; 397 397 398 398 if( p_sys->b_rtpts ) … … 418 418 p_buffer->p_buffer[11] = p_sys->i_ssrc&0xff; 419 419 420 p_buffer->i_ size= 12;420 p_buffer->i_buffer = 12; 421 421 } 422 422 … … 430 430 { 431 431 sout_access_thread_t *p_thread = (sout_access_thread_t*)p_this; 432 sout_instance_t *p_sout = p_thread->p_sout;433 432 mtime_t i_date_last = -1; 434 433 mtime_t i_to_send = p_thread->i_group; … … 437 436 while( !p_thread->b_die ) 438 437 { 439 sout_buffer_t *p_pk;438 block_t *p_pk; 440 439 mtime_t i_date, i_sent; 441 440 442 p_pk = sout_FifoGet( p_thread->p_fifo );441 p_pk = block_FifoGet( p_thread->p_fifo ); 443 442 444 443 i_date = p_thread->i_caching + p_pk->i_dts; … … 450 449 msg_Dbg( p_thread, "mmh, hole > 2s -> drop" ); 451 450 452 sout_BufferDelete( p_sout, p_pk);451 block_Release( p_pk ); 453 452 i_date_last = i_date; 454 453 i_dropped_packets++; … … 460 459 msg_Dbg( p_thread, "mmh, paquets in the past -> drop" ); 461 460 462 sout_BufferDelete( p_sout, p_pk);461 block_Release( p_pk ); 463 462 i_date_last = i_date; 464 463 i_dropped_packets++; … … 475 474 i_sent - i_date ); 476 475 } 477 sout_BufferDelete( p_sout, p_pk);476 block_Release( p_pk ); 478 477 i_date_last = i_date; 479 478 i_dropped_packets++; … … 487 486 i_to_send = p_thread->i_group; 488 487 } 489 send( p_thread->i_handle, p_pk->p_buffer, p_pk->i_ size, 0 );488 send( p_thread->i_handle, p_pk->p_buffer, p_pk->i_buffer, 0 ); 490 489 491 490 if( i_dropped_packets ) … … 504 503 #endif 505 504 506 sout_BufferDelete( p_sout, p_pk);505 block_Release( p_pk ); 507 506 i_date_last = i_date; 508 507 }
