1 module libwasm.bindings.PeerConnectionImpl; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.MediaStreamTrack; 7 import libwasm.bindings.PeerConnectionImplEnums; 8 import libwasm.bindings.PeerConnectionObserver; 9 import libwasm.bindings.Performance; 10 import libwasm.bindings.RTCCertificate; 11 import libwasm.bindings.RTCConfiguration; 12 import libwasm.bindings.RTCDataChannel; 13 import libwasm.bindings.RTCPeerConnection; 14 import libwasm.bindings.RTCRtpSender; 15 import libwasm.bindings.RTCRtpSources; 16 import libwasm.bindings.TransceiverImpl; 17 import libwasm.bindings.Window; 18 19 @safe: 20 nothrow: 21 22 struct PeerConnectionImpl { 23 nothrow: 24 JsHandle handle; 25 alias handle this; 26 this(Handle h) { 27 this.handle = JsHandle(h); 28 } 29 void initialize()(scope ref PeerConnectionObserver observer, scope ref Window window, scope ref RTCConfiguration iceServers, scope ref nsISupports thread) { 30 Serialize_Object_VarArgCall!void(this.handle, "initialize", "Handle;Handle;Handle;Handle", tuple(cast(Handle)observer.handle, cast(Handle)window._parent, cast(Handle)iceServers.handle, cast(Handle)thread.handle)); 31 } 32 void createOffer()(scope ref RTCOfferOptions options) { 33 Object_Call_Handle__void(this.handle, "createOffer", options._parent); 34 } 35 void createOffer()() { 36 Object_Call__void(this.handle, "createOffer"); 37 } 38 void createAnswer()() { 39 Object_Call__void(this.handle, "createAnswer"); 40 } 41 void setLocalDescription()(int action, string sdp) { 42 Serialize_Object_VarArgCall!void(this.handle, "setLocalDescription", "int;string", tuple(action, sdp)); 43 } 44 void setRemoteDescription()(int action, string sdp) { 45 Serialize_Object_VarArgCall!void(this.handle, "setRemoteDescription", "int;string", tuple(action, sdp)); 46 } 47 void getStats(T0)(scope auto ref Optional!(T0) selector) if (isTOrPointer!(T0, MediaStreamTrack)) { 48 Serialize_Object_VarArgCall!void(this.handle, "getStats", "Optional!Handle", tuple(!selector.empty, cast(Handle)selector.front._parent)); 49 } 50 auto createTransceiverImpl(T1)(string kind, scope auto ref Optional!(T1) track) if (isTOrPointer!(T1, MediaStreamTrack)) { 51 return TransceiverImpl(Serialize_Object_VarArgCall!Handle(this.handle, "createTransceiverImpl", "string;Optional!Handle", tuple(kind, !track.empty, cast(Handle)track.front._parent))); 52 } 53 bool checkNegotiationNeeded()() { 54 return Object_Getter__bool(this.handle, "checkNegotiationNeeded"); 55 } 56 void insertDTMF()(scope ref TransceiverImpl transceiver, string tones, uint duration /* = 100 */, uint interToneGap /* = 70 */) { 57 Serialize_Object_VarArgCall!void(this.handle, "insertDTMF", "Handle;string;uint;uint", tuple(cast(Handle)transceiver.handle, tones, duration, interToneGap)); 58 } 59 void insertDTMF()(scope ref TransceiverImpl transceiver, string tones, uint duration /* = 100 */) { 60 Serialize_Object_VarArgCall!void(this.handle, "insertDTMF", "Handle;string;uint", tuple(cast(Handle)transceiver.handle, tones, duration)); 61 } 62 void insertDTMF()(scope ref TransceiverImpl transceiver, string tones) { 63 Serialize_Object_VarArgCall!void(this.handle, "insertDTMF", "Handle;string", tuple(cast(Handle)transceiver.handle, tones)); 64 } 65 string getDTMFToneBuffer()(scope ref RTCRtpSender sender) { 66 return Serialize_Object_VarArgCall!string(this.handle, "getDTMFToneBuffer", "Handle", tuple(cast(Handle)sender.handle)); 67 } 68 auto getRtpSources()(scope ref MediaStreamTrack track, double rtpSourceNow) { 69 return Sequence!(RTCRtpSourceEntry)(Serialize_Object_VarArgCall!Handle(this.handle, "getRtpSources", "Handle;double", tuple(cast(Handle)track._parent, rtpSourceNow))); 70 } 71 double getNowInRtpSourceReferenceTime()() { 72 return Object_Getter__double(this.handle, "getNowInRtpSourceReferenceTime"); 73 } 74 void replaceTrackNoRenegotiation(T1)(scope ref TransceiverImpl transceiverImpl, scope auto ref Optional!(T1) withTrack) if (isTOrPointer!(T1, MediaStreamTrack)) { 75 Serialize_Object_VarArgCall!void(this.handle, "replaceTrackNoRenegotiation", "Handle;Optional!Handle", tuple(cast(Handle)transceiverImpl.handle, !withTrack.empty, cast(Handle)withTrack.front._parent)); 76 } 77 void closeStreams()() { 78 Object_Call__void(this.handle, "closeStreams"); 79 } 80 void addRIDExtension()(scope ref MediaStreamTrack recvTrack, ushort extensionId) { 81 Serialize_Object_VarArgCall!void(this.handle, "addRIDExtension", "Handle;ushort", tuple(cast(Handle)recvTrack._parent, extensionId)); 82 } 83 void addRIDFilter()(scope ref MediaStreamTrack recvTrack, string rid) { 84 Serialize_Object_VarArgCall!void(this.handle, "addRIDFilter", "Handle;string", tuple(cast(Handle)recvTrack._parent, rid)); 85 } 86 void insertAudioLevelForContributingSource()(scope ref MediaStreamTrack recvTrack, uint source, double timestamp, bool hasLevel, byte level) { 87 Serialize_Object_VarArgCall!void(this.handle, "insertAudioLevelForContributingSource", "Handle;uint;double;bool;byte", tuple(cast(Handle)recvTrack._parent, source, timestamp, hasLevel, level)); 88 } 89 void enablePacketDump()(uint level, mozPacketDumpType type, bool sending) { 90 Serialize_Object_VarArgCall!void(this.handle, "enablePacketDump", "uint;Enum;bool", tuple(level, type, sending)); 91 } 92 void disablePacketDump()(uint level, mozPacketDumpType type, bool sending) { 93 Serialize_Object_VarArgCall!void(this.handle, "disablePacketDump", "uint;Enum;bool", tuple(level, type, sending)); 94 } 95 void addIceCandidate(T2)(string candidate, string mid, scope auto ref Optional!(T2) level) if (isTOrPointer!(T2, ushort)) { 96 Serialize_Object_VarArgCall!void(this.handle, "addIceCandidate", "string;string;Optional!(ushort)", tuple(candidate, mid, !level.empty, level.front)); 97 } 98 void close()() { 99 Object_Call__void(this.handle, "close"); 100 } 101 bool pluginCrash()(uint pluginId, string name) { 102 return Serialize_Object_VarArgCall!bool(this.handle, "pluginCrash", "uint;string", tuple(pluginId, name)); 103 } 104 void certificate()(scope ref RTCCertificate certificate) { 105 Object_Call_Handle__void(this.handle, "certificate", certificate.handle); 106 } 107 auto certificate()() { 108 return RTCCertificate(Object_Getter__Handle(this.handle, "certificate")); 109 } 110 string fingerprint()() { 111 return Object_Getter__string(this.handle, "fingerprint"); 112 } 113 string localDescription()() { 114 return Object_Getter__string(this.handle, "localDescription"); 115 } 116 string currentLocalDescription()() { 117 return Object_Getter__string(this.handle, "currentLocalDescription"); 118 } 119 string pendingLocalDescription()() { 120 return Object_Getter__string(this.handle, "pendingLocalDescription"); 121 } 122 string remoteDescription()() { 123 return Object_Getter__string(this.handle, "remoteDescription"); 124 } 125 string currentRemoteDescription()() { 126 return Object_Getter__string(this.handle, "currentRemoteDescription"); 127 } 128 string pendingRemoteDescription()() { 129 return Object_Getter__string(this.handle, "pendingRemoteDescription"); 130 } 131 PCImplIceConnectionState iceConnectionState()() { 132 return Object_Getter__int(this.handle, "iceConnectionState"); 133 } 134 PCImplIceGatheringState iceGatheringState()() { 135 return Object_Getter__int(this.handle, "iceGatheringState"); 136 } 137 PCImplSignalingState signalingState()() { 138 return Object_Getter__int(this.handle, "signalingState"); 139 } 140 void id()(string id) { 141 Object_Call_string__void(this.handle, "id", id); 142 } 143 string id()() { 144 return Object_Getter__string(this.handle, "id"); 145 } 146 void peerIdentity()(string peerIdentity) { 147 Object_Call_string__void(this.handle, "peerIdentity", peerIdentity); 148 } 149 string peerIdentity()() { 150 return Object_Getter__string(this.handle, "peerIdentity"); 151 } 152 bool privacyRequested()() { 153 return Object_Getter__bool(this.handle, "privacyRequested"); 154 } 155 auto createDataChannel()(string label, string protocol, ushort type, bool ordered, ushort maxTime, ushort maxNum, bool externalNegotiated, ushort stream) { 156 return RTCDataChannel(Serialize_Object_VarArgCall!Handle(this.handle, "createDataChannel", "string;string;ushort;bool;ushort;ushort;bool;ushort", tuple(label, protocol, type, ordered, maxTime, maxNum, externalNegotiated, stream))); 157 } 158 } 159 160