mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine handshake, pithy print clock
This commit is contained in:
parent
3669419e4c
commit
b855caa045
4 changed files with 12 additions and 9 deletions
|
@ -291,7 +291,7 @@ int SrsClient::playing(SrsSource* source)
|
||||||
// reportable
|
// reportable
|
||||||
if (pithy_print.can_print()) {
|
if (pithy_print.can_print()) {
|
||||||
srs_trace("-> clock=%u, time=%"PRId64", cmr=%d, msgs=%d, obytes=%"PRId64", ibytes=%"PRId64", okbps=%d, ikbps=%d",
|
srs_trace("-> clock=%u, time=%"PRId64", cmr=%d, msgs=%d, obytes=%"PRId64", ibytes=%"PRId64", okbps=%d, ikbps=%d",
|
||||||
(int)srs_get_system_time_ms(), pithy_print.get_age(), ctl_msg_ret, count, rtmp->get_send_bytes(), rtmp->get_recv_bytes(), rtmp->get_send_kbps(), rtmp->get_recv_kbps());
|
(int)(srs_get_system_time_ms()/1000), pithy_print.get_age(), ctl_msg_ret, count, rtmp->get_send_bytes(), rtmp->get_recv_bytes(), rtmp->get_send_kbps(), rtmp->get_recv_kbps());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
|
@ -347,7 +347,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
|
||||||
// reportable
|
// reportable
|
||||||
if (pithy_print.can_print()) {
|
if (pithy_print.can_print()) {
|
||||||
srs_trace("<- clock=%u, time=%"PRId64", obytes=%"PRId64", ibytes=%"PRId64", okbps=%d, ikbps=%d",
|
srs_trace("<- clock=%u, time=%"PRId64", obytes=%"PRId64", ibytes=%"PRId64", okbps=%d, ikbps=%d",
|
||||||
(int)srs_get_system_time_ms(), pithy_print.get_age(), rtmp->get_send_bytes(), rtmp->get_recv_bytes(), rtmp->get_send_kbps(), rtmp->get_recv_kbps());
|
(int)(srs_get_system_time_ms()/1000), pithy_print.get_age(), rtmp->get_send_bytes(), rtmp->get_recv_bytes(), rtmp->get_send_kbps(), rtmp->get_recv_kbps());
|
||||||
}
|
}
|
||||||
|
|
||||||
// process audio packet
|
// process audio packet
|
||||||
|
|
|
@ -1066,7 +1066,7 @@ SrsSimpleHandshake::~SrsSimpleHandshake()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsSimpleHandshake::handshake(SrsSocket& skt)
|
int SrsSimpleHandshake::handshake(SrsSocket& skt, SrsComplexHandshake& complex_hs)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
@ -1089,8 +1089,7 @@ int SrsSimpleHandshake::handshake(SrsSocket& skt)
|
||||||
srs_verbose("check c0 success, required plain text.");
|
srs_verbose("check c0 success, required plain text.");
|
||||||
|
|
||||||
// try complex handshake
|
// try complex handshake
|
||||||
SrsComplexHandshake complex_handshake;
|
ret = complex_hs.handshake(skt, c0c1 + 1);
|
||||||
ret = complex_handshake.handshake(skt, c0c1 + 1);
|
|
||||||
if (ret == ERROR_SUCCESS) {
|
if (ret == ERROR_SUCCESS) {
|
||||||
srs_trace("complex handshake success.");
|
srs_trace("complex handshake success.");
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1099,7 +1098,7 @@ int SrsSimpleHandshake::handshake(SrsSocket& skt)
|
||||||
srs_error("complex handshake failed. ret=%d", ret);
|
srs_error("complex handshake failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_info("complex handhskae failed, try simple. ret=%d", ret);
|
srs_info("rollback complex to simple handshake. ret=%d", ret);
|
||||||
|
|
||||||
char* s0s1s2 = new char[3073];
|
char* s0s1s2 = new char[3073];
|
||||||
SrsAutoFree(char, s0s1s2, true);
|
SrsAutoFree(char, s0s1s2, true);
|
||||||
|
|
|
@ -31,6 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_core.hpp>
|
#include <srs_core.hpp>
|
||||||
|
|
||||||
class SrsSocket;
|
class SrsSocket;
|
||||||
|
class SrsComplexHandshake;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* try complex handshake, if failed, fallback to simple handshake.
|
* try complex handshake, if failed, fallback to simple handshake.
|
||||||
|
@ -43,8 +44,10 @@ public:
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* simple handshake.
|
* simple handshake.
|
||||||
|
* @param complex_hs, try complex handshake first,
|
||||||
|
* if failed, rollback to simple handshake.
|
||||||
*/
|
*/
|
||||||
virtual int handshake(SrsSocket& skt);
|
virtual int handshake(SrsSocket& skt, SrsComplexHandshake& complex_hs);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -225,8 +225,9 @@ int SrsRtmp::handshake()
|
||||||
|
|
||||||
SrsSocket skt(stfd);
|
SrsSocket skt(stfd);
|
||||||
|
|
||||||
SrsSimpleHandshake hs;
|
SrsComplexHandshake complex_hs;
|
||||||
if ((ret = hs.handshake(skt)) != ERROR_SUCCESS) {
|
SrsSimpleHandshake simple_hs;
|
||||||
|
if ((ret = simple_hs.handshake(skt, complex_hs)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue