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_item_New( p_access, psz_location, psz_location );
192 input_item_AddSubItem( input_GetItem( p_input ), p_new_loc );
193 vlc_gc_decref( p_new_loc );
194 vlc_object_release( p_input );
196 free( psz_location );
198 p_access->pf_read = ReadRedirect;
203 if( Start( p_access, 0 ) )
205 msg_Err( p_access, "cannot start stream" );
206 free( p_sys->p_header );
207 vlc_UrlClean( &p_sys->proxy );
208 vlc_UrlClean( &p_sys->url );
213 if( !p_sys->b_broadcast )
215 p_access->info.i_size = p_sys->asfh.i_file_size;
221 /*****************************************************************************
222 * Close: free unused data structures
223 *****************************************************************************/
224 void MMSHClose ( access_t *p_access )
226 access_sys_t *p_sys = p_access->p_sys;
230 free( p_sys->p_header );
232 vlc_UrlClean( &p_sys->proxy );
233 vlc_UrlClean( &p_sys->url );
237 /*****************************************************************************
239 *****************************************************************************/
240 static int Control( access_t *p_access, int i_query, va_list args )
242 access_sys_t *p_sys = p_access->p_sys;
252 case ACCESS_CAN_SEEK:
253 pb_bool = (bool*)va_arg( args, bool* );
254 *pb_bool = !p_sys->b_broadcast;
257 case ACCESS_CAN_FASTSEEK:
258 pb_bool = (bool*)va_arg( args, bool* );
262 case ACCESS_CAN_PAUSE:
263 case ACCESS_CAN_CONTROL_PACE:
264 pb_bool = (bool*)va_arg( args, bool* );
270 pi_int = (int*)va_arg( args, int * );
271 *pi_int = 3 * p_sys->asfh.i_min_data_packet_size;
274 case ACCESS_GET_PTS_DELAY:
275 pi_64 = (int64_t*)va_arg( args, int64_t * );
276 *pi_64 = (int64_t)var_GetInteger( p_access, "mms-caching" ) * INT64_C(1000);
279 case ACCESS_GET_PRIVATE_ID_STATE:
280 i_int = (int)va_arg( args, int );
281 pb_bool = (bool *)va_arg( args, bool * );
283 if( (i_int < 0) || (i_int > 127) )
285 *pb_bool = p_sys->asfh.stream[i_int].i_selected ? true : false;
289 case ACCESS_SET_PAUSE_STATE:
290 b_bool = (bool)va_arg( args, int );
294 Seek( p_access, p_access->info.i_pos );
297 case ACCESS_GET_TITLE_INFO:
298 case ACCESS_SET_TITLE:
299 case ACCESS_SET_SEEKPOINT:
300 case ACCESS_SET_PRIVATE_ID_STATE:
301 case ACCESS_GET_CONTENT_TYPE:
305 msg_Warn( p_access, "unimplemented query in control" );
312 /*****************************************************************************
313 * Seek: try to go at the right place
314 *****************************************************************************/
315 static int Seek( access_t *p_access, int64_t i_pos )
317 access_sys_t *p_sys = p_access->p_sys;
322 msg_Dbg( p_access, "seeking to %"PRId64, i_pos );
324 i_packet = ( i_pos - p_sys->i_header ) / p_sys->asfh.i_min_data_packet_size;
325 i_offset = ( i_pos - p_sys->i_header ) % p_sys->asfh.i_min_data_packet_size;
328 Start( p_access, i_packet * p_sys->asfh.i_min_data_packet_size );
330 while( vlc_object_alive (p_access) )
332 if( GetPacket( p_access, &ck ) )
336 if( ck.i_type != 0x4824 )
339 msg_Warn( p_access, "skipping header" );
342 p_access->info.i_pos = i_pos;
343 p_access->info.b_eof = false;
344 p_sys->i_packet_used += i_offset;
349 /*****************************************************************************
351 *****************************************************************************/
352 static ssize_t ReadRedirect( access_t *p_access, uint8_t *p, size_t i_len )
357 /*****************************************************************************
359 *****************************************************************************/
360 static ssize_t Read( access_t *p_access, uint8_t *p_buffer, size_t i_len )
362 access_sys_t *p_sys = p_access->p_sys;
366 if( p_access->info.b_eof )
369 while( i_data < (size_t) i_len )
371 if( p_access->info.i_pos < (p_sys->i_start + p_sys->i_header) )
373 int i_offset = p_access->info.i_pos - p_sys->i_start;
374 i_copy = __MIN( p_sys->i_header - i_offset,
375 (int)((size_t)i_len - i_data) );
376 memcpy( &p_buffer[i_data], &p_sys->p_header[i_offset], i_copy );
379 p_access->info.i_pos += i_copy;
381 else if( p_sys->i_packet_used < p_sys->i_packet_length )
383 i_copy = __MIN( p_sys->i_packet_length - p_sys->i_packet_used,
385 memcpy( &p_buffer[i_data],
386 &p_sys->p_packet[p_sys->i_packet_used],
390 p_sys->i_packet_used += i_copy;
391 p_access->info.i_pos += i_copy;
393 else if( (p_sys->i_packet_length > 0) &&
394 ((int)p_sys->i_packet_used < p_sys->asfh.i_min_data_packet_size) )
396 i_copy = __MIN( p_sys->asfh.i_min_data_packet_size - p_sys->i_packet_used,
398 memset( &p_buffer[i_data], 0, i_copy );
401 p_sys->i_packet_used += i_copy;
402 p_access->info.i_pos += i_copy;
407 if( GetPacket( p_access, &ck ) )
410 if( p_sys->b_broadcast )
412 if( (ck.i_type == 0x4524) && (ck.i_sequence != 0) )
413 i_ret = Restart( p_access );
414 else if( ck.i_type == 0x4324 )
415 i_ret = Reset( p_access );
419 p_access->info.b_eof = true;
423 if( ck.i_type != 0x4424 )
425 p_sys->i_packet_used = 0;
426 p_sys->i_packet_length = 0;
435 static int Restart( access_t *p_access )
437 access_sys_t *p_sys = p_access->p_sys;
438 char *psz_location = NULL;
440 msg_Dbg( p_access, "Restart the stream" );
441 p_sys->i_start = p_access->info.i_pos;
444 msg_Dbg( p_access, "stoping the stream" );
448 msg_Dbg( p_access, "describe the stream" );
449 if( Describe( p_access, &psz_location ) )
451 msg_Err( p_access, "describe failed" );
455 if( Start( p_access, 0 ) )
457 msg_Err( p_access, "Start failed" );
462 static int Reset( access_t *p_access )
464 access_sys_t *p_sys = p_access->p_sys;
465 asf_header_t old_asfh = p_sys->asfh;
468 msg_Dbg( p_access, "Reset the stream" );
469 p_sys->i_start = p_access->info.i_pos;
472 p_sys->i_packet_sequence = 0;
473 p_sys->i_packet_used = 0;
474 p_sys->i_packet_length = 0;
475 p_sys->p_packet = NULL;
477 /* Get the next header FIXME memory loss ? */
478 GetHeader( p_access );
479 if( p_sys->i_header <= 0 )
482 asf_HeaderParse ( &p_sys->asfh,
483 p_sys->p_header, p_sys->i_header );
484 msg_Dbg( p_access, "packet count=%"PRId64" packet size=%d",
485 p_sys->asfh.i_data_packets_count,
486 p_sys->asfh.i_min_data_packet_size );
488 asf_StreamSelect( &p_sys->asfh,
489 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
490 var_CreateGetInteger( p_access, "mms-all" ),
491 var_CreateGetInteger( p_access, "audio" ),
492 var_CreateGetInteger( p_access, "video" ) );
494 /* Check we have comptible asfh */
495 for( i = 1; i < 128; i++ )
497 asf_stream_t *p_old = &old_asfh.stream[i];
498 asf_stream_t *p_new = &p_sys->asfh.stream[i];
500 if( p_old->i_cat != p_new->i_cat || p_old->i_selected != p_new->i_selected )
505 msg_Warn( p_access, "incompatible asf header, restart" );
506 return Restart( p_access );
510 p_sys->i_packet_used = 0;
511 p_sys->i_packet_length = 0;
515 static int OpenConnection( access_t *p_access )
517 access_sys_t *p_sys = p_access->p_sys;
518 vlc_url_t srv = p_sys->b_proxy ? p_sys->proxy : p_sys->url;
520 if( ( p_sys->fd = net_ConnectTCP( p_access,
521 srv.psz_host, srv.i_port ) ) < 0 )
523 msg_Err( p_access, "cannot connect to %s:%d",
524 srv.psz_host, srv.i_port );
530 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
531 "GET http://%s:%d%s HTTP/1.0\r\n",
532 p_sys->url.psz_host, p_sys->url.i_port,
533 ( (p_sys->url.psz_path == NULL) ||
534 (*p_sys->url.psz_path == '\0') ) ?
535 "/" : p_sys->url.psz_path );
537 /* Proxy Authentication */
538 if( p_sys->proxy.psz_username && *p_sys->proxy.psz_username )
543 if( asprintf( &buf, "%s:%s", p_sys->proxy.psz_username,
544 p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" ) == -1 )
547 b64 = vlc_b64_encode( buf );
550 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
551 "Proxy-Authorization: Basic %s\r\n", b64 );
557 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
558 "GET %s HTTP/1.0\r\n"
560 ( (p_sys->url.psz_path == NULL) ||
561 (*p_sys->url.psz_path == '\0') ) ?
562 "/" : p_sys->url.psz_path,
563 p_sys->url.psz_host, p_sys->url.i_port );
568 /*****************************************************************************
570 *****************************************************************************/
571 static int Describe( access_t *p_access, char **ppsz_location )
573 access_sys_t *p_sys = p_access->p_sys;
574 char *psz_location = NULL;
579 p_sys->b_broadcast = true;
580 p_sys->i_request_context = 1;
581 p_sys->i_packet_sequence = 0;
582 p_sys->i_packet_used = 0;
583 p_sys->i_packet_length = 0;
584 p_sys->p_packet = NULL;
585 GenerateGuid ( &p_sys->guid );
587 if( OpenConnection( p_access ) )
590 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
592 "User-Agent: "MMSH_USER_AGENT"\r\n"
593 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=%d,max-duration=0\r\n"
594 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
595 "Connection: Close\r\n",
596 p_sys->i_request_context++,
597 GUID_PRINT( p_sys->guid ) );
599 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
601 msg_Err( p_access, "failed to send request" );
605 /* Receive the http header */
606 if( ( psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL ) ) == NULL )
608 msg_Err( p_access, "failed to read answer" );
612 if( strncmp( psz, "HTTP/1.", 7 ) )
614 msg_Err( p_access, "invalid HTTP reply '%s'", psz );
618 i_code = atoi( &psz[9] );
621 msg_Err( p_access, "error: %s", psz );
626 msg_Dbg( p_access, "HTTP reply '%s'", psz );
630 char *psz = net_Gets( p_access, p_sys->fd, NULL );
635 msg_Err( p_access, "failed to read answer" );
645 if( ( p = strchr( psz, ':' ) ) == NULL )
647 msg_Err( p_access, "malformed header line: %s", psz );
652 while( *p == ' ' ) p++;
654 /* FIXME FIXME test Content-Type to see if it's a plain stream or an
656 if( !strcasecmp( psz, "Pragma" ) )
658 if( strstr( p, "features" ) )
660 /* FIXME, it is a bit badly done here ..... */
661 if( strstr( p, "broadcast" ) )
663 msg_Dbg( p_access, "stream type = broadcast" );
664 p_sys->b_broadcast = true;
666 else if( strstr( p, "seekable" ) )
668 msg_Dbg( p_access, "stream type = seekable" );
669 p_sys->b_broadcast = false;
673 msg_Warn( p_access, "unknow stream types (%s)", p );
674 p_sys->b_broadcast = false;
678 else if( !strcasecmp( psz, "Location" ) )
680 psz_location = strdup( p );
686 /* Handle the redirection */
687 if( ( (i_code == 301) || (i_code == 302) ||
688 (i_code == 303) || (i_code == 307) ) &&
689 psz_location && *psz_location )
691 msg_Dbg( p_access, "redirection to %s", psz_location );
692 net_Close( p_sys->fd ); p_sys->fd = -1;
694 *ppsz_location = psz_location;
698 /* Read the asf header */
699 GetHeader( p_access );
700 if( p_sys->i_header <= 0 )
702 msg_Err( p_access, "header size == 0" );
705 /* close this connection */
706 net_Close( p_sys->fd );
709 /* *** parse header and get stream and their id *** */
710 /* get all streams properties,
712 * TODO : stream bitrates properties(optional)
713 * and bitrate mutual exclusion(optional) */
714 asf_HeaderParse ( &p_sys->asfh,
715 p_sys->p_header, p_sys->i_header );
716 msg_Dbg( p_access, "packet count=%"PRId64" packet size=%d",
717 p_sys->asfh.i_data_packets_count,
718 p_sys->asfh.i_min_data_packet_size );
720 asf_StreamSelect( &p_sys->asfh,
721 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
722 var_CreateGetInteger( p_access, "mms-all" ),
723 var_CreateGetInteger( p_access, "audio" ),
724 var_CreateGetInteger( p_access, "video" ) );
730 net_Close( p_sys->fd );
736 static void GetHeader( access_t *p_access )
738 access_sys_t *p_sys = p_access->p_sys;
740 /* Read the asf header */
742 free( p_sys->p_header );
743 p_sys->p_header = NULL;
747 if( GetPacket( p_access, &ck ) || ck.i_type != 0x4824 )
752 p_sys->i_header += ck.i_data;
753 p_sys->p_header = realloc( p_sys->p_header, p_sys->i_header );
754 memcpy( &p_sys->p_header[p_sys->i_header - ck.i_data],
755 ck.p_data, ck.i_data );
758 msg_Dbg( p_access, "complete header size=%d", p_sys->i_header );
762 /*****************************************************************************
764 ****************************************************************************/
765 static int Start( access_t *p_access, int64_t i_pos )
767 access_sys_t *p_sys = p_access->p_sys;
769 int i_streams_selected = 0;
773 msg_Dbg( p_access, "starting stream" );
775 for( i = 1; i < 128; i++ )
777 if( p_sys->asfh.stream[i].i_cat == ASF_STREAM_UNKNOWN )
780 if( p_sys->asfh.stream[i].i_selected )
781 i_streams_selected++;
783 if( i_streams_selected <= 0 )
785 msg_Err( p_access, "no stream selected" );
789 if( OpenConnection( p_access ) )
792 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
794 "User-Agent: "MMSH_USER_AGENT"\r\n" );
795 if( p_sys->b_broadcast )
797 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
798 "Pragma: no-cache,rate=1.000000,request-context=%d\r\n",
799 p_sys->i_request_context++ );
803 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
804 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=%u:%u,request-context=%d,max-duration=0\r\n",
805 (uint32_t)((i_pos >> 32)&0xffffffff),
806 (uint32_t)(i_pos&0xffffffff),
807 p_sys->i_request_context++ );
809 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
810 "Pragma: xPlayStrm=1\r\n"
811 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
812 "Pragma: stream-switch-count=%d\r\n"
813 "Pragma: stream-switch-entry=",
814 GUID_PRINT( p_sys->guid ),
817 for( i = 1; i < 128; i++ )
819 if( p_sys->asfh.stream[i].i_cat != ASF_STREAM_UNKNOWN )
822 if( p_sys->asfh.stream[i].i_selected )
826 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
827 "ffff:%d:%d ", i, i_select );
830 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" );
831 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
832 "Connection: Close\r\n" );
834 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
836 msg_Err( p_access, "failed to send request" );
840 psz = net_Gets( VLC_OBJECT(p_access), p_sys->fd, NULL );
843 msg_Err( p_access, "cannot read data 0" );
847 if( atoi( &psz[9] ) >= 400 )
849 msg_Err( p_access, "error: %s", psz );
853 msg_Dbg( p_access, "HTTP reply '%s'", psz );
856 /* FIXME check HTTP code */
859 char *psz = net_Gets( p_access, p_sys->fd, NULL );
862 msg_Err( p_access, "cannot read data 1" );
870 msg_Dbg( p_access, "%s", psz );
874 p_sys->i_packet_used = 0;
875 p_sys->i_packet_length = 0;
880 /*****************************************************************************
882 *****************************************************************************/
883 static void Stop( access_t *p_access )
885 access_sys_t *p_sys = p_access->p_sys;
887 msg_Dbg( p_access, "closing stream" );
890 net_Close( p_sys->fd );
895 /*****************************************************************************
897 *****************************************************************************/
898 static int GetPacket( access_t * p_access, chunk_t *p_ck )
900 access_sys_t *p_sys = p_access->p_sys;
904 memset( p_ck, 0, sizeof( chunk_t ) );
906 /* Read the chunk header */
907 /* Some headers are short, like 0x4324. Reading 12 bytes will cause us
908 * to lose synchronization with the stream. Just read to the length
909 * (4 bytes), decode and then read up to 8 additional bytes to get the
912 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer, 4, true ) < 4 )
914 msg_Err( p_access, "cannot read data 2" );
918 p_ck->i_type = GetWLE( p_sys->buffer);
919 p_ck->i_size = GetWLE( p_sys->buffer + 2);
921 restsize = p_ck->i_size;
925 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer + 4, restsize, true ) < restsize )
927 msg_Err( p_access, "cannot read data 3" );
930 p_ck->i_sequence = GetDWLE( p_sys->buffer + 4);
931 p_ck->i_unknown = GetWLE( p_sys->buffer + 8);
933 /* Set i_size2 to 8 if this header was short, since a real value won't be
934 * present in the buffer. Using 8 avoid reading additional data for the
940 p_ck->i_size2 = GetWLE( p_sys->buffer + 10);
942 p_ck->p_data = p_sys->buffer + 12;
943 p_ck->i_data = p_ck->i_size2 - 8;
945 if( p_ck->i_type == 0x4524 ) // Transfer complete
947 if( p_ck->i_sequence == 0 )
949 msg_Warn( p_access, "EOF" );
954 msg_Warn( p_access, "next stream following" );
958 else if( p_ck->i_type == 0x4324 )
960 /* 0x4324 is CHUNK_TYPE_RESET: a new stream will follow with a sequence of 0 */
961 msg_Warn( p_access, "next stream following (reset) seq=%d", p_ck->i_sequence );
964 else if( (p_ck->i_type != 0x4824) && (p_ck->i_type != 0x4424) )
966 msg_Err( p_access, "invalid chunk FATAL (0x%x)", p_ck->i_type );
970 if( (p_ck->i_data > 0) &&
971 (net_Read( p_access, p_sys->fd, NULL, &p_sys->buffer[12],
972 p_ck->i_data, true ) < p_ck->i_data) )
974 msg_Err( p_access, "cannot read data 4" );
979 if( (p_sys->i_packet_sequence != 0) &&
980 (p_ck->i_sequence != p_sys->i_packet_sequence) )
982 msg_Warn( p_access, "packet lost ? (%d != %d)", p_ck->i_sequence, p_sys->i_packet_sequence );
986 p_sys->i_packet_sequence = p_ck->i_sequence + 1;
987 p_sys->i_packet_used = 0;
988 p_sys->i_packet_length = p_ck->i_data;
989 p_sys->p_packet = p_ck->p_data;