Skip to content

Commit

Permalink
refine handshake, pithy print clock
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Nov 10, 2013
1 parent 3669419 commit b855caa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions trunk/src/core/srs_core_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions trunk/src/core/srs_core_handshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ SrsSimpleHandshake::~SrsSimpleHandshake()
{
}

int SrsSimpleHandshake::handshake(SrsSocket& skt)
int SrsSimpleHandshake::handshake(SrsSocket& skt, SrsComplexHandshake& complex_hs)
{
int ret = ERROR_SUCCESS;

Expand All @@ -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;
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion trunk/src/core/srs_core_handshake.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -43,8 +44,10 @@ class SrsSimpleHandshake
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);
};

/**
Expand Down
5 changes: 3 additions & 2 deletions trunk/src/core/srs_core_rtmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b855caa

Please sign in to comment.