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 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_access.h>
34 #include "vlc_strings.h"
35 #include "vlc_input.h"
37 #include <vlc_network.h>
49 /*****************************************************************************
51 *****************************************************************************/
52 int MMSHOpen ( access_t * );
53 void MMSHClose ( access_t * );
55 static ssize_t Read( access_t *, uint8_t *, size_t );
56 static ssize_t ReadRedirect( access_t *, uint8_t *, size_t );
57 static int Seek( access_t *, int64_t );
58 static int Control( access_t *, int, va_list );
60 static int Describe( access_t *, char **ppsz_location );
61 static int Start( access_t *, int64_t );
62 static void Stop( access_t * );
64 static int GetPacket( access_t *, chunk_t * );
65 static void GetHeader( access_t *p_access );
67 static int Restart( access_t * );
68 static int Reset( access_t * );
70 //#define MMSH_USER_AGENT "NSPlayer/4.1.0.3856"
71 #define MMSH_USER_AGENT "NSPlayer/7.10.0.3059"
73 /****************************************************************************
74 * Open: connect to ftp server and ask for file
75 ****************************************************************************/
76 int MMSHOpen( access_t *p_access )
79 char *psz_location = NULL;
85 p_access->pf_read = Read;
86 p_access->pf_block = NULL;
87 p_access->pf_control = Control;
88 p_access->pf_seek = Seek;
89 p_access->info.i_update = 0;
90 p_access->info.i_size = 0;
91 p_access->info.i_pos = 0;
92 p_access->info.b_eof = false;
93 p_access->info.i_title = 0;
94 p_access->info.i_seekpoint = 0;
96 p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
100 memset( p_sys, 0, sizeof( access_sys_t ) );
101 p_sys->i_proto= MMS_PROTO_HTTP;
106 p_sys->b_proxy = false;
107 memset( &p_sys->proxy, 0, sizeof(p_sys->proxy) );
110 /* TODO reuse instead http-proxy from http access ? */
111 psz_proxy = var_CreateGetString( p_access, "mmsh-proxy" );
114 char *psz_http_proxy = config_GetPsz( p_access, "http-proxy" );
115 if( psz_http_proxy && *psz_http_proxy )
118 psz_proxy = psz_http_proxy;
119 var_SetString( p_access, "mmsh-proxy", psz_proxy );
123 free( psz_http_proxy );
129 p_sys->b_proxy = true;
130 vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 );
135 char *psz_proxy = getenv( "http_proxy" );
136 if( psz_proxy && *psz_proxy )
138 p_sys->b_proxy = true;
139 vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 );
147 if( ( p_sys->proxy.psz_host == NULL ) ||
148 ( *p_sys->proxy.psz_host == '\0' ) )
150 msg_Warn( p_access, "invalid proxy host" );
151 vlc_UrlClean( &p_sys->proxy );
156 if( p_sys->proxy.i_port <= 0 )
157 p_sys->proxy.i_port = 80;
158 msg_Dbg( p_access, "Using http proxy %s:%d",
159 p_sys->proxy.psz_host, p_sys->proxy.i_port );
162 /* open a tcp connection */
163 vlc_UrlParse( &p_sys->url, p_access->psz_path, 0 );
164 if( ( p_sys->url.psz_host == NULL ) ||
165 ( *p_sys->url.psz_host == '\0' ) )
167 msg_Err( p_access, "invalid host" );
168 vlc_UrlClean( &p_sys->proxy );
169 vlc_UrlClean( &p_sys->url );
173 if( p_sys->url.i_port <= 0 )
174 p_sys->url.i_port = 80;
176 if( Describe( p_access, &psz_location ) )
178 vlc_UrlClean( &p_sys->proxy );
179 vlc_UrlClean( &p_sys->url );
183 /* Handle redirection */
184 if( psz_location && *psz_location )
186 msg_Dbg( p_access, "redirection to %s", psz_location );
188 input_thread_t * p_input = vlc_object_find( p_access, VLC_OBJECT_INPUT, FIND_PARENT );
189 input_item_t * p_new_loc;
190 /** \bug we do not autodelete here */
191 p_new_loc = input_ItemNew( p_access, psz_location, psz_location );
192 input_ItemAddSubItem( input_GetItem( p_input ), p_new_loc );
193 vlc_object_release( p_input );
195 free( psz_location );
197 p_access->pf_read = ReadRedirect;
202 if( Start( p_access, 0 ) )
204 msg_Err( p_access, "cannot start stream" );
205 free( p_sys->p_header );
206 vlc_UrlClean( &p_sys->proxy );
207 vlc_UrlClean( &p_sys->url );
212 if( !p_sys->b_broadcast )
214 p_access->info.i_size = p_sys->asfh.i_file_size;
220 /*****************************************************************************
221 * Close: free unused data structures
222 *****************************************************************************/
223 void MMSHClose ( access_t *p_access )
225 access_sys_t *p_sys = p_access->p_sys;
229 free( p_sys->p_header );
231 vlc_UrlClean( &p_sys->proxy );
232 vlc_UrlClean( &p_sys->url );
236 /*****************************************************************************
238 *****************************************************************************/
239 static int Control( access_t *p_access, int i_query, va_list args )
241 access_sys_t *p_sys = p_access->p_sys;
250 case ACCESS_CAN_SEEK:
251 pb_bool = (bool*)va_arg( args, bool* );
252 *pb_bool = !p_sys->b_broadcast;
255 case ACCESS_CAN_FASTSEEK:
256 case ACCESS_CAN_PAUSE:
257 pb_bool = (bool*)va_arg( args, bool* );
261 case ACCESS_CAN_CONTROL_PACE:
262 pb_bool = (bool*)va_arg( args, bool* );
268 pi_int = (int*)va_arg( args, int * );
269 *pi_int = 3 * p_sys->asfh.i_min_data_packet_size;
272 case ACCESS_GET_PTS_DELAY:
273 pi_64 = (int64_t*)va_arg( args, int64_t * );
274 *pi_64 = (int64_t)var_GetInteger( p_access, "mms-caching" ) * INT64_C(1000);
277 case ACCESS_GET_PRIVATE_ID_STATE:
278 i_int = (int)va_arg( args, int );
279 pb_bool = (bool *)va_arg( args, bool * );
281 if( (i_int < 0) || (i_int > 127) )
283 *pb_bool = p_sys->asfh.stream[i_int].i_selected ? true : false;
287 case ACCESS_SET_PAUSE_STATE:
288 case ACCESS_GET_TITLE_INFO:
289 case ACCESS_SET_TITLE:
290 case ACCESS_SET_SEEKPOINT:
291 case ACCESS_SET_PRIVATE_ID_STATE:
292 case ACCESS_GET_CONTENT_TYPE:
296 msg_Warn( p_access, "unimplemented query in control" );
303 /*****************************************************************************
304 * Seek: try to go at the right place
305 *****************************************************************************/
306 static int Seek( access_t *p_access, int64_t i_pos )
308 access_sys_t *p_sys = p_access->p_sys;
313 msg_Dbg( p_access, "seeking to %"PRId64, i_pos );
315 i_packet = ( i_pos - p_sys->i_header ) / p_sys->asfh.i_min_data_packet_size;
316 i_offset = ( i_pos - p_sys->i_header ) % p_sys->asfh.i_min_data_packet_size;
319 Start( p_access, i_packet * p_sys->asfh.i_min_data_packet_size );
321 while( !p_access->b_die )
323 msg_Warn( p_access, "GetPacket 1" );
324 if( GetPacket( p_access, &ck ) )
328 if( ck.i_type != 0x4824 )
331 msg_Warn( p_access, "skipping header" );
334 p_access->info.i_pos = i_pos;
335 p_access->info.b_eof = false;
336 p_sys->i_packet_used += i_offset;
341 /*****************************************************************************
343 *****************************************************************************/
344 static ssize_t ReadRedirect( access_t *p_access, uint8_t *p, size_t i_len )
349 /*****************************************************************************
351 *****************************************************************************/
352 static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
354 access_sys_t *p_sys = p_access->p_sys;
358 if( p_access->info.b_eof )
361 while( i_data < (size_t) i_len )
363 if( p_access->info.i_pos < (p_sys->i_start + p_sys->i_header) )
365 int i_offset = p_access->info.i_pos - p_sys->i_start;
366 i_copy = __MIN( p_sys->i_header - i_offset,
367 (int)((size_t)i_len - i_data) );
368 memcpy( &p_buffer[i_data], &p_sys->p_header[i_offset], i_copy );
371 p_access->info.i_pos += i_copy;
373 else if( p_sys->i_packet_used < p_sys->i_packet_length )
375 i_copy = __MIN( p_sys->i_packet_length - p_sys->i_packet_used,
377 memcpy( &p_buffer[i_data],
378 &p_sys->p_packet[p_sys->i_packet_used],
382 p_sys->i_packet_used += i_copy;
383 p_access->info.i_pos += i_copy;
385 else if( (p_sys->i_packet_length > 0) &&
386 ((int)p_sys->i_packet_used < p_sys->asfh.i_min_data_packet_size) )
388 i_copy = __MIN( p_sys->asfh.i_min_data_packet_size - p_sys->i_packet_used,
390 memset( &p_buffer[i_data], 0, i_copy );
393 p_sys->i_packet_used += i_copy;
394 p_access->info.i_pos += i_copy;
399 msg_Warn( p_access, "GetPacket 2" );
400 if( GetPacket( p_access, &ck ) )
403 if( p_sys->b_broadcast )
405 if( (ck.i_type == 0x4524) && (ck.i_sequence != 0) )
406 i_ret = Restart( p_access );
407 else if( ck.i_type == 0x4324 )
408 i_ret = Reset( p_access );
412 p_access->info.b_eof = true;
416 if( ck.i_type != 0x4424 )
418 p_sys->i_packet_used = 0;
419 p_sys->i_packet_length = 0;
428 static int Restart( access_t *p_access )
430 access_sys_t *p_sys = p_access->p_sys;
431 char *psz_location = NULL;
433 msg_Dbg( p_access, "Restart the stream" );
434 p_sys->i_start = p_access->info.i_pos;
437 msg_Dbg( p_access, "stoping the stream" );
441 msg_Dbg( p_access, "describe the stream" );
442 if( Describe( p_access, &psz_location ) )
444 msg_Err( p_access, "describe failed" );
448 if( Start( p_access, 0 ) )
450 msg_Err( p_access, "Start failed" );
455 static int Reset( access_t *p_access )
457 access_sys_t *p_sys = p_access->p_sys;
458 asf_header_t old_asfh = p_sys->asfh;
461 msg_Dbg( p_access, "Reset the stream" );
462 p_sys->i_start = p_access->info.i_pos;
465 p_sys->i_packet_sequence = 0;
466 p_sys->i_packet_used = 0;
467 p_sys->i_packet_length = 0;
468 p_sys->p_packet = NULL;
470 /* Get the next header FIXME memory loss ? */
471 GetHeader( p_access );
472 if( p_sys->i_header <= 0 )
475 asf_HeaderParse ( &p_sys->asfh,
476 p_sys->p_header, p_sys->i_header );
477 msg_Dbg( p_access, "packet count=%"PRId64" packet size=%d",
478 p_sys->asfh.i_data_packets_count,
479 p_sys->asfh.i_min_data_packet_size );
481 asf_StreamSelect( &p_sys->asfh,
482 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
483 var_CreateGetInteger( p_access, "mms-all" ),
484 var_CreateGetInteger( p_access, "audio" ),
485 var_CreateGetInteger( p_access, "video" ) );
487 /* Check we have comptible asfh */
488 for( i = 1; i < 128; i++ )
490 asf_stream_t *p_old = &old_asfh.stream[i];
491 asf_stream_t *p_new = &p_sys->asfh.stream[i];
493 if( p_old->i_cat != p_new->i_cat || p_old->i_selected != p_new->i_selected )
498 msg_Warn( p_access, "incompatible asf header, restart" );
499 return Restart( p_access );
503 p_sys->i_packet_used = 0;
504 p_sys->i_packet_length = 0;
508 static int OpenConnection( access_t *p_access )
510 access_sys_t *p_sys = p_access->p_sys;
511 vlc_url_t srv = p_sys->b_proxy ? p_sys->proxy : p_sys->url;
513 if( ( p_sys->fd = net_ConnectTCP( p_access,
514 srv.psz_host, srv.i_port ) ) < 0 )
516 msg_Err( p_access, "cannot connect to %s:%d",
517 srv.psz_host, srv.i_port );
523 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
524 "GET http://%s:%d%s HTTP/1.0\r\n",
525 p_sys->url.psz_host, p_sys->url.i_port,
526 ( (p_sys->url.psz_path == NULL) ||
527 (*p_sys->url.psz_path == '\0') ) ?
528 "/" : p_sys->url.psz_path );
530 /* Proxy Authentication */
531 if( p_sys->proxy.psz_username && *p_sys->proxy.psz_username )
536 asprintf( &buf, "%s:%s", p_sys->proxy.psz_username,
537 p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" );
539 b64 = vlc_b64_encode( buf );
542 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
543 "Proxy-Authorization: Basic %s\r\n", b64 );
549 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
550 "GET %s HTTP/1.0\r\n"
552 ( (p_sys->url.psz_path == NULL) ||
553 (*p_sys->url.psz_path == '\0') ) ?
554 "/" : p_sys->url.psz_path,
555 p_sys->url.psz_host, p_sys->url.i_port );
560 /*****************************************************************************
562 *****************************************************************************/
563 static int Describe( access_t *p_access, char **ppsz_location )
565 access_sys_t *p_sys = p_access->p_sys;
566 char *psz_location = NULL;
571 p_sys->b_broadcast = true;
572 p_sys->i_request_context = 1;
573 p_sys->i_packet_sequence = 0;
574 p_sys->i_packet_used = 0;
575 p_sys->i_packet_length = 0;
576 p_sys->p_packet = NULL;
577 GenerateGuid ( &p_sys->guid );
579 if( OpenConnection( p_access ) )
582 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
584 "User-Agent: "MMSH_USER_AGENT"\r\n"
585 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=%d,max-duration=0\r\n"
586 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
587 "Connection: Close\r\n",
588 p_sys->i_request_context++,
589 GUID_PRINT( p_sys->guid ) );
591 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
593 msg_Err( p_access, "failed to send request" );
597 /* Receive the http header */
598 if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL ) ) == NULL )
600 msg_Err( p_access, "failed to read answer" );
604 if( strncmp( psz, "HTTP/1.", 7 ) )
606 msg_Err( p_access, "invalid HTTP reply '%s'", psz );
610 i_code = atoi( &psz[9] );
613 msg_Err( p_access, "error: %s", psz );
618 msg_Dbg( p_access, "HTTP reply '%s'", psz );
622 char *psz = net_Gets( p_access, p_sys->fd, NULL );
627 msg_Err( p_access, "failed to read answer" );
637 if( ( p = strchr( psz, ':' ) ) == NULL )
639 msg_Err( p_access, "malformed header line: %s", psz );
644 while( *p == ' ' ) p++;
646 /* FIXME FIXME test Content-Type to see if it's a plain stream or an
648 if( !strcasecmp( psz, "Pragma" ) )
650 if( strstr( p, "features" ) )
652 /* FIXME, it is a bit badly done here ..... */
653 if( strstr( p, "broadcast" ) )
655 msg_Dbg( p_access, "stream type = broadcast" );
656 p_sys->b_broadcast = true;
658 else if( strstr( p, "seekable" ) )
660 msg_Dbg( p_access, "stream type = seekable" );
661 p_sys->b_broadcast = false;
665 msg_Warn( p_access, "unknow stream types (%s)", p );
666 p_sys->b_broadcast = false;
670 else if( !strcasecmp( psz, "Location" ) )
672 psz_location = strdup( p );
678 /* Handle the redirection */
679 if( ( (i_code == 301) || (i_code == 302) ||
680 (i_code == 303) || (i_code == 307) ) &&
681 psz_location && *psz_location )
683 msg_Dbg( p_access, "redirection to %s", psz_location );
684 net_Close( p_sys->fd ); p_sys->fd = -1;
686 *ppsz_location = psz_location;
690 /* Read the asf header */
691 GetHeader( p_access );
692 if( p_sys->i_header <= 0 )
694 msg_Err( p_access, "header size == 0" );
697 /* close this connection */
698 net_Close( p_sys->fd );
701 /* *** parse header and get stream and their id *** */
702 /* get all streams properties,
704 * TODO : stream bitrates properties(optional)
705 * and bitrate mutual exclusion(optional) */
706 asf_HeaderParse ( &p_sys->asfh,
707 p_sys->p_header, p_sys->i_header );
708 msg_Dbg( p_access, "packet count=%"PRId64" packet size=%d",
709 p_sys->asfh.i_data_packets_count,
710 p_sys->asfh.i_min_data_packet_size );
712 asf_StreamSelect( &p_sys->asfh,
713 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
714 var_CreateGetInteger( p_access, "mms-all" ),
715 var_CreateGetInteger( p_access, "audio" ),
716 var_CreateGetInteger( p_access, "video" ) );
722 net_Close( p_sys->fd );
728 static void GetHeader( access_t *p_access )
730 access_sys_t *p_sys = p_access->p_sys;
732 /* Read the asf header */
734 free( p_sys->p_header );
735 p_sys->p_header = NULL;
739 if( GetPacket( p_access, &ck ) || ck.i_type != 0x4824 )
744 p_sys->i_header += ck.i_data;
745 p_sys->p_header = realloc( p_sys->p_header, p_sys->i_header );
746 memcpy( &p_sys->p_header[p_sys->i_header - ck.i_data],
747 ck.p_data, ck.i_data );
750 msg_Dbg( p_access, "complete header size=%d", p_sys->i_header );
754 /*****************************************************************************
756 ****************************************************************************/
757 static int Start( access_t *p_access, int64_t i_pos )
759 access_sys_t *p_sys = p_access->p_sys;
761 int i_streams_selected = 0;
765 msg_Dbg( p_access, "starting stream" );
767 for( i = 1; i < 128; i++ )
769 if( p_sys->asfh.stream[i].i_cat == ASF_STREAM_UNKNOWN )
772 if( p_sys->asfh.stream[i].i_selected )
773 i_streams_selected++;
775 if( i_streams_selected <= 0 )
777 msg_Err( p_access, "no stream selected" );
781 if( OpenConnection( p_access ) )
784 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
786 "User-Agent: "MMSH_USER_AGENT"\r\n" );
787 if( p_sys->b_broadcast )
789 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
790 "Pragma: no-cache,rate=1.000000,request-context=%d\r\n",
791 p_sys->i_request_context++ );
795 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
796 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=%u:%u,request-context=%d,max-duration=0\r\n",
797 (uint32_t)((i_pos >> 32)&0xffffffff),
798 (uint32_t)(i_pos&0xffffffff),
799 p_sys->i_request_context++ );
801 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
802 "Pragma: xPlayStrm=1\r\n"
803 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
804 "Pragma: stream-switch-count=%d\r\n"
805 "Pragma: stream-switch-entry=",
806 GUID_PRINT( p_sys->guid ),
809 for( i = 1; i < 128; i++ )
811 if( p_sys->asfh.stream[i].i_cat != ASF_STREAM_UNKNOWN )
814 if( p_sys->asfh.stream[i].i_selected )
818 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
819 "ffff:%d:%d ", i, i_select );
822 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" );
823 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
824 "Connection: Close\r\n" );
826 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
828 msg_Err( p_access, "failed to send request" );
832 psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL );
835 msg_Err( p_access, "cannot read data 0" );
839 if( atoi( &psz[9] ) >= 400 )
841 msg_Err( p_access, "error: %s", psz );
845 msg_Dbg( p_access, "HTTP reply '%s'", psz );
848 /* FIXME check HTTP code */
851 char *psz = net_Gets( p_access, p_sys->fd, NULL );
854 msg_Err( p_access, "cannot read data 1" );
862 msg_Dbg( p_access, "%s", psz );
866 p_sys->i_packet_used = 0;
867 p_sys->i_packet_length = 0;
872 /*****************************************************************************
874 *****************************************************************************/
875 static void Stop( access_t *p_access )
877 access_sys_t *p_sys = p_access->p_sys;
879 msg_Dbg( p_access, "closing stream" );
882 net_Close( p_sys->fd );
887 /*****************************************************************************
889 *****************************************************************************/
890 static int GetPacket( access_t * p_access, chunk_t *p_ck )
892 access_sys_t *p_sys = p_access->p_sys;
896 memset( p_ck, 0, sizeof( chunk_t ) );
898 /* Read the chunk header */
899 /* Some headers are short, like 0x4324. Reading 12 bytes will cause us
900 * to lose synchronization with the stream. Just read to the length
901 * (4 bytes), decode and then read up to 8 additional bytes to get the
904 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer, 4, true ) < 4 )
906 msg_Err( p_access, "cannot read data 2" );
910 p_ck->i_type = GetWLE( p_sys->buffer);
911 p_ck->i_size = GetWLE( p_sys->buffer + 2);
913 restsize = p_ck->i_size;
917 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer + 4, restsize, true ) < restsize )
919 msg_Err( p_access, "cannot read data 3" );
922 p_ck->i_sequence = GetDWLE( p_sys->buffer + 4);
923 p_ck->i_unknown = GetWLE( p_sys->buffer + 8);
925 /* Set i_size2 to 8 if this header was short, since a real value won't be
926 * present in the buffer. Using 8 avoid reading additional data for the
932 p_ck->i_size2 = GetWLE( p_sys->buffer + 10);
934 p_ck->p_data = p_sys->buffer + 12;
935 p_ck->i_data = p_ck->i_size2 - 8;
937 if( p_ck->i_type == 0x4524 ) // Transfer complete
939 if( p_ck->i_sequence == 0 )
941 msg_Warn( p_access, "EOF" );
946 msg_Warn( p_access, "next stream following" );
950 else if( p_ck->i_type == 0x4324 )
952 /* 0x4324 is CHUNK_TYPE_RESET: a new stream will follow with a sequence of 0 */
953 msg_Warn( p_access, "next stream following (reset) seq=%d", p_ck->i_sequence );
956 else if( (p_ck->i_type != 0x4824) && (p_ck->i_type != 0x4424) )
958 msg_Err( p_access, "invalid chunk FATAL (0x%x)", p_ck->i_type );
962 if( (p_ck->i_data > 0) &&
963 (net_Read( p_access, p_sys->fd, NULL, &p_sys->buffer[12],
964 p_ck->i_data, true ) < p_ck->i_data) )
966 msg_Err( p_access, "cannot read data 4" );
971 if( (p_sys->i_packet_sequence != 0) &&
972 (p_ck->i_sequence != p_sys->i_packet_sequence) )
974 msg_Warn( p_access, "packet lost ? (%d != %d)", p_ck->i_sequence, p_sys->i_packet_sequence );
978 p_sys->i_packet_sequence = p_ck->i_sequence + 1;
979 p_sys->i_packet_used = 0;
980 p_sys->i_packet_length = p_ck->i_data;
981 p_sys->p_packet = p_ck->p_data;