1 /*****************************************************************************
2 * live.cpp : live.com support.
3 *****************************************************************************
4 * Copyright (C) 2003 VideoLAN
5 * $Id: livedotcom.cpp,v 1.14 2004/01/25 20:05:28 hartman Exp $
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
30 #include <vlc/input.h>
32 #include <codecs.h> /* BITMAPINFOHEADER, WAVEFORMATEX */
36 # include <winsock2.h>
39 #include "BasicUsageEnvironment.hh"
40 #include "GroupsockHelper.hh"
41 #include "liveMedia.hh"
45 /*****************************************************************************
47 *****************************************************************************/
48 static int DemuxOpen ( vlc_object_t * );
49 static void DemuxClose( vlc_object_t * );
51 static int AccessOpen ( vlc_object_t * );
52 static void AccessClose( vlc_object_t * );
54 #define CACHING_TEXT N_("Caching value (ms)")
55 #define CACHING_LONGTEXT N_( \
56 "Allows you to modify the default caching value for rtsp streams. This " \
57 "value should be set in miliseconds units." )
60 set_description( _("live.com (RTSP/RTP/SDP) demuxer" ) );
61 set_capability( "demux", 50 );
62 set_callbacks( DemuxOpen, DemuxClose );
63 add_shortcut( "live" );
66 set_description( _("RTSP/RTP describe") );
67 add_shortcut( "rtsp" );
68 add_shortcut( "sdp" );
69 set_capability( "access", 0 );
70 set_callbacks( AccessOpen, AccessClose );
71 add_bool( "rtsp-tcp", 0, NULL,
72 N_("Use rtp over rtsp (tcp)"),
73 N_("Use rtp over rtsp (tcp)"), VLC_TRUE );
74 add_integer( "rtsp-caching", 4 * DEFAULT_PTS_DELAY / 1000, NULL,
75 CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
79 * - Support PS/TS (need to rework the TS/PS demuxer a lot).
80 * - Support X-QT/X-QUICKTIME generic codec for audio.
82 * - Check memory leak, delete/free -> still one when using rtsp-tcp but I'm
83 * not sure if it comes from me.
87 /*****************************************************************************
89 *****************************************************************************/
100 input_thread_t *p_input;
102 vlc_bool_t b_quicktime;
107 RTPSource *rtpSource;
108 FramedSource *readSource;
110 uint8_t buffer[65536];
119 char *p_sdp; /* XXX mallocated */
122 TaskScheduler *scheduler;
123 UsageEnvironment *env ;
127 live_track_t **track; /* XXX mallocated */
137 static ssize_t Read ( input_thread_t *, byte_t *, size_t );
138 static ssize_t MRLRead( input_thread_t *, byte_t *, size_t );
140 static int Demux ( input_thread_t * );
141 static int Control( input_thread_t *, int, va_list );
145 /*****************************************************************************
147 *****************************************************************************/
148 static int AccessOpen( vlc_object_t *p_this )
150 input_thread_t *p_input = (input_thread_t *)p_this;
153 TaskScheduler *scheduler = NULL;
154 UsageEnvironment *env = NULL;
155 RTSPClient *rtsp = NULL;
160 if( p_input->psz_access == NULL || ( strcasecmp( p_input->psz_access, "rtsp" ) && strcasecmp( p_input->psz_access, "sdp" ) ) )
162 msg_Warn( p_input, "RTSP access discarded" );
165 if( !strcasecmp( p_input->psz_access, "rtsp" ) )
167 if( ( scheduler = BasicTaskScheduler::createNew() ) == NULL )
169 msg_Err( p_input, "BasicTaskScheduler::createNew failed" );
172 if( ( env = BasicUsageEnvironment::createNew(*scheduler) ) == NULL )
175 msg_Err( p_input, "BasicUsageEnvironment::createNew failed" );
178 if( ( rtsp = RTSPClient::createNew(*env, 1/*verbose*/, "VLC Media Player" ) ) == NULL )
182 msg_Err( p_input, "RTSPClient::createNew failed" );
186 psz_url = (char*)malloc( strlen( p_input->psz_name ) + 8 );
187 sprintf( psz_url, "rtsp://%s", p_input->psz_name );
189 p_sys = (access_sys_t*)malloc( sizeof( access_sys_t ) );
190 p_sys->p_sdp = rtsp->describeURL( psz_url );
192 if( p_sys->p_sdp == NULL )
194 msg_Err( p_input, "describeURL failed (%s)", env->getResultMsg() );
203 p_sys->i_sdp = strlen( p_sys->p_sdp );
206 //fprintf( stderr, "sdp=%s\n", p_sys->p_sdp );
211 var_Create( p_input, "rtsp-tcp", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
212 var_Get( p_input, "rtsp-tcp", &val );
214 p_input->p_access_data = p_sys;
217 /* Set exported functions */
218 p_input->pf_read = Read;
219 p_input->pf_seek = NULL;
220 p_input->pf_set_program = input_SetProgram;
221 p_input->pf_set_area = NULL;
222 p_input->p_private = NULL;
224 p_input->psz_demux = "live";
226 /* Finished to set some variable */
227 vlc_mutex_lock( &p_input->stream.stream_lock );
228 /* FIXME that's not true but eg over tcp, server send data too fast */
229 p_input->stream.b_pace_control = val.b_bool;
230 p_input->stream.p_selected_area->i_tell = 0;
231 p_input->stream.b_seekable = 1; /* Hack to display time */
232 p_input->stream.p_selected_area->i_size = 0;
233 p_input->stream.i_method = INPUT_METHOD_NETWORK;
234 vlc_mutex_unlock( &p_input->stream.stream_lock );
236 /* Update default_pts to a suitable value for RTSP access */
237 var_Create( p_input, "rtsp-caching", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
238 var_Get( p_input, "rtsp-caching", &val );
239 p_input->i_pts_delay = val.i_int * 1000;
245 p_input->p_access_data = (access_sys_t*)0;
247 p_input->pf_read = MRLRead;
248 p_input->pf_seek = NULL;
249 p_input->pf_set_program = input_SetProgram;
250 p_input->pf_set_area = NULL;
251 p_input->p_private = NULL;
252 p_input->psz_demux = "live";
253 /* Finished to set some variable */
254 vlc_mutex_lock( &p_input->stream.stream_lock );
255 p_input->stream.b_pace_control = VLC_TRUE;
256 p_input->stream.p_selected_area->i_tell = 0;
257 p_input->stream.b_seekable = VLC_FALSE;
258 p_input->stream.p_selected_area->i_size = 0;
259 p_input->stream.i_method = INPUT_METHOD_NETWORK;
260 vlc_mutex_unlock( &p_input->stream.stream_lock );
266 /*****************************************************************************
268 *****************************************************************************/
269 static void AccessClose( vlc_object_t *p_this )
271 input_thread_t *p_input = (input_thread_t *)p_this;
272 access_sys_t *p_sys = p_input->p_access_data;
273 if( !strcasecmp( p_input->psz_access, "rtsp" ) )
275 delete[] p_sys->p_sdp;
280 /*****************************************************************************
282 *****************************************************************************/
283 static ssize_t Read ( input_thread_t *p_input, byte_t *p_buffer, size_t i_len )
285 access_sys_t *p_sys = p_input->p_access_data;
286 int i_copy = __MIN( (int)i_len, p_sys->i_sdp - p_sys->i_pos );
290 memcpy( p_buffer, &p_sys->p_sdp[p_sys->i_pos], i_copy );
291 p_sys->i_pos += i_copy;
295 /*****************************************************************************
296 * MRLRead: read data from the mrl
297 *****************************************************************************/
298 static ssize_t MRLRead ( input_thread_t *p_input, byte_t *p_buffer, size_t i_len )
300 int i_done = (int)p_input->p_access_data;
301 int i_copy = __MIN( (int)i_len, (int)strlen(p_input->psz_name) - i_done );
305 memcpy( p_buffer, &p_input->psz_name[i_done], i_copy );
307 p_input->p_access_data = (access_sys_t*)i_done;
313 /*****************************************************************************
315 *****************************************************************************/
316 static int DemuxOpen ( vlc_object_t *p_this )
318 input_thread_t *p_input = (input_thread_t *)p_this;
321 MediaSubsessionIterator *iter;
322 MediaSubsession *sub;
332 /* See if it looks like a SDP
333 v, o, s fields are mandatory and in this order */
334 if( stream_Peek( p_input->s, &p_peek, 7 ) < 7 )
336 msg_Err( p_input, "cannot peek" );
339 if( strncmp( (char*)p_peek, "v=0\r\n", 5 ) && strncmp( (char*)p_peek, "v=0\n", 4 ) &&
340 ( p_input->psz_access == NULL || strcasecmp( p_input->psz_access, "rtsp" ) ||
341 p_peek[0] < 'a' || p_peek[0] > 'z' || p_peek[1] != '=' ) )
343 msg_Warn( p_input, "SDP module discarded" );
347 p_input->pf_demux = Demux;
348 p_input->pf_demux_control = Control;
349 p_input->p_demux_data = p_sys = (demux_sys_t*)malloc( sizeof( demux_sys_t ) );
351 p_sys->scheduler = NULL;
358 p_sys->i_pcr_start = 0;
362 /* Gather the complete sdp file */
363 vlc_mutex_lock( &p_input->stream.stream_lock );
364 if( input_InitStream( p_input, 0 ) == -1)
366 vlc_mutex_unlock( &p_input->stream.stream_lock );
367 msg_Err( p_input, "cannot init stream" );
370 vlc_mutex_unlock( &p_input->stream.stream_lock );
374 p_sdp = (uint8_t*)malloc( i_sdp_max );
377 int i_read = stream_Read( p_input->s, &p_sdp[i_sdp], i_sdp_max - i_sdp - 1 );
381 msg_Err( p_input, "failed to read SDP" );
388 if( i_read < i_sdp_max - i_sdp - 1 )
395 p_sdp = (uint8_t*)realloc( p_sdp, i_sdp_max );
397 p_sys->p_sdp = (char*)p_sdp;
399 fprintf( stderr, "sdp=%s\n", p_sys->p_sdp );
401 if( ( p_sys->scheduler = BasicTaskScheduler::createNew() ) == NULL )
403 msg_Err( p_input, "BasicTaskScheduler::createNew failed" );
406 if( ( p_sys->env = BasicUsageEnvironment::createNew(*p_sys->scheduler) ) == NULL )
408 msg_Err( p_input, "BasicUsageEnvironment::createNew failed" );
411 if( p_input->psz_access != NULL && !strcasecmp( p_input->psz_access, "rtsp" ) )
416 if( ( p_sys->rtsp = RTSPClient::createNew(*p_sys->env, 1/*verbose*/, "VLC Media Player" ) ) == NULL )
418 msg_Err( p_input, "RTSPClient::createNew failed (%s)", p_sys->env->getResultMsg() );
421 psz_url = (char*)malloc( strlen( p_input->psz_name ) + 8 );
422 sprintf( psz_url, "rtsp://%s", p_input->psz_name );
424 psz_options = p_sys->rtsp->sendOptionsCmd( psz_url );
425 /* FIXME psz_options -> delete or free */
428 if( ( p_sys->ms = MediaSession::createNew(*p_sys->env, p_sys->p_sdp ) ) == NULL )
430 msg_Err( p_input, "MediaSession::createNew failed" );
434 var_Create( p_input, "rtsp-tcp", VLC_VAR_BOOL|VLC_VAR_DOINHERIT );
435 var_Get( p_input, "rtsp-tcp", &val );
437 /* Initialise each media subsession */
438 iter = new MediaSubsessionIterator( *p_sys->ms );
439 while( ( sub = iter->next() ) != NULL )
441 unsigned int i_buffer = 0;
443 /* Value taken from mplayer */
444 if( !strcmp( sub->mediumName(), "audio" ) )
448 else if( !strcmp( sub->mediumName(), "video" ) )
457 if( !sub->initiate() )
459 msg_Warn( p_input, "RTP subsession '%s/%s' failed(%s)", sub->mediumName(), sub->codecName(), p_sys->env->getResultMsg() );
463 int fd = sub->rtpSource()->RTPgs()->socketNum();
465 msg_Dbg( p_input, "RTP subsession '%s/%s'", sub->mediumName(), sub->codecName() );
467 /* Increase the buffer size */
468 increaseReceiveBufferTo( *p_sys->env, fd, i_buffer );
469 /* Issue the SETUP */
472 p_sys->rtsp->setupMediaSubsession( *sub, False, val.b_bool ? True : False );
480 if( !p_sys->rtsp->playMediaSession( *p_sys->ms ) )
482 msg_Err( p_input, "PLAY failed %s", p_sys->env->getResultMsg() );
487 /* Create all es struct */
489 while( ( sub = iter->next() ) != NULL )
493 if( sub->readSource() == NULL )
498 tk = (live_track_t*)malloc( sizeof( live_track_t ) );
499 tk->p_input = p_input;
502 tk->b_quicktime = VLC_FALSE;
504 /* Value taken from mplayer */
505 if( !strcmp( sub->mediumName(), "audio" ) )
507 es_format_Init( &tk->fmt, AUDIO_ES, VLC_FOURCC( 'u', 'n', 'd', 'f' ) );
508 tk->fmt.audio.i_channels = sub->numChannels();
509 tk->fmt.audio.i_rate = sub->rtpSource()->timestampFrequency();
511 if( !strcmp( sub->codecName(), "MPA" ) ||
512 !strcmp( sub->codecName(), "MPA-ROBUST" ) ||
513 !strcmp( sub->codecName(), "X-MP3-DRAFT-00" ) )
515 tk->fmt.i_codec = VLC_FOURCC( 'm', 'p', 'g', 'a' );
516 tk->fmt.audio.i_rate = 0;
518 else if( !strcmp( sub->codecName(), "AC3" ) )
520 tk->fmt.i_codec = VLC_FOURCC( 'a', '5', '2', ' ' );
521 tk->fmt.audio.i_rate = 0;
523 else if( !strcmp( sub->codecName(), "L16" ) )
525 tk->fmt.i_codec = VLC_FOURCC( 't', 'w', 'o', 's' );
526 tk->fmt.audio.i_bitspersample = 16;
528 else if( !strcmp( sub->codecName(), "L8" ) )
530 tk->fmt.i_codec = VLC_FOURCC( 'a', 'r', 'a', 'w' );
531 tk->fmt.audio.i_bitspersample = 8;
533 else if( !strcmp( sub->codecName(), "PCMU" ) )
535 tk->fmt.i_codec = VLC_FOURCC( 'u', 'l', 'a', 'w' );
537 else if( !strcmp( sub->codecName(), "PCMA" ) )
539 tk->fmt.i_codec = VLC_FOURCC( 'a', 'l', 'a', 'w' );
541 else if( !strcmp( sub->codecName(), "MP4A-LATM" ) )
543 unsigned int i_extra;
546 tk->fmt.i_codec = VLC_FOURCC( 'm', 'p', '4', 'a' );
548 if( ( p_extra = parseStreamMuxConfigStr( sub->fmtp_config(), i_extra ) ) )
550 tk->fmt.i_extra = i_extra;
551 tk->fmt.p_extra = malloc( sizeof( i_extra ) );
552 memcpy( tk->fmt.p_extra, p_extra, i_extra );
556 else if( !strcmp( sub->codecName(), "MPEG4-GENERIC" ) )
558 unsigned int i_extra;
561 tk->fmt.i_codec = VLC_FOURCC( 'm', 'p', '4', 'a' );
563 if( ( p_extra = parseGeneralConfigStr( sub->fmtp_config(), i_extra ) ) )
565 tk->fmt.i_extra = i_extra;
566 tk->fmt.p_extra = malloc( i_extra );
567 memcpy( tk->fmt.p_extra, p_extra, i_extra );
572 else if( !strcmp( sub->mediumName(), "video" ) )
574 es_format_Init( &tk->fmt, VIDEO_ES, VLC_FOURCC( 'u', 'n', 'd', 'f' ) );
575 if( !strcmp( sub->codecName(), "MPV" ) )
577 tk->fmt.i_codec = VLC_FOURCC( 'm', 'p', 'g', 'v' );
579 else if( !strcmp( sub->codecName(), "H263" ) ||
580 !strcmp( sub->codecName(), "H263-1998" ) )
582 tk->fmt.i_codec = VLC_FOURCC( 'h', '2', '6', '3' );
584 else if( !strcmp( sub->codecName(), "H261" ) )
586 tk->fmt.i_codec = VLC_FOURCC( 'h', '2', '6', '1' );
588 else if( !strcmp( sub->codecName(), "JPEG" ) )
590 tk->fmt.i_codec = VLC_FOURCC( 'M', 'J', 'P', 'G' );
592 else if( !strcmp( sub->codecName(), "MP4V-ES" ) )
594 unsigned int i_extra;
597 tk->fmt.i_codec = VLC_FOURCC( 'm', 'p', '4', 'v' );
599 if( ( p_extra = parseGeneralConfigStr( sub->fmtp_config(), i_extra ) ) )
601 tk->fmt.i_extra = i_extra;
602 tk->fmt.p_extra = malloc( i_extra );
603 memcpy( tk->fmt.p_extra, p_extra, i_extra );
607 else if( !strcmp( sub->codecName(), "X-QT" ) || !strcmp( sub->codecName(), "X-QUICKTIME" ) )
609 tk->b_quicktime = VLC_TRUE;
613 if( tk->fmt.i_codec != VLC_FOURCC( 'u', 'n', 'd', 'f' ) )
615 tk->p_es = es_out_Add( p_input->p_es_out, &tk->fmt );
622 if( tk->p_es || tk->b_quicktime )
624 TAB_APPEND( p_sys->i_track, p_sys->track, tk );
625 tk->readSource = sub->readSource();
626 tk->rtpSource = sub->rtpSource();
636 p_sys->i_length = (mtime_t)(p_sys->ms->playEndTime() * 1000000.0);
637 if( p_sys->i_length < 0 )
641 else if( p_sys->i_length > 0 )
643 p_input->stream.p_selected_area->i_size = 1000; /* needed for now */
646 if( p_sys->i_track <= 0 )
648 msg_Err( p_input, "no codec supported, aborting" );
657 Medium::close( p_sys->ms );
661 Medium::close( p_sys->rtsp );
667 if( p_sys->scheduler )
669 delete p_sys->scheduler;
673 free( p_sys->p_sdp );
681 /*****************************************************************************
683 *****************************************************************************/
684 static void DemuxClose( vlc_object_t *p_this )
686 input_thread_t *p_input = (input_thread_t *)p_this;
687 demux_sys_t *p_sys = p_input->p_demux_data;
690 for( i = 0; i < p_sys->i_track; i++ )
692 live_track_t *tk = p_sys->track[i];
698 free( p_sys->track );
701 if( p_sys->rtsp && p_sys->ms )
704 p_sys->rtsp->teardownMediaSession( *p_sys->ms );
706 Medium::close( p_sys->ms );
709 Medium::close( p_sys->rtsp );
716 if( p_sys->scheduler )
718 delete p_sys->scheduler;
722 free( p_sys->p_sdp );
728 static void StreamRead( void *p_private, unsigned int i_size, struct timeval pts );
729 static void StreamClose( void *p_private );
730 static void TaskInterrupt( void *p_private );
732 /*****************************************************************************
734 *****************************************************************************/
735 static int Demux ( input_thread_t *p_input )
737 demux_sys_t *p_sys = p_input->p_demux_data;
743 for( i = 0; i < p_sys->i_track; i++ )
745 live_track_t *tk = p_sys->track[i];
751 else if( tk->i_pts != 0 && i_pcr > tk->i_pts )
756 if( i_pcr != p_sys->i_pcr && i_pcr > 0 )
758 input_ClockManageRef( p_input,
759 p_input->stream.p_selected_program,
761 p_sys->i_pcr = i_pcr;
762 if( p_sys->i_pcr_start <= 0 || p_sys->i_pcr_start > i_pcr )
764 p_sys->i_pcr_start = i_pcr;
768 /* First warm we want to read data */
770 for( i = 0; i < p_sys->i_track; i++ )
772 live_track_t *tk = p_sys->track[i];
774 if( tk->waiting == 0 )
777 tk->readSource->getNextFrame( tk->buffer, 65536,
782 /* Create a task that will be called if we wait more than 300ms */
783 task = p_sys->scheduler->scheduleDelayedTask( 300000, TaskInterrupt, p_input );
786 p_sys->scheduler->doEventLoop( &p_sys->event );
788 /* remove the task */
789 p_sys->scheduler->unscheduleDelayedTask( task );
791 return p_input->b_error ? 0 : 1;
794 static int Control( input_thread_t *p_input, int i_query, va_list args )
796 demux_sys_t *p_sys = p_input->p_demux_data;
803 pi64 = (int64_t*)va_arg( args, int64_t * );
804 *pi64 = p_sys->i_pcr - p_sys->i_pcr_start + p_sys->i_start;
807 case DEMUX_GET_LENGTH:
808 pi64 = (int64_t*)va_arg( args, int64_t * );
809 *pi64 = p_sys->i_length;
812 case DEMUX_GET_POSITION:
813 pf = (double*)va_arg( args, double* );
814 if( p_sys->i_length > 0 )
816 *pf = (double)( p_sys->i_pcr - p_sys->i_pcr_start + p_sys->i_start)/
817 (double)(p_sys->i_length);
825 case DEMUX_SET_POSITION:
829 f = (double)va_arg( args, double );
830 time = f * (double)p_sys->i_length / 1000000.0; /* in second */
832 if( p_sys->rtsp && p_sys->i_length > 0 )
834 MediaSubsessionIterator *iter = new MediaSubsessionIterator( *p_sys->ms );
835 MediaSubsession *sub;
838 while( ( sub = iter->next() ) != NULL )
840 p_sys->rtsp->playMediaSubsession( *sub, time );
843 p_sys->i_start = (mtime_t)(f * (double)p_sys->i_length);
844 p_sys->i_pcr_start = 0;
846 for( i = 0; i < p_sys->i_track; i++ )
848 p_sys->track[i]->i_pts = 0;
856 return demux_vaControlDefault( p_input, i_query, args );
860 /*****************************************************************************
862 *****************************************************************************/
863 static void StreamRead( void *p_private, unsigned int i_size, struct timeval pts )
865 live_track_t *tk = (live_track_t*)p_private;
866 input_thread_t *p_input = tk->p_input;
867 demux_sys_t *p_sys = p_input->p_demux_data;
870 mtime_t i_pts = (mtime_t)pts.tv_sec * 1000000LL + (mtime_t)pts.tv_usec;
872 if( tk->b_quicktime && tk->p_es == NULL )
874 QuickTimeGenericRTPSource *qtRTPSource = (QuickTimeGenericRTPSource*)tk->rtpSource;
875 QuickTimeGenericRTPSource::QTState &qtState = qtRTPSource->qtState;
876 uint8_t *sdAtom = (uint8_t*)&qtState.sdAtom[4];
878 if( qtState.sdAtomSize < 16 + 32 )
885 tk->fmt.i_codec = VLC_FOURCC( sdAtom[0], sdAtom[1], sdAtom[2], sdAtom[3] );
886 tk->fmt.video.i_width = (sdAtom[28] << 8) | sdAtom[29];
887 tk->fmt.video.i_height = (sdAtom[30] << 8) | sdAtom[31];
889 tk->fmt.i_extra = qtState.sdAtomSize - 16;
890 tk->fmt.p_extra = malloc( tk->fmt.i_extra );
891 memcpy( tk->fmt.p_extra, &sdAtom[12], tk->fmt.i_extra );
893 tk->p_es = es_out_Add( p_input->p_es_out, &tk->fmt );
897 fprintf( stderr, "StreamRead size=%d pts=%lld\n",
899 pts.tv_sec * 1000000LL + pts.tv_usec );
903 msg_Warn( p_input, "buffer overflow" );
905 /* FIXME could i_size be > buffer size ? */
906 p_block = block_New( p_input, i_size );
908 memcpy( p_block->p_buffer, tk->buffer, i_size );
909 //p_block->i_rate = p_input->stream.control.i_rate;
911 if( i_pts != tk->i_pts )
914 p_block->i_pts = input_ClockGetTS( p_input,
915 p_input->stream.p_selected_program,
923 //fprintf( stderr, "tk -> dpts=%lld\n", i_pts - tk->i_pts );
925 es_out_Send( p_input->p_es_out, tk->p_es, p_block );
930 /* we have read data */
939 /*****************************************************************************
941 *****************************************************************************/
942 static void StreamClose( void *p_private )
944 live_track_t *tk = (live_track_t*)p_private;
945 input_thread_t *p_input = tk->p_input;
946 demux_sys_t *p_sys = p_input->p_demux_data;
948 fprintf( stderr, "StreamClose\n" );
951 p_input->b_error = VLC_TRUE;
955 /*****************************************************************************
957 *****************************************************************************/
958 static void TaskInterrupt( void *p_private )
960 input_thread_t *p_input = (input_thread_t*)p_private;
962 fprintf( stderr, "TaskInterrupt\n" );
965 p_input->p_demux_data->event = 0xff;