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;
251 case ACCESS_CAN_SEEK:
252 pb_bool = (bool*)va_arg( args, bool* );
253 *pb_bool = !p_sys->b_broadcast;
256 case ACCESS_CAN_FASTSEEK:
257 pb_bool = (bool*)va_arg( args, bool* );
261 case ACCESS_CAN_PAUSE:
262 case ACCESS_CAN_CONTROL_PACE:
263 pb_bool = (bool*)va_arg( args, bool* );
269 pi_int = (int*)va_arg( args, int * );
270 *pi_int = 3 * p_sys->asfh.i_min_data_packet_size;
273 case ACCESS_GET_PTS_DELAY:
274 pi_64 = (int64_t*)va_arg( args, int64_t * );
275 *pi_64 = (int64_t)var_GetInteger( p_access, "mms-caching" ) * INT64_C(1000);
278 case ACCESS_GET_PRIVATE_ID_STATE:
279 i_int = (int)va_arg( args, int );
280 pb_bool = (bool *)va_arg( args, bool * );
282 if( (i_int < 0) || (i_int > 127) )
284 *pb_bool = p_sys->asfh.stream[i_int].i_selected ? true : false;
288 case ACCESS_SET_PAUSE_STATE:
289 b_bool = (bool)va_arg( args, int );
293 Seek( p_access, p_access->info.i_pos );
296 case ACCESS_GET_TITLE_INFO:
297 case ACCESS_SET_TITLE:
298 case ACCESS_SET_SEEKPOINT:
299 case ACCESS_SET_PRIVATE_ID_STATE:
300 case ACCESS_GET_CONTENT_TYPE:
304 msg_Warn( p_access, "unimplemented query in control" );
311 /*****************************************************************************
312 * Seek: try to go at the right place
313 *****************************************************************************/
314 static int Seek( access_t *p_access, int64_t i_pos )
316 access_sys_t *p_sys = p_access->p_sys;
321 msg_Dbg( p_access, "seeking to %"PRId64, i_pos );
323 i_packet = ( i_pos - p_sys->i_header ) / p_sys->asfh.i_min_data_packet_size;
324 i_offset = ( i_pos - p_sys->i_header ) % p_sys->asfh.i_min_data_packet_size;
327 Start( p_access, i_packet * p_sys->asfh.i_min_data_packet_size );
329 while( vlc_object_alive (p_access) )
331 if( GetPacket( p_access, &ck ) )
335 if( ck.i_type != 0x4824 )
338 msg_Warn( p_access, "skipping header" );
341 p_access->info.i_pos = i_pos;
342 p_access->info.b_eof = false;
343 p_sys->i_packet_used += i_offset;
348 /*****************************************************************************
350 *****************************************************************************/
351 static ssize_t ReadRedirect( access_t *p_access, uint8_t *p, size_t i_len )
356 /*****************************************************************************
358 *****************************************************************************/
359 static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
361 access_sys_t *p_sys = p_access->p_sys;
365 if( p_access->info.b_eof )
368 while( i_data < (size_t) i_len )
370 if( p_access->info.i_pos < (p_sys->i_start + p_sys->i_header) )
372 int i_offset = p_access->info.i_pos - p_sys->i_start;
373 i_copy = __MIN( p_sys->i_header - i_offset,
374 (int)((size_t)i_len - i_data) );
375 memcpy( &p_buffer[i_data], &p_sys->p_header[i_offset], i_copy );
378 p_access->info.i_pos += i_copy;
380 else if( p_sys->i_packet_used < p_sys->i_packet_length )
382 i_copy = __MIN( p_sys->i_packet_length - p_sys->i_packet_used,
384 memcpy( &p_buffer[i_data],
385 &p_sys->p_packet[p_sys->i_packet_used],
389 p_sys->i_packet_used += i_copy;
390 p_access->info.i_pos += i_copy;
392 else if( (p_sys->i_packet_length > 0) &&
393 ((int)p_sys->i_packet_used < p_sys->asfh.i_min_data_packet_size) )
395 i_copy = __MIN( p_sys->asfh.i_min_data_packet_size - p_sys->i_packet_used,
397 memset( &p_buffer[i_data], 0, i_copy );
400 p_sys->i_packet_used += i_copy;
401 p_access->info.i_pos += i_copy;
406 if( GetPacket( p_access, &ck ) )
409 if( p_sys->b_broadcast )
411 if( (ck.i_type == 0x4524) && (ck.i_sequence != 0) )
412 i_ret = Restart( p_access );
413 else if( ck.i_type == 0x4324 )
414 i_ret = Reset( p_access );
418 p_access->info.b_eof = true;
422 if( ck.i_type != 0x4424 )
424 p_sys->i_packet_used = 0;
425 p_sys->i_packet_length = 0;
434 static int Restart( access_t *p_access )
436 access_sys_t *p_sys = p_access->p_sys;
437 char *psz_location = NULL;
439 msg_Dbg( p_access, "Restart the stream" );
440 p_sys->i_start = p_access->info.i_pos;
443 msg_Dbg( p_access, "stoping the stream" );
447 msg_Dbg( p_access, "describe the stream" );
448 if( Describe( p_access, &psz_location ) )
450 msg_Err( p_access, "describe failed" );
454 if( Start( p_access, 0 ) )
456 msg_Err( p_access, "Start failed" );
461 static int Reset( access_t *p_access )
463 access_sys_t *p_sys = p_access->p_sys;
464 asf_header_t old_asfh = p_sys->asfh;
467 msg_Dbg( p_access, "Reset the stream" );
468 p_sys->i_start = p_access->info.i_pos;
471 p_sys->i_packet_sequence = 0;
472 p_sys->i_packet_used = 0;
473 p_sys->i_packet_length = 0;
474 p_sys->p_packet = NULL;
476 /* Get the next header FIXME memory loss ? */
477 GetHeader( p_access );
478 if( p_sys->i_header <= 0 )
481 asf_HeaderParse ( &p_sys->asfh,
482 p_sys->p_header, p_sys->i_header );
483 msg_Dbg( p_access, "packet count=%"PRId64" packet size=%d",
484 p_sys->asfh.i_data_packets_count,
485 p_sys->asfh.i_min_data_packet_size );
487 asf_StreamSelect( &p_sys->asfh,
488 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
489 var_CreateGetInteger( p_access, "mms-all" ),
490 var_CreateGetInteger( p_access, "audio" ),
491 var_CreateGetInteger( p_access, "video" ) );
493 /* Check we have comptible asfh */
494 for( i = 1; i < 128; i++ )
496 asf_stream_t *p_old = &old_asfh.stream[i];
497 asf_stream_t *p_new = &p_sys->asfh.stream[i];
499 if( p_old->i_cat != p_new->i_cat || p_old->i_selected != p_new->i_selected )
504 msg_Warn( p_access, "incompatible asf header, restart" );
505 return Restart( p_access );
509 p_sys->i_packet_used = 0;
510 p_sys->i_packet_length = 0;
514 static int OpenConnection( access_t *p_access )
516 access_sys_t *p_sys = p_access->p_sys;
517 vlc_url_t srv = p_sys->b_proxy ? p_sys->proxy : p_sys->url;
519 if( ( p_sys->fd = net_ConnectTCP( p_access,
520 srv.psz_host, srv.i_port ) ) < 0 )
522 msg_Err( p_access, "cannot connect to %s:%d",
523 srv.psz_host, srv.i_port );
529 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
530 "GET http://%s:%d%s HTTP/1.0\r\n",
531 p_sys->url.psz_host, p_sys->url.i_port,
532 ( (p_sys->url.psz_path == NULL) ||
533 (*p_sys->url.psz_path == '\0') ) ?
534 "/" : p_sys->url.psz_path );
536 /* Proxy Authentication */
537 if( p_sys->proxy.psz_username && *p_sys->proxy.psz_username )
542 asprintf( &buf, "%s:%s", p_sys->proxy.psz_username,
543 p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" );
545 b64 = vlc_b64_encode( buf );
548 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
549 "Proxy-Authorization: Basic %s\r\n", b64 );
555 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
556 "GET %s HTTP/1.0\r\n"
558 ( (p_sys->url.psz_path == NULL) ||
559 (*p_sys->url.psz_path == '\0') ) ?
560 "/" : p_sys->url.psz_path,
561 p_sys->url.psz_host, p_sys->url.i_port );
566 /*****************************************************************************
568 *****************************************************************************/
569 static int Describe( access_t *p_access, char **ppsz_location )
571 access_sys_t *p_sys = p_access->p_sys;
572 char *psz_location = NULL;
577 p_sys->b_broadcast = true;
578 p_sys->i_request_context = 1;
579 p_sys->i_packet_sequence = 0;
580 p_sys->i_packet_used = 0;
581 p_sys->i_packet_length = 0;
582 p_sys->p_packet = NULL;
583 GenerateGuid ( &p_sys->guid );
585 if( OpenConnection( p_access ) )
588 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
590 "User-Agent: "MMSH_USER_AGENT"\r\n"
591 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=%d,max-duration=0\r\n"
592 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
593 "Connection: Close\r\n",
594 p_sys->i_request_context++,
595 GUID_PRINT( p_sys->guid ) );
597 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
599 msg_Err( p_access, "failed to send request" );
603 /* Receive the http header */
604 if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL ) ) == NULL )
606 msg_Err( p_access, "failed to read answer" );
610 if( strncmp( psz, "HTTP/1.", 7 ) )
612 msg_Err( p_access, "invalid HTTP reply '%s'", psz );
616 i_code = atoi( &psz[9] );
619 msg_Err( p_access, "error: %s", psz );
624 msg_Dbg( p_access, "HTTP reply '%s'", psz );
628 char *psz = net_Gets( p_access, p_sys->fd, NULL );
633 msg_Err( p_access, "failed to read answer" );
643 if( ( p = strchr( psz, ':' ) ) == NULL )
645 msg_Err( p_access, "malformed header line: %s", psz );
650 while( *p == ' ' ) p++;
652 /* FIXME FIXME test Content-Type to see if it's a plain stream or an
654 if( !strcasecmp( psz, "Pragma" ) )
656 if( strstr( p, "features" ) )
658 /* FIXME, it is a bit badly done here ..... */
659 if( strstr( p, "broadcast" ) )
661 msg_Dbg( p_access, "stream type = broadcast" );
662 p_sys->b_broadcast = true;
664 else if( strstr( p, "seekable" ) )
666 msg_Dbg( p_access, "stream type = seekable" );
667 p_sys->b_broadcast = false;
671 msg_Warn( p_access, "unknow stream types (%s)", p );
672 p_sys->b_broadcast = false;
676 else if( !strcasecmp( psz, "Location" ) )
678 psz_location = strdup( p );
684 /* Handle the redirection */
685 if( ( (i_code == 301) || (i_code == 302) ||
686 (i_code == 303) || (i_code == 307) ) &&
687 psz_location && *psz_location )
689 msg_Dbg( p_access, "redirection to %s", psz_location );
690 net_Close( p_sys->fd ); p_sys->fd = -1;
692 *ppsz_location = psz_location;
696 /* Read the asf header */
697 GetHeader( p_access );
698 if( p_sys->i_header <= 0 )
700 msg_Err( p_access, "header size == 0" );
703 /* close this connection */
704 net_Close( p_sys->fd );
707 /* *** parse header and get stream and their id *** */
708 /* get all streams properties,
710 * TODO : stream bitrates properties(optional)
711 * and bitrate mutual exclusion(optional) */
712 asf_HeaderParse ( &p_sys->asfh,
713 p_sys->p_header, p_sys->i_header );
714 msg_Dbg( p_access, "packet count=%"PRId64" packet size=%d",
715 p_sys->asfh.i_data_packets_count,
716 p_sys->asfh.i_min_data_packet_size );
718 asf_StreamSelect( &p_sys->asfh,
719 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
720 var_CreateGetInteger( p_access, "mms-all" ),
721 var_CreateGetInteger( p_access, "audio" ),
722 var_CreateGetInteger( p_access, "video" ) );
728 net_Close( p_sys->fd );
734 static void GetHeader( access_t *p_access )
736 access_sys_t *p_sys = p_access->p_sys;
738 /* Read the asf header */
740 free( p_sys->p_header );
741 p_sys->p_header = NULL;
745 if( GetPacket( p_access, &ck ) || ck.i_type != 0x4824 )
750 p_sys->i_header += ck.i_data;
751 p_sys->p_header = realloc( p_sys->p_header, p_sys->i_header );
752 memcpy( &p_sys->p_header[p_sys->i_header - ck.i_data],
753 ck.p_data, ck.i_data );
756 msg_Dbg( p_access, "complete header size=%d", p_sys->i_header );
760 /*****************************************************************************
762 ****************************************************************************/
763 static int Start( access_t *p_access, int64_t i_pos )
765 access_sys_t *p_sys = p_access->p_sys;
767 int i_streams_selected = 0;
771 msg_Dbg( p_access, "starting stream" );
773 for( i = 1; i < 128; i++ )
775 if( p_sys->asfh.stream[i].i_cat == ASF_STREAM_UNKNOWN )
778 if( p_sys->asfh.stream[i].i_selected )
779 i_streams_selected++;
781 if( i_streams_selected <= 0 )
783 msg_Err( p_access, "no stream selected" );
787 if( OpenConnection( p_access ) )
790 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
792 "User-Agent: "MMSH_USER_AGENT"\r\n" );
793 if( p_sys->b_broadcast )
795 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
796 "Pragma: no-cache,rate=1.000000,request-context=%d\r\n",
797 p_sys->i_request_context++ );
801 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
802 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=%u:%u,request-context=%d,max-duration=0\r\n",
803 (uint32_t)((i_pos >> 32)&0xffffffff),
804 (uint32_t)(i_pos&0xffffffff),
805 p_sys->i_request_context++ );
807 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
808 "Pragma: xPlayStrm=1\r\n"
809 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
810 "Pragma: stream-switch-count=%d\r\n"
811 "Pragma: stream-switch-entry=",
812 GUID_PRINT( p_sys->guid ),
815 for( i = 1; i < 128; i++ )
817 if( p_sys->asfh.stream[i].i_cat != ASF_STREAM_UNKNOWN )
820 if( p_sys->asfh.stream[i].i_selected )
824 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
825 "ffff:%d:%d ", i, i_select );
828 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" );
829 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
830 "Connection: Close\r\n" );
832 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
834 msg_Err( p_access, "failed to send request" );
838 psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL );
841 msg_Err( p_access, "cannot read data 0" );
845 if( atoi( &psz[9] ) >= 400 )
847 msg_Err( p_access, "error: %s", psz );
851 msg_Dbg( p_access, "HTTP reply '%s'", psz );
854 /* FIXME check HTTP code */
857 char *psz = net_Gets( p_access, p_sys->fd, NULL );
860 msg_Err( p_access, "cannot read data 1" );
868 msg_Dbg( p_access, "%s", psz );
872 p_sys->i_packet_used = 0;
873 p_sys->i_packet_length = 0;
878 /*****************************************************************************
880 *****************************************************************************/
881 static void Stop( access_t *p_access )
883 access_sys_t *p_sys = p_access->p_sys;
885 msg_Dbg( p_access, "closing stream" );
888 net_Close( p_sys->fd );
893 /*****************************************************************************
895 *****************************************************************************/
896 static int GetPacket( access_t * p_access, chunk_t *p_ck )
898 access_sys_t *p_sys = p_access->p_sys;
902 memset( p_ck, 0, sizeof( chunk_t ) );
904 /* Read the chunk header */
905 /* Some headers are short, like 0x4324. Reading 12 bytes will cause us
906 * to lose synchronization with the stream. Just read to the length
907 * (4 bytes), decode and then read up to 8 additional bytes to get the
910 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer, 4, true ) < 4 )
912 msg_Err( p_access, "cannot read data 2" );
916 p_ck->i_type = GetWLE( p_sys->buffer);
917 p_ck->i_size = GetWLE( p_sys->buffer + 2);
919 restsize = p_ck->i_size;
923 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer + 4, restsize, true ) < restsize )
925 msg_Err( p_access, "cannot read data 3" );
928 p_ck->i_sequence = GetDWLE( p_sys->buffer + 4);
929 p_ck->i_unknown = GetWLE( p_sys->buffer + 8);
931 /* Set i_size2 to 8 if this header was short, since a real value won't be
932 * present in the buffer. Using 8 avoid reading additional data for the
938 p_ck->i_size2 = GetWLE( p_sys->buffer + 10);
940 p_ck->p_data = p_sys->buffer + 12;
941 p_ck->i_data = p_ck->i_size2 - 8;
943 if( p_ck->i_type == 0x4524 ) // Transfer complete
945 if( p_ck->i_sequence == 0 )
947 msg_Warn( p_access, "EOF" );
952 msg_Warn( p_access, "next stream following" );
956 else if( p_ck->i_type == 0x4324 )
958 /* 0x4324 is CHUNK_TYPE_RESET: a new stream will follow with a sequence of 0 */
959 msg_Warn( p_access, "next stream following (reset) seq=%d", p_ck->i_sequence );
962 else if( (p_ck->i_type != 0x4824) && (p_ck->i_type != 0x4424) )
964 msg_Err( p_access, "invalid chunk FATAL (0x%x)", p_ck->i_type );
968 if( (p_ck->i_data > 0) &&
969 (net_Read( p_access, p_sys->fd, NULL, &p_sys->buffer[12],
970 p_ck->i_data, true ) < p_ck->i_data) )
972 msg_Err( p_access, "cannot read data 4" );
977 if( (p_sys->i_packet_sequence != 0) &&
978 (p_ck->i_sequence != p_sys->i_packet_sequence) )
980 msg_Warn( p_access, "packet lost ? (%d != %d)", p_ck->i_sequence, p_sys->i_packet_sequence );
984 p_sys->i_packet_sequence = p_ck->i_sequence + 1;
985 p_sys->i_packet_used = 0;
986 p_sys->i_packet_length = p_ck->i_data;
987 p_sys->p_packet = p_ck->p_data;