Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-11-28 10:33:36 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7f121efd7a7098287243f1501ea760435d87e7a5
7f121efd
1 parent
14fca601
merge from allspace srs-librtmp for win vs2010. 2.0.36
隐藏空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
70 行增加
和
55 行删除
trunk/auto/generate-srs-librtmp-single.sh
trunk/src/core/srs_core.hpp
trunk/src/libs/srs_lib_simple_socket.cpp
trunk/src/libs/srs_lib_simple_socket.hpp
trunk/src/libs/srs_librtmp.cpp
trunk/src/libs/srs_librtmp.hpp
trunk/auto/generate-srs-librtmp-single.sh
查看文件 @
7f121ef
...
...
@@ -112,7 +112,7 @@ int main(int argc, char** argv)
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
rtmp = srs_rtmp_create("rtmp://ossrs.net/live/livestream");
srs_
lib
_trace("create rtmp success");
srs_
human
_trace("create rtmp success");
srs_rtmp_destroy(rtmp);
return 0;
...
...
trunk/src/core/srs_core.hpp
查看文件 @
7f121ef
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 3
5
#define VERSION_REVISION 3
6
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server"
...
...
trunk/src/libs/srs_lib_simple_socket.cpp
查看文件 @
7f121ef
...
...
@@ -45,22 +45,22 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SimpleSocketStream
::
SimpleSocketStream
()
{
fd
=
-
1
;
SOCKET_RESET
(
fd
)
;
send_timeout
=
recv_timeout
=
ST_UTIME_NO_TIMEOUT
;
recv_bytes
=
send_bytes
=
0
;
SOCKET_SETUP
();
}
SimpleSocketStream
::~
SimpleSocketStream
()
{
if
(
fd
!=
-
1
)
{
::
close
(
fd
);
fd
=
-
1
;
}
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
))
{
return
ERROR_SOCKET_CREATE
;
}
...
...
@@ -95,12 +95,12 @@ int SimpleSocketStream::read(void* buf, size_t size, ssize_t* nread)
// On success a non-negative integer indicating the number of bytes actually read is returned
// (a value of 0 means the network connection is closed or end of file is reached).
if
(
nb_read
<=
0
)
{
if
(
nb_read
<
0
&&
errno
==
ETIME
)
{
if
(
nb_read
<
0
&&
SOCKET_ERRNO
()
==
SOCKET_
ETIME
)
{
return
ERROR_SOCKET_TIMEOUT
;
}
if
(
nb_read
==
0
)
{
errno
=
ECONNRESET
;
errno
=
SOCKET_
ECONNRESET
;
}
return
ERROR_SOCKET_READ
;
...
...
@@ -158,7 +158,7 @@ int SimpleSocketStream::writev(const iovec *iov, int iov_size, ssize_t* nwrite)
// returned, and errno is set appropriately.
if
(
nb_write
<=
0
)
{
// @see https://github.com/winlinvip/simple-rtmp-server/issues/200
if
(
nb_write
<
0
&&
errno
==
ETIME
)
{
if
(
nb_write
<
0
&&
SOCKET_ERRNO
()
==
SOCKET_
ETIME
)
{
return
ERROR_SOCKET_TIMEOUT
;
}
...
...
@@ -215,7 +215,7 @@ int SimpleSocketStream::write(void* buf, size_t size, ssize_t* nwrite)
if
(
nb_write
<=
0
)
{
// @see https://github.com/winlinvip/simple-rtmp-server/issues/200
if
(
nb_write
<
0
&&
errno
==
ETIME
)
{
if
(
nb_write
<
0
&&
SOCKET_ERRNO
()
==
SOCKET_
ETIME
)
{
return
ERROR_SOCKET_TIMEOUT
;
}
...
...
trunk/src/libs/srs_lib_simple_socket.hpp
查看文件 @
7f121ef
...
...
@@ -31,6 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core.hpp>
#include <srs_protocol_io.hpp>
#include <srs_librtmp.hpp>
/**
* simple socket stream,
...
...
@@ -43,7 +44,7 @@ private:
int64_t
send_timeout
;
int64_t
recv_bytes
;
int64_t
send_bytes
;
int
fd
;
SOCKET
fd
;
public
:
SimpleSocketStream
();
virtual
~
SimpleSocketStream
();
...
...
trunk/src/libs/srs_librtmp.cpp
查看文件 @
7f121ef
...
...
@@ -133,47 +133,29 @@ struct Context
return
0
;
}
int
open
(
const
char
*
pathname
,
int
flags
)
int
socket_setup
(
)
{
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
)
{
WORD
wVersionRequested
;
WSADATA
wsaData
;
int
err
;
/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
wVersionRequested
=
MAKEWORD
(
2
,
2
);
err
=
WSAStartup
(
wVersionRequested
,
&
wsaData
);
if
(
err
!=
0
)
{
/* Tell the user that we could not find a usable */
/* Winsock DLL. */
//printf("WSAStartup failed with error: %d\n", err);
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
);
return
0
;
}
ssize_t
read
(
int
fd
,
void
*
buf
,
size_t
count
)
int
socket_cleanup
(
)
{
return
(
ssize_t
)
fread
(
buf
,
count
,
1
,
(
FILE
*
)
fd
);
WSACleanup
();
return
0
;
}
pid_t
getpid
(
void
)
...
...
trunk/src/libs/srs_librtmp.hpp
查看文件 @
7f121ef
...
...
@@ -31,7 +31,23 @@ 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
#ifdef _WIN32
#ifndef _WIN32
#define SOCKET_ETIME ETIME
#define SOCKET_ECONNRESET ECONNRESET
#define SOCKET int
#define SOCKET_ERRNO() errno
#define SOCKET_RESET(fd) fd = -1; (void)0
#define SOCKET_CLOSE(fd) \
if (fd > 0) {\
::close(fd); \
fd = -1; \
} \
(void)0
#define SOCKET_VALID(x) (x > 0)
#define SOCKET_SETUP() (void)0
#define SOCKET_CLEANUP() (void)0
#else
#define _CRT_SECURE_NO_WARNINGS
typedef
unsigned
long
long
u_int64_t
;
typedef
long
long
int64_t
;
...
...
@@ -50,6 +66,17 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <windows.h>
int
gettimeofday
(
struct
timeval
*
tv
,
struct
timezone
*
tz
);
#define PRId64 "lld"
#define SOCKET_ETIME WSAETIMEDOUT
#define SOCKET_ECONNRESET WSAECONNRESET
#define SOCKET_ERRNO() WSAGetLastError()
#define SOCKET_RESET(x) x=INVALID_SOCKET
#define SOCKET_CLOSE(x) if(x!=INVALID_SOCKET){::closesocket(x);x=INVALID_SOCKET;}
#define SOCKET_VALID(x) (x!=INVALID_SOCKET)
#define SOCKET_BUFF(x) ((char*)x)
#define SOCKET_SETUP() socket_setup()
#define SOCKET_CLEANUP() socket_cleanup()
typedef
int
socklen_t
;
const
char
*
inet_ntop
(
int
af
,
const
void
*
src
,
char
*
dst
,
socklen_t
size
);
typedef
int
mode_t
;
...
...
@@ -58,18 +85,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#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
);
#include <io.h>
#include <fcntl.h>
#define open _open
#define close _close
#define lseek _lseek
#define write _write
#define read _read
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
);
int
socket_setup
();
int
socket_cleanup
();
#endif
/**
...
...
请
注册
或
登录
后发表评论