1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2001, 2002 the VideoLAN team
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
29 #include <vlc_access.h>
30 #include "vlc_playlist.h"
31 #include "vlc_strings.h"
33 #include <vlc_network.h>
45 /*****************************************************************************
47 *****************************************************************************/
48 int E_(MMSHOpen) ( access_t * );
49 void E_(MMSHClose) ( access_t * );
51 static int Read( access_t *, uint8_t *, int );
52 static int ReadRedirect( access_t *, uint8_t *, int );
53 static int Seek( access_t *, int64_t );
54 static int Control( access_t *, int, va_list );
56 static int Describe( access_t *, char **ppsz_location );
57 static int Start( access_t *, int64_t );
58 static void Stop( access_t * );
60 static int GetPacket( access_t *, chunk_t * );
61 static void GetHeader( access_t *p_access );
63 static int Restart( access_t * );
64 static int Reset( access_t * );
66 //#define MMSH_USER_AGENT "NSPlayer/4.1.0.3856"
67 #define MMSH_USER_AGENT "NSPlayer/7.10.0.3059"
69 /****************************************************************************
70 * Open: connect to ftp server and ask for file
71 ****************************************************************************/
72 int E_(MMSHOpen)( access_t *p_access )
75 char *psz_location = NULL;
81 p_access->pf_read = Read;
82 p_access->pf_block = NULL;
83 p_access->pf_control = Control;
84 p_access->pf_seek = Seek;
85 p_access->info.i_update = 0;
86 p_access->info.i_size = 0;
87 p_access->info.i_pos = 0;
88 p_access->info.b_eof = VLC_FALSE;
89 p_access->info.i_title = 0;
90 p_access->info.i_seekpoint = 0;
91 p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
92 memset( p_sys, 0, sizeof( access_sys_t ) );
93 p_sys->i_proto= MMS_PROTO_HTTP;
98 p_sys->b_proxy = VLC_FALSE;
99 memset( &p_sys->proxy, 0, sizeof(p_sys->proxy) );
102 /* TODO reuse instead http-proxy from http access ? */
103 psz_proxy = var_CreateGetString( p_access, "mmsh-proxy" );
106 char *psz_http_proxy = config_GetPsz( p_access, "http-proxy" );
107 if( psz_http_proxy && *psz_http_proxy )
110 psz_proxy = psz_http_proxy;
111 var_SetString( p_access, "mmsh-proxy", psz_proxy );
115 free( psz_http_proxy );
120 p_sys->b_proxy = VLC_TRUE;
121 vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 );
126 char *psz_proxy = getenv( "http_proxy" );
127 if( psz_proxy && *psz_proxy )
129 p_sys->b_proxy = VLC_TRUE;
130 vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 );
138 if( p_sys->proxy.psz_host == NULL || *p_sys->proxy.psz_host == '\0' )
140 msg_Warn( p_access, "invalid proxy host" );
141 vlc_UrlClean( &p_sys->proxy );
145 if( p_sys->proxy.i_port <= 0 )
146 p_sys->proxy.i_port = 80;
147 msg_Dbg( p_access, "Using http proxy %s:%d",
148 p_sys->proxy.psz_host, p_sys->proxy.i_port );
151 /* open a tcp connection */
152 vlc_UrlParse( &p_sys->url, p_access->psz_path, 0 );
153 if( p_sys->url.psz_host == NULL || *p_sys->url.psz_host == '\0' )
155 msg_Err( p_access, "invalid host" );
156 vlc_UrlClean( &p_sys->proxy );
157 vlc_UrlClean( &p_sys->url );
161 if( p_sys->url.i_port <= 0 )
162 p_sys->url.i_port = 80;
164 if( Describe( p_access, &psz_location ) )
166 vlc_UrlClean( &p_sys->proxy );
167 vlc_UrlClean( &p_sys->url );
171 /* Handle redirection */
172 if( psz_location && *psz_location )
174 playlist_t * p_playlist = pl_Yield( p_access );
175 msg_Dbg( p_access, "redirection to %s", psz_location );
177 /** \bug we do not autodelete here */
178 playlist_Add( p_playlist, psz_location, psz_location,
179 PLAYLIST_INSERT | PLAYLIST_GO, PLAYLIST_END, VLC_TRUE,
181 vlc_object_release( p_playlist );
183 free( psz_location );
185 p_access->pf_read = ReadRedirect;
190 if( Start( p_access, 0 ) )
192 msg_Err( p_access, "cannot start stream" );
193 free( p_sys->p_header );
194 vlc_UrlClean( &p_sys->proxy );
195 vlc_UrlClean( &p_sys->url );
200 if( !p_sys->b_broadcast )
202 p_access->info.i_size = p_sys->asfh.i_file_size;
208 /*****************************************************************************
209 * Close: free unused data structures
210 *****************************************************************************/
211 void E_( MMSHClose )( access_t *p_access )
213 access_sys_t *p_sys = p_access->p_sys;
217 if( p_sys->p_header )
218 free( p_sys->p_header );
220 vlc_UrlClean( &p_sys->proxy );
221 vlc_UrlClean( &p_sys->url );
225 /*****************************************************************************
227 *****************************************************************************/
228 static int Control( access_t *p_access, int i_query, va_list args )
230 access_sys_t *p_sys = p_access->p_sys;
239 case ACCESS_CAN_SEEK:
240 pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
241 *pb_bool = !p_sys->b_broadcast;
244 case ACCESS_CAN_FASTSEEK:
245 case ACCESS_CAN_PAUSE:
246 pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
247 *pb_bool = VLC_FALSE;
250 case ACCESS_CAN_CONTROL_PACE:
251 pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
253 #if 0 /* Disable for now until we have a clock synchro algo
254 * which works with something else than MPEG over UDP */
255 *pb_bool = VLC_FALSE;
262 pi_int = (int*)va_arg( args, int * );
263 *pi_int = 3 * p_sys->asfh.i_min_data_packet_size;
266 case ACCESS_GET_PTS_DELAY:
267 pi_64 = (int64_t*)va_arg( args, int64_t * );
268 *pi_64 = (int64_t)var_GetInteger( p_access, "mms-caching" ) * I64C(1000);
271 case ACCESS_GET_PRIVATE_ID_STATE:
272 i_int = (int)va_arg( args, int );
273 pb_bool = (vlc_bool_t *)va_arg( args, vlc_bool_t * );
275 if( i_int < 0 || i_int > 127 )
277 *pb_bool = p_sys->asfh.stream[i_int].i_selected ? VLC_TRUE : VLC_FALSE;
281 case ACCESS_SET_PAUSE_STATE:
282 case ACCESS_GET_TITLE_INFO:
283 case ACCESS_SET_TITLE:
284 case ACCESS_SET_SEEKPOINT:
285 case ACCESS_SET_PRIVATE_ID_STATE:
289 msg_Warn( p_access, "unimplemented query in control" );
296 /*****************************************************************************
297 * Seek: try to go at the right place
298 *****************************************************************************/
299 static int Seek( access_t *p_access, int64_t i_pos )
301 access_sys_t *p_sys = p_access->p_sys;
306 msg_Dbg( p_access, "seeking to "I64Fd, i_pos );
308 i_packet = ( i_pos - p_sys->i_header ) / p_sys->asfh.i_min_data_packet_size;
309 i_offset = ( i_pos - p_sys->i_header ) % p_sys->asfh.i_min_data_packet_size;
312 Start( p_access, i_packet * p_sys->asfh.i_min_data_packet_size );
314 while( !p_access->b_die )
316 if( GetPacket( p_access, &ck ) )
320 if( ck.i_type != 0x4824 )
323 msg_Warn( p_access, "skipping header" );
326 p_access->info.i_pos = i_pos;
327 p_access->info.b_eof = VLC_FALSE;
328 p_sys->i_packet_used += i_offset;
333 /*****************************************************************************
335 *****************************************************************************/
336 static int ReadRedirect( access_t *p_access, uint8_t *p, int i_len )
341 /*****************************************************************************
343 *****************************************************************************/
344 static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
346 access_sys_t *p_sys = p_access->p_sys;
350 if( p_access->info.b_eof )
353 while( i_data < (size_t) i_len )
355 if( p_access->info.i_pos < p_sys->i_start + p_sys->i_header )
357 int i_offset = p_access->info.i_pos - p_sys->i_start;
358 i_copy = __MIN( p_sys->i_header - i_offset, (int)((size_t)i_len - i_data) );
359 memcpy( &p_buffer[i_data], &p_sys->p_header[i_offset], i_copy );
362 p_access->info.i_pos += i_copy;
364 else if( p_sys->i_packet_used < p_sys->i_packet_length )
366 i_copy = __MIN( p_sys->i_packet_length - p_sys->i_packet_used,
369 memcpy( &p_buffer[i_data],
370 &p_sys->p_packet[p_sys->i_packet_used],
374 p_sys->i_packet_used += i_copy;
375 p_access->info.i_pos += i_copy;
377 else if( (p_sys->i_packet_length > 0) &&
378 ((int)p_sys->i_packet_used < p_sys->asfh.i_min_data_packet_size) )
380 i_copy = __MIN( p_sys->asfh.i_min_data_packet_size - p_sys->i_packet_used,
383 memset( &p_buffer[i_data], 0, i_copy );
386 p_sys->i_packet_used += i_copy;
387 p_access->info.i_pos += i_copy;
392 if( GetPacket( p_access, &ck ) )
395 if( p_sys->b_broadcast )
397 if( ck.i_type == 0x4524 && ck.i_sequence != 0 )
398 i_ret = Restart( p_access );
399 else if( ck.i_type == 0x4324 )
400 i_ret = Reset( p_access );
404 p_access->info.b_eof = VLC_TRUE;
408 if( ck.i_type != 0x4424 )
410 p_sys->i_packet_used = 0;
411 p_sys->i_packet_length = 0;
420 static int Restart( access_t *p_access )
422 access_sys_t *p_sys = p_access->p_sys;
423 char *psz_location = NULL;
425 msg_Dbg( p_access, "Restart the stream" );
426 p_sys->i_start = p_access->info.i_pos;
429 msg_Dbg( p_access, "stoping the stream" );
433 msg_Dbg( p_access, "describe the stream" );
434 if( Describe( p_access, &psz_location ) )
436 msg_Err( p_access, "describe failed" );
440 if( Start( p_access, 0 ) )
442 msg_Err( p_access, "Start failed" );
447 static int Reset( access_t *p_access )
449 access_sys_t *p_sys = p_access->p_sys;
450 asf_header_t old_asfh = p_sys->asfh;
453 msg_Dbg( p_access, "Reset the stream" );
454 p_sys->i_start = p_access->info.i_pos;
457 p_sys->i_packet_sequence = 0;
458 p_sys->i_packet_used = 0;
459 p_sys->i_packet_length = 0;
460 p_sys->p_packet = NULL;
462 /* Get the next header FIXME memory loss ? */
463 GetHeader( p_access );
464 if( p_sys->i_header <= 0 )
467 E_( asf_HeaderParse )( &p_sys->asfh,
468 p_sys->p_header, p_sys->i_header );
469 msg_Dbg( p_access, "packet count="I64Fd" packet size=%d",
470 p_sys->asfh.i_data_packets_count,
471 p_sys->asfh.i_min_data_packet_size );
473 E_( asf_StreamSelect)( &p_sys->asfh,
474 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
475 var_CreateGetInteger( p_access, "mms-all" ),
476 var_CreateGetInteger( p_access, "audio" ),
477 var_CreateGetInteger( p_access, "video" ) );
479 /* Check we have comptible asfh */
480 for( i = 1; i < 128; i++ )
482 asf_stream_t *p_old = &old_asfh.stream[i];
483 asf_stream_t *p_new = &p_sys->asfh.stream[i];
485 if( p_old->i_cat != p_new->i_cat || p_old->i_selected != p_new->i_selected )
490 msg_Warn( p_access, "incompatible asf header, restart" );
491 return Restart( p_access );
495 p_sys->i_packet_used = 0;
496 p_sys->i_packet_length = 0;
500 static int OpenConnection( access_t *p_access )
502 access_sys_t *p_sys = p_access->p_sys;
503 vlc_url_t srv = p_sys->b_proxy ? p_sys->proxy : p_sys->url;
505 if( ( p_sys->fd = net_ConnectTCP( p_access,
506 srv.psz_host, srv.i_port ) ) < 0 )
508 msg_Err( p_access, "cannot connect to %s:%d",
509 srv.psz_host, srv.i_port );
515 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
516 "GET http://%s:%d%s HTTP/1.0\r\n",
517 p_sys->url.psz_host, p_sys->url.i_port,
518 ( p_sys->url.psz_path == NULL || *p_sys->url.psz_path == '\0' ) ? "/" : p_sys->url.psz_path );
520 /* Proxy Authentication */
521 if( p_sys->proxy.psz_username && *p_sys->proxy.psz_username )
526 asprintf( &buf, "%s:%s", p_sys->proxy.psz_username,
527 p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" );
529 b64 = vlc_b64_encode( buf );
532 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
533 "Proxy-Authorization: Basic %s\r\n", b64 );
539 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
540 "GET %s HTTP/1.0\r\n"
542 ( p_sys->url.psz_path == NULL || *p_sys->url.psz_path == '\0' ) ? "/" : p_sys->url.psz_path,
543 p_sys->url.psz_host, p_sys->url.i_port );
548 /*****************************************************************************
550 *****************************************************************************/
551 static int Describe( access_t *p_access, char **ppsz_location )
553 access_sys_t *p_sys = p_access->p_sys;
554 char *psz_location = NULL;
559 p_sys->b_broadcast = VLC_TRUE;
560 p_sys->i_request_context = 1;
561 p_sys->i_packet_sequence = 0;
562 p_sys->i_packet_used = 0;
563 p_sys->i_packet_length = 0;
564 p_sys->p_packet = NULL;
565 E_( GenerateGuid )( &p_sys->guid );
567 if( OpenConnection( p_access ) )
570 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
572 "User-Agent: "MMSH_USER_AGENT"\r\n"
573 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=%d,max-duration=0\r\n"
574 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
575 "Connection: Close\r\n",
576 p_sys->i_request_context++,
577 GUID_PRINT( p_sys->guid ) );
579 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
581 msg_Err( p_access, "failed to send request" );
585 /* Receive the http header */
586 if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL ) ) == NULL )
588 msg_Err( p_access, "failed to read answer" );
591 if( strncmp( psz, "HTTP/1.", 7 ) )
593 msg_Err( p_access, "invalid HTTP reply '%s'", psz );
597 i_code = atoi( &psz[9] );
600 msg_Err( p_access, "error: %s", psz );
605 msg_Dbg( p_access, "HTTP reply '%s'", psz );
609 char *psz = net_Gets( p_access, p_sys->fd, NULL );
614 msg_Err( p_access, "failed to read answer" );
624 if( ( p = strchr( psz, ':' ) ) == NULL )
626 msg_Err( p_access, "malformed header line: %s", psz );
631 while( *p == ' ' ) p++;
633 /* FIXME FIXME test Content-Type to see if it's a plain stream or an
635 if( !strcasecmp( psz, "Pragma" ) )
637 if( strstr( p, "features" ) )
639 /* FIXME, it is a bit badly done here ..... */
640 if( strstr( p, "broadcast" ) )
642 msg_Dbg( p_access, "stream type = broadcast" );
643 p_sys->b_broadcast = VLC_TRUE;
645 else if( strstr( p, "seekable" ) )
647 msg_Dbg( p_access, "stream type = seekable" );
648 p_sys->b_broadcast = VLC_FALSE;
652 msg_Warn( p_access, "unknow stream types (%s)", p );
653 p_sys->b_broadcast = VLC_FALSE;
657 else if( !strcasecmp( psz, "Location" ) )
659 psz_location = strdup( p );
665 /* Handle the redirection */
666 if( ( i_code == 301 || i_code == 302 ||
667 i_code == 303 || i_code == 307 ) &&
668 psz_location && *psz_location )
670 msg_Dbg( p_access, "redirection to %s", psz_location );
671 net_Close( p_sys->fd ); p_sys->fd = -1;
673 *ppsz_location = psz_location;
677 /* Read the asf header */
678 GetHeader( p_access );
679 if( p_sys->i_header <= 0 )
681 msg_Err( p_access, "header size == 0" );
684 /* close this connection */
685 net_Close( p_sys->fd ); p_sys->fd = -1;
687 /* *** parse header and get stream and their id *** */
688 /* get all streams properties,
690 * TODO : stream bitrates properties(optional)
691 * and bitrate mutual exclusion(optional) */
692 E_( asf_HeaderParse )( &p_sys->asfh,
693 p_sys->p_header, p_sys->i_header );
694 msg_Dbg( p_access, "packet count="I64Fd" packet size=%d",
695 p_sys->asfh.i_data_packets_count,
696 p_sys->asfh.i_min_data_packet_size );
698 E_( asf_StreamSelect)( &p_sys->asfh,
699 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
700 var_CreateGetInteger( p_access, "mms-all" ),
701 var_CreateGetInteger( p_access, "audio" ),
702 var_CreateGetInteger( p_access, "video" ) );
708 net_Close( p_sys->fd );
714 static void GetHeader( access_t *p_access )
716 access_sys_t *p_sys = p_access->p_sys;
718 /* Read the asf header */
720 if( p_sys->p_header )
721 free( p_sys->p_header );
722 p_sys->p_header = NULL;
726 if( GetPacket( p_access, &ck ) || ck.i_type != 0x4824 )
731 p_sys->i_header += ck.i_data;
732 p_sys->p_header = realloc( p_sys->p_header, p_sys->i_header );
733 memcpy( &p_sys->p_header[p_sys->i_header - ck.i_data],
734 ck.p_data, ck.i_data );
737 msg_Dbg( p_access, "complete header size=%d", p_sys->i_header );
741 /*****************************************************************************
743 *****************************************************************************/
744 static int Start( access_t *p_access, off_t i_pos )
746 access_sys_t *p_sys = p_access->p_sys;
748 int i_streams_selected = 0;
752 msg_Dbg( p_access, "starting stream" );
754 for( i = 1; i < 128; i++ )
756 if( p_sys->asfh.stream[i].i_cat == ASF_STREAM_UNKNOWN )
759 if( p_sys->asfh.stream[i].i_selected )
760 i_streams_selected++;
762 if( i_streams_selected <= 0 )
764 msg_Err( p_access, "no stream selected" );
768 if( OpenConnection( p_access ) )
771 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
773 "User-Agent: "MMSH_USER_AGENT"\r\n" );
774 if( p_sys->b_broadcast )
776 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
777 "Pragma: no-cache,rate=1.000000,request-context=%d\r\n",
778 p_sys->i_request_context++ );
782 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
783 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=%u:%u,request-context=%d,max-duration=0\r\n",
784 (uint32_t)((i_pos >> 32)&0xffffffff),
785 (uint32_t)(i_pos&0xffffffff),
786 p_sys->i_request_context++ );
788 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
789 "Pragma: xPlayStrm=1\r\n"
790 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
791 "Pragma: stream-switch-count=%d\r\n"
792 "Pragma: stream-switch-entry=",
793 GUID_PRINT( p_sys->guid ),
796 for( i = 1; i < 128; i++ )
798 if( p_sys->asfh.stream[i].i_cat != ASF_STREAM_UNKNOWN )
801 if( p_sys->asfh.stream[i].i_selected )
806 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
807 "ffff:%d:%d ", i, i_select );
810 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" );
811 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
812 "Connection: Close\r\n" );
814 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
816 msg_Err( p_access, "failed to send request" );
820 if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL ) ) == NULL )
822 msg_Err( p_access, "cannot read data" );
825 if( atoi( &psz[9] ) >= 400 )
827 msg_Err( p_access, "error: %s", psz );
831 msg_Dbg( p_access, "HTTP reply '%s'", psz );
834 /* FIXME check HTTP code */
837 char *psz = net_Gets( p_access, p_sys->fd, NULL );
840 msg_Err( p_access, "cannot read data" );
848 msg_Dbg( p_access, "%s", psz );
852 p_sys->i_packet_used = 0;
853 p_sys->i_packet_length = 0;
858 /*****************************************************************************
860 *****************************************************************************/
861 static void Stop( access_t *p_access )
863 access_sys_t *p_sys = p_access->p_sys;
865 msg_Dbg( p_access, "closing stream" );
868 net_Close( p_sys->fd );
873 /*****************************************************************************
875 *****************************************************************************/
876 static int GetPacket( access_t * p_access, chunk_t *p_ck )
878 access_sys_t *p_sys = p_access->p_sys;
882 memset( p_ck, 0, sizeof( chunk_t ) );
884 /* Read the chunk header */
885 /* Some headers are short, like 0x4324. Reading 12 bytes will cause us
886 * to lose synchronization with the stream. Just read to the length
887 * (4 bytes), decode and then read up to 8 additional bytes to get the
890 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer, 4, VLC_TRUE ) < 4 )
893 p_ck->i_type = GetWLE( p_sys->buffer);
894 p_ck->i_size = GetWLE( p_sys->buffer + 2);
896 restsize = p_ck->i_size;
900 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer + 4, restsize, VLC_TRUE ) < restsize )
902 msg_Err( p_access, "cannot read data" );
905 p_ck->i_sequence = GetDWLE( p_sys->buffer + 4);
906 p_ck->i_unknown = GetWLE( p_sys->buffer + 8);
908 /* Set i_size2 to 8 if this header was short, since a real value won't be
909 * present in the buffer. Using 8 avoid reading additional data for the
915 p_ck->i_size2 = GetWLE( p_sys->buffer + 10);
917 p_ck->p_data = p_sys->buffer + 12;
918 p_ck->i_data = p_ck->i_size2 - 8;
920 if( p_ck->i_type == 0x4524 ) // Transfer complete
922 if( p_ck->i_sequence == 0 )
924 msg_Warn( p_access, "EOF" );
929 msg_Warn( p_access, "next stream following" );
933 else if( p_ck->i_type == 0x4324 )
935 /* 0x4324 is CHUNK_TYPE_RESET: a new stream will follow with a sequence of 0 */
936 msg_Warn( p_access, "next stream following (reset) seq=%d", p_ck->i_sequence );
939 else if( (p_ck->i_type != 0x4824) && (p_ck->i_type != 0x4424) )
941 msg_Err( p_access, "invalid chunk FATAL (0x%x)", p_ck->i_type );
945 if( (p_ck->i_data > 0) &&
946 (net_Read( p_access, p_sys->fd, NULL, &p_sys->buffer[12],
947 p_ck->i_data, VLC_TRUE ) < p_ck->i_data) )
949 msg_Err( p_access, "cannot read data" );
954 if( (p_sys->i_packet_sequence != 0) &&
955 (p_ck->i_sequence != p_sys->i_packet_sequence) )
957 msg_Warn( p_access, "packet lost ? (%d != %d)", p_ck->i_sequence, p_sys->i_packet_sequence );
961 p_sys->i_packet_sequence = p_ck->i_sequence + 1;
962 p_sys->i_packet_used = 0;
963 p_sys->i_packet_length = p_ck->i_data;
964 p_sys->p_packet = p_ck->p_data;