View the specific rtmp Protocol process from the crtmpserver 3

Source: Internet
Author: User

The client sends the 54bytes data Deserialize to decode the message. In this case, 4 bytes [cpp] case RM_HEADER_MESSAGETYPE_WINACKSIZE: {return DeserializeWinAckSize (buffer, message [RM_WINACKSIZE]) is consumed.} the response is 25000000. Therefore, [cpp] case when: {return ProcessWinAckSize (pFrom, request);} [cpp] bool BaseRTMPAppProtocolHandler: ProcessWinAckSize (BaseRTMPProtocol * pFrom, Variant & request) {if (request [RM_WINACKSIZE]! = _ V_NUMERIC) {FATAL ("Invalid message: % s", STR (request. toString (); return false;} uint32_t size = (uint32_t) request [RM_WINACKSIZE]; if (size> 4*1024*1024) | size = 0) {FATAL ("Invalid message: % s", STR (request. toString (); return false;} pFrom-> SetWinAckSize (request [RM_WINACKSIZE]); return true ;} 12 + 4 bytes have been removed from 54bytes, 38 is left, 12 bytes is removed, and 26 bytes Deserialize is left to decode the message (in this case, the remaining 26 bytes Completely consumed) [cpp] case RM_HEADER_MESSAGETYPE_FLEX: {message [RM_INVOKE] [RM_INVOKE_IS_FLEX] = (bool) (H_MT (header) = callback); return DeserializeInvoke (buffer, message [RM_INVOKE]);} process the message below (response) [cpp] bool RTMPProtocolSerializer: DeserializeInvoke (IOBuffer & buffer, Variant & message) {if (message [RM_INVOKE_IS_FLEX]) {if (! Buffer. Ignore (1) {FATAL ("Unable to ignore 1 byte"); return false ;}} if (! _ Amf0.read1_string (buffer, message [RM_INVOKE_FUNCTION]) {FATAL ("Unable to read % s", STR (RM_INVOKE_FUNCTION); return false;} if (! _ Amf0.ReadDouble (buffer, message [RM_INVOKE_ID]) {FATAL ("Unable to read % s", STR (RM_INVOKE_ID); return false ;}for (uint32_t I = 0; GETAVAILABLEBYTESCOUNT (buffer)> 0; I ++) {if (! _ Amf0.Read (buffer, message [RM_INVOKE_PARAMS] [I]) {FATAL ("Unable to de-serialize invoke parameter % u", I); return false ;}} return true;} [cpp] bool BaseRTMPAppProtocolHandler: InboundMessageAvailable (BaseRTMPProtocol * pFrom, Variant & request) {case RM_HEADER_MESSAGETYPE_FLEX: {ProcessInvoke (pFrom, request ); here we mainly process ProcessInvokeCreateStream} [cpp] bool BaseRTMPAppProtocolHandler: ProcessInvokeCreateStream (BaseRTMPProtocol * pFrom, Variant & request) {uint32_t id = 0; // 1. create the neutral stream if (pFrom-> CreateNeutralStream (id) = NULL) {FATAL ("Unable to create stream"); return false;} // 2. send the response Variant response = StreamMessageFactory: GetInvokeCreateStreamResult (request, id); return SendRTMPMessage (pFrom, response);} when the data is processed, a total of 37bytes data is sent to the client.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.