Skip to content

Instantly share code, notes, and snippets.

@suzp1984
Last active March 13, 2024 11:02
Show Gist options
  • Save suzp1984/5b7ca4333a0404ae1cd1d2227824c0f3 to your computer and use it in GitHub Desktop.
Save suzp1984/5b7ca4333a0404ae1cd1d2227824c0f3 to your computer and use it in GitHub Desktop.
SRS: RTMP handshake
/**
* https://github.com/ossrs/srs/blob/fa8096ad0117a085515729e12a3758ca26036552/trunk/src/protocol/srs_protocol_rtmp_handshake.hpp#L401-L431
*/
// Simple handshake.
// user can try complex handshake first,
// rollback to simple handshake if error ERROR_RTMP_TRY_SIMPLE_HS
class SrsSimpleHandshake
{
public:
SrsSimpleHandshake();
virtual ~SrsSimpleHandshake();
public:
// Simple handshake.
virtual srs_error_t handshake_with_client(SrsHandshakeBytes* hs_bytes, ISrsProtocolReadWriter* io);
virtual srs_error_t handshake_with_server(SrsHandshakeBytes* hs_bytes, ISrsProtocolReadWriter* io);
};
// Complex handshake,
// @see also crtmp(crtmpserver) or librtmp,
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
class SrsComplexHandshake
{
public:
SrsComplexHandshake();
virtual ~SrsComplexHandshake();
public:
// Complex hanshake.
// @return user must:
// continue connect app if success,
// try simple handshake if error is ERROR_RTMP_TRY_SIMPLE_HS,
// otherwise, disconnect
virtual srs_error_t handshake_with_client(SrsHandshakeBytes* hs_bytes, ISrsProtocolReadWriter* io);
virtual srs_error_t handshake_with_server(SrsHandshakeBytes* hs_bytes, ISrsProtocolReadWriter* io);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment