Crtmpserver support for _CHECKBW issues with Android and iOS for rtmp live streaming

Source: Internet
Author: User

In the mobile video streaming project encountered problems, mobile phone side in the push of the stream is no problem, mainly now is iOS and Android connection crtmpserver after playing when the CHECKBW too, An exception occurred: NetConnection.Call.Failed, but even the FMS server can play normally, due to the use of VLC library, is packaged well, can not determine which part of the problem, the following is the Android and iOS development reported anomalies.




Then, decided to analyze the Crtmpserver log and the original code, found in the Crtmpserver log found a warning:Default Implementation of Processinvokegeneric:request: _ CHECKBW.

Immediately found in the source of the method of throwing the log

BOOL Basertmpappprotocolhandler::P rocessinvokegeneric (basertmpprotocol *pfrom,variant & request) {WARN ("Default Implementation of Processinvokegeneric:request:%s ", STR (M_invoke_function (Request)); Variant response = genericmessagefactory::getinvokecallfailederror (request); return Sendrtmpmessage (pfrom, response) ;}
where to find the references

BOOL Basertmpappprotocolhandler::P rocessinvoke (Basertmpprotocol *pfrom,variant &request) {//PROD_ACCESS ( Createlogeventinvoke (pfrom, request)); string functionname = request[rm_invoke][rm_invoke_function];uint32_t Currentinvokeid = m_invoke_id (request); if (Currentinvokeid! = 0) {if (_nextinvokeid[pfrom->getid ()] <= Currentinvokeid) {_nextinvokeid[pfrom->getid ()] = Currentinvokeid + 1;}} if (functionname = = Rm_invoke_function_connect) {return processinvokeconnect (pfrom, request);} else if (functionname = = R M_invoke_function_createstream) {return Processinvokecreatestream (pfrom, request);} else if (functionname = = Rm_invoke _function_publish) {return processinvokepublish (pfrom, request);} else if (functionname = = Rm_invoke_function_play) { Return Processinvokeplay (pfrom, request);} else if (functionname = = Rm_invoke_function_pauseraw) {return Processinvokepauseraw (pfrom, request);} else if ( functionname = = rm_invoke_function_pause) {return processinvokepause (pfrom, request);} ElsE if (functionname = = Rm_invoke_function_seek) {return Processinvokeseek (pfrom, request);} else if (functionname = = Rm_inv Oke_function_closestream) {return Processinvokeclosestream (pfrom, request);} else if (functionname = = Rm_invoke_ Function_releasestream) {return Processinvokereleasestream (pfrom, request);} else if (functionname = = Rm_invoke_ Function_deletestream) {return Processinvokedeletestream (pfrom, request);} else if (functionname = = Rm_invoke_function _result) {return Processinvokeresult (pfrom, request);} else if (functionname = = Rm_invoke_function_error) {return Processinvokeresult (pfrom, request);} else if (functionname = = rm_invoke_function_onstatus) {return processinvokeonstatus (pfrom, request);} else if ( functionname = = rm_invoke_function_fcpublish) {return processinvokefcpublish (pfrom, request);} else if (functionname = = Rm_invoke_function_getstreamlength) {return processinvokegetstreamlength (pfrom, request);} else if (functionname = = RM _invoke_function_onbwdone) {returnProcessinvokeonbwdone (pfrom, request);} else if (functionname = = rm_invoke_function_checkbandwidth) {return processinvokecheckbandwidth (pfrom, request);} else {return processinvokegeneric (pfrom, request);}}
The client connection process is also combed

1, the client-server connection process
Client---->server, Command Message, "Connect"
client<----Server, "Window acknowledgement size"
client<----Server, "Set Peer Bandwidth", where Server Sends "Onbwdone", Client responds "_CHECKBW" message, Server responds "_result"
Client---->server, "Window acknowledgement size"
client<----Server, User Control Message, "Streambegin"
client<----Server, Command Message, "_result Connect Response"
2, the client to the server command format: CommandName (String) + transactionid (number) + Commandobject (object,av type, if not present set to NULL) + Streamname ( String) + start (number) + Duration (number) + Reset (Boolean)
Server responds to client command format: CommandName (String) + Description (String)
Client---->server, Command Message, "play", after which may be mixed, Server sends "Onbwcheck", Client responds "_result",
Client---->server, set Buffertime, user event, set buffertimelength= 36000000ms
client<----server, set chunk size, server Set block size,
client<----Server, User Control Message, "streamisrecoreded"
client<----Server, User Control Message, "Streambegin"
client<----Server, Command Message, "Onstatus,play.reset"
client<----Server, Command Message, "Onstatus,play.start"
client<----Server, sending command Message "Rtmpsampleaccess"
client<----Server, Audio Message
client<----Server, Video Message

Finally, the problem is fixed in: client---->server, Command Message, "play", which may be mixed, the Server sends "Onbwcheck", the Client responds "_result", this link.

Compared to the log and source processing logic found that the mobile phone sent instructions in the functionname value of "_CHECKBW", and the source processing logic functionname only for "checkbandwidth", so made a conjecture:

1, _CHECKBW will not be the meaning of checkbandwidth;

2, some such as flash do not need _CHECKBW and some clients need to continue to go on.

That is to doubt the problem here, decided to try, in the processing logic to increase the "_CHECKBW" processing, processing logic and the original "Checkbandwidth" the same, the source code is as follows:

BOOL Basertmpappprotocolhandler::P rocessinvoke (Basertmpprotocol *pfrom,variant &request) {//PROD_ACCESS ( Createlogeventinvoke (pfrom, request)); string functionname = request[rm_invoke][rm_invoke_function];uint32_t Currentinvokeid = m_invoke_id (request); if (Currentinvokeid! = 0) {if (_nextinvokeid[pfrom->getid ()] <= Currentinvokeid) {_nextinvokeid[pfrom->getid ()] = Currentinvokeid + 1;}} if (functionname = = Rm_invoke_function_connect) {return processinvokeconnect (pfrom, request);} else if (functionname = = R M_invoke_function_createstream) {return Processinvokecreatestream (pfrom, request);} else if (functionname = = Rm_invoke _function_publish) {return processinvokepublish (pfrom, request);} else if (functionname = = Rm_invoke_function_play) { Return Processinvokeplay (pfrom, request);} else if (functionname = = Rm_invoke_function_pauseraw) {return Processinvokepauseraw (pfrom, request);} else if ( functionname = = rm_invoke_function_pause) {return processinvokepause (pfrom, request);} ElsE if (functionname = = Rm_invoke_function_seek) {return Processinvokeseek (pfrom, request);} else if (functionname = = Rm_inv Oke_function_closestream) {return Processinvokeclosestream (pfrom, request);} else if (functionname = = Rm_invoke_ Function_releasestream) {return Processinvokereleasestream (pfrom, request);} else if (functionname = = Rm_invoke_ Function_deletestream) {return Processinvokedeletestream (pfrom, request);} else if (functionname = = Rm_invoke_function _result) {return Processinvokeresult (pfrom, request);} else if (functionname = = Rm_invoke_function_error) {return Processinvokeresult (pfrom, request);} else if (functionname = = rm_invoke_function_onstatus) {return processinvokeonstatus (pfrom, request);} else if ( functionname = = rm_invoke_function_fcpublish) {return processinvokefcpublish (pfrom, request);} else if (functionname = = Rm_invoke_function_getstreamlength) {return processinvokegetstreamlength (pfrom, request);} else if (functionname = = RM _invoke_function_onbwdone) {returnProcessinvokeonbwdone (pfrom, request);} else if (functionname = = rm_invoke_function_checkbandwidth) {return processinvokecheckbandwidth (pfrom, request);} else if (functionname = = "_CHECKBW") {return processinvokecheckbandwidth (pfrom, request);} else {return processinvokegeneric (pfrom, request);}}
Upload server after change, compile, run, test, not successful. Continue to look at the log, and found that different from before, there is another warning:processinvokecheckbandwidth:checkbandwidth is disabled.

Immediately reflected in the original configuration is not set to True checkbandwidth, immediately modify, restart after the test, success.

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.