winlin

refine handshake, pithy print clock

... ... @@ -291,7 +291,7 @@ int SrsClient::playing(SrsSource* source)
// reportable
if (pithy_print.can_print()) {
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) {
... ... @@ -347,7 +347,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
// reportable
if (pithy_print.can_print()) {
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
... ...
... ... @@ -1066,7 +1066,7 @@ SrsSimpleHandshake::~SrsSimpleHandshake()
{
}
int SrsSimpleHandshake::handshake(SrsSocket& skt)
int SrsSimpleHandshake::handshake(SrsSocket& skt, SrsComplexHandshake& complex_hs)
{
int ret = ERROR_SUCCESS;
... ... @@ -1089,8 +1089,7 @@ int SrsSimpleHandshake::handshake(SrsSocket& skt)
srs_verbose("check c0 success, required plain text.");
// try complex handshake
SrsComplexHandshake complex_handshake;
ret = complex_handshake.handshake(skt, c0c1 + 1);
ret = complex_hs.handshake(skt, c0c1 + 1);
if (ret == ERROR_SUCCESS) {
srs_trace("complex handshake success.");
return ret;
... ... @@ -1099,7 +1098,7 @@ int SrsSimpleHandshake::handshake(SrsSocket& skt)
srs_error("complex handshake failed. ret=%d", 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];
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>
class SrsSocket;
class SrsComplexHandshake;
/**
* try complex handshake, if failed, fallback to simple handshake.
... ... @@ -43,8 +44,10 @@ public:
public:
/**
* 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);
SrsSimpleHandshake hs;
if ((ret = hs.handshake(skt)) != ERROR_SUCCESS) {
SrsComplexHandshake complex_hs;
SrsSimpleHandshake simple_hs;
if ((ret = simple_hs.handshake(skt, complex_hs)) != ERROR_SUCCESS) {
return ret;
}
... ...