zego-express-engine-webrtc
Version:
zego webrtc express sdk
1 lines • 21.7 kB
JavaScript
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("long"),require("protobufjs/minimal"));else if("function"==typeof define&&define.amd)define(["long","protobufjs/minimal"],t);else{var n="object"==typeof exports?t(require("long"),require("protobufjs/minimal")):t(e.long,e["protobufjs/minimal"]);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(Object("undefined"!=typeof self?self:this),function(e,t){return function(){"use strict";var n={1290:function(e,t,n){n.d(t,{RnN:function(){return u},nkr:function(){return i},v$W:function(){return r},zUi:function(){return o},zub:function(){return s}});var r="zc.crh.a.0",i="zc.ctcc.a.0",o="zc.hrh.smt.0",s="zc.hrh.smt.1",u="zc.hrh.grdbc"},3788:function(e){e.exports=t},4872:function(e,t,n){function r(e){return"string"==typeof e}n.d(t,{QP:function(){return r}})},4908:function(e,t,n){n.d(t,{Of:function(){return s},Og:function(){return o},iJ:function(){return u},ns:function(){return c}});var r=n(8627),i=n(5095),o={event:"/sdk/start_publish",error:{},urls:i.yp,server_url:i.tK,publish_option:i.Gq,message:i.tK,stream_id:i.tK,stream_sid:i.Tr,room_id:i.tK,video_en_codec_id:i.Tr,cap_w:i.Tr,cap_h:i.Tr,w:i.Tr,h:i.Tr,video_en_fps:i.Tr,video_en_bps:i.Tr,audio_c_channel_count:i.Tr,audio_en_bps:i.Tr,aec_level:i.Tr,ans_level:i.Tr,agc:i.yS,traffic_control_min_video_bitrate:{bitrate:i.Tr,mode:i.Tr},cap_volume:i.Tr,enable_camera:i.yS,enable_mic:i.yS,video_activate:i.yS,audio_activate:i.yS,gw_version:i.Tr,is_dual_stream:i.Tr,is_mini:i.yS,is_peer:i.yS},s={event:"/sdk/publish_target",error:{t:r.ZEp,i:r.xU2,u:r.S4u,l:r.I7C,v:r.HO9,m:r.aUw,p:r.Oy0}},u={event:"/mss/pushadd",error:{t:r.ZEp},stream_id:i.tK,url:i.tK},c={event:"/mss/pushdel",error:{t:r.ZEp},stream_id:i.tK,url:i.tK}},5095:function(e,t,n){n.d(t,{Gq:function(){return r},Tr:function(){return s},tK:function(){return i},yS:function(){return u},yp:function(){return o}});var r=function(e){return e},i=function(e){return e},o=function(e){return e},s=function(e){return e},u=function(e){return e}},6272:function(e,t,n){n.d(t,{Rl:function(){return f},Wk:function(){return a},aw:function(){return o},dO:function(){return s},fT:function(){return r},h2:function(){return c},pt:function(){return i},qC:function(){return u}});var r="room not exist",i="device is not found",o="stream is not from zego",s="input param error",u="local stream wrong",c="no preview",a="publish stream no found",f="network is broken"},6994:function(t){t.exports=e},7202:function(e,t,n){var r=n(6994);t.A=r.default||r},8627:function(e,t,n){n.d(t,{Be2:function(){return N},FB3:function(){return S},HO9:function(){return f},I7C:function(){return k},JSm:function(){return C},L8E:function(){return O},LLz:function(){return p},OrZ:function(){return b},Oy0:function(){return c},PTE:function(){return v},Q9p:function(){return u},S4u:function(){return i},S5f:function(){return o},V2t:function(){return m},ZEp:function(){return s},_HD:function(){return a},aUw:function(){return h},ckg:function(){return E},jut:function(){return y},m6U:function(){return q},mrK:function(){return j},rBJ:function(){return $},sVF:function(){return d},s_m:function(){return g},t85:function(){return w},xU2:function(){return z},yK:function(){return _},yTe:function(){return l},zs3:function(){return x}});var r=n(6272),i={code:1000002,message:"not login room"},o={code:1000018,message:r.qC},s={code:1100001,message:r.dO},u={code:1100002,message:"network timeout."},c={code:1100999,message:"unknown server error"},a={code:1101005,message:"signal hb fail"},f={code:1102021,message:"biz channel error."},h={code:1102024,message:"invalid channel"},d={code:1102026,msg:r.fT},l={code:1003040,message:"Pushing CDN status failed. It may be an error in the CDN url"},v={code:1003050,message:"the extra info of the stream is null"},m={code:1003051,message:"the extra info of the stream is too long"},p={code:1103001,message:r.dO},b={code:1103002,message:"browser do not support"},_={code:1103010,message:"screen fail"},g={code:1103011,message:"enumerate devices fail"},y={code:1103012,message:"use camera device fail"},w={code:1103042,message:"screen canceled"},O={code:1103043,message:"screen not support"},S={code:1103053,message:"https is required"},z={code:1103055,message:r.Wk},j={code:1103061,message:"get media fail"},q={code:1103062,message:"update stream info fail"},k={code:1103063,message:"publish target no response"},x={code:1103064,message:"get device not allowed"},N={code:1103065,message:"device is not readable"},C={code:1103066,message:"device does not meet constraints"},$={code:1103052,message:"publisher cdn push error"},E={code:1103048,message:r.pt}},8866:function(e,t,n){n.d(t,{UY:function(){return i},l3:function(){return r}});n(7202),n(8627),n(4908);var r=Promise;var i=function(){return new Promise(function(e,t){e(Math.random())})}}},r={};function i(e){var t=r[e];if(void 0!==t)return t.exports;var o=r[e]={exports:{}};return n[e](o,o.exports,i),o.exports}i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};i.r(o),i.d(o,{StreamCDN:function(){return J}});var s,u=i(8627),c=i(4908),a=i(4872),f=i(1290),h=i(8866),d=function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,u)}c((r=r.apply(e,t||[])).next())})},l=function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,r=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){s.label=u[1];break}if(6===u[0]&&s.label<i[1]){s.label=i[1],i=u;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(u);break}i[2]&&s.ops.pop(),s.trys.pop();continue}u=t.call(e,s)}catch(e){u=[6,e],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},v=function(){function e(e,t){this._=e,this.O=t,this.attempt=0,this.S=.3,this.j=4.8,this.q=0,this.retryTimer=null,this.maxTimer=null,this.isOverTime=!1,this.RETRY_MAX_TIME=60}return e.prototype.setRetryRule=function(e){switch(this.q=e,e){case 1:this.S=.3,this.j=32;break;case 0:this.S=.3,this.j=4.8}},e.prototype.getRetryDelayByCount=function(e){return d(this,void 0,void 0,function(){var t,n,r,i;return l(this,function(o){switch(o.label){case 0:return t=1===this.q?e+2:e<2?0:e,n=Math.min(this.j,this.S*Math.pow(2,t)),[4,(0,h.UY)()];case 1:return r=o.sent(),i=Math.floor(r*(1e3*n+1)),this._.info("".concat(f.RnN," ").concat(this.attempt," ").concat(n," ").concat(i)),[2,i]}})})},e.prototype.initCallback=function(e,t){this.sucCallBack=e,this.failCallBack=t},e.prototype.startMaxTime=function(){var e,t=this;this._.info("".concat(f.zUi," ").concat(null===(e=this.requestInfo)||void 0===e?void 0:e.streamID," call")),this.maxTimer?this._.warn("".concat(f.zUi," max timer")):(this.maxTimer=setTimeout(function(){var e;t._.warn("".concat(f.zUi," ").concat(null===(e=t.requestInfo)||void 0===e?void 0:e.streamID," over max time ").concat(t.RETRY_MAX_TIME,"s, stop retry")),t.isOverTime=!0,t.requestFail(t._err||u.Q9p)},1e3*this.RETRY_MAX_TIME),this._.info("".concat(f.zUi," maxTimer=").concat(this.maxTimer)))},e.prototype.invalid=function(){this.clearRetryTimer(),this.attempt=0},e.prototype.clearRetryTimer=function(){this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)},e.prototype.requestFail=function(e){this.invalid(),this.stopMaxTime(),this.failCallBack&&(this.failCallBack(e),this.resetCallback())},e.prototype.stopMaxTime=function(){this._.info("".concat(f.zub," stop max timer")),this.maxTimer&&clearTimeout(this.maxTimer),this.maxTimer=null},e.prototype.resetCallback=function(){this.sucCallBack=void 0,this.failCallBack=void 0},e}(),m=(s=function(e,t){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},s(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),p=function(e){function t(t,n,r){var i=e.call(this,t,n)||this;return i._=t,i.O=n,i.k=r,i.RETRY_MAX_TIME=8,i}return m(t,e),t.prototype.initReqParams=function(e,t){this.streamId=e,this.cdnPushConfig=t},t.prototype.active=function(e){var t=this;if(void 0===e&&(e=!1),this.retryTimer)this._.warn("".concat(f.v$W," was actived, ignore"));else if(this.isOverTime)this._.warn("".concat(f.v$W," retry over time, stop retry"));else{var n=function(){t.clearRetryTimer(),t.k.sendCDNRequest(t.streamId,t.cdnPushConfig,function(e,n){var r=e.body;t.invalid(),t.stopMaxTime(),t.sucCallBack&&(t.sucCallBack&&t.sucCallBack(r,n),t.resetCallback())},function(e){t._err=e;var n=e.status_code;t.isOverTime?t.requestFail(e):((429===n||n>=500&&n<600)&&t.setRetryRule(1),t.active())}),e||t.attempt++};e?n():this.getRetryDelayByCount(this.attempt).then(function(e){t.retryTimer=setTimeout(n,e)})}},t}(v),b=i(3788);const _=i(6994);(b=b.default||b).util.Long=_.default||_,b.util.Long.fromBits=b.util.Long.fromBits||function(){return 0};for(var g=b.roots,y=b.types?b.types.basic:{double:1,float:5,int32:0,uint32:0,sint32:0,fixed32:5,sfixed32:5,int64:0,uint64:0,sint64:0,fixed64:1,sfixed64:1,bool:0,string:2,bytes:2},w=b.types?b.types.packed:{double:1,float:5,int32:0,uint32:0,sint32:0,fixed32:5,sfixed32:5,int64:0,uint64:0,sint64:0,fixed64:1,sfixed64:1,bool:0},O=Object.keys(y),S={$:function(e){return S[e]?S[e].call(this):g[e].decode?g[e].decode(this,this.uint32()):S.$.call(this,"int32")}},z={$:function(e,t,n){var r=y[e];return void 0===r?g[e].encode?(this.uint32(n<<3|2).fork(),g[e].encode(t,this).ldelim()):z.$.call(this,"int32",t,n):z[e].call(this.uint32(n<<3|r),t)}},j=0;j<O.length;j++)S[O[j]]=b.Reader.prototype[O[j]],z[O[j]]=b.Writer.prototype[O[j]];!function e(t,n,r,i){for(var o=0,s=Object.keys(t);o<s.length;o++){var u=s[o];if(t[u].$m&&Object.keys(t[u].$m).every(function(e){return Number(e)})){if(r[u])throw Error(`nested type ${r}.${u} has already exist`);r[u]=function(t,r){function i(e){for(var n in t){var r=t[n];"{"===r[1].charAt(0)?this[r[0]]={}:"["!==r[1].charAt(0)&&"<"!==r[1].charAt(0)||(this[r[0]]=[])}if(e)for(var i=Object.keys(e),o=0;o<i.length;++o)null!=e[i[o]]&&(this[i[o]]=e[i[o]])}var o={};for(var s in t){var u=t[s],c=u[1];"{"===c.charAt(0)?(i.prototype[u[0]]=b.util.emptyObject,o[c]={$m:c.substring(1).split(",").map(function(e,t){return[`$${t+1}`,e,null]}).reduce(function(e,t,n){return e[n+1]=t,e},{})}):i.prototype[u[0]]="["===c.charAt(0)||"<"===c.charAt(0)?b.util.emptyArray:"bytes"===c?b.util.newBuffer([]):u[2]&&u[2].hasOwnProperty("low")&&u[2].hasOwnProperty("high")?b.util.Long.fromBits(u[2].low,u[2].high,u[2].unsigned):u[2]}return i.create=function(e){return new i(e)},i.decode=function(e,n){e instanceof b.Reader||(e=b.Reader.create(e));for(var r=void 0===n?e.len:e.pos+n,o=new i;e.pos<r;){var s=e.uint32(),u=s>>>3;if(u>0&&t[u]){var c=t[u][0],a=t[u][1];if("{"===a.charAt(0)){o[c]===b.util.emptyObject&&(o[c]={});var f=i.$namespace[a].decode(e,e.uint32());o[c][f.$1]=f.$2}else if("["===a.charAt(0)||"<"===a.charAt(0)){a=a.substring(1),o[c]&&o[c].length||(o[c]=[]);if(void 0!==w[a=!S[a]&&!g[a].decode?"int32":a]&&2==(7&s))for(var h=e.uint32()+e.pos;e.pos<h;)o[c].push(S.$.call(e,a));else o[c].push(S.$.call(e,a))}else o[c]=S.$.call(e,a)}else e.skipType(7&s)}return o},i.encode=function(e,n){for(var r in n||(n=b.Writer.create()),t){var o=t[r][0],s=t[r][1];if("{"===s.charAt(0)){if(null!=e[o]&&e.hasOwnProperty(o))for(var u=0,c=Object.keys(e[o]);u<c.length;++u)n.uint32(r<<3|2).fork(),i.$namespace[s].encode({$1:c[u],$2:e[o][c[u]]},n).ldelim()}else if("["===s.charAt(0)||"<"===s.charAt(0)){var a="<"===s.charAt(0);s=s.substring(1);var f=e[o];if(null!=f&&f.length){if(s=void 0===y[s]&&!g[s].encode?"int32":s,a&&void 0!==w[s]){n.uint32(r<<3|2).fork();for(u=0;u<f.length;u++)z[s].call(n,f[u]);n.ldelim()}else for(u=0;u<f.length;u++)z.$.call(n,s,f[u],r)}}else null!=e[o]&&e.hasOwnProperty(o)&&z.$.call(n,s,e[o],r)}return n},Object.keys(o).length&&(i.$namespace=e(o,n+"."+r,i.$namespace||{},!0)),i}(t[u].$m,u)}else t[u].$s?r[u]=function(e,t){function r(e,t,n){b.rpc.Service.call(this,e,t,n)}return(r.prototype=Object.create(b.rpc.Service.prototype)).constructor=r,r.create=function(e,t,n){return new r(e,t,n)},Object.keys(e).forEach(function(i){var o=e[i];function s(e,t){return this.rpcCall(s,g[o[0]],g[o[1]],e,t)}Object.defineProperty(s,"name",{value:i}),Object.defineProperty(s,"path",{value:`${n}.${t}`}),r.prototype[i]=s}),r}(t[u].$s,u):t[u].$e&&Object.values(t[u].$e).every(function(e){return Number(e)===e})&&(r[u]=function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[n[t[r]]=e[t[r]]]=t[r];return n}(t[u].$e));r[u]&&!i&&(g[`${n}.${u}`]=r[u]),delete t[u].$m,delete t[u].$s,delete t[u].$e,r[u]=e(t[u],Boolean(n)?`${n}.${u}`:u,r[u]||{})}return r}({media:{proto_media:{MediaServerCommonResponse:{$m:{1:["code","uint32",0],2:["message","string",""]}},NotifySdkNeedStreamRequest:{$m:{1:["request_seq","uint32",0],2:["stream_id","string",""],3:["playAddr","string",""],4:["transCodecId","int32",0],5:["transCodecSuffix","string",""],6:["cdnType","int32",0],7:["retry","int32",0]}},NotifySdkNeedStreamResponse:{$m:{1:["request_seq","uint32",0],2:["response","media.proto_media.MediaServerCommonResponse",null],3:["transCodecSuffix","string",""],4:["action","int32",0],5:["action_delay","int32",0],6:["ttl","int32",0]}},RelayPublishCdnRequest:{$m:{1:["request_seq","uint32",0],2:["request_cmd","int32",0],3:["streamid","string",""],4:["cdn_server","string",""],5:["publish_timeout","uint32",0],6:["request_seq_v2","uint64",{low:0,high:0,unsigned:!0}]}},RelayPublishCdnResponse:{$m:{1:["request_seq","uint32",0],2:["response","media.proto_media.MediaServerCommonResponse",null],3:["request_seq_v2","uint64",{low:0,high:0,unsigned:!0}]}}}}},"",g,!1);var q=g.media,k=i(3788),x=i.n(k),N=i(7202);x().util.Long=N.A,x().configure();var C,$=q.proto_media,E=function(){function e(){}return e.prototype.encodeRelayPublishCdnReq=function(e){var t=$.RelayPublishCdnRequest.create(e);return $.RelayPublishCdnRequest.encode(t).finish()},e.prototype.decodeRelayPublishCdnRsp=function(e){var t=$.RelayPublishCdnResponse.decode(e);return t.request_seq_v2&&N.A.isLong(t.request_seq_v2)&&(t.request_seq_v2=t.request_seq_v2.toNumber()),t},e.prototype.encodeNotifySdkNeedStreamReq=function(e){var t=$.NotifySdkNeedStreamRequest.create(e);return $.NotifySdkNeedStreamRequest.encode(t).finish()},e.prototype.decodeNotifySdkNeedStreamRsp=function(e){return $.NotifySdkNeedStreamResponse.decode(e)},e}(),T=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),D=function(e){function t(t,n,r){var i=e.call(this,t,n)||this;return i._=t,i.O=n,i.k=r,i.RETRY_MAX_TIME=90,i}return T(t,e),t.prototype.initReqParams=function(e,t){this.streamID=e,this.transCodecConfig=t},t.prototype.active=function(e){var t=this;if(void 0===e&&(e=!1),this._.info("".concat(f.nkr," call")),this.retryTimer)this._.warn("".concat(f.nkr," was active, ignore"));else if(this.isOverTime)this._.warn("".concat(f.nkr," retry over time, stop retry"));else{var n=function(){t.clearRetryTimer(),t.k.sendNotifySdkNeedStreamHttpRes(t.streamID,t.transCodecConfig,function(e,n){var r=e.body;t.invalid(),t.stopMaxTime(),t.sucCallBack&&(t.sucCallBack&&t.sucCallBack(r,n),t.resetCallback())},function(e){t._err=e;var n=e.status_code;t.isOverTime?t.requestFail(e):((429===n||n>=500&&n<600)&&t.setRetryRule(1),t.active())}),e||t.attempt++};e?n():this.getRetryDelayByCount(this.attempt).then(function(e){t.retryTimer=setTimeout(n,e)})}},t}(v);!function(e){e[e.I=0]="I",e[e.H=10]="H",e[e.M=100]="M",e[e.L=1e3]="L"}(C||(C={}));var R={},P={_sendCDNPublishByAccessHub:function(e,t,n,r){var i=this;this.mediaProtoBuf||(this.mediaProtoBuf=new E);var o=new p(this.logger,this.stateCenter,this);o.initReqParams(e,t);var s=function(e,t){try{var n=i.mediaProtoBuf.decodeRelayPublishCdnRsp(e);i.logger.info("zb.sh.pt rsp decode ".concat(JSON.stringify(n)));var r=(null==n?void 0:n.response)||{};return{code:r.code,msg:r.message}}catch(e){return{code:-1}}};o.initCallback(function(e,o){var c=s(e),a=c.code,f=c.msg;a&&0!=a?(i.logger.error("zb.sh.pt "+t.type+" error code: "+a+" "+f),r(5004===a?u.yTe:u.Oy0," cmd: ".concat(t.type," ").concat(a," ").concat(f))):(i.logger.info("zb.sh.pt "+t.type+" success"),n&&n({errorCode:0,extendedData:""}))},function(e){var n=e.status_code,o=e.body,u=e.code,f=e.msg,h=JSON.parse(JSON.stringify(c.Of.error.p)),d="";if(u)h={code:u,msg:f},d=f;else if(200===n)i.logger.info("zb.sh.pt error: "),h=c.Of.error.p,d="cmd: ".concat(t.type);else{var l="";if((0,a.QP)(o))l=o;else{var v=s(o);l=v.code+" "+v.msg}d="request media server fail, error: "+n+" "+l}i.logger.error("zb.sh.pt "+d),r&&r(h,d)}),o.startMaxTime(),o.active(!0)},sendCDNRequest:function(e,t,n,r){var i=this;this.mediaProtoBuf||(this.mediaProtoBuf=new E);var o="addpush"===t.type?1:2,s={request_seq:this.stateCenter.cdnSeq++,request_cmd:o,streamid:e,cdn_server:t.pushUrl,request_seq_v2:this.stateCenter.cdnSeqV2++};this.logger.info("zb.sh.scpba "+JSON.stringify(s));var u=this.mediaProtoBuf.encodeRelayPublishCdnReq(s);this.sendHttpPBRequest({interfaceID:6,resID:this.stateCenter.appid+"/"+e},u,function(e,t){i.logger.info("zb.sh.pt receive message "+(null==e?void 0:e.status_code)),n&&n(e,t)},function(e){r&&r(e)},{timeout:4e3})},_publishTarget:function(e,t,n){this.logger.info("zb.sh.pt call");var r=e.streamID;this.stateCenter.testEnvironment&&(r="zegotest-"+this.stateCenter.appid+"-"+e.streamID),this._sendCDNPublishByAccessHub(r,e,t,n)},notifySdkNeedStream:function(e,t,n,r){var i=this;this.mediaProtoBuf||(this.mediaProtoBuf=new E);var o=new D(this.logger,this.stateCenter,this);return o.initReqParams(e,t),o.initCallback(function(e){try{var t=i.mediaProtoBuf.decodeNotifySdkNeedStreamRsp(e);i.logger.info("zb.sh.nsns receive message:"+JSON.stringify(t));var o=(null==t?void 0:t.response)||{},s=o.code;s&&0!=s?r({code:s,message:o.message||""},t):n&&n(t)}catch(e){e({code:-1})}},function(e){i.logger.error("zb.sh.nsns err:"+JSON.stringify(e)),r&&r(e)}),o.startMaxTime(),o.active(!0),o},sendNotifySdkNeedStreamHttpRes:function(e,t,n,r){this.mediaProtoBuf||(this.mediaProtoBuf=new E);var i=t.playAddr,o=t.transCodecID,s=t.transCodecSuffix,u=t.retry,c={request_seq:this.stateCenter.cdnSeq++,stream_id:e,playAddr:i,transCodecId:o,transCodecSuffix:s,cdnType:0,retry:u};this.logger.info("zb.sh.nsns request body:"+JSON.stringify(c));var a=this.mediaProtoBuf.encodeNotifySdkNeedStreamReq(c);this.sendHttpPBRequest({interfaceID:19,resID:this.stateCenter.appid+"/"+e},a,function(e,t){n&&n(e,t)},function(e){r&&r(e)},{timeout:4e3})}},I=function(){function e(e,t,n,r){this._=e,this.dataReport=t,this.N=n,this.O=r,this.screenShotReady=!1}return Object.defineProperty(e.prototype,"C",{get:function(){return this.O.reporter},enumerable:!1,configurable:!0}),e.prototype.publishTarget=function(e){var t=this,n="";switch(e.type){case"addpush":n=c.iJ.event;break;case"delpush":case"clearpush":n=c.ns.event}var r=this.C.createSpan(C.H,{key:c.Og.event,par:e.streamID},{key:""},n);return r.setAttributes({url:c.ns.url(e.pushUrl)}),new h.l3(function(n,i){var o=function(e,n){t._.error("zb.pt "+(n||e.message)),t.C.setError(r,e,n),i({errorCode:e.code,extendedData:e.message+(n?" "+n:"")})};if(-1==["addpush","delpush","clearpush"].indexOf(e.type))return t._.error("zb.sh.pt cdn push type error"),void o(u.rBJ,"type error");if(e.streamID&&(0,a.QP)(e.streamID))if(e.pushUrl&&(0,a.QP)(e.pushUrl))if(t.O.publishStreamList[e.streamID]){var s=t.N.getRoomByStreamID(e.streamID);if(s){s.streamHandler._publishTarget(e,function(e){r.end(),n(e)},o)}else o(c.Of.error.u)}else o(c.Of.error.i);else o(c.Of.error.t,"push url error");else o(c.Of.error.t,"stream id type error")})},e}(),J={type:"StreamCDN",install:function(e,t,n){for(var r in Object.defineProperty(t.prototype,"initStreamCDN",{value:function(){this.streamCDNModule=new I(this.logger,this.dataReport,this.streamCenter,this.stateCenter)},writable:!1}),R)Object.defineProperty(e.prototype,r,{value:R[r],writable:!1});for(var r in P)Object.defineProperty(n.prototype,r,{value:P[r],writable:!1})}};return o}()});