From 3a3498f17c036e1a5029501ac5e3059e3da95691 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Mon, 8 Oct 2018 10:43:19 +0200 Subject: [PATCH] Added nicer error message handler in RTMP output connector --- src/output/output_rtmp.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp index 141653ba..2cec1183 100644 --- a/src/output/output_rtmp.cpp +++ b/src/output/output_rtmp.cpp @@ -789,6 +789,36 @@ namespace Mist { return; }//seek if (amfData.getContentP(0)->StrValue() == "_error"){ + if (!amfData.getContentP(3)){ + WARN_MSG("Received generic error response (no useful content)"); + return; + } + if (amfData.getContentP(3)->GetType() == AMF::AMF0_OBJECT){ + std::string code, description; + if (amfData.getContentP(3)->getContentP("code") && amfData.getContentP(3)->getContentP("code")->StrValue().size()){ + code = amfData.getContentP(3)->getContentP("code")->StrValue(); + } + if (amfData.getContentP(3)->getContentP("description") && amfData.getContentP(3)->getContentP("description")->StrValue().size()){ + description = amfData.getContentP(3)->getContentP("description")->StrValue(); + } + if (amfData.getContentP(3)->getContentP("details") && amfData.getContentP(3)->getContentP("details")->StrValue().size()){ + if (description.size()){ + description += "," + amfData.getContentP(3)->getContentP("details")->StrValue(); + }else{ + description = amfData.getContentP(3)->getContentP("details")->StrValue(); + } + } + if (code.size() || description.size()){ + WARN_MSG("Received error response: %s; %s", amfData.getContentP(3)->getContentP("code")->StrValue().c_str(), amfData.getContentP(3)->getContentP("description")->StrValue().c_str()); + }else{ + WARN_MSG("Received generic error response (no useful content)"); + } + return; + } + if(amfData.getContentP(3)->GetType() == AMF::AMF0_STRING){ + WARN_MSG("Received error response: %s", amfData.getContentP(3)->StrValue().c_str()); + return; + } WARN_MSG("Received error response: %s", amfData.Print().c_str()); return; }