mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add comments for RTMP protocol stack
This commit is contained in:
parent
2516e3c596
commit
59dff7d268
2 changed files with 29 additions and 18 deletions
|
@ -321,15 +321,6 @@ SrsProtocol::~SrsProtocol()
|
|||
srs_freep(buffer);
|
||||
}
|
||||
|
||||
string SrsProtocol::get_request_name(double transcationId)
|
||||
{
|
||||
if (requests.find(transcationId) == requests.end()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return requests[transcationId];
|
||||
}
|
||||
|
||||
void SrsProtocol::set_recv_timeout(int64_t timeout_us)
|
||||
{
|
||||
return skt->set_recv_timeout(timeout_us);
|
||||
|
@ -605,12 +596,14 @@ int SrsProtocol::do_decode_message(SrsMessageHeader& header, SrsStream* stream,
|
|||
stream->skip(1);
|
||||
}
|
||||
|
||||
std::string request_name = get_request_name(transactionId);
|
||||
if (request_name.empty()) {
|
||||
// find the call name
|
||||
if (requests.find(transactionId) == requests.end()) {
|
||||
ret = ERROR_RTMP_NO_REQUEST;
|
||||
srs_error("decode AMF0/AMF3 request failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string request_name = requests[transactionId];
|
||||
srs_verbose("AMF0/AMF3 request parsed. request_name=%s", request_name.c_str());
|
||||
|
||||
if (request_name == RTMP_AMF0_COMMAND_CONNECT) {
|
||||
|
|
|
@ -124,16 +124,21 @@ public:
|
|||
SrsProtocol(ISrsProtocolReaderWriter* io);
|
||||
virtual ~SrsProtocol();
|
||||
public:
|
||||
// TODO: FIXME: to private.
|
||||
std::string get_request_name(double transcationId);
|
||||
/**
|
||||
* set the timeout in us.
|
||||
* set/get the recv timeout in us.
|
||||
* if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
|
||||
*/
|
||||
virtual void set_recv_timeout(int64_t timeout_us);
|
||||
virtual int64_t get_recv_timeout();
|
||||
/**
|
||||
* set/get the send timeout in us.
|
||||
* if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
|
||||
*/
|
||||
virtual void set_send_timeout(int64_t timeout_us);
|
||||
virtual int64_t get_send_timeout();
|
||||
/**
|
||||
* get recv/send bytes.
|
||||
*/
|
||||
virtual int64_t get_recv_bytes();
|
||||
virtual int64_t get_send_bytes();
|
||||
public:
|
||||
|
@ -213,7 +218,13 @@ private:
|
|||
*/
|
||||
virtual int on_send_message(SrsMessage* msg, SrsPacket* packet);
|
||||
private:
|
||||
/**
|
||||
* auto response the ack message.
|
||||
*/
|
||||
virtual int response_acknowledgement_message();
|
||||
/**
|
||||
* auto response the ping message.
|
||||
*/
|
||||
virtual int response_ping_message(int32_t timestamp);
|
||||
};
|
||||
|
||||
|
@ -252,7 +263,6 @@ public:
|
|||
* @remark, we use 64bits for large time for jitter detect and hls.
|
||||
*/
|
||||
int64_t timestamp;
|
||||
|
||||
public:
|
||||
/**
|
||||
* get the perfered cid(chunk stream id) which sendout over.
|
||||
|
@ -260,11 +270,10 @@ public:
|
|||
* for example, dispatch to all connections.
|
||||
*/
|
||||
int perfer_cid;
|
||||
|
||||
public:
|
||||
SrsMessageHeader();
|
||||
virtual ~SrsMessageHeader();
|
||||
|
||||
public:
|
||||
bool is_audio();
|
||||
bool is_video();
|
||||
bool is_amf0_command();
|
||||
|
@ -277,9 +286,18 @@ public:
|
|||
bool is_user_control_message();
|
||||
bool is_set_peer_bandwidth();
|
||||
bool is_aggregate();
|
||||
|
||||
public:
|
||||
/**
|
||||
* create a amf0 script header, set the size and stream_id.
|
||||
*/
|
||||
void initialize_amf0_script(int size, int stream);
|
||||
/**
|
||||
* create a audio header, set the size, timestamp and stream_id.
|
||||
*/
|
||||
void initialize_audio(int size, u_int32_t time, int stream);
|
||||
/**
|
||||
* create a video header, set the size, timestamp and stream_id.
|
||||
*/
|
||||
void initialize_video(int size, u_int32_t time, int stream);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue