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
2013-10-18 20:15:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d4b6178f0f95bcef82539868c16c20d9bfc91517
d4b6178f
1 parent
96e1de25
get peer ip and add rtmp class
隐藏空白字符变更
内嵌
并排对比
正在显示
11 个修改的文件
包含
175 行增加
和
31 行删除
trunk/configure
trunk/src/core/srs_core_client.cpp
trunk/src/core/srs_core_conn_rtmp.hpp → trunk/src/core/srs_core_client.hpp
trunk/src/core/srs_core_conn.hpp
trunk/src/core/srs_core_error.hpp
trunk/src/core/srs_core_conn_rtmp.cpp → trunk/src/core/srs_core_rtmp.cpp
trunk/src/core/srs_core_rtmp.hpp
trunk/src/core/srs_core_server.cpp
trunk/src/core/srs_core_server.hpp
trunk/src/main/srs_main_server.cpp
trunk/src/srs/srs.upp
trunk/configure
查看文件 @
d4b6178
...
...
@@ -82,7 +82,9 @@ LibSTfile="${LibSTRoot}/libst.a"
MODULE_ID
=
"CORE"
MODULE_DEPENDS
=()
ModuleLibIncs
=(
${
LibSTRoot
}
)
MODULE_FILES
=(
"srs_core"
"srs_core_log"
"srs_core_server"
"srs_core_error"
"srs_core_conn"
"srs_core_conn_rtmp"
)
MODULE_FILES
=(
"srs_core"
"srs_core_log"
"srs_core_server"
"srs_core_error"
"srs_core_conn"
"srs_core_client"
"srs_core_rtmp"
)
MODULE_DIR
=
"src/core"
. auto/modules.sh
CORE_OBJS
=
"
${
MODULE_OBJS
[@]
}
"
...
...
trunk/src/core/srs_core_client.cpp
0 → 100755
查看文件 @
d4b6178
/*
The MIT License (MIT)
Copyright (c) 2013 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core_client.hpp>
#include <arpa/inet.h>
#include <srs_core_error.hpp>
#include <srs_core_log.hpp>
#include <srs_core_rtmp.hpp>
SrsClient
::
SrsClient
(
SrsServer
*
srs_server
,
st_netfd_t
client_stfd
)
:
SrsConnection
(
srs_server
,
client_stfd
)
{
ip
=
NULL
;
rtmp
=
new
SrsRtmp
(
client_stfd
);
}
SrsClient
::~
SrsClient
()
{
if
(
ip
)
{
delete
[]
ip
;
ip
=
NULL
;
}
if
(
rtmp
)
{
delete
rtmp
;
rtmp
=
NULL
;
}
}
int
SrsClient
::
do_cycle
()
{
int
ret
=
ERROR_SUCCESS
;
if
((
ret
=
get_peer_ip
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
ret
;
}
int
SrsClient
::
get_peer_ip
()
{
int
ret
=
ERROR_SUCCESS
;
int
fd
=
st_netfd_fileno
(
stfd
);
// discovery client information
sockaddr_in
addr
;
socklen_t
addrlen
=
sizeof
(
addr
);
if
(
getpeername
(
fd
,
(
sockaddr
*
)
&
addr
,
&
addrlen
)
==
-
1
)
{
ret
=
ERROR_SOCKET_GET_PEER_NAME
;
SrsError
(
"discovery client information failed. ret=%d"
,
ret
);
return
ret
;
}
SrsVerbose
(
"get peer name success."
);
// ip v4 or v6
char
buf
[
INET6_ADDRSTRLEN
];
memset
(
buf
,
0
,
sizeof
(
buf
));
if
((
inet_ntop
(
addr
.
sin_family
,
&
addr
.
sin_addr
,
buf
,
sizeof
(
buf
)))
==
NULL
)
{
ret
=
ERROR_SOCKET_GET_PEER_IP
;
SrsError
(
"convert client information failed. ret=%d"
,
ret
);
return
ret
;
}
SrsVerbose
(
"get peer ip of client ip=%s, fd=%d"
,
buf
,
fd
);
ip
=
new
char
[
strlen
(
buf
)
+
1
];
strcpy
(
ip
,
buf
);
SrsInfo
(
"get peer ip success. ip=%s, fd=%d"
,
ip
,
fd
);
return
ret
;
}
...
...
trunk/src/core/srs_core_c
onn_rtmp
.hpp → trunk/src/core/srs_core_c
lient
.hpp
查看文件 @
d4b6178
...
...
@@ -21,22 +21,30 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_CORE_CONN_RTMP_HPP
#define SRS_CORE_CONN_RTMP_HPP
#ifndef SRS_CORE_CLIENT_HPP
#define SRS_CORE_CLIENT_HPP
/*
#include <srs_core_c
onn_rtmp
.hpp>
#include <srs_core_c
lient
.hpp>
*/
#include <srs_core.hpp>
#include <srs_core_conn.hpp>
class
SrsRtmpConnection
:
public
SrsConnection
class
SrsRtmp
;
class
SrsClient
:
public
SrsConnection
{
private
:
char
*
ip
;
SrsRtmp
*
rtmp
;
public
:
SrsRtmpConnection
(
SrsServer
*
srs_server
,
st_netfd_t
client_stfd
);
virtual
~
SrsRtmpConnection
();
SrsClient
(
SrsServer
*
srs_server
,
st_netfd_t
client_stfd
);
virtual
~
SrsClient
();
protected
:
virtual
int
do_cycle
();
private
:
virtual
int
get_peer_ip
();
};
#endif
\ No newline at end of file
...
...
trunk/src/core/srs_core_conn.hpp
查看文件 @
d4b6178
...
...
@@ -35,7 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class
SrsServer
;
class
SrsConnection
{
pr
ivate
:
pr
otected
:
SrsServer
*
server
;
st_netfd_t
stfd
;
public
:
...
...
trunk/src/core/srs_core_error.hpp
查看文件 @
d4b6178
...
...
@@ -43,5 +43,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_SOCKET_BIND 202
#define ERROR_SOCKET_LISTEN 203
#define ERROR_SOCKET_CLOSED 204
#define ERROR_SOCKET_GET_PEER_NAME 205
#define ERROR_SOCKET_GET_PEER_IP 206
#endif
\ No newline at end of file
...
...
trunk/src/core/srs_core_
conn_
rtmp.cpp → trunk/src/core/srs_core_rtmp.cpp
查看文件 @
d4b6178
...
...
@@ -21,22 +21,13 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core_
conn_
rtmp.hpp>
#include <srs_core_rtmp.hpp>
#include <srs_core_error.hpp>
SrsRtmpConnection
::
SrsRtmpConnection
(
SrsServer
*
srs_server
,
st_netfd_t
client_stfd
)
:
SrsConnection
(
srs_server
,
client_stfd
)
SrsRtmp
::
SrsRtmp
(
st_netfd_t
client_stfd
)
{
stfd
=
client_stfd
;
}
SrsRtmp
Connection
::~
SrsRtmpConnection
()
SrsRtmp
::~
SrsRtmp
()
{
}
int
SrsRtmpConnection
::
do_cycle
()
{
int
ret
=
ERROR_SUCCESS
;
return
ret
;
}
...
...
trunk/src/core/srs_core_rtmp.hpp
0 → 100755
查看文件 @
d4b6178
/*
The MIT License (MIT)
Copyright (c) 2013 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_CORE_RTMP_HPP
#define SRS_CORE_RTMP_HPP
/*
#include <srs_core_rtmp.hpp>
*/
#include <srs_core.hpp>
#include <st.h>
class
SrsRtmp
{
private
:
st_netfd_t
stfd
;
public
:
SrsRtmp
(
st_netfd_t
client_stfd
);
virtual
~
SrsRtmp
();
};
#endif
\ No newline at end of file
...
...
trunk/src/core/srs_core_server.cpp
查看文件 @
d4b6178
...
...
@@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_log.hpp>
#include <srs_core_error.hpp>
#include <srs_core_c
onn_rtmp
.hpp>
#include <srs_core_c
lient
.hpp>
#define SERVER_LISTEN_BACKLOG 10
...
...
@@ -76,7 +76,7 @@ int SrsServer::initialize()
return
ret
;
}
int
SrsServer
::
start
(
int
port
)
int
SrsServer
::
listen
(
int
port
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -106,7 +106,7 @@ int SrsServer::start(int port)
}
SrsVerbose
(
"bind socket success. fd=%d"
,
fd
);
if
(
listen
(
fd
,
SERVER_LISTEN_BACKLOG
)
==
-
1
)
{
if
(
::
listen
(
fd
,
SERVER_LISTEN_BACKLOG
)
==
-
1
)
{
ret
=
ERROR_SOCKET_LISTEN
;
SrsError
(
"listen socket error. ret=%d"
,
ret
);
return
ret
;
...
...
@@ -159,7 +159,7 @@ int SrsServer::accept_client(st_netfd_t client_stfd)
{
int
ret
=
ERROR_SUCCESS
;
SrsConnection
*
conn
=
new
Srs
RtmpConnection
(
this
,
client_stfd
);
SrsConnection
*
conn
=
new
Srs
Client
(
this
,
client_stfd
);
// directly enqueue, the cycle thread will remove the client.
conns
.
push_back
(
conn
);
...
...
trunk/src/core/srs_core_server.hpp
查看文件 @
d4b6178
...
...
@@ -46,7 +46,7 @@ public:
virtual
~
SrsServer
();
public
:
virtual
int
initialize
();
virtual
int
start
(
int
port
);
virtual
int
listen
(
int
port
);
virtual
int
cycle
();
virtual
void
remove
(
SrsConnection
*
conn
);
private
:
...
...
trunk/src/main/srs_main_server.cpp
查看文件 @
d4b6178
...
...
@@ -25,8 +25,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_error.hpp>
#include <srs_core_server.hpp>
#include <unistd.h>
int
main
(
int
/*argc*/
,
char
**
/*argv*/
){
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -36,7 +34,7 @@ int main(int /*argc*/, char** /*argv*/){
return
ret
;
}
if
((
ret
=
server
.
start
(
19350
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
server
.
listen
(
19350
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
...
...
trunk/src/srs/srs.upp
查看文件 @
d4b6178
...
...
@@ -10,8 +10,10 @@ file
..\core\srs_core_server.cpp,
..\core\srs_core_conn.hpp,
..\core\srs_core_conn.cpp,
..\core\srs_core_conn_rtmp.hpp,
..\core\srs_core_conn_rtmp.cpp,
..\core\srs_core_client.hpp,
..\core\srs_core_client.cpp,
..\core\srs_core_rtmp.hpp,
..\core\srs_core_rtmp.cpp,
..\core\srs_core_log.hpp,
..\core\srs_core_log.cpp;
mainconfig
...
...
请
注册
或
登录
后发表评论