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 block_t *Block( access_t *p_access );
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;
82 STANDARD_BLOCK_ACCESS_INIT
84 p_sys->i_proto= MMS_PROTO_HTTP;
88 p_sys->b_proxy = false;
89 memset( &p_sys->proxy, 0, sizeof(p_sys->proxy) );
92 /* TODO reuse instead http-proxy from http access ? */
93 psz_proxy = var_CreateGetString( p_access, "mmsh-proxy" );
96 char *psz_http_proxy = config_GetPsz( p_access, "http-proxy" );
97 if( psz_http_proxy && *psz_http_proxy )
100 psz_proxy = psz_http_proxy;
101 var_SetString( p_access, "mmsh-proxy", psz_proxy );
105 free( psz_http_proxy );
111 p_sys->b_proxy = true;
112 vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 );
117 char *psz_proxy = getenv( "http_proxy" );
118 if( psz_proxy && *psz_proxy )
120 p_sys->b_proxy = true;
121 vlc_UrlParse( &p_sys->proxy, psz_proxy, 0 );
129 if( ( p_sys->proxy.psz_host == NULL ) ||
130 ( *p_sys->proxy.psz_host == '\0' ) )
132 msg_Warn( p_access, "invalid proxy host" );
133 vlc_UrlClean( &p_sys->proxy );
138 if( p_sys->proxy.i_port <= 0 )
139 p_sys->proxy.i_port = 80;
140 msg_Dbg( p_access, "Using http proxy %s:%d",
141 p_sys->proxy.psz_host, p_sys->proxy.i_port );
144 /* open a tcp connection */
145 vlc_UrlParse( &p_sys->url, p_access->psz_path, 0 );
146 if( ( p_sys->url.psz_host == NULL ) ||
147 ( *p_sys->url.psz_host == '\0' ) )
149 msg_Err( p_access, "invalid host" );
152 if( p_sys->url.i_port <= 0 )
153 p_sys->url.i_port = 80;
155 if( Describe( p_access, &psz_location ) )
158 /* Handle redirection */
159 if( psz_location && *psz_location )
161 msg_Dbg( p_access, "redirection to %s", psz_location );
163 input_thread_t * p_input = access_GetParentInput( p_access );
164 input_item_t * p_new_loc;
168 free( psz_location );
171 /** \bug we do not autodelete here */
172 p_new_loc = input_item_New( p_access, psz_location, psz_location );
173 input_item_AddSubItem( input_GetItem( p_input ), p_new_loc );
174 vlc_gc_decref( p_new_loc );
175 vlc_object_release( p_input );
177 free( psz_location );
179 p_access->pf_block = NULL;
180 p_access->pf_read = ReadRedirect;
183 free( psz_location );
186 if( Start( p_access, 0 ) )
188 msg_Err( p_access, "cannot start stream" );
189 free( p_sys->p_header );
193 if( !p_sys->b_broadcast )
195 p_access->info.i_size = p_sys->asfh.i_file_size;
201 vlc_UrlClean( &p_sys->proxy );
202 vlc_UrlClean( &p_sys->url );
207 /*****************************************************************************
208 * Close: free unused data structures
209 *****************************************************************************/
210 void MMSHClose ( access_t *p_access )
212 access_sys_t *p_sys = p_access->p_sys;
216 free( p_sys->p_header );
218 vlc_UrlClean( &p_sys->proxy );
219 vlc_UrlClean( &p_sys->url );
223 /*****************************************************************************
225 *****************************************************************************/
226 static int Control( access_t *p_access, int i_query, va_list args )
228 access_sys_t *p_sys = p_access->p_sys;
237 case ACCESS_CAN_SEEK:
238 pb_bool = (bool*)va_arg( args, bool* );
239 *pb_bool = !p_sys->b_broadcast;
242 case ACCESS_CAN_FASTSEEK:
243 pb_bool = (bool*)va_arg( args, bool* );
247 case ACCESS_CAN_PAUSE:
248 case ACCESS_CAN_CONTROL_PACE:
249 pb_bool = (bool*)va_arg( args, bool* );
254 case ACCESS_GET_PTS_DELAY:
255 pi_64 = (int64_t*)va_arg( args, int64_t * );
256 *pi_64 = (int64_t)var_GetInteger( p_access, "mms-caching" ) * INT64_C(1000);
259 case ACCESS_GET_PRIVATE_ID_STATE:
260 i_int = (int)va_arg( args, int );
261 pb_bool = (bool *)va_arg( args, bool * );
263 if( (i_int < 0) || (i_int > 127) )
265 *pb_bool = p_sys->asfh.stream[i_int].i_selected ? true : false;
269 case ACCESS_SET_PAUSE_STATE:
270 b_bool = (bool)va_arg( args, int );
274 Seek( p_access, p_access->info.i_pos );
277 case ACCESS_GET_TITLE_INFO:
278 case ACCESS_SET_TITLE:
279 case ACCESS_SET_SEEKPOINT:
280 case ACCESS_SET_PRIVATE_ID_STATE:
281 case ACCESS_GET_CONTENT_TYPE:
285 msg_Warn( p_access, "unimplemented query in control" );
292 /*****************************************************************************
293 * Seek: try to go at the right place
294 *****************************************************************************/
295 static int Seek( access_t *p_access, int64_t i_pos )
297 access_sys_t *p_sys = p_access->p_sys;
302 msg_Dbg( p_access, "seeking to %"PRId64, i_pos );
304 i_packet = ( i_pos - p_sys->i_header ) / p_sys->asfh.i_min_data_packet_size;
305 i_offset = ( i_pos - p_sys->i_header ) % p_sys->asfh.i_min_data_packet_size;
308 Start( p_access, i_packet * p_sys->asfh.i_min_data_packet_size );
310 while( vlc_object_alive (p_access) )
312 if( GetPacket( p_access, &ck ) )
316 if( ck.i_type != 0x4824 )
319 msg_Warn( p_access, "skipping header" );
322 p_access->info.i_pos = i_pos;
323 p_access->info.b_eof = false;
324 p_sys->i_packet_used += i_offset;
329 /*****************************************************************************
331 *****************************************************************************/
332 static ssize_t ReadRedirect( access_t *p_access, uint8_t *p, size_t i_len )
334 VLC_UNUSED(p_access); VLC_UNUSED(p); VLC_UNUSED(i_len);
338 /*****************************************************************************
340 *****************************************************************************/
341 static block_t *Block( access_t *p_access )
343 access_sys_t *p_sys = p_access->p_sys;
344 const unsigned i_packet_min = p_sys->asfh.i_min_data_packet_size;
346 if( p_access->info.i_pos < p_sys->i_start + p_sys->i_header )
348 const size_t i_offset = p_access->info.i_pos - p_sys->i_start;
349 const size_t i_copy = p_sys->i_header - i_offset;
351 block_t *p_block = block_New( p_access, i_copy );
355 memcpy( p_block->p_buffer, &p_sys->p_header[i_offset], i_copy );
356 p_access->info.i_pos += i_copy;
359 else if( p_sys->i_packet_length > 0 &&
360 p_sys->i_packet_used < __MAX( p_sys->i_packet_length, i_packet_min ) )
363 size_t i_padding = 0;
365 if( p_sys->i_packet_used < p_sys->i_packet_length )
366 i_copy = p_sys->i_packet_length - p_sys->i_packet_used;
367 if( __MAX( p_sys->i_packet_used, p_sys->i_packet_length ) < i_packet_min )
368 i_padding = i_packet_min - __MAX( p_sys->i_packet_used, p_sys->i_packet_length );
370 block_t *p_block = block_New( p_access, i_copy + i_padding );
375 memcpy( &p_block->p_buffer[0], &p_sys->p_packet[p_sys->i_packet_used], i_copy );
377 memset( &p_block->p_buffer[i_copy], 0, i_padding );
379 p_sys->i_packet_used += i_copy + i_padding;
380 p_access->info.i_pos += i_copy + i_padding;
386 if( GetPacket( p_access, &ck ) )
389 if( p_sys->b_broadcast )
391 if( (ck.i_type == 0x4524) && (ck.i_sequence != 0) )
392 i_ret = Restart( p_access );
393 else if( ck.i_type == 0x4324 )
394 i_ret = Reset( p_access );
398 p_access->info.b_eof = true;
402 if( ck.i_type != 0x4424 )
404 p_sys->i_packet_used = 0;
405 p_sys->i_packet_length = 0;
412 static int Restart( access_t *p_access )
414 access_sys_t *p_sys = p_access->p_sys;
415 char *psz_location = NULL;
417 msg_Dbg( p_access, "Restart the stream" );
418 p_sys->i_start = p_access->info.i_pos;
421 msg_Dbg( p_access, "stoping the stream" );
425 msg_Dbg( p_access, "describe the stream" );
426 if( Describe( p_access, &psz_location ) )
428 msg_Err( p_access, "describe failed" );
431 free( psz_location );
434 if( Start( p_access, 0 ) )
436 msg_Err( p_access, "Start failed" );
441 static int Reset( access_t *p_access )
443 access_sys_t *p_sys = p_access->p_sys;
444 asf_header_t old_asfh = p_sys->asfh;
447 msg_Dbg( p_access, "Reset the stream" );
448 p_sys->i_start = p_access->info.i_pos;
451 p_sys->i_packet_sequence = 0;
452 p_sys->i_packet_used = 0;
453 p_sys->i_packet_length = 0;
454 p_sys->p_packet = NULL;
456 /* Get the next header FIXME memory loss ? */
457 GetHeader( p_access );
458 if( p_sys->i_header <= 0 )
461 asf_HeaderParse ( &p_sys->asfh,
462 p_sys->p_header, p_sys->i_header );
463 msg_Dbg( p_access, "packet count=%"PRId64" packet size=%d",
464 p_sys->asfh.i_data_packets_count,
465 p_sys->asfh.i_min_data_packet_size );
467 asf_StreamSelect( &p_sys->asfh,
468 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
469 var_CreateGetInteger( p_access, "mms-all" ),
470 var_CreateGetInteger( p_access, "audio" ),
471 var_CreateGetInteger( p_access, "video" ) );
473 /* Check we have comptible asfh */
474 for( i = 1; i < 128; i++ )
476 asf_stream_t *p_old = &old_asfh.stream[i];
477 asf_stream_t *p_new = &p_sys->asfh.stream[i];
479 if( p_old->i_cat != p_new->i_cat || p_old->i_selected != p_new->i_selected )
484 msg_Warn( p_access, "incompatible asf header, restart" );
485 return Restart( p_access );
489 p_sys->i_packet_used = 0;
490 p_sys->i_packet_length = 0;
494 static int OpenConnection( access_t *p_access )
496 access_sys_t *p_sys = p_access->p_sys;
497 vlc_url_t srv = p_sys->b_proxy ? p_sys->proxy : p_sys->url;
499 if( ( p_sys->fd = net_ConnectTCP( p_access,
500 srv.psz_host, srv.i_port ) ) < 0 )
502 msg_Err( p_access, "cannot connect to %s:%d",
503 srv.psz_host, srv.i_port );
509 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
510 "GET http://%s:%d%s HTTP/1.0\r\n",
511 p_sys->url.psz_host, p_sys->url.i_port,
512 ( (p_sys->url.psz_path == NULL) ||
513 (*p_sys->url.psz_path == '\0') ) ?
514 "/" : p_sys->url.psz_path );
516 /* Proxy Authentication */
517 if( p_sys->proxy.psz_username && *p_sys->proxy.psz_username )
522 if( asprintf( &buf, "%s:%s", p_sys->proxy.psz_username,
523 p_sys->proxy.psz_password ? p_sys->proxy.psz_password : "" ) == -1 )
526 b64 = vlc_b64_encode( buf );
529 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
530 "Proxy-Authorization: Basic %s\r\n", b64 );
536 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
537 "GET %s HTTP/1.0\r\n"
539 ( (p_sys->url.psz_path == NULL) ||
540 (*p_sys->url.psz_path == '\0') ) ?
541 "/" : p_sys->url.psz_path,
542 p_sys->url.psz_host, p_sys->url.i_port );
547 /*****************************************************************************
549 *****************************************************************************/
550 static int Describe( access_t *p_access, char **ppsz_location )
552 access_sys_t *p_sys = p_access->p_sys;
553 char *psz_location = NULL;
558 p_sys->b_broadcast = true;
559 p_sys->i_request_context = 1;
560 p_sys->i_packet_sequence = 0;
561 p_sys->i_packet_used = 0;
562 p_sys->i_packet_length = 0;
563 p_sys->p_packet = NULL;
565 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( p_access, p_sys->fd, NULL ) ) == NULL )
588 msg_Err( p_access, "failed to read answer" );
592 if( strncmp( psz, "HTTP/1.", 7 ) )
594 msg_Err( p_access, "invalid HTTP reply '%s'", psz );
598 i_code = atoi( &psz[9] );
601 msg_Err( p_access, "error: %s", psz );
606 msg_Dbg( p_access, "HTTP reply '%s'", psz );
610 char *psz = net_Gets( p_access, p_sys->fd, NULL );
615 msg_Err( p_access, "failed to read answer" );
625 if( ( p = strchr( psz, ':' ) ) == NULL )
627 msg_Err( p_access, "malformed header line: %s", psz );
632 while( *p == ' ' ) p++;
634 /* FIXME FIXME test Content-Type to see if it's a plain stream or an
636 if( !strcasecmp( psz, "Pragma" ) )
638 if( strstr( p, "features" ) )
640 /* FIXME, it is a bit badly done here ..... */
641 if( strstr( p, "broadcast" ) )
643 msg_Dbg( p_access, "stream type = broadcast" );
644 p_sys->b_broadcast = true;
646 else if( strstr( p, "seekable" ) )
648 msg_Dbg( p_access, "stream type = seekable" );
649 p_sys->b_broadcast = false;
653 msg_Warn( p_access, "unknow stream types (%s)", p );
654 p_sys->b_broadcast = false;
658 else if( !strcasecmp( psz, "Location" ) )
660 psz_location = strdup( p );
666 /* Handle the redirection */
667 if( ( (i_code == 301) || (i_code == 302) ||
668 (i_code == 303) || (i_code == 307) ) &&
669 psz_location && *psz_location )
671 msg_Dbg( p_access, "redirection to %s", psz_location );
672 net_Close( p_sys->fd ); p_sys->fd = -1;
674 *ppsz_location = psz_location;
677 free( psz_location );
679 /* Read the asf header */
680 GetHeader( p_access );
681 if( p_sys->i_header <= 0 )
683 msg_Err( p_access, "header size == 0" );
686 /* close this connection */
687 net_Close( p_sys->fd );
690 /* *** parse header and get stream and their id *** */
691 /* get all streams properties,
693 * TODO : stream bitrates properties(optional)
694 * and bitrate mutual exclusion(optional) */
695 asf_HeaderParse ( &p_sys->asfh,
696 p_sys->p_header, p_sys->i_header );
697 msg_Dbg( p_access, "packet count=%"PRId64" packet size=%d",
698 p_sys->asfh.i_data_packets_count,
699 p_sys->asfh.i_min_data_packet_size );
701 if( p_sys->asfh.i_min_data_packet_size <= 0 )
704 asf_StreamSelect( &p_sys->asfh,
705 var_CreateGetInteger( p_access, "mms-maxbitrate" ),
706 var_CreateGetInteger( p_access, "mms-all" ),
707 var_CreateGetInteger( p_access, "audio" ),
708 var_CreateGetInteger( p_access, "video" ) );
714 net_Close( p_sys->fd );
720 static void GetHeader( access_t *p_access )
722 access_sys_t *p_sys = p_access->p_sys;
724 /* Read the asf header */
726 free( p_sys->p_header );
727 p_sys->p_header = NULL;
731 if( GetPacket( p_access, &ck ) || ck.i_type != 0x4824 )
736 p_sys->i_header += ck.i_data;
737 p_sys->p_header = xrealloc( p_sys->p_header, p_sys->i_header );
738 memcpy( &p_sys->p_header[p_sys->i_header - ck.i_data],
739 ck.p_data, ck.i_data );
742 msg_Dbg( p_access, "complete header size=%d", p_sys->i_header );
746 /*****************************************************************************
748 ****************************************************************************/
749 static int Start( access_t *p_access, int64_t i_pos )
751 access_sys_t *p_sys = p_access->p_sys;
753 int i_streams_selected = 0;
757 msg_Dbg( p_access, "starting stream" );
759 for( i = 1; i < 128; i++ )
761 if( p_sys->asfh.stream[i].i_cat == ASF_STREAM_UNKNOWN )
764 if( p_sys->asfh.stream[i].i_selected )
765 i_streams_selected++;
767 if( i_streams_selected <= 0 )
769 msg_Err( p_access, "no stream selected" );
773 if( OpenConnection( p_access ) )
776 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
778 "User-Agent: "MMSH_USER_AGENT"\r\n" );
779 if( p_sys->b_broadcast )
781 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
782 "Pragma: no-cache,rate=1.000000,request-context=%d\r\n",
783 p_sys->i_request_context++ );
787 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
788 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=%u:%u,request-context=%d,max-duration=0\r\n",
789 (uint32_t)((i_pos >> 32)&0xffffffff),
790 (uint32_t)(i_pos&0xffffffff),
791 p_sys->i_request_context++ );
793 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
794 "Pragma: xPlayStrm=1\r\n"
795 "Pragma: xClientGUID={"GUID_FMT"}\r\n"
796 "Pragma: stream-switch-count=%d\r\n"
797 "Pragma: stream-switch-entry=",
798 GUID_PRINT( p_sys->guid ),
801 for( i = 1; i < 128; i++ )
803 if( p_sys->asfh.stream[i].i_cat != ASF_STREAM_UNKNOWN )
806 if( p_sys->asfh.stream[i].i_selected )
810 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
811 "ffff:%d:%d ", i, i_select );
814 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" );
815 net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL,
816 "Connection: Close\r\n" );
818 if( net_Printf( VLC_OBJECT(p_access), p_sys->fd, NULL, "\r\n" ) < 0 )
820 msg_Err( p_access, "failed to send request" );
824 psz = net_Gets( p_access, p_sys->fd, NULL );
827 msg_Err( p_access, "cannot read data 0" );
831 if( atoi( &psz[9] ) >= 400 )
833 msg_Err( p_access, "error: %s", psz );
837 msg_Dbg( p_access, "HTTP reply '%s'", psz );
840 /* FIXME check HTTP code */
843 char *psz = net_Gets( p_access, p_sys->fd, NULL );
846 msg_Err( p_access, "cannot read data 1" );
854 msg_Dbg( p_access, "%s", psz );
858 p_sys->i_packet_used = 0;
859 p_sys->i_packet_length = 0;
864 /*****************************************************************************
866 *****************************************************************************/
867 static void Stop( access_t *p_access )
869 access_sys_t *p_sys = p_access->p_sys;
871 msg_Dbg( p_access, "closing stream" );
874 net_Close( p_sys->fd );
879 /*****************************************************************************
881 *****************************************************************************/
882 static int GetPacket( access_t * p_access, chunk_t *p_ck )
884 access_sys_t *p_sys = p_access->p_sys;
888 memset( p_ck, 0, sizeof( chunk_t ) );
890 /* Read the chunk header */
891 /* Some headers are short, like 0x4324. Reading 12 bytes will cause us
892 * to lose synchronization with the stream. Just read to the length
893 * (4 bytes), decode and then read up to 8 additional bytes to get the
896 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer, 4, true ) < 4 )
898 msg_Err( p_access, "cannot read data 2" );
902 p_ck->i_type = GetWLE( p_sys->buffer);
903 p_ck->i_size = GetWLE( p_sys->buffer + 2);
905 restsize = p_ck->i_size;
909 if( net_Read( p_access, p_sys->fd, NULL, p_sys->buffer + 4, restsize, true ) < restsize )
911 msg_Err( p_access, "cannot read data 3" );
914 p_ck->i_sequence = GetDWLE( p_sys->buffer + 4);
915 p_ck->i_unknown = GetWLE( p_sys->buffer + 8);
917 /* Set i_size2 to 8 if this header was short, since a real value won't be
918 * present in the buffer. Using 8 avoid reading additional data for the
924 p_ck->i_size2 = GetWLE( p_sys->buffer + 10);
926 p_ck->p_data = p_sys->buffer + 12;
927 p_ck->i_data = p_ck->i_size2 - 8;
929 if( p_ck->i_type == 0x4524 ) // Transfer complete
931 if( p_ck->i_sequence == 0 )
933 msg_Warn( p_access, "EOF" );
938 msg_Warn( p_access, "next stream following" );
942 else if( p_ck->i_type == 0x4324 )
944 /* 0x4324 is CHUNK_TYPE_RESET: a new stream will follow with a sequence of 0 */
945 msg_Warn( p_access, "next stream following (reset) seq=%d", p_ck->i_sequence );
948 else if( (p_ck->i_type != 0x4824) && (p_ck->i_type != 0x4424) )
950 msg_Err( p_access, "invalid chunk FATAL (0x%x)", p_ck->i_type );
954 if( (p_ck->i_data > 0) &&
955 (net_Read( p_access, p_sys->fd, NULL, &p_sys->buffer[12],
956 p_ck->i_data, true ) < p_ck->i_data) )
958 msg_Err( p_access, "cannot read data 4" );
963 if( (p_sys->i_packet_sequence != 0) &&
964 (p_ck->i_sequence != p_sys->i_packet_sequence) )
966 msg_Warn( p_access, "packet lost ? (%d != %d)", p_ck->i_sequence, p_sys->i_packet_sequence );
970 p_sys->i_packet_sequence = p_ck->i_sequence + 1;
971 p_sys->i_packet_used = 0;
972 p_sys->i_packet_length = p_ck->i_data;
973 p_sys->p_packet = p_ck->p_data;