.gitignore added
[dotfiles/.git] / .config / google-chrome / Default / Extensions / pkedcjkdefgpdelpbcmbmeomcjbeemfm / 9221.427.0.1_0 / mirroring_webrtc.js
1 'use strict';var LLa={TAB:0,ln:1,jv:2},Y$=function(a){Mb("MediaRouter.WebRtc.Start.Success",a,LLa)};var Z$=function(a,b){Ak.call(this,b);this.G=a;this.l=new qb;this.g=nw(b.id);this.m=new qb;this.D=!1;this.o=null;this.F=!1;this.u=this.C=null;MLa(this);NLa(this);this.g.sendMessage(new Ps("GET_TURN_CREDENTIALS"))};r(Z$,Ak);
2 Z$.prototype.start=function(a){var b=this;return this.l.promise.then(function(c){if(c.g)return Promise.reject(new Fj("Mirroring already started"));if(b.o)return Promise.reject(new Fj("Session permanently stopped"));b.C=new Bb("MediaRouter.WebRtc.Session.Launch");c.ea.addStream(a);c.start();return b.m.promise})};
3 Z$.prototype.stop=function(){var a=this;this.m.reject(new Fj("Session stop requested."));this.u&&(this.u.end(),this.u=null);if(this.o)return this.o;this.F=this.D=!1;this.C=null;return this.o=this.l.promise.then(function(b){b.stop()}).then(function(){return a.g.dispose()}).catch(function(b){a.g.dispose();throw b;})};
4 var MLa=function(a){a.g.onMessage=function(b){if(!b.type)throw Error("Message has no type.");switch(b.type){case "TURN_CREDENTIALS":a.l.resolve(new Rv(a.h.id,b.data.credentials));break;case "ANSWER":a.l.promise.then(function(c){Sv(c,b.data)});break;case "KNOCK_ANSWER":a.F=!0;a.l.promise.then(function(c){Sv(c,b.data)});break;case "STOP":a.m.reject(new Fj("Stop signal received"));a.stop();break;default:throw new Fj("Unknown message type: "+b.type);}}},NLa=function(a){a.l.promise.then(function(b){jaa(b,
5 function(c){a.g.sendMessage(new Ps("OFFER",new Rs(c,a.G)))});kaa(b,function(c){c=JSON.parse(c);if(!c.type)throw Error("Invalid message");a.g.sendMessage(new Ps(c.type,c.data))});gaa(b,function(){a.D=!0;a.g.sendMessage(new Ps("SESSION_START_SUCCESS"));!a.F&&a.C&&a.C.end();a.C=null;a.u=new Hb("MediaRouter.WebRtc.Session.Length");a.m.resolve(a)});iaa(b,function(){a.g.sendMessage(new Ps("SESSION_END"))});haa(b,function(c){a.D||a.m.reject(c);a.g.sendMessage(new Ps("SESSION_FAILURE"))})})};var $$=function(){ok.call(this,"webrtc")};r($$,ok);k=$$.prototype;k.ej=function(a,b){return new Z$(a,b)};k.ji=function(){Y$(0)};k.gi=function(){Y$(1)};k.Mj=function(){Y$(2)};k.hi=function(){Kb("MediaRouter.WebRtc.Session.End")};k.Ug=function(a){Mb("MediaRouter.WebRtc.Start.Failure",a,Ej)};k.ii=function(){Kb("MediaRouter.WebRtc.Stream.End")};var OLa=new $$;fk("mr.mirror.webrtc.WebRtcService",OLa);