[vlc-commits] mmsh: use transport stream functions
Rémi Denis-Courmont
git at videolan.org
Sun Nov 11 16:33:19 CET 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 10 11:13:37 2018 +0200| [016e42bc0daff9943ff14fb953165cdfd2be8fde] | committer: Rémi Denis-Courmont
mmsh: use transport stream functions
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=016e42bc0daff9943ff14fb953165cdfd2be8fde
---
modules/access/mms/mmsh.c | 54 ++++++++++++++++++++++++-----------------------
modules/access/mms/mmsh.h | 2 +-
2 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/modules/access/mms/mmsh.c b/modules/access/mms/mmsh.c
index c134680960..a3788fa931 100644
--- a/modules/access/mms/mmsh.c
+++ b/modules/access/mms/mmsh.c
@@ -34,7 +34,7 @@
#include <vlc_strings.h>
#include <vlc_input.h>
-#include <vlc_network.h>
+#include <vlc_tls.h>
#include <vlc_url.h>
#include <vlc_memstream.h>
#include "asf.h"
@@ -84,7 +84,7 @@ int MMSHOpen( stream_t *p_access )
p_access->p_sys = p_sys;
p_sys->i_proto= MMS_PROTO_HTTP;
- p_sys->fd = -1;
+ p_sys->stream = NULL;
p_sys->i_position = 0;
/* Handle proxy */
@@ -528,8 +528,9 @@ static int OpenConnection( stream_t *p_access,
if( vlc_memstream_close( stream ) )
return VLC_ENOMEM;
- int fd = net_ConnectTCP( p_access, srv->psz_host, srv->i_port );
- if( fd < 0 )
+ vlc_tls_t *sock = vlc_tls_SocketOpenTCP( VLC_OBJECT(p_access),
+ srv->psz_host, srv->i_port );
+ if( sock == NULL )
{
free( stream->ptr );
return VLC_EGENERIC;
@@ -537,17 +538,17 @@ static int OpenConnection( stream_t *p_access,
msg_Dbg( p_access, "sending request:\n%s", stream->ptr );
- ssize_t val = net_Write( p_access, fd, stream->ptr, stream->length );
+ ssize_t val = vlc_tls_Write( sock, stream->ptr, stream->length );
free( stream->ptr );
if( val < (ssize_t)stream->length )
{
msg_Err( p_access, "failed to send request" );
- net_Close( fd );
- fd = -1;
+ vlc_tls_Close( sock );
+ stream = NULL;
}
- p_sys->fd = fd;
- return (fd >= 0) ? VLC_SUCCESS : VLC_EGENERIC;
+ p_sys->stream = sock;
+ return (sock != NULL) ? VLC_SUCCESS : VLC_EGENERIC;
}
/*****************************************************************************
@@ -585,7 +586,7 @@ static int Describe( stream_t *p_access, char **ppsz_location )
return VLC_EGENERIC;
/* Receive the http header */
- char *psz = net_Gets( p_access, p_sys->fd );
+ char *psz = vlc_tls_GetLine( p_sys->stream );
if( psz == NULL )
{
msg_Err( p_access, "failed to read answer" );
@@ -610,7 +611,7 @@ static int Describe( stream_t *p_access, char **ppsz_location )
free( psz );
for( ;; )
{
- psz = net_Gets( p_access, p_sys->fd );
+ psz = vlc_tls_GetLine( p_sys->stream );
if( psz == NULL )
{
@@ -689,7 +690,8 @@ static int Describe( stream_t *p_access, char **ppsz_location )
psz_location )
{
msg_Dbg( p_access, "redirection to %s", psz_location );
- net_Close( p_sys->fd ); p_sys->fd = -1;
+ vlc_tls_Close( p_sys->stream );
+ p_sys->stream = NULL;
*ppsz_location = psz_location;
return VLC_SUCCESS;
@@ -704,8 +706,8 @@ static int Describe( stream_t *p_access, char **ppsz_location )
goto error;
}
/* close this connection */
- net_Close( p_sys->fd );
- p_sys->fd = -1;
+ vlc_tls_Close( p_sys->stream );
+ p_sys->stream = NULL;
/* *** parse header and get stream and their id *** */
/* get all streams properties,
@@ -729,10 +731,10 @@ static int Describe( stream_t *p_access, char **ppsz_location )
return VLC_SUCCESS;
error:
- if( p_sys->fd >= 0 )
+ if( p_sys->stream != NULL )
{
- net_Close( p_sys->fd );
- p_sys->fd = -1;
+ vlc_tls_Close( p_sys->stream );
+ p_sys->stream = NULL;
}
return VLC_EGENERIC;
}
@@ -825,7 +827,7 @@ static int Start( stream_t *p_access, uint64_t i_pos )
if( OpenConnection( p_access, &stream ) )
return VLC_EGENERIC;
- char *psz = net_Gets( p_access, p_sys->fd );
+ char *psz = vlc_tls_GetLine( p_sys->stream );
if( psz == NULL )
{
msg_Err( p_access, "cannot read data 0" );
@@ -844,7 +846,7 @@ static int Start( stream_t *p_access, uint64_t i_pos )
/* FIXME check HTTP code */
for( ;; )
{
- psz = net_Gets( p_access, p_sys->fd );
+ psz = vlc_tls_GetLine( p_sys->stream );
if( psz == NULL )
{
msg_Err( p_access, "cannot read data 1" );
@@ -873,10 +875,10 @@ static void Stop( stream_t *p_access )
access_sys_t *p_sys = p_access->p_sys;
msg_Dbg( p_access, "closing stream" );
- if( p_sys->fd >= 0 )
+ if( p_sys->stream != NULL )
{
- net_Close( p_sys->fd );
- p_sys->fd = -1;
+ vlc_tls_Close( p_sys->stream );
+ p_sys->stream = NULL;
}
}
@@ -897,7 +899,7 @@ static int GetPacket( stream_t * p_access, chunk_t *p_ck )
* (4 bytes), decode and then read up to 8 additional bytes to get the
* entire header.
*/
- if( net_Read( p_access, p_sys->fd, p_sys->buffer, 4 ) < 4 )
+ if( vlc_tls_Read( p_sys->stream, p_sys->buffer, 4, true ) < 4 )
{
msg_Err( p_access, "cannot read data 2" );
return VLC_EGENERIC;
@@ -910,7 +912,7 @@ static int GetPacket( stream_t * p_access, chunk_t *p_ck )
if( restsize > 8 )
restsize = 8;
- if( net_Read( p_access, p_sys->fd, p_sys->buffer + 4, restsize ) < restsize )
+ if( vlc_tls_Read( p_sys->stream, p_sys->buffer + 4, restsize, true ) < restsize )
{
msg_Err( p_access, "cannot read data 3" );
return VLC_EGENERIC;
@@ -961,8 +963,8 @@ static int GetPacket( stream_t * p_access, chunk_t *p_ck )
}
if( (p_ck->i_data > 0) &&
- (net_Read( p_access, p_sys->fd, &p_sys->buffer[12],
- p_ck->i_data ) < p_ck->i_data) )
+ (vlc_tls_Read( p_sys->stream, &p_sys->buffer[12], p_ck->i_data,
+ true ) < p_ck->i_data) )
{
msg_Err( p_access, "cannot read data 4" );
return VLC_EGENERIC;
diff --git a/modules/access/mms/mmsh.h b/modules/access/mms/mmsh.h
index b65ae71434..3a8666cf81 100644
--- a/modules/access/mms/mmsh.h
+++ b/modules/access/mms/mmsh.h
@@ -44,7 +44,7 @@ typedef struct
{
int i_proto;
- int fd;
+ struct vlc_tls *stream;
vlc_url_t url;
bool b_proxy;
More information about the vlc-commits
mailing list