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
2015-10-14 11:47:35 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e4c852945feb32fecab88ecbe0ee75372cadbb9f
e4c85294
1 parent
a9ad7b21
refine code, support override vhost
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
55 行增加
和
39 行删除
trunk/src/app/srs_app_caster_flv.cpp
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_rtmp_conn.hpp
trunk/src/app/srs_app_caster_flv.cpp
查看文件 @
e4c8529
...
...
@@ -184,6 +184,7 @@ int SrsDynamicHttpConn::do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec)
pprint
->
elapse
();
if
((
ret
=
sdk
->
connect
(
output
,
SRS_CONSTS_RTMP_RECV_TIMEOUT_US
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"flv: connect %s failed. ret=%d"
,
output
.
c_str
(),
ret
);
return
ret
;
}
...
...
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
e4c8529
...
...
@@ -94,6 +94,11 @@ SrsSimpleRtmpClient::~SrsSimpleRtmpClient()
int
SrsSimpleRtmpClient
::
connect
(
string
url
,
int64_t
timeout
)
{
return
connect
(
url
,
""
,
timeout
);
}
int
SrsSimpleRtmpClient
::
connect
(
string
url
,
string
vhost
,
int64_t
timeout
)
{
int
ret
=
ERROR_SUCCESS
;
// when ok, ignore.
...
...
@@ -122,21 +127,21 @@ int SrsSimpleRtmpClient::connect(string url, int64_t timeout)
// connect to vhost/app
if
((
ret
=
client
->
handshake
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"
mpegts
: handshake with server failed. ret=%d"
,
ret
);
srs_error
(
"
sdk
: handshake with server failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
ret
=
connect_app
(
req
->
host
,
req
->
port
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"mpegts: connect with server failed. ret=%d"
,
ret
);
if
((
ret
=
connect_app
(
vhost
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"sdk: connect with server failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
ret
=
client
->
create_stream
(
stream_id
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"
mpegts
: connect with server failed, stream_id=%d. ret=%d"
,
stream_id
,
ret
);
srs_error
(
"
sdk
: connect with server failed, stream_id=%d. ret=%d"
,
stream_id
,
ret
);
return
ret
;
}
// publish.
if
((
ret
=
client
->
publish
(
req
->
stream
,
stream_id
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"
mpegts
: publish failed, stream=%s, stream_id=%d. ret=%d"
,
srs_error
(
"
sdk
: publish failed, stream=%s, stream_id=%d. ret=%d"
,
req
->
stream
.
c_str
(),
stream_id
,
ret
);
return
ret
;
}
...
...
@@ -144,35 +149,7 @@ int SrsSimpleRtmpClient::connect(string url, int64_t timeout)
return
ret
;
}
void
SrsSimpleRtmpClient
::
close
()
{
transport
->
close
();
srs_freep
(
client
);
srs_freep
(
req
);
}
int
SrsSimpleRtmpClient
::
rtmp_write_packet
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
)
{
int
ret
=
ERROR_SUCCESS
;
SrsSharedPtrMessage
*
msg
=
NULL
;
if
((
ret
=
srs_rtmp_create_msg
(
type
,
timestamp
,
data
,
size
,
stream_id
,
&
msg
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"flv: create shared ptr msg failed. ret=%d"
,
ret
);
return
ret
;
}
srs_assert
(
msg
);
// send out encoded msg.
if
((
ret
=
client
->
send_and_free_message
(
msg
,
stream_id
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
ret
;
}
int
SrsSimpleRtmpClient
::
connect_app
(
string
ep_server
,
int
ep_port
)
int
SrsSimpleRtmpClient
::
connect_app
(
string
vhost
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -185,7 +162,7 @@ int SrsSimpleRtmpClient::connect_app(string ep_server, int ep_port)
// @see https://github.com/simple-rtmp-server/srs/issues/147
SrsAmf0Object
*
data
=
req
->
args
;
data
->
set
(
"srs_sig"
,
SrsAmf0Any
::
str
(
RTMP_SIG_SRS_KEY
));
data
->
set
(
"srs_server"
,
SrsAmf0Any
::
str
(
RTMP_SIG_SRS_
KEY
" "
RTMP_SIG_SRS_VERSION
" ("
RTMP_SIG_SRS_URL_SHORT
")"
));
data
->
set
(
"srs_server"
,
SrsAmf0Any
::
str
(
RTMP_SIG_SRS_
SERVER
));
data
->
set
(
"srs_license"
,
SrsAmf0Any
::
str
(
RTMP_SIG_SRS_LICENSE
));
data
->
set
(
"srs_role"
,
SrsAmf0Any
::
str
(
RTMP_SIG_SRS_ROLE
));
data
->
set
(
"srs_url"
,
SrsAmf0Any
::
str
(
RTMP_SIG_SRS_URL
));
...
...
@@ -207,14 +184,22 @@ int SrsSimpleRtmpClient::connect_app(string ep_server, int ep_port)
// generate the tcUrl
std
::
string
param
=
""
;
std
::
string
tc_url
=
srs_generate_tc_url
(
ep_server
,
req
->
vhost
,
req
->
app
,
ep_port
,
param
);
std
::
string
target_vhost
=
req
->
vhost
;
if
(
vhost
.
empty
())
{
target_vhost
=
vhost
;
}
std
::
string
tc_url
=
srs_generate_tc_url
(
req
->
host
,
target_vhost
,
req
->
app
,
req
->
port
,
param
);
// replace the tcUrl in request,
// which will replace the tc_url in client.connect_app().
req
->
tcUrl
=
tc_url
;
// upnode server identity will show in the connect_app of client.
// @see https://github.com/simple-rtmp-server/srs/issues/160
// the debug_srs_upnode is config in vhost and default to true.
bool
debug_srs_upnode
=
_srs_config
->
get_debug_srs_upnode
(
req
->
vhost
);
if
((
ret
=
client
->
connect_app
(
req
->
app
,
tc_url
,
req
,
debug_srs_upnode
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"
mpegts
: connect with server failed, tcUrl=%s, dsu=%d. ret=%d"
,
srs_error
(
"
sdk
: connect with server failed, tcUrl=%s, dsu=%d. ret=%d"
,
tc_url
.
c_str
(),
debug_srs_upnode
,
ret
);
return
ret
;
}
...
...
@@ -222,6 +207,34 @@ int SrsSimpleRtmpClient::connect_app(string ep_server, int ep_port)
return
ret
;
}
void
SrsSimpleRtmpClient
::
close
()
{
transport
->
close
();
srs_freep
(
client
);
srs_freep
(
req
);
}
int
SrsSimpleRtmpClient
::
rtmp_write_packet
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
)
{
int
ret
=
ERROR_SUCCESS
;
SrsSharedPtrMessage
*
msg
=
NULL
;
if
((
ret
=
srs_rtmp_create_msg
(
type
,
timestamp
,
data
,
size
,
stream_id
,
&
msg
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"sdk: create shared ptr msg failed. ret=%d"
,
ret
);
return
ret
;
}
srs_assert
(
msg
);
// send out encoded msg.
if
((
ret
=
client
->
send_and_free_message
(
msg
,
stream_id
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
ret
;
}
SrsRtmpConn
::
SrsRtmpConn
(
SrsServer
*
svr
,
st_netfd_t
c
)
:
SrsConnection
(
svr
,
c
)
{
...
...
trunk/src/app/srs_app_rtmp_conn.hpp
查看文件 @
e4c8529
...
...
@@ -72,11 +72,13 @@ public:
virtual
~
SrsSimpleRtmpClient
();
public
:
virtual
int
connect
(
std
::
string
url
,
int64_t
timeout
);
virtual
int
connect
(
std
::
string
url
,
std
::
string
vhost
,
int64_t
timeout
);
private
:
virtual
int
connect_app
(
std
::
string
vhost
);
public
:
virtual
void
close
();
public
:
virtual
int
rtmp_write_packet
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
);
private
:
virtual
int
connect_app
(
std
::
string
ep_server
,
int
ep_port
);
};
/**
...
...
请
注册
或
登录
后发表评论