1 module libwasm.bindings.PeerConnectionObserver; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.MediaStreamTrack; 7 import libwasm.bindings.PeerConnectionObserverEnums; 8 import libwasm.bindings.RTCDataChannel; 9 import libwasm.bindings.RTCPeerConnection; 10 import libwasm.bindings.RTCStatsReport; 11 import libwasm.bindings.TransceiverImpl; 12 13 @safe: 14 nothrow: 15 16 struct PeerConnectionObserver { 17 nothrow: 18 JsHandle handle; 19 alias handle this; 20 this(Handle h) { 21 this.handle = JsHandle(h); 22 } 23 void onCreateOfferSuccess()(string offer) { 24 Object_Call_string__void(this.handle, "onCreateOfferSuccess", offer); 25 } 26 void onCreateOfferError()(uint name, string message) { 27 Serialize_Object_VarArgCall!void(this.handle, "onCreateOfferError", "uint;string", tuple(name, message)); 28 } 29 void onCreateAnswerSuccess()(string answer) { 30 Object_Call_string__void(this.handle, "onCreateAnswerSuccess", answer); 31 } 32 void onCreateAnswerError()(uint name, string message) { 33 Serialize_Object_VarArgCall!void(this.handle, "onCreateAnswerError", "uint;string", tuple(name, message)); 34 } 35 void onSetLocalDescriptionSuccess()() { 36 Object_Call__void(this.handle, "onSetLocalDescriptionSuccess"); 37 } 38 void onSetRemoteDescriptionSuccess()() { 39 Object_Call__void(this.handle, "onSetRemoteDescriptionSuccess"); 40 } 41 void onSetLocalDescriptionError()(uint name, string message) { 42 Serialize_Object_VarArgCall!void(this.handle, "onSetLocalDescriptionError", "uint;string", tuple(name, message)); 43 } 44 void onSetRemoteDescriptionError()(uint name, string message) { 45 Serialize_Object_VarArgCall!void(this.handle, "onSetRemoteDescriptionError", "uint;string", tuple(name, message)); 46 } 47 void onAddIceCandidateSuccess()() { 48 Object_Call__void(this.handle, "onAddIceCandidateSuccess"); 49 } 50 void onAddIceCandidateError()(uint name, string message) { 51 Serialize_Object_VarArgCall!void(this.handle, "onAddIceCandidateError", "uint;string", tuple(name, message)); 52 } 53 void onIceCandidate()(ushort level, string mid, string candidate) { 54 Serialize_Object_VarArgCall!void(this.handle, "onIceCandidate", "ushort;string;string", tuple(level, mid, candidate)); 55 } 56 void onGetStatsSuccess()(scope ref RTCStatsReportInternal report) { 57 Object_Call_Handle__void(this.handle, "onGetStatsSuccess", report.handle); 58 } 59 void onGetStatsSuccess()() { 60 Object_Call__void(this.handle, "onGetStatsSuccess"); 61 } 62 void onGetStatsError()(uint name, string message) { 63 Serialize_Object_VarArgCall!void(this.handle, "onGetStatsError", "uint;string", tuple(name, message)); 64 } 65 void notifyDataChannel()(scope ref RTCDataChannel channel) { 66 Object_Call_Handle__void(this.handle, "notifyDataChannel", channel._parent); 67 } 68 void onStateChange()(PCObserverStateType state) { 69 Object_Call_int__void(this.handle, "onStateChange", state); 70 } 71 void onTransceiverNeeded()(string kind, scope ref TransceiverImpl transceiverImpl) { 72 Serialize_Object_VarArgCall!void(this.handle, "onTransceiverNeeded", "string;Handle", tuple(kind, cast(Handle)transceiverImpl.handle)); 73 } 74 void onDTMFToneChange()(scope ref MediaStreamTrack track, string tone) { 75 Serialize_Object_VarArgCall!void(this.handle, "onDTMFToneChange", "Handle;string", tuple(cast(Handle)track._parent, tone)); 76 } 77 void onPacket()(uint level, mozPacketDumpType type, bool sending, scope ref ArrayBuffer packet) { 78 Serialize_Object_VarArgCall!void(this.handle, "onPacket", "uint;Enum;bool;Handle", tuple(level, type, sending, cast(Handle)packet.handle)); 79 } 80 void syncTransceivers()() { 81 Object_Call__void(this.handle, "syncTransceivers"); 82 } 83 } 84 85