public ResToWebHookOnStreamChange OnMediaServerStart(Object req)
        {
            var str = Convert.ToString(req);

            string[] tmpStrArr = str !.Split('\n', StringSplitOptions.RemoveEmptyEntries);
            str = "";
            foreach (var tmpstr in tmpStrArr)
            {
                if (!string.IsNullOrEmpty(tmpstr) && !tmpstr.Trim().StartsWith("\"."))
                {
                    str += tmpstr + "\r\n";
                }
            }



            var tmpObj = JsonHelper.FromJson <ZLMediaKitConfigForResponse>(str);


            ResponseStruct rs;
            var            ret = MediaServerCtrlApi.OnMediaServerStart(tmpObj, out rs);

            if (rs.Code != ErrorNumber.None)
            {
                throw new HttpResponseException(JsonHelper.ToJson(rs));
            }

            return(ret);
        }
        public ResToWebHookOnPublish OnPublish(ReqForWebHookOnPublish req)
        {
            ResponseStruct rs;
            var            ret = MediaServerCtrlApi.OnPublishNew(req, out rs);

            if (rs.Code != ErrorNumber.None)
            {
                throw new HttpResponseException(JsonHelper.ToJson(rs));
            }

            return(ret);
        }
        public ResToWebHookOnStreamChange OnRecordMp4Completed(ReqForWebHookOnRecordMp4Completed record)
        {
            ResponseStruct rs;
            var            ret = MediaServerCtrlApi.OnRecordMp4Completed(record, out rs);

            if (rs.Code != ErrorNumber.None)
            {
                throw new HttpResponseException(JsonHelper.ToJson(rs));
            }

            return(ret);
        }
        public ResMediaServerWebApiReg MediaServerRegister(ResMediaServerWebApiReg req)
        {
            ResponseStruct rs;

            if (string.IsNullOrEmpty(req.Ipaddress))
            {
                req.Ipaddress = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
                IPAddress thisip = IPAddress.Parse(req.Ipaddress);
                req.Ipaddress = thisip.MapToIPv4().ToString();
            }


            var ret = MediaServerCtrlApi.ServerReg(req, out rs);

            if (rs.Code != ErrorNumber.None)
            {
                throw new HttpResponseException(JsonHelper.ToJson(rs));
            }

            return(ret);
        }