Mercurial > mplayer.hg
changeset 15520:2c5186ed83b9
ported smb:// to the new stream api
author | nicodvb |
---|---|
date | Thu, 19 May 2005 20:58:11 +0000 |
parents | 07a841d9a8e1 |
children | 77a604e12143 |
files | libmpdemux/Makefile libmpdemux/open.c libmpdemux/stream.c |
diffstat | 3 files changed, 9 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/Makefile Thu May 19 20:58:11 2005 +0000 +++ b/libmpdemux/Makefile Thu May 19 20:58:11 2005 +0000 @@ -3,7 +3,7 @@ include ../config.mak -SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c stream_vstream.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c muxer_rawvideo.c demux_lavf.c demux_nsv.c demux_vqf.c stream_dvd.c +SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c stream_smb.c stream_vstream.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c muxer_rawvideo.c demux_lavf.c demux_nsv.c demux_vqf.c stream_dvd.c ifeq ($(XMMS_PLUGINS),yes) SRCS += demux_xmms.c endif
--- a/libmpdemux/open.c Thu May 19 20:58:11 2005 +0000 +++ b/libmpdemux/open.c Thu May 19 20:58:11 2005 +0000 @@ -34,45 +34,6 @@ int vcd_track=0; char* cdrom_device=NULL; - -// Define function about auth the libsmbclient library -// FIXME: I really do not not is this function is properly working - -#ifdef LIBSMBCLIENT - -#include "libsmbclient.h" - -static char smb_password[15]; -static char smb_username[15]; - -static void smb_auth_fn(const char *server, const char *share, - char *workgroup, int wgmaxlen, char *username, int unmaxlen, - char *password, int pwmaxlen) -{ - char temp[128]; - - strcpy(temp, "LAN"); - if (temp[strlen(temp) - 1] == 0x0a) - temp[strlen(temp) - 1] = 0x00; - - if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1); - - strcpy(temp, smb_username); - if (temp[strlen(temp) - 1] == 0x0a) - temp[strlen(temp) - 1] = 0x00; - - if (temp[0]) strncpy(username, temp, unmaxlen - 1); - - strcpy(temp, smb_password); - if (temp[strlen(temp) - 1] == 0x0a) - temp[strlen(temp) - 1] = 0x00; - - if (temp[0]) strncpy(password, temp, pwmaxlen - 1); -} - - -#endif - // Open a new stream (stdin/file/vcd/url) stream_t* open_stream(char* filename,char** options, int* file_format){ @@ -122,50 +83,12 @@ strncmp("cdda://", filename, 7) && strncmp("cddb://", filename, 7) && strncmp("mpst://", filename, 7) && strncmp("tivo://", filename, 7) && strncmp("file://", filename, 7) && strncmp("cue://", filename, 6) && - strncmp("ftp://", filename, 6) && + strncmp("ftp://", filename, 6) && strncmp("smb://", filename, 6) && strncmp("dvd://", filename, 6) && strncmp("dvdnav://", filename, 9) && strstr(filename, "://")) { url = url_new(filename); } if(url) { - if (strcmp(url->protocol, "smb")==0){ -#ifdef LIBSMBCLIENT - - // we need init of libsmbclient - int err; - - // FIXME: HACK: make the username/password global varaibles - // so the auth_fn function should grab it ... - // i cannot thing other way... - err = smbc_init(smb_auth_fn, 10); /* Initialize things */ - // libsmbclient using - if (err < 0) { - mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBInitError,err); - return NULL; - } - f=smbc_open(filename, O_RDONLY, 0666); - - // cannot open the file, outputs that - // MSGTR_FileNotFound -> MSGTR_SMBFileNotFound - if(f<0){ - mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBFileNotFound,filename); - return NULL; - } - len=smbc_lseek(f,0,SEEK_END); - smbc_lseek(f,0,SEEK_SET); - // FIXME: I really wonder is such situation -> but who cares ;) -// if (len == -1) -// return new_stream(f,STREAMTYPE_STREAM); // open as stream - url_free(url); - url = NULL; - stream=new_stream(f,STREAMTYPE_SMB); - stream->end_pos=len; - return stream; -#else - mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_SMBNotCompiled); - return NULL; -#endif - } stream=new_stream(f,STREAMTYPE_STREAM); if( streaming_start( stream, file_format, url )<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_UnableOpenURL, filename);
--- a/libmpdemux/stream.c Thu May 19 20:58:11 2005 +0000 +++ b/libmpdemux/stream.c Thu May 19 20:58:11 2005 +0000 @@ -37,10 +37,6 @@ //#include "vcd_read_bincue.h" -#ifdef LIBSMBCLIENT -#include "libsmbclient.h" -#endif - #ifdef HAVE_VCD extern stream_info_t stream_info_vcd; #endif @@ -62,6 +58,9 @@ #ifdef USE_DVDNAV extern stream_info_t stream_info_dvdnav; #endif +#ifdef LIBSMBCLIENT +extern stream_info_t stream_info_smb; +#endif extern stream_info_t stream_info_cue; extern stream_info_t stream_info_null; @@ -87,6 +86,9 @@ #ifdef HAVE_VSTREAM &stream_info_vstream, #endif +#ifdef LIBSMBCLIENT + &stream_info_smb, +#endif &stream_info_cue, &stream_info_dvd, #ifdef USE_DVDNAV @@ -191,11 +193,6 @@ int len; if (/*s->fd == NULL ||*/ s->eof) { s->buf_pos = s->buf_len = 0; return 0; } switch(s->type){ -#ifdef LIBSMBCLIENT - case STREAMTYPE_SMB: - len=smbc_read(s->fd,s->buffer,STREAM_BUFFER_SIZE); - break; -#endif case STREAMTYPE_STREAM: #ifdef MPLAYER_NETWORK if( s->streaming_ctrl!=NULL ) { @@ -230,7 +227,6 @@ s->buf_pos=s->buf_len=0; switch(s->type){ - case STREAMTYPE_SMB: case STREAMTYPE_STREAM: #ifdef _LARGEFILE_SOURCE newpos=pos&(~((long long)STREAM_BUFFER_SIZE-1));break; @@ -264,12 +260,6 @@ if(newpos==0 || newpos!=s->pos){ switch(s->type){ -#ifdef LIBSMBCLIENT - case STREAMTYPE_SMB: - s->pos=newpos; // real seek - if(smbc_lseek(s->fd,s->pos,SEEK_SET)<0) s->eof=1; - break; -#endif case STREAMTYPE_STREAM: //s->pos=newpos; // real seek // Some streaming protocol allow to seek backward and forward @@ -386,15 +376,7 @@ cache_uninit(s); } #endif - switch(s->type) { -#ifdef LIBSMBCLIENT - case STREAMTYPE_SMB: - smbc_close(s->fd); - break; -#endif - default: - if(s->close) s->close(s); - } + if(s->close) s->close(s); if(s->fd>0){ /* on unix we define closesocket to close on windows however we have to distinguish between