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-11-28 23:43:52 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
844718c99baa6ab5b0508fe4dd7c161949c54ca6
844718c9
1 parent
1f8bb0e9
refine the forwarder
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
50 行增加
和
8 行删除
trunk/src/core/srs_core_forward.cpp
trunk/src/core/srs_core_forward.hpp
trunk/src/core/srs_core_rtmp.cpp
trunk/src/core/srs_core_rtmp.hpp
trunk/src/core/srs_core_source.cpp
trunk/src/core/srs_core_forward.cpp
查看文件 @
844718c
...
...
@@ -32,34 +32,34 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SrsForwarder
::
SrsForwarder
()
{
client
=
new
SrsRtmpClient
();
port
=
1935
;
tid
=
NULL
;
loop
=
false
;
}
SrsForwarder
::~
SrsForwarder
()
{
srs_freep
(
client
);
if
(
tid
)
{
loop
=
false
;
st_thread_interrupt
(
tid
);
st_thread_join
(
tid
,
NULL
);
tid
=
NULL
;
}
srs_freep
(
client
);
}
int
SrsForwarder
::
on_publish
(
std
::
string
vhost
,
std
::
string
app
,
std
::
string
stream
,
std
::
string
forward_server
)
{
int
ret
=
ERROR_SUCCESS
;
tc_url
=
"rtmp://"
;
std
::
string
tc_url
=
"rtmp://"
;
tc_url
+=
vhost
;
tc_url
+=
"/"
;
tc_url
+=
app
;
stream_name
=
stream
;
server
=
forward_server
;
std
::
string
stream_name
=
stream
;
std
::
string
server
=
forward_server
;
int
port
=
1935
;
size_t
pos
=
forward_server
.
find
(
":"
);
if
(
pos
!=
std
::
string
::
npos
)
{
...
...
trunk/src/core/srs_core_forward.hpp
查看文件 @
844718c
...
...
@@ -31,6 +31,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
#include <st.h>
class
SrsSharedPtrMessage
;
class
SrsOnMetaDataPacket
;
class
SrsRtmpClient
;
...
...
@@ -45,9 +47,11 @@ private:
std
::
string
stream_name
;
std
::
string
server
;
int
port
;
SrsRtmpClient
*
client
;
private
:
st_thread_t
tid
;
bool
loop
;
private
:
SrsRtmpClient
*
client
;
public
:
SrsForwarder
();
virtual
~
SrsForwarder
();
...
...
trunk/src/core/srs_core_rtmp.cpp
查看文件 @
844718c
...
...
@@ -23,6 +23,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_rtmp.hpp>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <srs_core_log.hpp>
#include <srs_core_error.hpp>
#include <srs_core_socket.hpp>
...
...
@@ -181,6 +186,34 @@ SrsRtmpClient::~SrsRtmpClient()
}
}
int
SrsRtmpClient
::
connect_to
(
std
::
string
server
,
int
port
)
{
int
ret
=
ERROR_SUCCESS
;
return
ret
;
}
std
::
string
SrsRtmpClient
::
parse_server
(
std
::
string
host
){
if
(
inet_addr
(
host
.
c_str
())
!=
INADDR_NONE
){
return
host
;
}
hostent
*
answer
=
gethostbyname
(
host
.
c_str
());
if
(
answer
==
NULL
){
srs_error
(
"dns resolve host %s error."
,
host
.
c_str
());
return
""
;
}
char
ipv4
[
16
];
memset
(
ipv4
,
0
,
sizeof
(
ipv4
));
for
(
int
i
=
0
;
i
<
answer
->
h_length
;
i
++
){
inet_ntop
(
AF_INET
,
answer
->
h_addr_list
[
i
],
ipv4
,
sizeof
(
ipv4
));
srs_info
(
"dns resolve host %s to %s."
,
host
.
c_str
(),
ipv4
);
break
;
}
return
ipv4
;
}
SrsRtmp
::
SrsRtmp
(
st_netfd_t
client_stfd
)
{
protocol
=
new
SrsProtocol
(
client_stfd
);
...
...
trunk/src/core/srs_core_rtmp.hpp
查看文件 @
844718c
...
...
@@ -40,6 +40,8 @@ class SrsCommonMessage;
class
SrsCreateStreamPacket
;
class
SrsFMLEStartPacket
;
class
SrsPublishPacket
;
class
SrsSharedPtrMessage
;
class
SrsOnMetaDataPacket
;
/**
* the original request from client.
...
...
@@ -102,6 +104,9 @@ private:
public
:
SrsRtmpClient
();
virtual
~
SrsRtmpClient
();
private
:
virtual
int
connect_to
(
std
::
string
server
,
int
port
);
std
::
string
parse_server
(
std
::
string
host
);
};
/**
...
...
trunk/src/core/srs_core_source.cpp
查看文件 @
844718c
...
...
@@ -618,7 +618,7 @@ int SrsSource::on_publish(std::string vhost, std::string app, std::string stream
// create forwarders
SrsConfDirective
*
conf
=
config
->
get_forward
(
vhost
);
for
(
int
i
=
0
;
conf
&&
i
<
conf
->
args
.
size
();
i
++
)
{
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
args
.
size
();
i
++
)
{
std
::
string
forward_server
=
conf
->
args
.
at
(
i
);
SrsForwarder
*
forwarder
=
new
SrsForwarder
();
...
...
请
注册
或
登录
后发表评论