zego-express-engine-webrtc
Version:
zego webrtc express sdk
1 lines • 30 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]}}("undefined"!=typeof self?self:this,(function(e,t){return function(){"use strict";var n={2362:function(){!function(){function e(e){this.zegoStream=e}Object.defineProperty(e.prototype,"active",{get:function(){return this.zegoStream.active},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.zegoStream.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"videoCaptureStream",{get:function(){return this.zegoStream.originVideoStream},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"audioCaptureStream",{get:function(){return this.zegoStream.originAudioStream},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stream",{get:function(){return this.zegoStream.stream},enumerable:!1,configurable:!0}),e.prototype.getAudioTracks=function(){return this.zegoStream.getAudioTracks()},e.prototype.getVideoTracks=function(){return this.zegoStream.getVideoTracks()},e.prototype.getTracks=function(){return this.zegoStream.getTracks()},Object.defineProperty(e.prototype,"videoDeviceId",{get:function(){return this.zegoStream.videoDeviceId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"audioDeviceId",{get:function(){return this.zegoStream.audioDeviceId},enumerable:!1,configurable:!0}),e.prototype.on=function(e,t){return this.zegoStream.on(e,t)},e.prototype.off=function(e,t){return this.zegoStream.off(e,t)},e.prototype.startCaptureMicrophone=function(e){return this.zegoStream.startCaptureMicrophone(e)},e.prototype.startCaptureCamera=function(e){return this.zegoStream.startCaptureCamera(e)},e.prototype.startCaptureCameraAndMicrophone=function(e,t){return this.zegoStream.startCaptureCameraAndMicrophone(e,t)},e.prototype.startCaptureCustomAudio=function(e){return this.zegoStream.startCaptureCustomAudio(e)},e.prototype.startCaptureCustomVideo=function(e){return this.zegoStream.startCaptureCustomVideo(e)},e.prototype.startCaptureCustomVideoAndAudio=function(e,t){return this.zegoStream.startCaptureCustomVideoAndAudio(e,t)},e.prototype.startCaptureScreen=function(e){return this.zegoStream.startCaptureScreen(e)},e.prototype.startCaptureScreenWithAudio=function(e,t){return this.zegoStream.startCaptureScreenWithAudio(e,t)},e.prototype.stopCaptureAudio=function(){return this.zegoStream.stopCaptureAudio()},e.prototype.stopCaptureVideo=function(){return this.zegoStream.stopCaptureVideo()},e.prototype.playAudio=function(e){this.zegoStream.playAudio(e)},e.prototype.playCaptureAudio=function(e){this.zegoStream.playCaptureAudio(e)},e.prototype.playVideo=function(e,t){this.zegoStream.playVideo(e,t)},e.prototype.playCaptureVideo=function(e,t){this.zegoStream.playCaptureVideo(e,t)},e.prototype.takeStreamSnapshot=function(e){return this.zegoStream.takeStreamSnapshot(e)},e.prototype.resumeVideo=function(){return this.zegoStream.resumeVideo()},e.prototype.resumeAudio=function(){return this.zegoStream.resumeAudio()},e.prototype.stopVideo=function(){this.zegoStream.stopVideo()},e.prototype.stopAudio=function(){this.zegoStream.stopAudio()},e.prototype.stopPlayCaptureVideo=function(){this.zegoStream.stopPlayCaptureVideo()},e.prototype.stopPlayCaptureAudio=function(){this.zegoStream.stopPlayCaptureAudio()},e.prototype.setVolume=function(e){return this.zegoStream.setVolume(e)},e.prototype.useAudioOutputDevice=function(e){return this.zegoStream.setAudioOutputDevice(e)}}()},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"},4908:function(e,t,n){n.d(t,{Of:function(){return s},iJ:function(){return u},ns:function(){return c},pO:function(){return o}});var r=n(8627),i=n(5095),o={event:"/sdk/start_publish",error:{t:r.LLz,i:r.Q9p,u:r.xfZ,l:r.gSF,m:r.PA0,p:r.fzq,v:r.f43,_:r.qvY,k:r.S4u,S:r.SRE,O:r.Xxx,j:r.g9p,q:r.jZ$,P:r.$wo,C:r.SmZ,N:r.VU9,D:r.MrD,T:r.ZpF,R:r.iei,J:r.aa2,B:r.HCP,U:r.dg1,Z:r._68,F:r.kbF,W:r.kOd,K:r.WP4,X:r.JDv,G:r.Q3v,V:r.RBR,Y:r.NCg,ee:r.xbZ,te:r.OdW,ne:r.sJH,re:r.MrS},urls:i.yp,is_center:i.yS,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,use_na:i.Tr,is_dual_stream:i.Tr,is_mini:i.yS,is_peer:i.yS},s={event:"/sdk/publish_target",error:{ie:r.ZEp,oe:r.xU2,se:r.S4u,ue:r.I7C,ce:r.HO9,ae:r.aUw,fe:r.Oy0}},u={event:"/mss/pushadd",error:{ie:r.ZEp},stream_id:i.tK,url:i.tK},c={event:"/mss/pushdel",error:{ie: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}},8627:function(e,t,n){n.d(t,{$wo:function(){return J},Arx:function(){return ke},B3d:function(){return pe},Be2:function(){return re},FB3:function(){return W},HCP:function(){return Z},HO9:function(){return v},I4J:function(){return Ce},I7C:function(){return te},J79:function(){return c},JDv:function(){return oe},JSm:function(){return ie},L8E:function(){return L},LLz:function(){return O},MK1:function(){return de},MrD:function(){return V},MrS:function(){return S},MuX:function(){return Pe},NCg:function(){return Je},OdW:function(){return Ne},OrZ:function(){return j},Oy0:function(){return l},PA0:function(){return a},PTE:function(){return z},Q3v:function(){return se},Q4o:function(){return $e},Q9p:function(){return h},RBR:function(){return ce},RZs:function(){return qe},RfS:function(){return U},S4u:function(){return o},S5f:function(){return f},SB8:function(){return _e},SRE:function(){return F},SmZ:function(){return N},Tij:function(){return we},V2t:function(){return w},VU9:function(){return D},WP4:function(){return G},XHx:function(){return ye},Xxx:function(){return k},ZEp:function(){return d},ZpF:function(){return C},Zws:function(){return ve},_68:function(){return M},_HD:function(){return m},a$$:function(){return Ie},aUw:function(){return b},aa2:function(){return I},ann:function(){return fe},b1q:function(){return Ee},cMG:function(){return xe},ckD:function(){return De},ckg:function(){return Re},clM:function(){return s},d49:function(){return u},dXc:function(){return Oe},dg1:function(){return T},dqB:function(){return he},ekj:function(){return be},f43:function(){return H},fzq:function(){return A},g9p:function(){return p},gHA:function(){return le},gSF:function(){return g},hYx:function(){return Te},hje:function(){return ge},iei:function(){return $},jZ$:function(){return R},jut:function(){return x},kOd:function(){return X},kbF:function(){return Q},lgu:function(){return ze},m6U:function(){return ee},mrK:function(){return Y},pWJ:function(){return je},qvY:function(){return ue},rBJ:function(){return Me},sJH:function(){return P},sVF:function(){return y},s_m:function(){return q},t85:function(){return B},wxm:function(){return me},xU2:function(){return K},xbZ:function(){return ae},xfZ:function(){return _},yK:function(){return E},zML:function(){return Se},zs3:function(){return ne}});var r=n(8866),i="the user cancels the stream request.",o={code:1000002,message:"not login room"},s={code:1000014,message:"stream ID is too long"},u={code:1000015,message:"streamID is empty"},c={code:1000016,message:"stream ID contains illegal characters"},a={code:1000017,message:r.Rl},f={code:1000018,message:r.qC},d={code:1100001,message:r.dO},h={code:1100002,message:"network timeout."},l={code:1100999,message:"unknown server error"},m={code:1101005,message:"signal hb fail"},g={code:1102017,message:"dispatch error"},p={code:1102018,message:"token expired"},v={code:1102021,message:"biz channel error."},_={code:1102022,message:"dispatch request timeout"},b={code:1102024,message:"invalid channel"},y={code:1102026,msg:r.fT},k={code:1003025,message:"stream is forbided by media server"},z={code:1003050,message:"the extra info of the stream is null"},w={code:1003051,message:"the extra info of the stream is too long"},S={code:1003080,message:"browser does not support the codec"},O={code:1103001,message:r.dO},j={code:1103002,message:"browser do not support"},E={code:1103010,message:"screen fail"},q={code:1103011,message:"enumerate devices fail"},x={code:1103012,message:"use camera device fail"},P={code:1103019,message:"publish streams auth fail"},C={code:1103021,message:"session request fail"},N={code:1103022,message:"create offer error"},D={code:1103023,message:"setLocalDescription error"},T={code:1103024,message:"mediaDesc error"},$={code:1103025,message:"other side offer error"},M={code:1103026,message:"candidate error"},R={code:1103027,message:"server session closed"},I={code:1103028,message:"ice connection error"},J={code:1103030,message:"negotiation timeout"},B={code:1103042,message:"screen canceled"},L={code:1103043,message:"screen not support"},A={code:1103044,message:r.aw},H={code:1103099,message:"stream is not capturing"},U={code:1103049,message:"repeated pull same stream"},Z={code:1103050,message:"websocket disconnected"},F={code:1103051,message:"publisher retry timeout"},W={code:1103053,message:"https is required"},K={code:1103055,message:r.Wk},Q={code:1103056,message:"publish is publishing"},X={code:1103058,message:"client ip changed"},G={code:1103059,message:"ttl over time"},V={code:1103060,message:"session request timeout"},Y={code:1103061,message:"get media fail"},ee={code:1103062,message:"update stream info fail"},te={code:1103063,message:"publish target no response"},ne={code:1103064,message:"get device not allowed"},re={code:1103065,message:"device is not readable"},ie={code:1103066,message:"device does not meet constraints"},oe={code:1103067,message:"update sdp time out"},se={code:1103068,message:"update sdp fail"},ue={code:1103073,message:"video effect is starting, please operate after video effect is started"},ce={code:1103078,message:"publish stream poor and net probe poor"},ae={code:1103089,message:i},fe={code:1104001,message:"input parm error"},de={code:1104021,message:"session request fail"},he={code:1104022,message:"create offer error"},le={code:1104023,message:"setLocalDescription error"},me={code:1104024,message:"mediaDesc error"},ge={code:1104025,message:"other side offer error"},pe={code:1104026,message:"candidate error"},ve={code:1104028,message:"ice connection error"},_e={code:1104029,message:"websocket disconnected"},be={code:1104030,message:"negotiation timeout"},ye={code:1104031,message:"player retry timeout"},ke={code:1104032,message:"player is playing"},ze={code:1104033,message:"client ip changed"},we={code:1104034,message:"ttl is over time"},Se={code:1104035,message:"reset session push"},Oe={code:1104036,message:"session request timeout"},je={code:1104037,message:"probe time out"},Ee={code:1104038,message:"resource mode is not supported"},qe={code:1004002,message:"play stream not found"},xe={code:1004020,message:"play stream interrupted"},Pe={code:1104041,message:"stream quality poor and net probe poor"},Ce={code:1104042,message:i},Ne={code:1104043,message:"mini sdp error"},De={code:1104045,message:"play streams is out limit"},Te={code:1104046,message:"play streams auth fail"},$e={code:1104099,message:"play streams system error"},Me={code:1103052,message:"publisher cdn push error"},Re={code:1103048,message:r.pt},Ie={code:1000055,message:"cdn url is invalid"},Je={code:1103100,message:"background process is start, but not subscribe yet"}},8866:function(e,t,n){n.d(t,{Rl:function(){return d},UY:function(){return h},Wk:function(){return f},aw:function(){return s},dO:function(){return u},fT:function(){return i},h2:function(){return a},l3:function(){return r},pt:function(){return o},qC:function(){return c}});n(7202),n(8627),n(4872);var r=Promise;var i="room not exist",o="device is not found",s="stream is not from zego",u="input param error",c="local stream wrong",a="no preview",f="publish stream no found",d="network is broken";var h=function(){return new Promise((function(e,t){e(Math.random())}))}},7202:function(e,t,n){var r=n(6994);t.A=r.default||r},4872:function(e,t,n){n.d(t,{QP:function(){return r}});n(2362);function r(e){return"string"==typeof e}},6994:function(t){t.exports=e},3788:function(e){e.exports=t}},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),d=i(8866),h=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])}}},m=function(){function e(e,t){this.de=e,this.he=t,this.attempt=0,this.le=.3,this.me=4.8,this.ge=0,this.retryTimer=null,this.maxTimer=null,this.isOverTime=!1,this.RETRY_MAX_TIME=60}return e.prototype.setRetryRule=function(e){switch(this.ge=e,e){case 1:this.le=.3,this.me=32;break;case 0:this.le=.3,this.me=4.8}},e.prototype.getRetryDelayByCount=function(e){return h(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.ge?e+2:e<2?0:e,n=Math.min(this.me,this.le*Math.pow(2,t)),[4,(0,d.UY)()];case 1:return r=o.sent(),i=Math.floor(r*(1e3*n+1)),this.de.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.de.info("".concat(f.zUi," ").concat(null===(e=this.requestInfo)||void 0===e?void 0:e.streamID," call")),this.maxTimer?this.de.warn("".concat(f.zUi," max timer")):(this.maxTimer=setTimeout((function(){var e;t.de.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)}),1e3*this.RETRY_MAX_TIME),this.de.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.de.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}(),g=(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.de=t,i.he=n,i.pe=r,i.RETRY_MAX_TIME=8,i}return g(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.de.warn("".concat(f.v$W," was actived, ignore"));else if(this.isOverTime)this.de.warn("".concat(f.v$W," retry over time, stop retry"));else{var n=function(){t.clearRetryTimer(),t.pe.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}(m),v=i(3788);const _=i(6994);(v=v.default||v).util.Long=_.default||_,v.util.Long.fromBits=v.util.Long.fromBits||function(){return 0};for(var b=v.roots,y=v.types?v.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},k=v.types?v.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},z=Object.keys(y),w={$:function(e){return w[e]?w[e].call(this):b[e].decode?b[e].decode(this,this.uint32()):w.$.call(this,"int32")}},S={$:function(e,t,n){var r=y[e];return void 0===r?b[e].encode?(this.uint32(n<<3|2).fork(),b[e].encode(t,this).ldelim()):S.$.call(this,"int32",t,n):S[e].call(this.uint32(n<<3|r),t)}},O=0;O<z.length;O++)w[z[O]]=v.Reader.prototype[z[O]],S[z[O]]=v.Writer.prototype[z[O]];!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]]=v.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)?v.util.emptyArray:"bytes"===c?v.util.newBuffer([]):u[2]&&u[2].hasOwnProperty("low")&&u[2].hasOwnProperty("high")?v.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 v.Reader||(e=v.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]===v.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!==k[a=!w[a]&&!b[a].decode?"int32":a]&&2==(7&s))for(var d=e.uint32()+e.pos;e.pos<d;)o[c].push(w.$.call(e,a));else o[c].push(w.$.call(e,a))}else o[c]=w.$.call(e,a)}else e.skipType(7&s)}return o},i.encode=function(e,n){for(var r in n||(n=v.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]&&!b[s].encode?"int32":s,a&&void 0!==k[s]){n.uint32(r<<3|2).fork();for(u=0;u<f.length;u++)S[s].call(n,f[u]);n.ldelim()}else for(u=0;u<f.length;u++)S.$.call(n,s,f[u],r)}}else null!=e[o]&&e.hasOwnProperty(o)&&S.$.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){v.rpc.Service.call(this,e,t,n)}return(r.prototype=Object.create(v.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,b[o[0]],b[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&&(b[`${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}]}}}}},"",b,!1);var j=b.media,E=i(3788),q=i.n(E),x=i(7202);q().util.Long=x.A,q().configure();var P,C,N=j.proto_media,D=function(){function e(){}return e.prototype.encodeRelayPublishCdnReq=function(e){var t=N.RelayPublishCdnRequest.create(e);return N.RelayPublishCdnRequest.encode(t).finish()},e.prototype.decodeRelayPublishCdnRsp=function(e){var t=N.RelayPublishCdnResponse.decode(e);return t.request_seq_v2&&x.A.isLong(t.request_seq_v2)&&(t.request_seq_v2=t.request_seq_v2.toNumber()),t},e.prototype.encodeNotifySdkNeedStreamReq=function(e){var t=N.NotifySdkNeedStreamRequest.create(e);return N.NotifySdkNeedStreamRequest.encode(t).finish()},e.prototype.decodeNotifySdkNeedStreamRsp=function(e){return N.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)}}(),$=function(e){function t(t,n,r){var i=e.call(this,t,n)||this;return i.de=t,i.he=n,i.pe=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.de.info("".concat(f.nkr," call")),this.retryTimer)this.de.warn("".concat(f.nkr," was active, ignore"));else if(this.isOverTime)this.de.warn("".concat(f.nkr," retry over time, stop retry"));else{var n=function(){t.clearRetryTimer(),t.pe.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}(m);(C=P||(P={}))[C.I=0]="I",C[C.H=10]="H",C[C.M=100]="M",C[C.L=1e3]="L";var M={},R={_sendCDNPublishByAccessHub:function(e,t,n,r){var i=this;this.mediaProtoBuf||(this.mediaProtoBuf=new D);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.a$$: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,d=JSON.parse(JSON.stringify(c.Of.error.fe)),h="";if(u)d={code:u,msg:f},h=f;else if(200===n)i.logger.info("zb.sh.pt error: "),d=c.Of.error.fe,h="cmd: ".concat(t.type);else{var l="";if((0,a.QP)(o))l=o;else{var m=s(o);l=m.code+" "+m.msg}h="request media server fail, error: "+n+" "+l}i.logger.error("zb.sh.pt "+h),r&&r(d,h)})),o.startMaxTime(),o.active(!0)},sendCDNRequest:function(e,t,n,r){var i=this,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 D);var o=new $(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)),console.debug("%c### decodeBody: ".concat(JSON.stringify(t)),"color:blue");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}),console.debug("%c### error","color:red",e)}}),(function(e){console.debug("%c### err","color:red",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 D);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.de=e,this.dataReport=t,this.ve=n,this.he=r,this.screenShotReady=!1}return Object.defineProperty(e.prototype,"_e",{get:function(){return this.he.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._e.createSpan(P.H,{key:c.pO.event,par:e.streamID},{key:""},n);return r.setAttributes({url:c.ns.url(e.pushUrl)}),new d.l3((function(n,i){var o=function(e,n){t.de.error("zb.pt "+(n||e.message)),t._e.setError(r,e,n),i({errorCode:e.code,extendedData:e.message+(n?" "+n:"")})};if(-1==["addpush","delpush","clearpush"].indexOf(e.type))return t.de.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.he.publishStreamList[e.streamID]){var s=t.ve.getRoomByStreamID(e.streamID);if(s){s.streamHandler._publishTarget(e,(function(e){r.end(),n(e)}),o)}else o(c.Of.error.se)}else o(c.Of.error.oe);else o(c.Of.error.ie,"push url error");else o(c.Of.error.ie,"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}),M)Object.defineProperty(e.prototype,r,{value:M[r],writable:!1});for(var r in R)Object.defineProperty(n.prototype,r,{value:R[r],writable:!1})}};return o}()}));