mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine simple rtmp client for post flv stream.
This commit is contained in:
parent
adb8f243bf
commit
a9ad7b211b
3 changed files with 7 additions and 6 deletions
|
@ -183,7 +183,7 @@ int SrsDynamicHttpConn::do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec)
|
||||||
while (!rr->eof()) {
|
while (!rr->eof()) {
|
||||||
pprint->elapse();
|
pprint->elapse();
|
||||||
|
|
||||||
if ((ret = sdk->connect(output)) != ERROR_SUCCESS) {
|
if ((ret = sdk->connect(output, SRS_CONSTS_RTMP_RECV_TIMEOUT_US)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +206,7 @@ int SrsDynamicHttpConn::do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: FIXME: for post flv, reconnect when error.
|
||||||
if ((ret = sdk->rtmp_write_packet(type, time, data, size)) != ERROR_SUCCESS) {
|
if ((ret = sdk->rtmp_write_packet(type, time, data, size)) != ERROR_SUCCESS) {
|
||||||
if (!srs_is_client_gracefully_close(ret)) {
|
if (!srs_is_client_gracefully_close(ret)) {
|
||||||
srs_error("flv: proxy rtmp packet failed. ret=%d", ret);
|
srs_error("flv: proxy rtmp packet failed. ret=%d", ret);
|
||||||
|
|
|
@ -92,7 +92,7 @@ SrsSimpleRtmpClient::~SrsSimpleRtmpClient()
|
||||||
srs_freep(transport);
|
srs_freep(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsSimpleRtmpClient::connect(string url)
|
int SrsSimpleRtmpClient::connect(string url, int64_t timeout)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
@ -110,15 +110,15 @@ int SrsSimpleRtmpClient::connect(string url)
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect host.
|
// connect host.
|
||||||
if ((ret = transport->connect(req->host, req->port, ST_UTIME_NO_TIMEOUT)) != ERROR_SUCCESS) {
|
if ((ret = transport->connect(req->host, req->port, timeout)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_freep(client);
|
srs_freep(client);
|
||||||
client = new SrsRtmpClient(transport);
|
client = new SrsRtmpClient(transport);
|
||||||
|
|
||||||
client->set_recv_timeout(SRS_CONSTS_RTMP_RECV_TIMEOUT_US);
|
client->set_recv_timeout(timeout);
|
||||||
client->set_send_timeout(SRS_CONSTS_RTMP_SEND_TIMEOUT_US);
|
client->set_send_timeout(timeout);
|
||||||
|
|
||||||
// connect to vhost/app
|
// connect to vhost/app
|
||||||
if ((ret = client->handshake()) != ERROR_SUCCESS) {
|
if ((ret = client->handshake()) != ERROR_SUCCESS) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
SrsSimpleRtmpClient();
|
SrsSimpleRtmpClient();
|
||||||
virtual ~SrsSimpleRtmpClient();
|
virtual ~SrsSimpleRtmpClient();
|
||||||
public:
|
public:
|
||||||
virtual int connect(std::string url);
|
virtual int connect(std::string url, int64_t timeout);
|
||||||
virtual void close();
|
virtual void close();
|
||||||
public:
|
public:
|
||||||
virtual int rtmp_write_packet(char type, u_int32_t timestamp, char* data, int size);
|
virtual int rtmp_write_packet(char type, u_int32_t timestamp, char* data, int size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue