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:18:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1f8bb0e935f059f5af7193cc79c6d1f29d739036
1f8bb0e9
1 parent
f09d4576
add forward st thread
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
73 行增加
和
0 行删除
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_forward.cpp
查看文件 @
1f8bb0e
...
...
@@ -23,19 +23,53 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_forward.hpp>
#include <stdlib.h>
#include <srs_core_error.hpp>
#include <srs_core_rtmp.hpp>
#include <srs_core_log.hpp>
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
;
}
}
int
SrsForwarder
::
on_publish
(
std
::
string
vhost
,
std
::
string
app
,
std
::
string
stream
,
std
::
string
forward_server
)
{
int
ret
=
ERROR_SUCCESS
;
tc_url
=
"rtmp://"
;
tc_url
+=
vhost
;
tc_url
+=
"/"
;
tc_url
+=
app
;
stream_name
=
stream
;
server
=
forward_server
;
size_t
pos
=
forward_server
.
find
(
":"
);
if
(
pos
!=
std
::
string
::
npos
)
{
port
=
::
atoi
(
forward_server
.
substr
(
pos
+
1
).
c_str
());
server
=
forward_server
.
substr
(
0
,
pos
);
}
srs_trace
(
"forward stream=%s, tcUrl=%s to server=%s, port=%d"
,
stream_name
.
c_str
(),
tc_url
.
c_str
(),
server
.
c_str
(),
port
);
return
ret
;
}
...
...
trunk/src/core/srs_core_forward.hpp
查看文件 @
1f8bb0e
...
...
@@ -33,12 +33,21 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class
SrsSharedPtrMessage
;
class
SrsOnMetaDataPacket
;
class
SrsRtmpClient
;
/**
* forward the stream to other servers.
*/
class
SrsForwarder
{
private
:
std
::
string
tc_url
;
std
::
string
stream_name
;
std
::
string
server
;
int
port
;
SrsRtmpClient
*
client
;
st_thread_t
tid
;
bool
loop
;
public
:
SrsForwarder
();
virtual
~
SrsForwarder
();
...
...
trunk/src/core/srs_core_rtmp.cpp
查看文件 @
1f8bb0e
...
...
@@ -163,6 +163,24 @@ SrsResponse::~SrsResponse()
{
}
SrsRtmpClient
::
SrsRtmpClient
()
{
stfd
=
NULL
;
}
SrsRtmpClient
::~
SrsRtmpClient
()
{
if
(
stfd
)
{
int
fd
=
st_netfd_fileno
(
stfd
);
st_netfd_close
(
stfd
);
stfd
=
NULL
;
// st does not close it sometimes,
// close it manually.
close
(
fd
);
}
}
SrsRtmp
::
SrsRtmp
(
st_netfd_t
client_stfd
)
{
protocol
=
new
SrsProtocol
(
client_stfd
);
...
...
trunk/src/core/srs_core_rtmp.hpp
查看文件 @
1f8bb0e
...
...
@@ -93,6 +93,18 @@ enum SrsClientType
};
/**
* implements the client role protocol.
*/
class
SrsRtmpClient
{
private
:
st_netfd_t
stfd
;
public
:
SrsRtmpClient
();
virtual
~
SrsRtmpClient
();
};
/**
* the rtmp provices rtmp-command-protocol services,
* a high level protocol, media stream oriented services,
* such as connect to vhost/app, play stream, get audio/video data.
...
...
请
注册
或
登录
后发表评论