1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine code by winlin, for merged from allspace.

This commit is contained in:
winlin 2014-11-27 15:22:39 +08:00
parent 1855c9429c
commit 18c308248e
11 changed files with 416 additions and 539 deletions

View file

@ -45,28 +45,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SimpleSocketStream::SimpleSocketStream()
{
//fd = -1;
SOCKET_RESET(fd);
SOCKET_RESET(fd);
send_timeout = recv_timeout = ST_UTIME_NO_TIMEOUT;
recv_bytes = send_bytes = 0;
SOCKET_SETUP();
SOCKET_SETUP();
}
SimpleSocketStream::~SimpleSocketStream()
{
//if (fd != -1) {
// ::close(fd);
// fd = -1;
//}
SOCKET_CLOSE(fd);
SOCKET_CLEANUP();
SOCKET_CLOSE(fd);
SOCKET_CLEANUP();
}
int SimpleSocketStream::create_socket()
{
//if((fd = ::socket(AF_INET, SOCK_STREAM, 0)) < 0){
fd = ::socket(AF_INET, SOCK_STREAM, 0);
if(!SOCKET_VALID(fd)){
fd = ::socket(AF_INET, SOCK_STREAM, 0);
if (!SOCKET_VALID(fd)) {
return ERROR_SOCKET_CREATE;
}

View file

@ -22,7 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_librtmp.hpp>
#include <srs_platform.hpp>
#include <stdlib.h>
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <sstream>
using namespace std;
#include <srs_platform.hpp>
#include <srs_kernel_error.hpp>
#include <srs_protocol_rtmp.hpp>
#include <srs_lib_simple_socket.hpp>
@ -107,56 +108,6 @@ struct Context
}
};
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
#ifdef _WIN32
/*
int open(const char *pathname, int flags)
{
return open(pathname, flags, 0);
}
int open(const char *pathname, int flags, mode_t mode)
{
FILE* file = NULL;
if ((flags & O_RDONLY) == O_RDONLY) {
file = fopen(pathname, "r");
} else {
file = fopen(pathname, "w+");
}
if (file == NULL) {
return -1;
}
return (int)file;
}
int close(int fd)
{
FILE* file = (FILE*)fd;
return fclose(file);
}
off_t lseek(int fd, off_t offset, int whence)
{
return (off_t)fseek((FILE*)fd, offset, whence);
}
ssize_t write(int fd, const void *buf, size_t count)
{
return (ssize_t)fwrite(buf, count, 1, (FILE*)fd);
}
ssize_t read(int fd, void *buf, size_t count)
{
return (ssize_t)fread(buf, count, 1, (FILE*)fd);
}
*/
#endif
int srs_librtmp_context_parse_uri(Context* context)
{
int ret = ERROR_SUCCESS;

View file

@ -31,53 +31,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <sys/types.h>
// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213
#if 0
#define _CRT_SECURE_NO_WARNINGS
typedef unsigned long long u_int64_t;
typedef long long int64_t;
typedef unsigned int u_int32_t;
typedef int int32_t;
typedef unsigned char u_int8_t;
typedef char int8_t;
typedef unsigned short u_int16_t;
typedef short int16_t;
typedef int64_t ssize_t;
struct iovec {
void *iov_base; /* Starting address */
size_t iov_len; /* Number of bytes to transfer */
};
#include <time.h>
#include <windows.h>
int gettimeofday(struct timeval* tv, struct timezone* tz);
#define PRId64 "lld"
typedef int socklen_t;
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
typedef int mode_t;
#define S_IRUSR 0
#define S_IWUSR 0
#define S_IRGRP 0
#define S_IWGRP 0
#define S_IROTH 0
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
int close(int fd);
off_t lseek(int fd, off_t offset, int whence);
ssize_t write(int fd, const void *buf, size_t count);
ssize_t read(int fd, void *buf, size_t count);
typedef int pid_t;
pid_t getpid(void);
#define snprintf _snprintf
ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
typedef int64_t useconds_t;
int usleep(useconds_t usec);
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
#include <stdint.h>
typedef uint32_t u_int32_t;
#endif
/**
* srs-librtmp is a librtmp like library,
* used to play/publish rtmp stream from/to rtmp server.