最近遇到srs客户端推流时,连接CRtmpServer后立即中断,经调试发现srs在
int SrsRtmpClient::fmle_publish(string stream, int& stream_id)函数中调用了
下面的代码导致连接CRtmpServer后
// SrsFMLEStartPacket if (true) { SrsFMLEStartPacket* pkt = SrsFMLEStartPacket::create_release_stream(stream); if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) { srs_error("send FMLE publish " "release stream failed. stream=%s, ret=%d", stream.c_str(), ret); return ret; } }
CRtmpServer找不到那个流就当作错误处理了。
bool BaseRTMPAppProtocolHandler::ProcessInvokeReleaseStream(BaseRTMPProtocol *pFrom, Variant & request) { //1. Attempt to find the stream map<uint32_t, BaseStream *> streams = GetApplication()->GetStreamsManager()-> FindByProtocolIdByName(pFrom->GetId(), M_INVOKE_PARAM(request, 1), false); uint32_t streamId = 0; if (streams.size() > 0) { //2. Is this the correct kind? if (TAG_KIND_OF(MAP_VAL(streams.begin())->GetType(), ST_IN_NET_RTMP)) { //3. get the rtmp stream id InNetRTMPStream *pInNetRTMPStream = (InNetRTMPStream *) MAP_VAL(streams.begin()); streamId = pInNetRTMPStream->GetRTMPStreamId(); //4. close the stream if (!pFrom->CloseStream(streamId, true)) { FATAL("Unable to close stream"); return true; } } } if (streamId > 0) { //5. Send the response Variant response = StreamMessageFactory::GetInvokeReleaseStreamResult(3, streamId, M_INVOKE_ID(request), streamId); if (!pFrom->SendMessage(response)) { FATAL("Unable to send message to client"); return false; } } //srs 连接前会发送释放的请求,如果找不到不做错误处理 //else { // Variant response = // StreamMessageFactory::GetInvokeReleaseStreamErrorNotFound(request); // if (!pFrom->SendMessage(response)) { // FATAL("Unable to send message to client"); // return false; // } //} //3. Done return true; }
找到basertmpappprotocolhandler.cpp将错误处理的代码注释即可修复。