|
|
|
|
/*
|
|
|
|
|
** ffplay <EFBFBD><EFBFBD> file <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> rtsp<EFBFBD><EFBFBD>rtp<EFBFBD><EFBFBD>tcp <EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>Э<EFBFBD>飬<EFBFBD><EFBFBD> file:ǰ<EFBFBD><EFBFBD>ʾ file Э<EFBFBD>顣
|
|
|
|
|
** URLContext <EFBFBD>ṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳһ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>Щ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>Э<EFBFBD>飬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṩͳһ<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿڡ<EFBFBD>
|
|
|
|
|
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʵ<EFBFBD><EFBFBD> URLContext <EFBFBD>ӿڡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> file <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Э<EFBFBD><EFBFBD><EFBFBD><EFBFBD> URLContext <EFBFBD>ӿ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "../berrno.h"
|
|
|
|
|
|
|
|
|
|
#include "avformat.h"
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
|
|
#ifndef CONFIG_WIN32
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <io.h>
|
|
|
|
|
#define open(fname,oflag,pmode) _open(fname,oflag,pmode)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
static int file_open(URLContext *h, const char *filename, int flags)
|
|
|
|
|
{
|
|
|
|
|
int access;
|
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
|
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>fileЭ<EFBFBD><EFBFBD>
|
|
|
|
|
strstart(filename, "file:", &filename);
|
|
|
|
|
|
|
|
|
|
// <EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>־
|
|
|
|
|
if (flags &URL_RDWR)
|
|
|
|
|
access = O_CREAT | O_TRUNC | O_RDWR;
|
|
|
|
|
else if (flags &URL_WRONLY)
|
|
|
|
|
access = O_CREAT | O_TRUNC | O_WRONLY;
|
|
|
|
|
else
|
|
|
|
|
access = O_RDONLY;
|
|
|
|
|
#if defined(CONFIG_WIN32) || defined(CONFIG_OS2) || defined(__CYGWIN__)
|
|
|
|
|
access |= O_BINARY;
|
|
|
|
|
#endif
|
|
|
|
|
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
fd = open(filename, access, 0666);
|
|
|
|
|
if (fd < 0)
|
|
|
|
|
return - ENOENT;
|
|
|
|
|
|
|
|
|
|
// <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>URLContext<EFBFBD><EFBFBD>priv_data
|
|
|
|
|
h->priv_data = (void*)(size_t)fd;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
static int file_read(URLContext *h, unsigned char *buf, int size)
|
|
|
|
|
{
|
|
|
|
|
int fd = (size_t)h->priv_data;
|
|
|
|
|
return read(fd, buf, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
static int file_write(URLContext *h, unsigned char *buf, int size)
|
|
|
|
|
{
|
|
|
|
|
int fd = (size_t)h->priv_data;
|
|
|
|
|
return write(fd, buf, size);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת */
|
|
|
|
|
static offset_t file_seek(URLContext *h, offset_t pos, int whence)
|
|
|
|
|
{
|
|
|
|
|
int fd = (size_t)h->priv_data;
|
|
|
|
|
return lseek(fd, pos, whence);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <EFBFBD>ر<EFBFBD><EFBFBD>ļ<EFBFBD> */
|
|
|
|
|
static int file_close(URLContext *h)
|
|
|
|
|
{
|
|
|
|
|
int fd = (size_t)h->priv_data;
|
|
|
|
|
return close(fd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FILE<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>protocol */
|
|
|
|
|
URLProtocol file_protocol =
|
|
|
|
|
{
|
|
|
|
|
"file",
|
|
|
|
|
file_open,
|
|
|
|
|
file_read,
|
|
|
|
|
file_write,
|
|
|
|
|
file_seek,
|
|
|
|
|
file_close,
|
|
|
|
|
};
|