From bee804e0954448a1af66aa3c6b458e8a2dc97fc3 Mon Sep 17 00:00:00 2001 From: adbenitez Date: Fri, 12 Sep 2025 18:59:34 +0200 Subject: [PATCH] update to new calls-app's API --- jni/deltachat-core-rust | 2 +- src/main/assets/calls/index.html | 46 +++++++++---------- .../notifications/NotificationCenter.java | 13 +++++- .../videochat/VideochatActivity.java | 15 +++++- .../securesms/videochat/VideochatUtil.java | 2 +- 5 files changed, 50 insertions(+), 28 deletions(-) diff --git a/jni/deltachat-core-rust b/jni/deltachat-core-rust index 75bcf8660..5d9b88762 160000 --- a/jni/deltachat-core-rust +++ b/jni/deltachat-core-rust @@ -1 +1 @@ -Subproject commit 75bcf8660bca5b80bea7835bd85df11518a0f7e4 +Subproject commit 5d9b887624f8c1641e40e009727b977de1c62bee diff --git a/src/main/assets/calls/index.html b/src/main/assets/calls/index.html index 53aa9bea8..2040aaf0a 100644 --- a/src/main/assets/calls/index.html +++ b/src/main/assets/calls/index.html @@ -9,57 +9,57 @@ - +`+T(l));break}S.push(R)}}if(l.__c!=null&&l.__c.__H!=null){var P=l.__c.__H.__;if(P)for(var O=0;O=n.__.length&&n.__.push({}),n.__[e]}function At(e){return J=1,Ht(mt,e)}function Ht(e,t,n){var o=ge(Y++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):mt(void 0,t),function(s){var c=o.__N?o.__N[0]:o.__[0],u=o.t(c,s);c!==u&&(o.__N=[u,o.__[1]],o.__c.setState({}))}],o.__c=k,!k.__f)){var r=function(s,c,u){if(!o.__c.__H)return!0;var v=o.__c.__H.__.filter(function(y){return!!y.__c});if(v.every(function(y){return!y.__N}))return!i||i.call(this,s,c,u);var a=o.__c.props!==s;return v.forEach(function(y){if(y.__N){var h=y.__[0];y.__=y.__N,y.__N=void 0,h!==y.__[0]&&(a=!0)}}),i&&i.call(this,s,c,u)||a};k.__f=!0;var i=k.shouldComponentUpdate,_=k.componentWillUpdate;k.componentWillUpdate=function(s,c,u){if(this.__e){var v=i;i=void 0,r(s,c,u),i=v}_&&_.call(this,s,c,u)},k.shouldComponentUpdate=r}return o.__N||o.__}function Ut(e,t){var n=ge(Y++,3);!x.__s&&ht(n.__H,t)&&(n.__=e,n.u=t,k.__H.__h.push(n))}function je(e){return J=5,dt(function(){return{current:e}},[])}function dt(e,t){var n=ge(Y++,7);return ht(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ft(e,t){return J=8,dt(function(){return e},t)}function Lt(){for(var e;e=pt.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(ee),e.__H.__h.forEach(de),e.__H.__h=[]}catch(t){e.__H.__h=[],x.__e(t,e.__v)}}x.__b=function(e){k=null,Se&&Se(e)},x.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Oe&&Oe(e,t)},x.__r=function(e){$e&&$e(e),Y=0;var t=(k=e.__c).__H;t&&(_e===k?(t.__h=[],k.__h=[],t.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.forEach(ee),t.__h.forEach(de),t.__h=[],Y=0)),_e=k},x.diffed=function(e){Ee&&Ee(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(pt.push(t)!==1&&Te===x.requestAnimationFrame||((Te=x.requestAnimationFrame)||Mt)(Lt)),t.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),_e=k=null},x.__c=function(e,t){t.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(o){return!o.__||de(o)})}catch(o){t.some(function(r){r.__h&&(r.__h=[])}),t=[],x.__e(o,n.__v)}}),Pe&&Pe(e,t)},x.unmount=function(e){De&&De(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ee(o)}catch(r){t=r}}),n.__H=void 0,t&&x.__e(t,n.__v))};var Ie=typeof requestAnimationFrame=="function";function Mt(e){var t,n=function(){clearTimeout(o),Ie&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);Ie&&(t=requestAnimationFrame(n))}function ee(e){var t=k,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),k=t}function de(e){var t=k;e.__c=e.__(),k=t}function ht(e,t){return!e||e.length!==t.length||t.some(function(n,o){return n!==e[o]})}function mt(e,t){return typeof t=="function"?t(e):t}function vt(e,t){for(var n in t)e[n]=t[n];return e}function Re(e,t){for(var n in e)if(n!=="__source"&&!(n in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function Ae(e,t){this.props=e,this.context=t}(Ae.prototype=new E).isPureReactComponent=!0,Ae.prototype.shouldComponentUpdate=function(e,t){return Re(this.props,e)||Re(this.state,t)};var He=p.__b;p.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),He&&He(e)};var zt=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;function yt(e){function t(n){var o=vt({},n);return delete o.ref,e(o,n.ref||null)}return t.$$typeof=zt,t.render=t,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t}var Wt=p.__e;p.__e=function(e,t,n,o){if(e.then){for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return t.__e==null&&(t.__e=n.__e,t.__k=n.__k),r.__c(e,t)}Wt(e,t,n,o)};var Ue=p.unmount;function gt(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=vt({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return gt(o,t,n)})),e}function bt(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return bt(o,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function se(){this.__u=0,this.o=null,this.__b=null}function wt(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function K(){this.i=null,this.l=null}p.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ue&&Ue(e)},(se.prototype=new E).__c=function(e,t){var n=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(n);var r=wt(o.__v),i=!1,_=function(){i||(i=!0,n.__R=null,r?r(s):s())};n.__R=_;var s=function(){if(!--o.__u){if(o.state.__a){var c=o.state.__a;o.__v.__k[0]=bt(c,c.__c.__P,c.__c.__O)}var u;for(o.setState({__a:o.__b=null});u=o.o.pop();)u.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(_,_)},se.prototype.componentWillUnmount=function(){this.o=[]},se.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=gt(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&fe(F,null,e.fallback);return r&&(r.__u&=-33),[fe(F,null,t.__a?null:e.children),r]};var Fe=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]{});this.peerConnection=new RTCPeerConnection(tn),this.state="connecting",this.iceTricklingBuffer=[],this.iceTricklingDataChannel=this.peerConnection.createDataChannel("iceTrickling",{negotiated:!0,id:1}),this.iceTricklingDataChannel.onmessage=t=>{console.log("received ICE candidate from remote peer",t.data),this.peerConnection.addIceCandidate(JSON.parse(t.data))},this.iceTricklingDataChannel.onopen=()=>{console.log("iceTricklingDataChannel open: sending buffered ICE candidates",this.iceTricklingBuffer);for(const t of this.iceTricklingBuffer)qe(this.iceTricklingDataChannel,t);this.iceTricklingBuffer=[]}}async init(t,n,o){this.onStateChanged=o,this.peerConnection.ontrack=s=>{const c=s.streams[0];n(c),this.state="in-call",this.onStateChanged(this.state)},t.getTracks().forEach(s=>this.peerConnection.addTrack(s,t));const r=async s=>{const c=Be(this.peerConnection),u={type:"offer",sdp:s},v=new RTCSessionDescription(u);this.peerConnection.setRemoteDescription(v),this.peerConnection.setLocalDescription(await this.peerConnection.createAnswer()),await c;const a=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),window.calls.acceptCall(a)},i=s=>{const c={type:"answer",sdp:s},u=new RTCSessionDescription(c);this.peerConnection.setRemoteDescription(u)},_=async()=>{const s=decodeURIComponent(window.location.hash.substring(1));if(s==="startCall")console.log("URL hash CMD: ",s),await this.startCall();else if(s.startsWith("acceptCall=")){const c=window.atob(s.substring(11));console.log("URL hash CMD: acceptCall:",c),await r(c)}else if(s.startsWith("onAnswer=")){const c=window.atob(s.substring(9));console.log("URL hash CMD: onAnswer:",c),i(c)}else console.log("unexpected URL hash: ",s)};_(),window.addEventListener("hashchange",_)}async startCall(){const t=Be(this.peerConnection);this.peerConnection.setLocalDescription(await this.peerConnection.createOffer()),await t;const n=this.peerConnection.localDescription.sdp;this.peerConnection.onicecandidate=this.trickleIceOverDataChannel.bind(this),window.calls.startCall(n),this.state="ringing",this.onStateChanged(this.state)}async endCall(){window.calls.endCall()}getState(){return this.state}trickleIceOverDataChannel(t){if(this.iceTricklingDataChannel.readyState!=="open"){console.log("Gathered new ICE candidate, but iceTricklingDataChannel is not yet open, will buffer it",t.candidate),this.iceTricklingBuffer.push(t.candidate);return}qe(this.iceTricklingDataChannel,t.candidate)}}function Be(e){(e.localDescription!=null||e.remoteDescription!=null)&&console.warn("gatheredEnoughIce called after setLocalDescription or setRemoteDescription: it might not have captured all ICE candidate events");const t=new Promise(o=>{const r=i=>{i.candidate!=null&&i.candidate.type==="relay"&&(setTimeout(o,100),e.removeEventListener("icecandidate",r))};e.addEventListener("icecandidate",r)}),n=new Promise(o=>{const r=()=>{e.iceGatheringState==="complete"&&(o(),e.removeEventListener("icegatheringstatechange",r))};e.addEventListener("icegatheringstatechange",r)});return Promise.race([t,n])}function qe(e,t){console.log("sending ICE candidate to remote peer",t),e.send(JSON.stringify(t===null?t:t.toJSON()))}var on=0;function w(e,t,n,o,r,i){t||(t={});var _,s,c=t;if("ref"in c)for(s in c={},t)s=="ref"?_=t[s]:c[s]=t[s];var u={type:e,props:c,key:n,ref:_,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--on,__i:-1,__u:0,__source:r,__self:i};if(typeof e=="function"&&(_=e.defaultProps))for(s in _)c[s]===void 0&&(c[s]=_[s]);return p.vnode&&p.vnode(u),u}var Ve="/home/adbenitez/projects/deltachat/call/src/components/VideoThumbnail.tsx";const rn={position:"absolute",right:"15px",top:"15px",height:"100px",width:"100px",zIndex:1,imageRendering:"crisp-edges",borderRadius:"5px",boxShadow:"rgba(0, 0, 0, 0.29) 0px 2px 8px 0px, rgba(0, 0, 0, 0.28) 0px 2px 8px 0px"};function an({videoRef:e}){return w("div",{style:rn,children:w("video",{style:{borderRadius:"5px",objectFit:"cover",transform:"scaleX(-1)"},width:"100%",height:"100%",muted:!0,autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:Ve,lineNumber:21,columnNumber:7},this)},void 0,!1,{fileName:Ve,lineNumber:20,columnNumber:5},this)}var Ye="/home/adbenitez/projects/deltachat/call/src/components/FullscreenVideo.tsx";const ln={imageRendering:"crisp-edges",width:"100%",height:"100%"};function _n({videoRef:e}){return w("div",{style:ln,children:w("video",{style:{transform:"scaleX(-1)"},width:"100%",height:"100%",autoPlay:!0,playsInline:!0,ref:e},void 0,!1,{fileName:Ye,lineNumber:14,columnNumber:7},this)},void 0,!1,{fileName:Ye,lineNumber:13,columnNumber:5},this)}var Je="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/call-end.jsx";const sn=(e,t)=>w("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:w("path",{fill:"currentColor",d:"M12 8q2.95 0 5.813 1.188T22.9 12.75q.3.3.3.7t-.3.7l-2.3 2.25q-.275.275-.638.3t-.662-.2l-2.9-2.2q-.2-.15-.3-.35t-.1-.45v-2.85q-.95-.3-1.95-.475T12 10t-2.05.175T8 10.65v2.85q0 .25-.1.45t-.3.35l-2.9 2.2q-.3.225-.663.2t-.637-.3l-2.3-2.25q-.3-.3-.3-.7t.3-.7q2.2-2.375 5.075-3.562T12 8"},void 0,!1,{fileName:Je,lineNumber:3,columnNumber:123},void 0)},void 0,!1,{fileName:Je,lineNumber:3,columnNumber:48},void 0),cn=yt(sn),un="_btn_ppybd_1",fn={btn:un};var pn="/home/adbenitez/projects/deltachat/call/src/components/Button.tsx";function dn({children:e,...t}){return w("div",{className:fn.btn,...t,children:e},void 0,!1,{fileName:pn,lineNumber:10,columnNumber:5},this)}var Xe="/home/adbenitez/projects/deltachat/call/src/components/EndCallButton.tsx";const Ge={color:"white",background:"#cb2233",borderRadius:"50%",fontSize:"1.5em"};function hn({...e}){return e.style={...Ge,...e.style||{}},w(dn,{style:Ge,...e,children:w(cn,{},void 0,!1,{fileName:Xe,lineNumber:20,columnNumber:7},this)},void 0,!1,{fileName:Xe,lineNumber:19,columnNumber:5},this)}var Ke="/home/adbenitez/projects/deltachat/call/~icons/material-symbols/person.jsx";const mn=(e,t)=>w("svg",{viewBox:"0 0 24 24",width:"1.2em",height:"1.2em",ref:t,...e,children:w("path",{fill:"currentColor",d:"M12 12q-1.65 0-2.825-1.175T8 8t1.175-2.825T12 4t2.825 1.175T16 8t-1.175 2.825T12 12m-8 8v-2.8q0-.85.438-1.562T5.6 14.55q1.55-.775 3.15-1.162T12 13t3.25.388t3.15 1.162q.725.375 1.163 1.088T20 17.2V20z"},void 0,!1,{fileName:Ke,lineNumber:3,columnNumber:122},void 0)},void 0,!1,{fileName:Ke,lineNumber:3,columnNumber:47},void 0),vn=yt(mn);var yn="/home/adbenitez/projects/deltachat/call/src/components/AvatarCircle.tsx";const Ze={display:"inline-flex",flexDirection:"row",alignItems:"center",padding:"0.5em",color:"white",background:"#c8c7cd",borderRadius:"50%",fontSize:"1.5em"};function gn({children:e,...t}){return t.style={...Ze,...t.style||{}},w("div",{style:Ze,...t,children:e},void 0,!1,{fileName:yn,lineNumber:20,columnNumber:5},this)}var Qe="/home/adbenitez/projects/deltachat/call/src/components/AvatarPlaceholder.tsx";function bn({...e}){return w(gn,{style:{padding:"0.2em",fontSize:"5em"},...e,children:w(vn,{},void 0,!1,{fileName:Qe,lineNumber:12,columnNumber:7},this)},void 0,!1,{fileName:Qe,lineNumber:11,columnNumber:5},this)}var wn="/home/adbenitez/projects/deltachat/call/src/components/AvatarImage.tsx";function Nn({url:e,...t}){return t.style={width:"8em",height:"8em",borderRadius:"50%",backgroundImage:`url(${e})`,backgroundSize:"cover",backgroundPosition:"center",...t.style||{}},w("div",{...t},void 0,!1,{fileName:wn,lineNumber:16,columnNumber:10},this)}var A="/home/adbenitez/projects/deltachat/call/src/App.tsx";const Z=new nn;function kn(){const[e,t]=ie(At(Z.getState()),"state"),n=ie(je(null),"outVidRef"),o=ie(je(null),"incVidRef");Ut(()=>{(async()=>{const c=await navigator.mediaDevices.getUserMedia({video:!0,audio:!0});n.current.srcObject=c;const u=v=>{o.current.srcObject=v};await Z.init(c,u,t)})()},[]);const r=Ft(()=>{Z.endCall()},[Z]);let i="";e==="connecting"?i="Connecting...":e==="ringing"&&(i="Ringing...");const _=e==="in-call";return w("div",{style:{height:"100vh",overflow:"hidden"},children:[w("div",{style:{display:_?"block":"none",height:"100%"},children:[w(_n,{videoRef:o},void 0,!1,{fileName:A,lineNumber:55,columnNumber:9},this),w(an,{videoRef:n},void 0,!1,{fileName:A,lineNumber:56,columnNumber:9},this)]},void 0,!0,{fileName:A,lineNumber:54,columnNumber:7},this),w("div",{style:{position:"absolute",top:0,width:"100%",paddingTop:"1em",textAlign:"center"},children:i},void 0,!1,{fileName:A,lineNumber:59,columnNumber:7},this),w("div",{style:{display:_?"none":"flex",alignItems:"center",textAlign:"center",justifyContent:"center",height:"100%"},children:window.calls.getAvatar?w(Nn,{url:window.calls.getAvatar()},void 0,!1,{fileName:A,lineNumber:80,columnNumber:11},this):w(bn,{},void 0,!1,{fileName:A,lineNumber:82,columnNumber:11},this)},void 0,!1,{fileName:A,lineNumber:70,columnNumber:7},this),w("div",{style:{position:"absolute",bottom:"1em",width:"100%",textAlign:"center"},children:w(hn,{onClick:r},void 0,!1,{fileName:A,lineNumber:93,columnNumber:9},this)},void 0,!1,{fileName:A,lineNumber:85,columnNumber:7},this)]},void 0,!0,{fileName:A,lineNumber:53,columnNumber:5},this)}var Cn="/home/adbenitez/projects/deltachat/call/src/index.tsx";Dt(w(kn,{},void 0,!1,{fileName:Cn,lineNumber:4,columnNumber:8},void 0),document.getElementById("root"));