From 3c6763804c92fc3d5f4d1bc5b9492f59b7743547 Mon Sep 17 00:00:00 2001 From: giangndm <45644921+giangndm@users.noreply.github.com> Date: Wed, 23 Oct 2024 10:33:52 +0700 Subject: [PATCH] feat: added sip outgoing hook, UI and demo (#22) --- apps/web/app/actions/sip.ts | 98 + apps/web/app/actions/token.ts | 2 +- apps/web/app/env.ts | 5 +- apps/web/app/page.tsx | 6 + .../react_ui_samples/sipIncoming/content.tsx | 54 + .../app/react_ui_samples/sipIncoming/page.tsx | 65 + .../react_ui_samples/sipOutgoing/content.tsx | 51 + .../app/react_ui_samples/sipOutgoing/page.tsx | 91 + packages/sdk-core/protobuf/README.md | 0 packages/sdk-core/protobuf/sip_gateway.proto | 224 ++ packages/sdk-core/protobuf/sync.sh | 1 - packages/sdk-core/src/data.ts | 2 +- .../src/generated/protobuf/cluster_gateway.ts | 2 +- .../src/generated/protobuf/features.mixer.ts | 2 +- .../src/generated/protobuf/features.ts | 2 +- .../src/generated/protobuf/gateway.ts | 2 +- .../src/generated/protobuf/session.ts | 2 +- .../sdk-core/src/generated/protobuf/shared.ts | 2 +- .../src/generated/protobuf/sip_gateway.ts | 2943 +++++++++++++++++ packages/sdk-core/src/lib.ts | 3 + packages/sdk-core/src/session.ts | 22 +- packages/sdk-core/src/sip_incoming.ts | 153 + packages/sdk-core/src/sip_outgoing.ts | 201 ++ packages/sdk-react-hooks/src/context.ts | 2 +- .../sdk-react-hooks/src/hooks/session.tsx | 2 +- .../src/hooks/sip/sip_incoming.tsx | 22 + .../src/hooks/sip/sip_outgoing.tsx | 22 + packages/sdk-react-hooks/src/lib.tsx | 3 + packages/sdk-react-hooks/src/provider.tsx | 2 +- .../src/components/previews/camera.tsx | 30 +- .../src/components/previews/microphone.tsx | 35 +- .../src/components/uis/clock_timer.tsx | 27 + packages/sdk-react-ui/src/lib.tsx | 5 + .../src/panels/controls_panel.tsx | 4 +- .../src/panels/devices_selection.tsx | 6 +- .../sdk-react-ui/src/panels/sip_incoming.tsx | 92 + .../sdk-react-ui/src/panels/sip_outgoing.tsx | 55 + 37 files changed, 4184 insertions(+), 56 deletions(-) create mode 100644 apps/web/app/actions/sip.ts create mode 100644 apps/web/app/react_ui_samples/sipIncoming/content.tsx create mode 100644 apps/web/app/react_ui_samples/sipIncoming/page.tsx create mode 100644 apps/web/app/react_ui_samples/sipOutgoing/content.tsx create mode 100644 apps/web/app/react_ui_samples/sipOutgoing/page.tsx delete mode 100644 packages/sdk-core/protobuf/README.md create mode 100644 packages/sdk-core/protobuf/sip_gateway.proto delete mode 100644 packages/sdk-core/protobuf/sync.sh create mode 100644 packages/sdk-core/src/generated/protobuf/sip_gateway.ts create mode 100644 packages/sdk-core/src/sip_incoming.ts create mode 100644 packages/sdk-core/src/sip_outgoing.ts create mode 100644 packages/sdk-react-hooks/src/hooks/sip/sip_incoming.tsx create mode 100644 packages/sdk-react-hooks/src/hooks/sip/sip_outgoing.tsx create mode 100644 packages/sdk-react-ui/src/components/uis/clock_timer.tsx create mode 100644 packages/sdk-react-ui/src/panels/sip_incoming.tsx create mode 100644 packages/sdk-react-ui/src/panels/sip_outgoing.tsx diff --git a/apps/web/app/actions/sip.ts b/apps/web/app/actions/sip.ts new file mode 100644 index 0000000..a9b9830 --- /dev/null +++ b/apps/web/app/actions/sip.ts @@ -0,0 +1,98 @@ +"use server"; + +import { env } from "../env"; +import { generate_random_token } from "./token"; + +interface MakeCallParams { + sip_server: string; + sip_auth?: { + username: string; + password: string; + }; + from_number: string; + to_number: string; + hook: string; +} + +interface MakeCallResponse { + status: boolean, + data?: { + gateway: string, + call_id: string, + call_token: string, + call_ws: string + }, + error?: string +} + +export async function make_outgoing_call(params: MakeCallParams) { + console.log("Creating webrtc token"); + const [room, peer, token] = await generate_random_token(); + const url = env.SIP_GATEWAY + "/call/outgoing"; + const rawResponse = await fetch(url, { + method: "POST", + headers: { + Authorization: "Bearer " + env.APP_SECRET, + Accept: "application/json", + "Content-Type": "application/json", + }, + body: JSON.stringify({ + ...params, + streaming: { + room, + peer: params.to_number, + record: false, + }, + }), + cache: "no-cache", + }); + + const content = await rawResponse.json() as MakeCallResponse; + if (content.status && content.data) { + return { + room: room!, + peer: peer!, + token: token!, + callTo: params.to_number, + callWs: env.SIP_GATEWAY + content.data.call_ws, + } + } else { + throw new Error(content.error); + } +} + +interface CreateNotifyTokenParams { + client_id: string, + ttl: number, +} + +interface CreateNotifyTokenResponse { + status: boolean, + data?: { + token: string + }, + error?: string +} + +export async function create_notify_ws(params: CreateNotifyTokenParams) { + console.log("Creating notify token"); + const url = env.SIP_GATEWAY + "/token/notify"; + const rawResponse = await fetch(url, { + method: "POST", + headers: { + Authorization: "Bearer " + env.APP_SECRET, + Accept: "application/json", + "Content-Type": "application/json", + }, + body: JSON.stringify(params), + cache: "no-cache", + }); + + const content = await rawResponse.json() as CreateNotifyTokenResponse; + if (content.status && content.data) { + return env.SIP_GATEWAY + "/call/incoming/notify?token=" + content.data.token; + } else { + throw new Error(content.error); + } +} + diff --git a/apps/web/app/actions/token.ts b/apps/web/app/actions/token.ts index de49105..2d6e22e 100644 --- a/apps/web/app/actions/token.ts +++ b/apps/web/app/actions/token.ts @@ -40,7 +40,7 @@ export async function generate_token( } } -export async function generate_random_token(server?: string) { +export async function generate_random_token(server?: string): Promise<[string, string, string]> { const now = new Date().getTime(); const room = "room-" + now; const peer = "peer-" + now; diff --git a/apps/web/app/env.ts b/apps/web/app/env.ts index 74c1573..28a44ba 100644 --- a/apps/web/app/env.ts +++ b/apps/web/app/env.ts @@ -2,5 +2,6 @@ export const env = { GATEWAY_ENDPOINTS: ( (process.env.NEXT_PUBLIC_GATEWAYS as string) || "http://localhost:3001" ).split(";"), - APP_SECRET: (process.env.APP_SECRET as string) || "insecure", -}; + SIP_GATEWAY: (process.env.NEXT_PUBLIC_SIP_GATEWAY as string) || "http://localhost:3001", + APP_SECRET: (process.env.APP_SECRET as string) || "zsz94nsrj3xvmbu555nmu25hwqo6shiq", +}; \ No newline at end of file diff --git a/apps/web/app/page.tsx b/apps/web/app/page.tsx index fd0e4b1..992715a 100644 --- a/apps/web/app/page.tsx +++ b/apps/web/app/page.tsx @@ -59,6 +59,12 @@ export default function Page(): JSX.Element {
Meet
+
+ Sip Outgoing call +
+
+ Sip Incoming call +
); diff --git a/apps/web/app/react_ui_samples/sipIncoming/content.tsx b/apps/web/app/react_ui_samples/sipIncoming/content.tsx new file mode 100644 index 0000000..6d9b6fa --- /dev/null +++ b/apps/web/app/react_ui_samples/sipIncoming/content.tsx @@ -0,0 +1,54 @@ +"use client"; + +import { Atm0sMediaProvider } from "@atm0s-media-sdk/react-hooks"; +import { Atm0sMediaUIProvider, SipIncomingCallWidget } from "@atm0s-media-sdk/react-ui"; +import { useCallback, useState } from "react"; +import { env } from "../../env"; +import { AudioMixerMode } from "@atm0s-media-sdk/core"; + +export interface IncomingCallPanelProps { + callFrom: string, + callWs: string, + room: string; + peer: string, + token: string, + record: boolean, + onEnd?: () => void; +} + +export default function PageContent({ callFrom, callWs, room, peer, token, record, onEnd }: IncomingCallPanelProps) { + const [active, setActive] = useState(true); + const onEnd2 = useCallback(() => { + setActive(false); + onEnd && onEnd(); + }, [onEnd]) + + return ( +
+
+ {active && + + + + } +
+
+ ); +} \ No newline at end of file diff --git a/apps/web/app/react_ui_samples/sipIncoming/page.tsx b/apps/web/app/react_ui_samples/sipIncoming/page.tsx new file mode 100644 index 0000000..71c5b31 --- /dev/null +++ b/apps/web/app/react_ui_samples/sipIncoming/page.tsx @@ -0,0 +1,65 @@ +"use client"; + +import { generate_random_token } from "../../actions/token"; +import Content, { IncomingCallPanelProps } from "./content"; +import { useState } from "react"; + +export default function SipIncoming({ + searchParams, +}: { + searchParams: { server?: string }; +}) { + // Create a single session state object using the Session interface + const [session, setSession] = useState(null); + + const [callWs, setCallWs] = useState(""); + const [callFrom, setCallFrom] = useState(""); + const [record, setRecord] = useState(false); + + const handleCall = async () => { + const [room, peer, token] = await generate_random_token(); + setSession({ + callFrom, + callWs, + room, + peer, + token, + record, + }) + }; + + return ( +
{/* Centering the form */} +
{ e.preventDefault(); handleCall(); }} className="bg-white p-4 rounded-lg shadow-md space-y-4 w-96"> {/* Reduced padding and width */} +

Show a Incoming SIP Call

{/* Reduced title size */} + setCallWs(e.target.value)} + className="input-class p-2 border border-gray-300 rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-blue-500" // Reduced padding + /> + setCallFrom(e.target.value)} + className="input-class p-2 border border-gray-300 rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-blue-500" // Reduced padding + /> + +
+ setRecord(e.target.checked)} + className="mr-2" + /> + +
+ + +
+ {session && setSession(null)} />} {/* Pass session object to Content */} +
+ ); +} diff --git a/apps/web/app/react_ui_samples/sipOutgoing/content.tsx b/apps/web/app/react_ui_samples/sipOutgoing/content.tsx new file mode 100644 index 0000000..d3db6b4 --- /dev/null +++ b/apps/web/app/react_ui_samples/sipOutgoing/content.tsx @@ -0,0 +1,51 @@ +"use client"; + +import { AudioMixerMode } from "@atm0s-media-sdk/core"; +import { Atm0sMediaProvider } from "@atm0s-media-sdk/react-hooks"; +import { Atm0sMediaUIProvider, SipOutgoingCallWidget } from "@atm0s-media-sdk/react-ui"; +import { useCallback, useState } from "react"; +import { env } from "../../env"; + +export interface OutgoingCallPanelProps { + room: string; + peer: string; + token: string; + callTo: string, + callWs: string; + onEnd?: () => void; +} + +export default function PageContent({ room, peer, token, callTo, callWs, onEnd }: OutgoingCallPanelProps) { + const [active, setActive] = useState(true); + const hangUp = useCallback(() => { + setActive(false); + onEnd && onEnd(); + }, [onEnd]) + + return ( +
+ {active && + + + + } +
+ ); +} \ No newline at end of file diff --git a/apps/web/app/react_ui_samples/sipOutgoing/page.tsx b/apps/web/app/react_ui_samples/sipOutgoing/page.tsx new file mode 100644 index 0000000..fa2554e --- /dev/null +++ b/apps/web/app/react_ui_samples/sipOutgoing/page.tsx @@ -0,0 +1,91 @@ +"use client"; + +import { generate_random_token } from "../../actions/token"; +import { make_outgoing_call } from "../../actions/sip"; // Import the server action +import Content, { OutgoingCallPanelProps } from "./content"; +import { useState } from "react"; + +export default function SipOutgoing({ + searchParams, +}: { + searchParams: { server?: string }; +}) { + // New state variables for the input form + const [sipServer, setSipServer] = useState(""); + const [sipUser, setSipUser] = useState(""); + const [sipPassword, setSipPassword] = useState(""); + const [sipFrom, setSipFrom] = useState(""); + const [sipTo, setSipTo] = useState(""); + const [sipHook, setSipHook] = useState(""); + + const [outgoingProps, setOutgoingProps] = useState(null) + + // Function to handle the call button click + const handleCall = async () => { + const props = await make_outgoing_call({ + sip_server: sipServer, + sip_auth: sipUser ? { + username: sipUser, + password: sipPassword, + } : undefined, + from_number: sipFrom, + to_number: sipTo, + hook: sipHook, + }); + // Logic to display the outgoing call with callWs and streamingToken + setOutgoingProps(props) + }; + + return ( +
{/* Centering the form */} +
{ e.preventDefault(); handleCall(); }} className="bg-white p-4 rounded-lg shadow-md space-y-4 w-96"> {/* Reduced padding and width */} +

Make a SIP Call

{/* Reduced title size */} + setSipServer(e.target.value)} + className="input-class p-2 border border-gray-300 rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-blue-500" // Reduced padding + /> + setSipUser(e.target.value)} + className="input-class p-2 border border-gray-300 rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-blue-500" // Reduced padding + /> + setSipPassword(e.target.value)} + className="input-class p-2 border border-gray-300 rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-blue-500" // Reduced padding + /> + setSipFrom(e.target.value)} + className="input-class p-2 border border-gray-300 rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-blue-500" // Reduced padding + /> + setSipTo(e.target.value)} + className="input-class p-2 border border-gray-300 rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-blue-500" // Reduced padding + /> + setSipHook(e.target.value)} + className="input-class p-2 border border-gray-300 rounded-lg w-full focus:outline-none focus:ring-2 focus:ring-blue-500" // Reduced padding + /> + {/* Reduced button padding */} +
+ + {outgoingProps && setOutgoingProps(null)} />} +
+ ); +} diff --git a/packages/sdk-core/protobuf/README.md b/packages/sdk-core/protobuf/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/packages/sdk-core/protobuf/sip_gateway.proto b/packages/sdk-core/protobuf/sip_gateway.proto new file mode 100644 index 0000000..1bb98d2 --- /dev/null +++ b/packages/sdk-core/protobuf/sip_gateway.proto @@ -0,0 +1,224 @@ +syntax = "proto3"; + +package sip_gateway; + +message IncomingCallData { + message IncomingCallEvent { + message SipEvent { + message Cancelled { + + } + + message Bye { + + } + + oneof event { + Cancelled cancelled = 1; + Bye bye = 2; + } + } + + message Accepted { + + } + + message Ended { + + } + + message Error { + string message = 1; + } + + oneof event { + Error err = 1; + SipEvent sip = 2; + Accepted accepted = 3; + Ended ended = 4; + } + } + + message IncomingCallRequest { + message Ring { + + } + + message Accept { + string room = 1; + string peer = 2; + bool record = 3; + } + + message Accept2 { + + } + + message End { + + } + + uint32 req_id = 1; + oneof action { + Ring ring = 10; + Accept accept = 11; + Accept2 accept2 = 12; + End end = 13; + } + } + + message IncomingCallResponse { + message Ring { + + } + + message Accept { + + } + + message Accept2 { + string room = 1; + string peer = 2; + string token = 3; + } + + message End { + + } + + message Error { + string message = 1; + } + + uint32 req_id = 1; + oneof response { + Error error = 10; + Ring ring = 11; + Accept accept = 12; + Accept2 accept2 = 13; + End end = 14; + } + } + + oneof data { + IncomingCallEvent event = 1; + IncomingCallRequest request = 2; + IncomingCallResponse response = 3; + } +} + + +message OutgoingCallData { + message OutgoingCallEvent { + message SipEvent { + message Provisional { + uint32 code = 1; + } + + message Early { + uint32 code = 1; + } + + message Accepted { + uint32 code = 1; + } + + message Failure { + uint32 code = 1; + } + + message Bye { + + } + + oneof event { + Provisional provisional = 1; + Early early = 2; + Accepted accepted = 3; + Failure failure = 4; + Bye bye = 5; + } + } + + message Ended { + + } + + message Error { + string message = 1; + } + + oneof event { + Error err = 1; + SipEvent sip = 2; + Ended ended = 3; + } + } + + message OutgoingCallRequest { + message End { + + } + + uint32 req_id = 1; + oneof action { + End end = 10; + } + } + + message OutgoingCallResponse { + message End { + + } + + message Error { + string message = 1; + } + + uint32 req_id = 1; + oneof response { + Error error = 10; + End end = 11; + } + } + + oneof data { + OutgoingCallEvent event = 1; + OutgoingCallRequest request = 2; + OutgoingCallResponse response = 3; + } +} + +message IncomingCallNotify { + message CallArrived { + string call_token = 1; + string call_ws = 2; + string call_from = 3; + string call_to = 4; + } + + message CallCancelled { + string call_from = 3; + string call_to = 4; + } + + message CallAccepted { + string call_from = 3; + string call_to = 4; + } + + string call_id = 1; + oneof event { + CallArrived arrived = 10; + CallCancelled cancelled = 11; + CallAccepted accepted = 12; + } +} + +message CallEvent { + oneof event { + IncomingCallNotify notify = 1; + OutgoingCallData.OutgoingCallEvent outgoing = 2; + IncomingCallData.IncomingCallEvent incoming = 3; + } +} \ No newline at end of file diff --git a/packages/sdk-core/protobuf/sync.sh b/packages/sdk-core/protobuf/sync.sh deleted file mode 100644 index df474bd..0000000 --- a/packages/sdk-core/protobuf/sync.sh +++ /dev/null @@ -1 +0,0 @@ -cp /Users/giangminh/Workspace/8xff/dev/atm0s-media-server/packages/protocol/proto/*.proto ./ diff --git a/packages/sdk-core/src/data.ts b/packages/sdk-core/src/data.ts index 9622c7e..07af00e 100644 --- a/packages/sdk-core/src/data.ts +++ b/packages/sdk-core/src/data.ts @@ -44,7 +44,7 @@ export class Datachannel extends EventEmitter { dc.onmessage = (e) => { const msg = ServerEvent.decode(new Uint8Array(e.data)); - console.log("[Datachannel] on event", msg); + console.debug("[Datachannel] on event", msg); if (msg.room) { this.emit(DatachannelEvent.ROOM, msg.room); } else if (msg.session) { diff --git a/packages/sdk-core/src/generated/protobuf/cluster_gateway.ts b/packages/sdk-core/src/generated/protobuf/cluster_gateway.ts index 94ab571..934dcfd 100644 --- a/packages/sdk-core/src/generated/protobuf/cluster_gateway.ts +++ b/packages/sdk-core/src/generated/protobuf/cluster_gateway.ts @@ -1,7 +1,7 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.174.0 -// protoc v5.27.3 +// protoc v4.25.1 // source: cluster_gateway.proto /* eslint-disable */ diff --git a/packages/sdk-core/src/generated/protobuf/features.mixer.ts b/packages/sdk-core/src/generated/protobuf/features.mixer.ts index b5b5bd2..f43e576 100644 --- a/packages/sdk-core/src/generated/protobuf/features.mixer.ts +++ b/packages/sdk-core/src/generated/protobuf/features.mixer.ts @@ -1,7 +1,7 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.174.0 -// protoc v5.27.3 +// protoc v4.25.1 // source: features.mixer.proto /* eslint-disable */ diff --git a/packages/sdk-core/src/generated/protobuf/features.ts b/packages/sdk-core/src/generated/protobuf/features.ts index 10db89a..934cfff 100644 --- a/packages/sdk-core/src/generated/protobuf/features.ts +++ b/packages/sdk-core/src/generated/protobuf/features.ts @@ -1,7 +1,7 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.174.0 -// protoc v5.27.3 +// protoc v4.25.1 // source: features.proto /* eslint-disable */ diff --git a/packages/sdk-core/src/generated/protobuf/gateway.ts b/packages/sdk-core/src/generated/protobuf/gateway.ts index 613c6fd..3a5d8a7 100644 --- a/packages/sdk-core/src/generated/protobuf/gateway.ts +++ b/packages/sdk-core/src/generated/protobuf/gateway.ts @@ -1,7 +1,7 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.174.0 -// protoc v5.27.3 +// protoc v4.25.1 // source: gateway.proto /* eslint-disable */ diff --git a/packages/sdk-core/src/generated/protobuf/session.ts b/packages/sdk-core/src/generated/protobuf/session.ts index 8bb235c..850b3f1 100644 --- a/packages/sdk-core/src/generated/protobuf/session.ts +++ b/packages/sdk-core/src/generated/protobuf/session.ts @@ -1,7 +1,7 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.174.0 -// protoc v5.27.3 +// protoc v4.25.1 // source: session.proto /* eslint-disable */ diff --git a/packages/sdk-core/src/generated/protobuf/shared.ts b/packages/sdk-core/src/generated/protobuf/shared.ts index cd66e73..50d37be 100644 --- a/packages/sdk-core/src/generated/protobuf/shared.ts +++ b/packages/sdk-core/src/generated/protobuf/shared.ts @@ -1,7 +1,7 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v1.174.0 -// protoc v5.27.3 +// protoc v4.25.1 // source: shared.proto /* eslint-disable */ diff --git a/packages/sdk-core/src/generated/protobuf/sip_gateway.ts b/packages/sdk-core/src/generated/protobuf/sip_gateway.ts new file mode 100644 index 0000000..205fa12 --- /dev/null +++ b/packages/sdk-core/src/generated/protobuf/sip_gateway.ts @@ -0,0 +1,2943 @@ +// Code generated by protoc-gen-ts_proto. DO NOT EDIT. +// versions: +// protoc-gen-ts_proto v1.174.0 +// protoc v4.25.1 +// source: sip_gateway.proto + +/* eslint-disable */ +import * as _m0 from "protobufjs/minimal"; + +export const protobufPackage = "sip_gateway"; + +export interface IncomingCallNotify { + callId: string; + arrived?: IncomingCallNotify_CallArrived | undefined; + cancelled?: IncomingCallNotify_CallCancelled | undefined; + accepted?: IncomingCallNotify_CallAccepted | undefined; +} + +export interface IncomingCallNotify_CallArrived { + callToken: string; + callWs: string; + from: string; + to: string; +} + +export interface IncomingCallNotify_CallCancelled { +} + +export interface IncomingCallNotify_CallAccepted { +} + +export interface IncomingCallData { + event?: IncomingCallData_IncomingCallEvent | undefined; + request?: IncomingCallData_IncomingCallRequest | undefined; + response?: IncomingCallData_IncomingCallResponse | undefined; +} + +export interface IncomingCallData_IncomingCallEvent { + err?: IncomingCallData_IncomingCallEvent_Error | undefined; + sip?: IncomingCallData_IncomingCallEvent_SipEvent | undefined; + accepted?: IncomingCallData_IncomingCallEvent_Accepted | undefined; + ended?: IncomingCallData_IncomingCallEvent_Ended | undefined; +} + +export interface IncomingCallData_IncomingCallEvent_SipEvent { + cancelled?: IncomingCallData_IncomingCallEvent_SipEvent_Cancelled | undefined; + bye?: IncomingCallData_IncomingCallEvent_SipEvent_Bye | undefined; +} + +export interface IncomingCallData_IncomingCallEvent_SipEvent_Cancelled { +} + +export interface IncomingCallData_IncomingCallEvent_SipEvent_Bye { +} + +export interface IncomingCallData_IncomingCallEvent_Accepted { +} + +export interface IncomingCallData_IncomingCallEvent_Ended { +} + +export interface IncomingCallData_IncomingCallEvent_Error { + message: string; +} + +export interface IncomingCallData_IncomingCallRequest { + reqId: number; + ring?: IncomingCallData_IncomingCallRequest_Ring | undefined; + accept?: IncomingCallData_IncomingCallRequest_Accept | undefined; + accept2?: IncomingCallData_IncomingCallRequest_Accept2 | undefined; + end?: IncomingCallData_IncomingCallRequest_End | undefined; +} + +export interface IncomingCallData_IncomingCallRequest_Ring { +} + +export interface IncomingCallData_IncomingCallRequest_Accept { + room: string; + peer: string; + record: boolean; +} + +export interface IncomingCallData_IncomingCallRequest_Accept2 { +} + +export interface IncomingCallData_IncomingCallRequest_End { +} + +export interface IncomingCallData_IncomingCallResponse { + reqId: number; + error?: IncomingCallData_IncomingCallResponse_Error | undefined; + ring?: IncomingCallData_IncomingCallResponse_Ring | undefined; + accept?: IncomingCallData_IncomingCallResponse_Accept | undefined; + accept2?: IncomingCallData_IncomingCallResponse_Accept2 | undefined; + end?: IncomingCallData_IncomingCallResponse_End | undefined; +} + +export interface IncomingCallData_IncomingCallResponse_Ring { +} + +export interface IncomingCallData_IncomingCallResponse_Accept { +} + +export interface IncomingCallData_IncomingCallResponse_Accept2 { + room: string; + peer: string; + token: string; +} + +export interface IncomingCallData_IncomingCallResponse_End { +} + +export interface IncomingCallData_IncomingCallResponse_Error { + message: string; +} + +export interface OutgoingCallData { + event?: OutgoingCallData_OutgoingCallEvent | undefined; + request?: OutgoingCallData_OutgoingCallRequest | undefined; + response?: OutgoingCallData_OutgoingCallResponse | undefined; +} + +export interface OutgoingCallData_OutgoingCallEvent { + err?: OutgoingCallData_OutgoingCallEvent_Error | undefined; + sip?: OutgoingCallData_OutgoingCallEvent_SipEvent | undefined; + ended?: OutgoingCallData_OutgoingCallEvent_Ended | undefined; +} + +export interface OutgoingCallData_OutgoingCallEvent_SipEvent { + provisional?: OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional | undefined; + early?: OutgoingCallData_OutgoingCallEvent_SipEvent_Early | undefined; + accepted?: OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted | undefined; + failure?: OutgoingCallData_OutgoingCallEvent_SipEvent_Failure | undefined; + bye?: OutgoingCallData_OutgoingCallEvent_SipEvent_Bye | undefined; +} + +export interface OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional { + code: number; +} + +export interface OutgoingCallData_OutgoingCallEvent_SipEvent_Early { + code: number; +} + +export interface OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted { + code: number; +} + +export interface OutgoingCallData_OutgoingCallEvent_SipEvent_Failure { + code: number; +} + +export interface OutgoingCallData_OutgoingCallEvent_SipEvent_Bye { +} + +export interface OutgoingCallData_OutgoingCallEvent_Ended { +} + +export interface OutgoingCallData_OutgoingCallEvent_Error { + message: string; +} + +export interface OutgoingCallData_OutgoingCallRequest { + reqId: number; + end?: OutgoingCallData_OutgoingCallRequest_End | undefined; +} + +export interface OutgoingCallData_OutgoingCallRequest_End { +} + +export interface OutgoingCallData_OutgoingCallResponse { + reqId: number; + error?: OutgoingCallData_OutgoingCallResponse_Error | undefined; + end?: OutgoingCallData_OutgoingCallResponse_End | undefined; +} + +export interface OutgoingCallData_OutgoingCallResponse_End { +} + +export interface OutgoingCallData_OutgoingCallResponse_Error { + message: string; +} + +function createBaseIncomingCallNotify(): IncomingCallNotify { + return { callId: "", arrived: undefined, cancelled: undefined, accepted: undefined }; +} + +export const IncomingCallNotify = { + encode(message: IncomingCallNotify, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.callId !== "") { + writer.uint32(10).string(message.callId); + } + if (message.arrived !== undefined) { + IncomingCallNotify_CallArrived.encode(message.arrived, writer.uint32(82).fork()).ldelim(); + } + if (message.cancelled !== undefined) { + IncomingCallNotify_CallCancelled.encode(message.cancelled, writer.uint32(90).fork()).ldelim(); + } + if (message.accepted !== undefined) { + IncomingCallNotify_CallAccepted.encode(message.accepted, writer.uint32(98).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallNotify { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallNotify(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.callId = reader.string(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.arrived = IncomingCallNotify_CallArrived.decode(reader, reader.uint32()); + continue; + case 11: + if (tag !== 90) { + break; + } + + message.cancelled = IncomingCallNotify_CallCancelled.decode(reader, reader.uint32()); + continue; + case 12: + if (tag !== 98) { + break; + } + + message.accepted = IncomingCallNotify_CallAccepted.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallNotify { + return { + callId: isSet(object.callId) ? globalThis.String(object.callId) : "", + arrived: isSet(object.arrived) ? IncomingCallNotify_CallArrived.fromJSON(object.arrived) : undefined, + cancelled: isSet(object.cancelled) ? IncomingCallNotify_CallCancelled.fromJSON(object.cancelled) : undefined, + accepted: isSet(object.accepted) ? IncomingCallNotify_CallAccepted.fromJSON(object.accepted) : undefined, + }; + }, + + toJSON(message: IncomingCallNotify): unknown { + const obj: any = {}; + if (message.callId !== "") { + obj.callId = message.callId; + } + if (message.arrived !== undefined) { + obj.arrived = IncomingCallNotify_CallArrived.toJSON(message.arrived); + } + if (message.cancelled !== undefined) { + obj.cancelled = IncomingCallNotify_CallCancelled.toJSON(message.cancelled); + } + if (message.accepted !== undefined) { + obj.accepted = IncomingCallNotify_CallAccepted.toJSON(message.accepted); + } + return obj; + }, + + create, I>>(base?: I): IncomingCallNotify { + return IncomingCallNotify.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): IncomingCallNotify { + const message = createBaseIncomingCallNotify(); + message.callId = object.callId ?? ""; + message.arrived = (object.arrived !== undefined && object.arrived !== null) + ? IncomingCallNotify_CallArrived.fromPartial(object.arrived) + : undefined; + message.cancelled = (object.cancelled !== undefined && object.cancelled !== null) + ? IncomingCallNotify_CallCancelled.fromPartial(object.cancelled) + : undefined; + message.accepted = (object.accepted !== undefined && object.accepted !== null) + ? IncomingCallNotify_CallAccepted.fromPartial(object.accepted) + : undefined; + return message; + }, +}; + +function createBaseIncomingCallNotify_CallArrived(): IncomingCallNotify_CallArrived { + return { callToken: "", callWs: "", from: "", to: "" }; +} + +export const IncomingCallNotify_CallArrived = { + encode(message: IncomingCallNotify_CallArrived, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.callToken !== "") { + writer.uint32(10).string(message.callToken); + } + if (message.callWs !== "") { + writer.uint32(18).string(message.callWs); + } + if (message.from !== "") { + writer.uint32(26).string(message.from); + } + if (message.to !== "") { + writer.uint32(34).string(message.to); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallNotify_CallArrived { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallNotify_CallArrived(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.callToken = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.callWs = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.from = reader.string(); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.to = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallNotify_CallArrived { + return { + callToken: isSet(object.callToken) ? globalThis.String(object.callToken) : "", + callWs: isSet(object.callWs) ? globalThis.String(object.callWs) : "", + from: isSet(object.from) ? globalThis.String(object.from) : "", + to: isSet(object.to) ? globalThis.String(object.to) : "", + }; + }, + + toJSON(message: IncomingCallNotify_CallArrived): unknown { + const obj: any = {}; + if (message.callToken !== "") { + obj.callToken = message.callToken; + } + if (message.callWs !== "") { + obj.callWs = message.callWs; + } + if (message.from !== "") { + obj.from = message.from; + } + if (message.to !== "") { + obj.to = message.to; + } + return obj; + }, + + create, I>>(base?: I): IncomingCallNotify_CallArrived { + return IncomingCallNotify_CallArrived.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): IncomingCallNotify_CallArrived { + const message = createBaseIncomingCallNotify_CallArrived(); + message.callToken = object.callToken ?? ""; + message.callWs = object.callWs ?? ""; + message.from = object.from ?? ""; + message.to = object.to ?? ""; + return message; + }, +}; + +function createBaseIncomingCallNotify_CallCancelled(): IncomingCallNotify_CallCancelled { + return {}; +} + +export const IncomingCallNotify_CallCancelled = { + encode(_: IncomingCallNotify_CallCancelled, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallNotify_CallCancelled { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallNotify_CallCancelled(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallNotify_CallCancelled { + return {}; + }, + + toJSON(_: IncomingCallNotify_CallCancelled): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallNotify_CallCancelled { + return IncomingCallNotify_CallCancelled.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallNotify_CallCancelled { + const message = createBaseIncomingCallNotify_CallCancelled(); + return message; + }, +}; + +function createBaseIncomingCallNotify_CallAccepted(): IncomingCallNotify_CallAccepted { + return {}; +} + +export const IncomingCallNotify_CallAccepted = { + encode(_: IncomingCallNotify_CallAccepted, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallNotify_CallAccepted { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallNotify_CallAccepted(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallNotify_CallAccepted { + return {}; + }, + + toJSON(_: IncomingCallNotify_CallAccepted): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>(base?: I): IncomingCallNotify_CallAccepted { + return IncomingCallNotify_CallAccepted.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(_: I): IncomingCallNotify_CallAccepted { + const message = createBaseIncomingCallNotify_CallAccepted(); + return message; + }, +}; + +function createBaseIncomingCallData(): IncomingCallData { + return { event: undefined, request: undefined, response: undefined }; +} + +export const IncomingCallData = { + encode(message: IncomingCallData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.event !== undefined) { + IncomingCallData_IncomingCallEvent.encode(message.event, writer.uint32(10).fork()).ldelim(); + } + if (message.request !== undefined) { + IncomingCallData_IncomingCallRequest.encode(message.request, writer.uint32(18).fork()).ldelim(); + } + if (message.response !== undefined) { + IncomingCallData_IncomingCallResponse.encode(message.response, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.event = IncomingCallData_IncomingCallEvent.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.request = IncomingCallData_IncomingCallRequest.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.response = IncomingCallData_IncomingCallResponse.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallData { + return { + event: isSet(object.event) ? IncomingCallData_IncomingCallEvent.fromJSON(object.event) : undefined, + request: isSet(object.request) ? IncomingCallData_IncomingCallRequest.fromJSON(object.request) : undefined, + response: isSet(object.response) ? IncomingCallData_IncomingCallResponse.fromJSON(object.response) : undefined, + }; + }, + + toJSON(message: IncomingCallData): unknown { + const obj: any = {}; + if (message.event !== undefined) { + obj.event = IncomingCallData_IncomingCallEvent.toJSON(message.event); + } + if (message.request !== undefined) { + obj.request = IncomingCallData_IncomingCallRequest.toJSON(message.request); + } + if (message.response !== undefined) { + obj.response = IncomingCallData_IncomingCallResponse.toJSON(message.response); + } + return obj; + }, + + create, I>>(base?: I): IncomingCallData { + return IncomingCallData.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): IncomingCallData { + const message = createBaseIncomingCallData(); + message.event = (object.event !== undefined && object.event !== null) + ? IncomingCallData_IncomingCallEvent.fromPartial(object.event) + : undefined; + message.request = (object.request !== undefined && object.request !== null) + ? IncomingCallData_IncomingCallRequest.fromPartial(object.request) + : undefined; + message.response = (object.response !== undefined && object.response !== null) + ? IncomingCallData_IncomingCallResponse.fromPartial(object.response) + : undefined; + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallEvent(): IncomingCallData_IncomingCallEvent { + return { err: undefined, sip: undefined, accepted: undefined, ended: undefined }; +} + +export const IncomingCallData_IncomingCallEvent = { + encode(message: IncomingCallData_IncomingCallEvent, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.err !== undefined) { + IncomingCallData_IncomingCallEvent_Error.encode(message.err, writer.uint32(10).fork()).ldelim(); + } + if (message.sip !== undefined) { + IncomingCallData_IncomingCallEvent_SipEvent.encode(message.sip, writer.uint32(18).fork()).ldelim(); + } + if (message.accepted !== undefined) { + IncomingCallData_IncomingCallEvent_Accepted.encode(message.accepted, writer.uint32(26).fork()).ldelim(); + } + if (message.ended !== undefined) { + IncomingCallData_IncomingCallEvent_Ended.encode(message.ended, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallEvent { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.err = IncomingCallData_IncomingCallEvent_Error.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.sip = IncomingCallData_IncomingCallEvent_SipEvent.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.accepted = IncomingCallData_IncomingCallEvent_Accepted.decode(reader, reader.uint32()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.ended = IncomingCallData_IncomingCallEvent_Ended.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallData_IncomingCallEvent { + return { + err: isSet(object.err) ? IncomingCallData_IncomingCallEvent_Error.fromJSON(object.err) : undefined, + sip: isSet(object.sip) ? IncomingCallData_IncomingCallEvent_SipEvent.fromJSON(object.sip) : undefined, + accepted: isSet(object.accepted) + ? IncomingCallData_IncomingCallEvent_Accepted.fromJSON(object.accepted) + : undefined, + ended: isSet(object.ended) ? IncomingCallData_IncomingCallEvent_Ended.fromJSON(object.ended) : undefined, + }; + }, + + toJSON(message: IncomingCallData_IncomingCallEvent): unknown { + const obj: any = {}; + if (message.err !== undefined) { + obj.err = IncomingCallData_IncomingCallEvent_Error.toJSON(message.err); + } + if (message.sip !== undefined) { + obj.sip = IncomingCallData_IncomingCallEvent_SipEvent.toJSON(message.sip); + } + if (message.accepted !== undefined) { + obj.accepted = IncomingCallData_IncomingCallEvent_Accepted.toJSON(message.accepted); + } + if (message.ended !== undefined) { + obj.ended = IncomingCallData_IncomingCallEvent_Ended.toJSON(message.ended); + } + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallEvent { + return IncomingCallData_IncomingCallEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): IncomingCallData_IncomingCallEvent { + const message = createBaseIncomingCallData_IncomingCallEvent(); + message.err = (object.err !== undefined && object.err !== null) + ? IncomingCallData_IncomingCallEvent_Error.fromPartial(object.err) + : undefined; + message.sip = (object.sip !== undefined && object.sip !== null) + ? IncomingCallData_IncomingCallEvent_SipEvent.fromPartial(object.sip) + : undefined; + message.accepted = (object.accepted !== undefined && object.accepted !== null) + ? IncomingCallData_IncomingCallEvent_Accepted.fromPartial(object.accepted) + : undefined; + message.ended = (object.ended !== undefined && object.ended !== null) + ? IncomingCallData_IncomingCallEvent_Ended.fromPartial(object.ended) + : undefined; + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallEvent_SipEvent(): IncomingCallData_IncomingCallEvent_SipEvent { + return { cancelled: undefined, bye: undefined }; +} + +export const IncomingCallData_IncomingCallEvent_SipEvent = { + encode(message: IncomingCallData_IncomingCallEvent_SipEvent, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.cancelled !== undefined) { + IncomingCallData_IncomingCallEvent_SipEvent_Cancelled.encode(message.cancelled, writer.uint32(10).fork()) + .ldelim(); + } + if (message.bye !== undefined) { + IncomingCallData_IncomingCallEvent_SipEvent_Bye.encode(message.bye, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallEvent_SipEvent { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallEvent_SipEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.cancelled = IncomingCallData_IncomingCallEvent_SipEvent_Cancelled.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.bye = IncomingCallData_IncomingCallEvent_SipEvent_Bye.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallData_IncomingCallEvent_SipEvent { + return { + cancelled: isSet(object.cancelled) + ? IncomingCallData_IncomingCallEvent_SipEvent_Cancelled.fromJSON(object.cancelled) + : undefined, + bye: isSet(object.bye) ? IncomingCallData_IncomingCallEvent_SipEvent_Bye.fromJSON(object.bye) : undefined, + }; + }, + + toJSON(message: IncomingCallData_IncomingCallEvent_SipEvent): unknown { + const obj: any = {}; + if (message.cancelled !== undefined) { + obj.cancelled = IncomingCallData_IncomingCallEvent_SipEvent_Cancelled.toJSON(message.cancelled); + } + if (message.bye !== undefined) { + obj.bye = IncomingCallData_IncomingCallEvent_SipEvent_Bye.toJSON(message.bye); + } + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallEvent_SipEvent { + return IncomingCallData_IncomingCallEvent_SipEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): IncomingCallData_IncomingCallEvent_SipEvent { + const message = createBaseIncomingCallData_IncomingCallEvent_SipEvent(); + message.cancelled = (object.cancelled !== undefined && object.cancelled !== null) + ? IncomingCallData_IncomingCallEvent_SipEvent_Cancelled.fromPartial(object.cancelled) + : undefined; + message.bye = (object.bye !== undefined && object.bye !== null) + ? IncomingCallData_IncomingCallEvent_SipEvent_Bye.fromPartial(object.bye) + : undefined; + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallEvent_SipEvent_Cancelled(): IncomingCallData_IncomingCallEvent_SipEvent_Cancelled { + return {}; +} + +export const IncomingCallData_IncomingCallEvent_SipEvent_Cancelled = { + encode( + _: IncomingCallData_IncomingCallEvent_SipEvent_Cancelled, + writer: _m0.Writer = _m0.Writer.create(), + ): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallEvent_SipEvent_Cancelled { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallEvent_SipEvent_Cancelled(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallEvent_SipEvent_Cancelled { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallEvent_SipEvent_Cancelled): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallEvent_SipEvent_Cancelled { + return IncomingCallData_IncomingCallEvent_SipEvent_Cancelled.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallEvent_SipEvent_Cancelled { + const message = createBaseIncomingCallData_IncomingCallEvent_SipEvent_Cancelled(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallEvent_SipEvent_Bye(): IncomingCallData_IncomingCallEvent_SipEvent_Bye { + return {}; +} + +export const IncomingCallData_IncomingCallEvent_SipEvent_Bye = { + encode(_: IncomingCallData_IncomingCallEvent_SipEvent_Bye, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallEvent_SipEvent_Bye { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallEvent_SipEvent_Bye(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallEvent_SipEvent_Bye { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallEvent_SipEvent_Bye): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallEvent_SipEvent_Bye { + return IncomingCallData_IncomingCallEvent_SipEvent_Bye.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallEvent_SipEvent_Bye { + const message = createBaseIncomingCallData_IncomingCallEvent_SipEvent_Bye(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallEvent_Accepted(): IncomingCallData_IncomingCallEvent_Accepted { + return {}; +} + +export const IncomingCallData_IncomingCallEvent_Accepted = { + encode(_: IncomingCallData_IncomingCallEvent_Accepted, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallEvent_Accepted { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallEvent_Accepted(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallEvent_Accepted { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallEvent_Accepted): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallEvent_Accepted { + return IncomingCallData_IncomingCallEvent_Accepted.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallEvent_Accepted { + const message = createBaseIncomingCallData_IncomingCallEvent_Accepted(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallEvent_Ended(): IncomingCallData_IncomingCallEvent_Ended { + return {}; +} + +export const IncomingCallData_IncomingCallEvent_Ended = { + encode(_: IncomingCallData_IncomingCallEvent_Ended, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallEvent_Ended { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallEvent_Ended(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallEvent_Ended { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallEvent_Ended): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallEvent_Ended { + return IncomingCallData_IncomingCallEvent_Ended.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallEvent_Ended { + const message = createBaseIncomingCallData_IncomingCallEvent_Ended(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallEvent_Error(): IncomingCallData_IncomingCallEvent_Error { + return { message: "" }; +} + +export const IncomingCallData_IncomingCallEvent_Error = { + encode(message: IncomingCallData_IncomingCallEvent_Error, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.message !== "") { + writer.uint32(10).string(message.message); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallEvent_Error { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallEvent_Error(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.message = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallData_IncomingCallEvent_Error { + return { message: isSet(object.message) ? globalThis.String(object.message) : "" }; + }, + + toJSON(message: IncomingCallData_IncomingCallEvent_Error): unknown { + const obj: any = {}; + if (message.message !== "") { + obj.message = message.message; + } + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallEvent_Error { + return IncomingCallData_IncomingCallEvent_Error.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): IncomingCallData_IncomingCallEvent_Error { + const message = createBaseIncomingCallData_IncomingCallEvent_Error(); + message.message = object.message ?? ""; + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallRequest(): IncomingCallData_IncomingCallRequest { + return { reqId: 0, ring: undefined, accept: undefined, accept2: undefined, end: undefined }; +} + +export const IncomingCallData_IncomingCallRequest = { + encode(message: IncomingCallData_IncomingCallRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.reqId !== 0) { + writer.uint32(8).uint32(message.reqId); + } + if (message.ring !== undefined) { + IncomingCallData_IncomingCallRequest_Ring.encode(message.ring, writer.uint32(82).fork()).ldelim(); + } + if (message.accept !== undefined) { + IncomingCallData_IncomingCallRequest_Accept.encode(message.accept, writer.uint32(90).fork()).ldelim(); + } + if (message.accept2 !== undefined) { + IncomingCallData_IncomingCallRequest_Accept2.encode(message.accept2, writer.uint32(98).fork()).ldelim(); + } + if (message.end !== undefined) { + IncomingCallData_IncomingCallRequest_End.encode(message.end, writer.uint32(106).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.reqId = reader.uint32(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.ring = IncomingCallData_IncomingCallRequest_Ring.decode(reader, reader.uint32()); + continue; + case 11: + if (tag !== 90) { + break; + } + + message.accept = IncomingCallData_IncomingCallRequest_Accept.decode(reader, reader.uint32()); + continue; + case 12: + if (tag !== 98) { + break; + } + + message.accept2 = IncomingCallData_IncomingCallRequest_Accept2.decode(reader, reader.uint32()); + continue; + case 13: + if (tag !== 106) { + break; + } + + message.end = IncomingCallData_IncomingCallRequest_End.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallData_IncomingCallRequest { + return { + reqId: isSet(object.reqId) ? globalThis.Number(object.reqId) : 0, + ring: isSet(object.ring) ? IncomingCallData_IncomingCallRequest_Ring.fromJSON(object.ring) : undefined, + accept: isSet(object.accept) ? IncomingCallData_IncomingCallRequest_Accept.fromJSON(object.accept) : undefined, + accept2: isSet(object.accept2) + ? IncomingCallData_IncomingCallRequest_Accept2.fromJSON(object.accept2) + : undefined, + end: isSet(object.end) ? IncomingCallData_IncomingCallRequest_End.fromJSON(object.end) : undefined, + }; + }, + + toJSON(message: IncomingCallData_IncomingCallRequest): unknown { + const obj: any = {}; + if (message.reqId !== 0) { + obj.reqId = Math.round(message.reqId); + } + if (message.ring !== undefined) { + obj.ring = IncomingCallData_IncomingCallRequest_Ring.toJSON(message.ring); + } + if (message.accept !== undefined) { + obj.accept = IncomingCallData_IncomingCallRequest_Accept.toJSON(message.accept); + } + if (message.accept2 !== undefined) { + obj.accept2 = IncomingCallData_IncomingCallRequest_Accept2.toJSON(message.accept2); + } + if (message.end !== undefined) { + obj.end = IncomingCallData_IncomingCallRequest_End.toJSON(message.end); + } + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallRequest { + return IncomingCallData_IncomingCallRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): IncomingCallData_IncomingCallRequest { + const message = createBaseIncomingCallData_IncomingCallRequest(); + message.reqId = object.reqId ?? 0; + message.ring = (object.ring !== undefined && object.ring !== null) + ? IncomingCallData_IncomingCallRequest_Ring.fromPartial(object.ring) + : undefined; + message.accept = (object.accept !== undefined && object.accept !== null) + ? IncomingCallData_IncomingCallRequest_Accept.fromPartial(object.accept) + : undefined; + message.accept2 = (object.accept2 !== undefined && object.accept2 !== null) + ? IncomingCallData_IncomingCallRequest_Accept2.fromPartial(object.accept2) + : undefined; + message.end = (object.end !== undefined && object.end !== null) + ? IncomingCallData_IncomingCallRequest_End.fromPartial(object.end) + : undefined; + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallRequest_Ring(): IncomingCallData_IncomingCallRequest_Ring { + return {}; +} + +export const IncomingCallData_IncomingCallRequest_Ring = { + encode(_: IncomingCallData_IncomingCallRequest_Ring, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallRequest_Ring { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallRequest_Ring(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallRequest_Ring { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallRequest_Ring): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallRequest_Ring { + return IncomingCallData_IncomingCallRequest_Ring.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallRequest_Ring { + const message = createBaseIncomingCallData_IncomingCallRequest_Ring(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallRequest_Accept(): IncomingCallData_IncomingCallRequest_Accept { + return { room: "", peer: "", record: false }; +} + +export const IncomingCallData_IncomingCallRequest_Accept = { + encode(message: IncomingCallData_IncomingCallRequest_Accept, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.room !== "") { + writer.uint32(10).string(message.room); + } + if (message.peer !== "") { + writer.uint32(18).string(message.peer); + } + if (message.record !== false) { + writer.uint32(24).bool(message.record); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallRequest_Accept { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallRequest_Accept(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.room = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.peer = reader.string(); + continue; + case 3: + if (tag !== 24) { + break; + } + + message.record = reader.bool(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallData_IncomingCallRequest_Accept { + return { + room: isSet(object.room) ? globalThis.String(object.room) : "", + peer: isSet(object.peer) ? globalThis.String(object.peer) : "", + record: isSet(object.record) ? globalThis.Boolean(object.record) : false, + }; + }, + + toJSON(message: IncomingCallData_IncomingCallRequest_Accept): unknown { + const obj: any = {}; + if (message.room !== "") { + obj.room = message.room; + } + if (message.peer !== "") { + obj.peer = message.peer; + } + if (message.record !== false) { + obj.record = message.record; + } + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallRequest_Accept { + return IncomingCallData_IncomingCallRequest_Accept.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): IncomingCallData_IncomingCallRequest_Accept { + const message = createBaseIncomingCallData_IncomingCallRequest_Accept(); + message.room = object.room ?? ""; + message.peer = object.peer ?? ""; + message.record = object.record ?? false; + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallRequest_Accept2(): IncomingCallData_IncomingCallRequest_Accept2 { + return {}; +} + +export const IncomingCallData_IncomingCallRequest_Accept2 = { + encode(_: IncomingCallData_IncomingCallRequest_Accept2, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallRequest_Accept2 { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallRequest_Accept2(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallRequest_Accept2 { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallRequest_Accept2): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallRequest_Accept2 { + return IncomingCallData_IncomingCallRequest_Accept2.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallRequest_Accept2 { + const message = createBaseIncomingCallData_IncomingCallRequest_Accept2(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallRequest_End(): IncomingCallData_IncomingCallRequest_End { + return {}; +} + +export const IncomingCallData_IncomingCallRequest_End = { + encode(_: IncomingCallData_IncomingCallRequest_End, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallRequest_End { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallRequest_End(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallRequest_End { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallRequest_End): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallRequest_End { + return IncomingCallData_IncomingCallRequest_End.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallRequest_End { + const message = createBaseIncomingCallData_IncomingCallRequest_End(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallResponse(): IncomingCallData_IncomingCallResponse { + return { reqId: 0, error: undefined, ring: undefined, accept: undefined, accept2: undefined, end: undefined }; +} + +export const IncomingCallData_IncomingCallResponse = { + encode(message: IncomingCallData_IncomingCallResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.reqId !== 0) { + writer.uint32(8).uint32(message.reqId); + } + if (message.error !== undefined) { + IncomingCallData_IncomingCallResponse_Error.encode(message.error, writer.uint32(82).fork()).ldelim(); + } + if (message.ring !== undefined) { + IncomingCallData_IncomingCallResponse_Ring.encode(message.ring, writer.uint32(90).fork()).ldelim(); + } + if (message.accept !== undefined) { + IncomingCallData_IncomingCallResponse_Accept.encode(message.accept, writer.uint32(98).fork()).ldelim(); + } + if (message.accept2 !== undefined) { + IncomingCallData_IncomingCallResponse_Accept2.encode(message.accept2, writer.uint32(106).fork()).ldelim(); + } + if (message.end !== undefined) { + IncomingCallData_IncomingCallResponse_End.encode(message.end, writer.uint32(114).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.reqId = reader.uint32(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.error = IncomingCallData_IncomingCallResponse_Error.decode(reader, reader.uint32()); + continue; + case 11: + if (tag !== 90) { + break; + } + + message.ring = IncomingCallData_IncomingCallResponse_Ring.decode(reader, reader.uint32()); + continue; + case 12: + if (tag !== 98) { + break; + } + + message.accept = IncomingCallData_IncomingCallResponse_Accept.decode(reader, reader.uint32()); + continue; + case 13: + if (tag !== 106) { + break; + } + + message.accept2 = IncomingCallData_IncomingCallResponse_Accept2.decode(reader, reader.uint32()); + continue; + case 14: + if (tag !== 114) { + break; + } + + message.end = IncomingCallData_IncomingCallResponse_End.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallData_IncomingCallResponse { + return { + reqId: isSet(object.reqId) ? globalThis.Number(object.reqId) : 0, + error: isSet(object.error) ? IncomingCallData_IncomingCallResponse_Error.fromJSON(object.error) : undefined, + ring: isSet(object.ring) ? IncomingCallData_IncomingCallResponse_Ring.fromJSON(object.ring) : undefined, + accept: isSet(object.accept) ? IncomingCallData_IncomingCallResponse_Accept.fromJSON(object.accept) : undefined, + accept2: isSet(object.accept2) + ? IncomingCallData_IncomingCallResponse_Accept2.fromJSON(object.accept2) + : undefined, + end: isSet(object.end) ? IncomingCallData_IncomingCallResponse_End.fromJSON(object.end) : undefined, + }; + }, + + toJSON(message: IncomingCallData_IncomingCallResponse): unknown { + const obj: any = {}; + if (message.reqId !== 0) { + obj.reqId = Math.round(message.reqId); + } + if (message.error !== undefined) { + obj.error = IncomingCallData_IncomingCallResponse_Error.toJSON(message.error); + } + if (message.ring !== undefined) { + obj.ring = IncomingCallData_IncomingCallResponse_Ring.toJSON(message.ring); + } + if (message.accept !== undefined) { + obj.accept = IncomingCallData_IncomingCallResponse_Accept.toJSON(message.accept); + } + if (message.accept2 !== undefined) { + obj.accept2 = IncomingCallData_IncomingCallResponse_Accept2.toJSON(message.accept2); + } + if (message.end !== undefined) { + obj.end = IncomingCallData_IncomingCallResponse_End.toJSON(message.end); + } + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallResponse { + return IncomingCallData_IncomingCallResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): IncomingCallData_IncomingCallResponse { + const message = createBaseIncomingCallData_IncomingCallResponse(); + message.reqId = object.reqId ?? 0; + message.error = (object.error !== undefined && object.error !== null) + ? IncomingCallData_IncomingCallResponse_Error.fromPartial(object.error) + : undefined; + message.ring = (object.ring !== undefined && object.ring !== null) + ? IncomingCallData_IncomingCallResponse_Ring.fromPartial(object.ring) + : undefined; + message.accept = (object.accept !== undefined && object.accept !== null) + ? IncomingCallData_IncomingCallResponse_Accept.fromPartial(object.accept) + : undefined; + message.accept2 = (object.accept2 !== undefined && object.accept2 !== null) + ? IncomingCallData_IncomingCallResponse_Accept2.fromPartial(object.accept2) + : undefined; + message.end = (object.end !== undefined && object.end !== null) + ? IncomingCallData_IncomingCallResponse_End.fromPartial(object.end) + : undefined; + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallResponse_Ring(): IncomingCallData_IncomingCallResponse_Ring { + return {}; +} + +export const IncomingCallData_IncomingCallResponse_Ring = { + encode(_: IncomingCallData_IncomingCallResponse_Ring, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallResponse_Ring { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallResponse_Ring(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallResponse_Ring { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallResponse_Ring): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallResponse_Ring { + return IncomingCallData_IncomingCallResponse_Ring.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallResponse_Ring { + const message = createBaseIncomingCallData_IncomingCallResponse_Ring(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallResponse_Accept(): IncomingCallData_IncomingCallResponse_Accept { + return {}; +} + +export const IncomingCallData_IncomingCallResponse_Accept = { + encode(_: IncomingCallData_IncomingCallResponse_Accept, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallResponse_Accept { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallResponse_Accept(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallResponse_Accept { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallResponse_Accept): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallResponse_Accept { + return IncomingCallData_IncomingCallResponse_Accept.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallResponse_Accept { + const message = createBaseIncomingCallData_IncomingCallResponse_Accept(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallResponse_Accept2(): IncomingCallData_IncomingCallResponse_Accept2 { + return { room: "", peer: "", token: "" }; +} + +export const IncomingCallData_IncomingCallResponse_Accept2 = { + encode(message: IncomingCallData_IncomingCallResponse_Accept2, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.room !== "") { + writer.uint32(10).string(message.room); + } + if (message.peer !== "") { + writer.uint32(18).string(message.peer); + } + if (message.token !== "") { + writer.uint32(26).string(message.token); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallResponse_Accept2 { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallResponse_Accept2(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.room = reader.string(); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.peer = reader.string(); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.token = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallData_IncomingCallResponse_Accept2 { + return { + room: isSet(object.room) ? globalThis.String(object.room) : "", + peer: isSet(object.peer) ? globalThis.String(object.peer) : "", + token: isSet(object.token) ? globalThis.String(object.token) : "", + }; + }, + + toJSON(message: IncomingCallData_IncomingCallResponse_Accept2): unknown { + const obj: any = {}; + if (message.room !== "") { + obj.room = message.room; + } + if (message.peer !== "") { + obj.peer = message.peer; + } + if (message.token !== "") { + obj.token = message.token; + } + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallResponse_Accept2 { + return IncomingCallData_IncomingCallResponse_Accept2.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): IncomingCallData_IncomingCallResponse_Accept2 { + const message = createBaseIncomingCallData_IncomingCallResponse_Accept2(); + message.room = object.room ?? ""; + message.peer = object.peer ?? ""; + message.token = object.token ?? ""; + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallResponse_End(): IncomingCallData_IncomingCallResponse_End { + return {}; +} + +export const IncomingCallData_IncomingCallResponse_End = { + encode(_: IncomingCallData_IncomingCallResponse_End, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallResponse_End { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallResponse_End(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): IncomingCallData_IncomingCallResponse_End { + return {}; + }, + + toJSON(_: IncomingCallData_IncomingCallResponse_End): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallResponse_End { + return IncomingCallData_IncomingCallResponse_End.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): IncomingCallData_IncomingCallResponse_End { + const message = createBaseIncomingCallData_IncomingCallResponse_End(); + return message; + }, +}; + +function createBaseIncomingCallData_IncomingCallResponse_Error(): IncomingCallData_IncomingCallResponse_Error { + return { message: "" }; +} + +export const IncomingCallData_IncomingCallResponse_Error = { + encode(message: IncomingCallData_IncomingCallResponse_Error, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.message !== "") { + writer.uint32(10).string(message.message); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): IncomingCallData_IncomingCallResponse_Error { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseIncomingCallData_IncomingCallResponse_Error(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.message = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): IncomingCallData_IncomingCallResponse_Error { + return { message: isSet(object.message) ? globalThis.String(object.message) : "" }; + }, + + toJSON(message: IncomingCallData_IncomingCallResponse_Error): unknown { + const obj: any = {}; + if (message.message !== "") { + obj.message = message.message; + } + return obj; + }, + + create, I>>( + base?: I, + ): IncomingCallData_IncomingCallResponse_Error { + return IncomingCallData_IncomingCallResponse_Error.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): IncomingCallData_IncomingCallResponse_Error { + const message = createBaseIncomingCallData_IncomingCallResponse_Error(); + message.message = object.message ?? ""; + return message; + }, +}; + +function createBaseOutgoingCallData(): OutgoingCallData { + return { event: undefined, request: undefined, response: undefined }; +} + +export const OutgoingCallData = { + encode(message: OutgoingCallData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.event !== undefined) { + OutgoingCallData_OutgoingCallEvent.encode(message.event, writer.uint32(10).fork()).ldelim(); + } + if (message.request !== undefined) { + OutgoingCallData_OutgoingCallRequest.encode(message.request, writer.uint32(18).fork()).ldelim(); + } + if (message.response !== undefined) { + OutgoingCallData_OutgoingCallResponse.encode(message.response, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.event = OutgoingCallData_OutgoingCallEvent.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.request = OutgoingCallData_OutgoingCallRequest.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.response = OutgoingCallData_OutgoingCallResponse.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData { + return { + event: isSet(object.event) ? OutgoingCallData_OutgoingCallEvent.fromJSON(object.event) : undefined, + request: isSet(object.request) ? OutgoingCallData_OutgoingCallRequest.fromJSON(object.request) : undefined, + response: isSet(object.response) ? OutgoingCallData_OutgoingCallResponse.fromJSON(object.response) : undefined, + }; + }, + + toJSON(message: OutgoingCallData): unknown { + const obj: any = {}; + if (message.event !== undefined) { + obj.event = OutgoingCallData_OutgoingCallEvent.toJSON(message.event); + } + if (message.request !== undefined) { + obj.request = OutgoingCallData_OutgoingCallRequest.toJSON(message.request); + } + if (message.response !== undefined) { + obj.response = OutgoingCallData_OutgoingCallResponse.toJSON(message.response); + } + return obj; + }, + + create, I>>(base?: I): OutgoingCallData { + return OutgoingCallData.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): OutgoingCallData { + const message = createBaseOutgoingCallData(); + message.event = (object.event !== undefined && object.event !== null) + ? OutgoingCallData_OutgoingCallEvent.fromPartial(object.event) + : undefined; + message.request = (object.request !== undefined && object.request !== null) + ? OutgoingCallData_OutgoingCallRequest.fromPartial(object.request) + : undefined; + message.response = (object.response !== undefined && object.response !== null) + ? OutgoingCallData_OutgoingCallResponse.fromPartial(object.response) + : undefined; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallEvent(): OutgoingCallData_OutgoingCallEvent { + return { err: undefined, sip: undefined, ended: undefined }; +} + +export const OutgoingCallData_OutgoingCallEvent = { + encode(message: OutgoingCallData_OutgoingCallEvent, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.err !== undefined) { + OutgoingCallData_OutgoingCallEvent_Error.encode(message.err, writer.uint32(10).fork()).ldelim(); + } + if (message.sip !== undefined) { + OutgoingCallData_OutgoingCallEvent_SipEvent.encode(message.sip, writer.uint32(18).fork()).ldelim(); + } + if (message.ended !== undefined) { + OutgoingCallData_OutgoingCallEvent_Ended.encode(message.ended, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallEvent { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.err = OutgoingCallData_OutgoingCallEvent_Error.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.sip = OutgoingCallData_OutgoingCallEvent_SipEvent.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.ended = OutgoingCallData_OutgoingCallEvent_Ended.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallEvent { + return { + err: isSet(object.err) ? OutgoingCallData_OutgoingCallEvent_Error.fromJSON(object.err) : undefined, + sip: isSet(object.sip) ? OutgoingCallData_OutgoingCallEvent_SipEvent.fromJSON(object.sip) : undefined, + ended: isSet(object.ended) ? OutgoingCallData_OutgoingCallEvent_Ended.fromJSON(object.ended) : undefined, + }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallEvent): unknown { + const obj: any = {}; + if (message.err !== undefined) { + obj.err = OutgoingCallData_OutgoingCallEvent_Error.toJSON(message.err); + } + if (message.sip !== undefined) { + obj.sip = OutgoingCallData_OutgoingCallEvent_SipEvent.toJSON(message.sip); + } + if (message.ended !== undefined) { + obj.ended = OutgoingCallData_OutgoingCallEvent_Ended.toJSON(message.ended); + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallEvent { + return OutgoingCallData_OutgoingCallEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallEvent { + const message = createBaseOutgoingCallData_OutgoingCallEvent(); + message.err = (object.err !== undefined && object.err !== null) + ? OutgoingCallData_OutgoingCallEvent_Error.fromPartial(object.err) + : undefined; + message.sip = (object.sip !== undefined && object.sip !== null) + ? OutgoingCallData_OutgoingCallEvent_SipEvent.fromPartial(object.sip) + : undefined; + message.ended = (object.ended !== undefined && object.ended !== null) + ? OutgoingCallData_OutgoingCallEvent_Ended.fromPartial(object.ended) + : undefined; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallEvent_SipEvent(): OutgoingCallData_OutgoingCallEvent_SipEvent { + return { provisional: undefined, early: undefined, accepted: undefined, failure: undefined, bye: undefined }; +} + +export const OutgoingCallData_OutgoingCallEvent_SipEvent = { + encode(message: OutgoingCallData_OutgoingCallEvent_SipEvent, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.provisional !== undefined) { + OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional.encode(message.provisional, writer.uint32(10).fork()) + .ldelim(); + } + if (message.early !== undefined) { + OutgoingCallData_OutgoingCallEvent_SipEvent_Early.encode(message.early, writer.uint32(18).fork()).ldelim(); + } + if (message.accepted !== undefined) { + OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted.encode(message.accepted, writer.uint32(26).fork()).ldelim(); + } + if (message.failure !== undefined) { + OutgoingCallData_OutgoingCallEvent_SipEvent_Failure.encode(message.failure, writer.uint32(34).fork()).ldelim(); + } + if (message.bye !== undefined) { + OutgoingCallData_OutgoingCallEvent_SipEvent_Bye.encode(message.bye, writer.uint32(42).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallEvent_SipEvent { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.provisional = OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional.decode(reader, reader.uint32()); + continue; + case 2: + if (tag !== 18) { + break; + } + + message.early = OutgoingCallData_OutgoingCallEvent_SipEvent_Early.decode(reader, reader.uint32()); + continue; + case 3: + if (tag !== 26) { + break; + } + + message.accepted = OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted.decode(reader, reader.uint32()); + continue; + case 4: + if (tag !== 34) { + break; + } + + message.failure = OutgoingCallData_OutgoingCallEvent_SipEvent_Failure.decode(reader, reader.uint32()); + continue; + case 5: + if (tag !== 42) { + break; + } + + message.bye = OutgoingCallData_OutgoingCallEvent_SipEvent_Bye.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallEvent_SipEvent { + return { + provisional: isSet(object.provisional) + ? OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional.fromJSON(object.provisional) + : undefined, + early: isSet(object.early) ? OutgoingCallData_OutgoingCallEvent_SipEvent_Early.fromJSON(object.early) : undefined, + accepted: isSet(object.accepted) + ? OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted.fromJSON(object.accepted) + : undefined, + failure: isSet(object.failure) + ? OutgoingCallData_OutgoingCallEvent_SipEvent_Failure.fromJSON(object.failure) + : undefined, + bye: isSet(object.bye) ? OutgoingCallData_OutgoingCallEvent_SipEvent_Bye.fromJSON(object.bye) : undefined, + }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallEvent_SipEvent): unknown { + const obj: any = {}; + if (message.provisional !== undefined) { + obj.provisional = OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional.toJSON(message.provisional); + } + if (message.early !== undefined) { + obj.early = OutgoingCallData_OutgoingCallEvent_SipEvent_Early.toJSON(message.early); + } + if (message.accepted !== undefined) { + obj.accepted = OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted.toJSON(message.accepted); + } + if (message.failure !== undefined) { + obj.failure = OutgoingCallData_OutgoingCallEvent_SipEvent_Failure.toJSON(message.failure); + } + if (message.bye !== undefined) { + obj.bye = OutgoingCallData_OutgoingCallEvent_SipEvent_Bye.toJSON(message.bye); + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent { + return OutgoingCallData_OutgoingCallEvent_SipEvent.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent { + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent(); + message.provisional = (object.provisional !== undefined && object.provisional !== null) + ? OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional.fromPartial(object.provisional) + : undefined; + message.early = (object.early !== undefined && object.early !== null) + ? OutgoingCallData_OutgoingCallEvent_SipEvent_Early.fromPartial(object.early) + : undefined; + message.accepted = (object.accepted !== undefined && object.accepted !== null) + ? OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted.fromPartial(object.accepted) + : undefined; + message.failure = (object.failure !== undefined && object.failure !== null) + ? OutgoingCallData_OutgoingCallEvent_SipEvent_Failure.fromPartial(object.failure) + : undefined; + message.bye = (object.bye !== undefined && object.bye !== null) + ? OutgoingCallData_OutgoingCallEvent_SipEvent_Bye.fromPartial(object.bye) + : undefined; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Provisional(): OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional { + return { code: 0 }; +} + +export const OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional = { + encode( + message: OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional, + writer: _m0.Writer = _m0.Writer.create(), + ): _m0.Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Provisional(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.code = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional { + return { code: isSet(object.code) ? globalThis.Number(object.code) : 0 }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional): unknown { + const obj: any = {}; + if (message.code !== 0) { + obj.code = Math.round(message.code); + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional { + return OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Provisional { + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Provisional(); + message.code = object.code ?? 0; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Early(): OutgoingCallData_OutgoingCallEvent_SipEvent_Early { + return { code: 0 }; +} + +export const OutgoingCallData_OutgoingCallEvent_SipEvent_Early = { + encode( + message: OutgoingCallData_OutgoingCallEvent_SipEvent_Early, + writer: _m0.Writer = _m0.Writer.create(), + ): _m0.Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallEvent_SipEvent_Early { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Early(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.code = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallEvent_SipEvent_Early { + return { code: isSet(object.code) ? globalThis.Number(object.code) : 0 }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallEvent_SipEvent_Early): unknown { + const obj: any = {}; + if (message.code !== 0) { + obj.code = Math.round(message.code); + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Early { + return OutgoingCallData_OutgoingCallEvent_SipEvent_Early.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Early { + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Early(); + message.code = object.code ?? 0; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Accepted(): OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted { + return { code: 0 }; +} + +export const OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted = { + encode( + message: OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted, + writer: _m0.Writer = _m0.Writer.create(), + ): _m0.Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Accepted(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.code = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted { + return { code: isSet(object.code) ? globalThis.Number(object.code) : 0 }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted): unknown { + const obj: any = {}; + if (message.code !== 0) { + obj.code = Math.round(message.code); + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted { + return OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Accepted { + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Accepted(); + message.code = object.code ?? 0; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Failure(): OutgoingCallData_OutgoingCallEvent_SipEvent_Failure { + return { code: 0 }; +} + +export const OutgoingCallData_OutgoingCallEvent_SipEvent_Failure = { + encode( + message: OutgoingCallData_OutgoingCallEvent_SipEvent_Failure, + writer: _m0.Writer = _m0.Writer.create(), + ): _m0.Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallEvent_SipEvent_Failure { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Failure(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.code = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallEvent_SipEvent_Failure { + return { code: isSet(object.code) ? globalThis.Number(object.code) : 0 }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallEvent_SipEvent_Failure): unknown { + const obj: any = {}; + if (message.code !== 0) { + obj.code = Math.round(message.code); + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Failure { + return OutgoingCallData_OutgoingCallEvent_SipEvent_Failure.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Failure { + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Failure(); + message.code = object.code ?? 0; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Bye(): OutgoingCallData_OutgoingCallEvent_SipEvent_Bye { + return {}; +} + +export const OutgoingCallData_OutgoingCallEvent_SipEvent_Bye = { + encode(_: OutgoingCallData_OutgoingCallEvent_SipEvent_Bye, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallEvent_SipEvent_Bye { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Bye(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): OutgoingCallData_OutgoingCallEvent_SipEvent_Bye { + return {}; + }, + + toJSON(_: OutgoingCallData_OutgoingCallEvent_SipEvent_Bye): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Bye { + return OutgoingCallData_OutgoingCallEvent_SipEvent_Bye.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): OutgoingCallData_OutgoingCallEvent_SipEvent_Bye { + const message = createBaseOutgoingCallData_OutgoingCallEvent_SipEvent_Bye(); + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallEvent_Ended(): OutgoingCallData_OutgoingCallEvent_Ended { + return {}; +} + +export const OutgoingCallData_OutgoingCallEvent_Ended = { + encode(_: OutgoingCallData_OutgoingCallEvent_Ended, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallEvent_Ended { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallEvent_Ended(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): OutgoingCallData_OutgoingCallEvent_Ended { + return {}; + }, + + toJSON(_: OutgoingCallData_OutgoingCallEvent_Ended): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallEvent_Ended { + return OutgoingCallData_OutgoingCallEvent_Ended.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): OutgoingCallData_OutgoingCallEvent_Ended { + const message = createBaseOutgoingCallData_OutgoingCallEvent_Ended(); + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallEvent_Error(): OutgoingCallData_OutgoingCallEvent_Error { + return { message: "" }; +} + +export const OutgoingCallData_OutgoingCallEvent_Error = { + encode(message: OutgoingCallData_OutgoingCallEvent_Error, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.message !== "") { + writer.uint32(10).string(message.message); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallEvent_Error { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallEvent_Error(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.message = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallEvent_Error { + return { message: isSet(object.message) ? globalThis.String(object.message) : "" }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallEvent_Error): unknown { + const obj: any = {}; + if (message.message !== "") { + obj.message = message.message; + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallEvent_Error { + return OutgoingCallData_OutgoingCallEvent_Error.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallEvent_Error { + const message = createBaseOutgoingCallData_OutgoingCallEvent_Error(); + message.message = object.message ?? ""; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallRequest(): OutgoingCallData_OutgoingCallRequest { + return { reqId: 0, end: undefined }; +} + +export const OutgoingCallData_OutgoingCallRequest = { + encode(message: OutgoingCallData_OutgoingCallRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.reqId !== 0) { + writer.uint32(8).uint32(message.reqId); + } + if (message.end !== undefined) { + OutgoingCallData_OutgoingCallRequest_End.encode(message.end, writer.uint32(82).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallRequest { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.reqId = reader.uint32(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.end = OutgoingCallData_OutgoingCallRequest_End.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallRequest { + return { + reqId: isSet(object.reqId) ? globalThis.Number(object.reqId) : 0, + end: isSet(object.end) ? OutgoingCallData_OutgoingCallRequest_End.fromJSON(object.end) : undefined, + }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallRequest): unknown { + const obj: any = {}; + if (message.reqId !== 0) { + obj.reqId = Math.round(message.reqId); + } + if (message.end !== undefined) { + obj.end = OutgoingCallData_OutgoingCallRequest_End.toJSON(message.end); + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallRequest { + return OutgoingCallData_OutgoingCallRequest.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallRequest { + const message = createBaseOutgoingCallData_OutgoingCallRequest(); + message.reqId = object.reqId ?? 0; + message.end = (object.end !== undefined && object.end !== null) + ? OutgoingCallData_OutgoingCallRequest_End.fromPartial(object.end) + : undefined; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallRequest_End(): OutgoingCallData_OutgoingCallRequest_End { + return {}; +} + +export const OutgoingCallData_OutgoingCallRequest_End = { + encode(_: OutgoingCallData_OutgoingCallRequest_End, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallRequest_End { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallRequest_End(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): OutgoingCallData_OutgoingCallRequest_End { + return {}; + }, + + toJSON(_: OutgoingCallData_OutgoingCallRequest_End): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallRequest_End { + return OutgoingCallData_OutgoingCallRequest_End.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): OutgoingCallData_OutgoingCallRequest_End { + const message = createBaseOutgoingCallData_OutgoingCallRequest_End(); + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallResponse(): OutgoingCallData_OutgoingCallResponse { + return { reqId: 0, error: undefined, end: undefined }; +} + +export const OutgoingCallData_OutgoingCallResponse = { + encode(message: OutgoingCallData_OutgoingCallResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.reqId !== 0) { + writer.uint32(8).uint32(message.reqId); + } + if (message.error !== undefined) { + OutgoingCallData_OutgoingCallResponse_Error.encode(message.error, writer.uint32(82).fork()).ldelim(); + } + if (message.end !== undefined) { + OutgoingCallData_OutgoingCallResponse_End.encode(message.end, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallResponse { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallResponse(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 8) { + break; + } + + message.reqId = reader.uint32(); + continue; + case 10: + if (tag !== 82) { + break; + } + + message.error = OutgoingCallData_OutgoingCallResponse_Error.decode(reader, reader.uint32()); + continue; + case 11: + if (tag !== 90) { + break; + } + + message.end = OutgoingCallData_OutgoingCallResponse_End.decode(reader, reader.uint32()); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallResponse { + return { + reqId: isSet(object.reqId) ? globalThis.Number(object.reqId) : 0, + error: isSet(object.error) ? OutgoingCallData_OutgoingCallResponse_Error.fromJSON(object.error) : undefined, + end: isSet(object.end) ? OutgoingCallData_OutgoingCallResponse_End.fromJSON(object.end) : undefined, + }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallResponse): unknown { + const obj: any = {}; + if (message.reqId !== 0) { + obj.reqId = Math.round(message.reqId); + } + if (message.error !== undefined) { + obj.error = OutgoingCallData_OutgoingCallResponse_Error.toJSON(message.error); + } + if (message.end !== undefined) { + obj.end = OutgoingCallData_OutgoingCallResponse_End.toJSON(message.end); + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallResponse { + return OutgoingCallData_OutgoingCallResponse.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallResponse { + const message = createBaseOutgoingCallData_OutgoingCallResponse(); + message.reqId = object.reqId ?? 0; + message.error = (object.error !== undefined && object.error !== null) + ? OutgoingCallData_OutgoingCallResponse_Error.fromPartial(object.error) + : undefined; + message.end = (object.end !== undefined && object.end !== null) + ? OutgoingCallData_OutgoingCallResponse_End.fromPartial(object.end) + : undefined; + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallResponse_End(): OutgoingCallData_OutgoingCallResponse_End { + return {}; +} + +export const OutgoingCallData_OutgoingCallResponse_End = { + encode(_: OutgoingCallData_OutgoingCallResponse_End, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallResponse_End { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallResponse_End(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(_: any): OutgoingCallData_OutgoingCallResponse_End { + return {}; + }, + + toJSON(_: OutgoingCallData_OutgoingCallResponse_End): unknown { + const obj: any = {}; + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallResponse_End { + return OutgoingCallData_OutgoingCallResponse_End.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + _: I, + ): OutgoingCallData_OutgoingCallResponse_End { + const message = createBaseOutgoingCallData_OutgoingCallResponse_End(); + return message; + }, +}; + +function createBaseOutgoingCallData_OutgoingCallResponse_Error(): OutgoingCallData_OutgoingCallResponse_Error { + return { message: "" }; +} + +export const OutgoingCallData_OutgoingCallResponse_Error = { + encode(message: OutgoingCallData_OutgoingCallResponse_Error, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.message !== "") { + writer.uint32(10).string(message.message); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): OutgoingCallData_OutgoingCallResponse_Error { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseOutgoingCallData_OutgoingCallResponse_Error(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if (tag !== 10) { + break; + } + + message.message = reader.string(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): OutgoingCallData_OutgoingCallResponse_Error { + return { message: isSet(object.message) ? globalThis.String(object.message) : "" }; + }, + + toJSON(message: OutgoingCallData_OutgoingCallResponse_Error): unknown { + const obj: any = {}; + if (message.message !== "") { + obj.message = message.message; + } + return obj; + }, + + create, I>>( + base?: I, + ): OutgoingCallData_OutgoingCallResponse_Error { + return OutgoingCallData_OutgoingCallResponse_Error.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): OutgoingCallData_OutgoingCallResponse_Error { + const message = createBaseOutgoingCallData_OutgoingCallResponse_Error(); + message.message = object.message ?? ""; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; + +export type DeepPartial = T extends Builtin ? T + : T extends globalThis.Array ? globalThis.Array> + : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } + : Partial; + +type KeysOfUnion = T extends T ? keyof T : never; +export type Exact = P extends Builtin ? P + : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; + +function isSet(value: any): boolean { + return value !== null && value !== undefined; +} diff --git a/packages/sdk-core/src/lib.ts b/packages/sdk-core/src/lib.ts index 05cd72c..a89c49d 100644 --- a/packages/sdk-core/src/lib.ts +++ b/packages/sdk-core/src/lib.ts @@ -45,3 +45,6 @@ export { ServerEvent_Receiver_VoiceActivity as TrackReceiverVoiceActivity } from export { Mode as AudioMixerMode } from "./generated/protobuf/features.mixer"; export { Receiver_Source as AudioMixerSource } from "./generated/protobuf/shared"; + +export { SipIncomingCall, type IncomingSipCallStatus } from "./sip_incoming"; +export { SipOutgoingCall, type OutgoingSipCallStatus } from "./sip_outgoing"; \ No newline at end of file diff --git a/packages/sdk-core/src/session.ts b/packages/sdk-core/src/session.ts index 6336319..beca912 100644 --- a/packages/sdk-core/src/session.ts +++ b/packages/sdk-core/src/session.ts @@ -55,7 +55,7 @@ export class Session extends EventEmitter { conn_id?: string; receivers: TrackReceiver[] = []; senders: TrackSender[] = []; - msgChannels: Map = new Map(); + msgChannels: Map = new Map(); _mixer?: mixer.AudioMixer; /// Prepaer state for flagging when ever this peer is created offer. @@ -68,7 +68,7 @@ export class Session extends EventEmitter { ) { super(); this.created_at = new Date().getTime(); - console.warn("Create session", this.created_at); + console.info("Create session", this.created_at); this.peer = new RTCPeerConnection(); this.dc = new Datachannel( this.peer.createDataChannel("data", { negotiated: true, id: 0 }), @@ -195,7 +195,7 @@ export class Session extends EventEmitter { } this.prepareState = false; this.version = version; - console.warn("Prepare senders and receivers to connect"); + console.info("Prepare senders and receivers to connect"); //prepare for senders. We need to lazy prepare because some transceiver dont allow update before connected for (let i = 0; i < this.senders.length; i++) { console.log("Prepare sender ", this.senders[i]!.name); @@ -358,9 +358,9 @@ export class Session extends EventEmitter { config?: MessageChannelConfig | undefined, ) { await this.dc.ready(); - console.warn("[MessageChannel] creating a new channel:", key); + console.info("[MessageChannel] creating a new channel:", key); if (this.msgChannels.has(key)) { - console.warn("[MessageChannel] a channel already exist with key:", key); + console.info("[MessageChannel] a channel already exist with key:", key); return this.msgChannels.get(key)!; } const msgChannel = new RoomMessageChannel(key, this.dc, config); @@ -387,11 +387,19 @@ export class Session extends EventEmitter { } async disconnect() { - console.warn("Disconnecting session", this.created_at); + if (this.prepareState) { + console.info("Disconnect session in prepare state"); + return; + } + if (["closed", "disconnected", "failed", "new"].includes(this.peer.connectionState)) { + console.info("Disconnect already disconnected session"); + return; + } + console.info("Disconnecting session", this.created_at); await this.dc.requestSession({ disconnect: {}, }); - console.warn("Disconnected session", this.created_at); + console.info("Disconnected session", this.created_at); this.peer.close(); } } diff --git a/packages/sdk-core/src/sip_incoming.ts b/packages/sdk-core/src/sip_incoming.ts new file mode 100644 index 0000000..256092a --- /dev/null +++ b/packages/sdk-core/src/sip_incoming.ts @@ -0,0 +1,153 @@ +import { IncomingCallData, IncomingCallData_IncomingCallRequest_Accept2, IncomingCallData_IncomingCallResponse_Accept2 } from "./generated/protobuf/sip_gateway"; +import { EventEmitter } from "./utils"; + +export interface IncomingSipCallStatus { + wsState: "WsConnecting" | "WsConnected" | "WsClosed", + sipState?: "Accepted" | "Cancelled" | "Bye", + startedAt?: number, +} + +export class SipIncomingCall extends EventEmitter { + _status: IncomingSipCallStatus = { wsState: "WsConnecting" } + wsConn: WebSocket; + reqIdSeed = 1; + reqs: Map void, (err: Error) => void]> = new Map(); + + constructor(private callWs: string) { + super() + this.wsConn = new WebSocket(callWs); + this.wsConn.binaryType = "arraybuffer"; + this.wsConn.onopen = () => { + this._status = { + ...this._status, + wsState: "WsConnected", + }; + this.emit("status", this._status) + }; + this.wsConn.onmessage = (msg) => { + let data = IncomingCallData.decode(new Uint8Array(msg.data)); + if (data.event) { + let event = data.event; + if (event.accepted) { + this._status = { + ...this._status, + sipState: "Accepted", + startedAt: Date.now(), + }; + this.emit("status", this._status) + } else if (event.ended) { + + } else if (event.err) { + this.emit("error", event.err.message) + } else if (event.sip) { + if (event.sip.cancelled) { + this._status = { + ...this._status, + sipState: "Cancelled", + }; + this.emit("status", this._status) + } else if (event.sip.bye) { + this._status = { + ...this._status, + sipState: "Bye", + }; + this.emit("status", this._status) + } + } + } else if (data.request) { + + } else if (data.response) { + const response = data.response; + if (response.reqId && this.reqs.has(response.reqId)) { + let [resolve, reject] = this.reqs.get(response.reqId)!; + this.reqs.delete(response.reqId); + if (response.error) { + reject(new Error(response.error.message)) + } else { + resolve(response.accept || response.end || response.end || response.ring || response.accept2) + } + } else { + console.error("Invalid response:", response); + } + } + }; + this.wsConn.onerror = (e) => { + this.emit("error", "WsConnectError"); + }; + this.wsConn.onclose = () => { + this._status = { + ...this._status, + wsState: "WsClosed", + }; + this.emit("status", this._status) + }; + } + + get status(): IncomingSipCallStatus { + return this._status; + } + + async accept(room: string, peer: string, record: boolean) { + return new Promise((resolve, reject) => { + const buf = IncomingCallData.encode({ + request: { + reqId: this.reqIdSeed, + accept: { + room, + peer, + record + } + } + }).finish(); + this.reqs.set(this.reqIdSeed, [resolve, reject]); + this.reqIdSeed += 1; + this.wsConn.send(buf); + }); + } + + async accept2(room: string, peer: string, record: boolean): Promise { + return new Promise((resolve, reject) => { + const buf = IncomingCallData.encode({ + request: { + reqId: this.reqIdSeed, + accept2: {} + } + }).finish(); + this.reqs.set(this.reqIdSeed, [resolve, reject]); + this.reqIdSeed += 1; + this.wsConn.send(buf); + }); + } + + async reject() { + return new Promise((resolve, reject) => { + const buf = IncomingCallData.encode({ + request: { + reqId: this.reqIdSeed, + end: {} + } + }).finish(); + this.reqs.set(this.reqIdSeed, [resolve, reject]); + this.reqIdSeed += 1; + this.wsConn.send(buf); + }); + } + + async end() { + return new Promise((resolve, reject) => { + const buf = IncomingCallData.encode({ + request: { + reqId: this.reqIdSeed, + end: {} + } + }).finish(); + this.reqs.set(this.reqIdSeed, [resolve, reject]); + this.reqIdSeed += 1; + this.wsConn.send(buf); + }); + } + + disconnect() { + this.wsConn.close(); + } +} \ No newline at end of file diff --git a/packages/sdk-core/src/sip_outgoing.ts b/packages/sdk-core/src/sip_outgoing.ts new file mode 100644 index 0000000..673b272 --- /dev/null +++ b/packages/sdk-core/src/sip_outgoing.ts @@ -0,0 +1,201 @@ +import { OutgoingCallData } from "./generated/protobuf/sip_gateway"; +import { EventEmitter } from "./utils"; + +export interface OutgoingSipCallStatus { + wsState: "WsConnecting" | "WsConnected" | "WsClosed", + sipState?: "Provisional" | "Early" | "Accepted" | "Failure" | "Bye", + sipCode?: number, + sipCodeStr?: string, + startedAt?: number, +} + +interface WsEvent { + type: "Sip" | "Destroyed" | "Error", + content?: { + type: "Provisional" | "Early" | "Accepted" | "Failure" | "Bye", + code?: number + }, + message?: string, +} + +interface WsMessage { + type: "Event", + content: WsEvent, +} + +export class SipOutgoingCall extends EventEmitter { + _status: OutgoingSipCallStatus = { wsState: "WsConnecting" } + wsConn: WebSocket; + reqIdSeed = 1; + reqs: Map void, (err: Error) => void]> = new Map(); + + constructor(callWs: string) { + super() + this.wsConn = new WebSocket(callWs); + this.wsConn.binaryType = "arraybuffer"; + this.wsConn.onopen = () => { + this._status = { + ...this._status, + wsState: "WsConnected", + }; + this.emit("status", this._status) + }; + this.wsConn.onmessage = (msg) => { + console.log(msg.data); + const data = OutgoingCallData.decode(new Uint8Array(msg.data)); + if (data.event) { + const event = data.event; + if (event.sip) { + if (event.sip.provisional) { + this._status = { + ...this._status, + sipState: "Provisional", + sipCode: event.sip.provisional.code, + sipCodeStr: (sipStatusCodes[event.sip.provisional.code] || 'Code ' + event.sip.provisional.code), + }; + } else if (event.sip.early) { + this._status = { + ...this._status, + sipState: "Early", + sipCode: event.sip.early.code, + sipCodeStr: (sipStatusCodes[event.sip.early.code] || 'Code ' + event.sip.early.code), + }; + } else if (event.sip.failure) { + this._status = { + ...this._status, + sipState: "Failure", + sipCode: event.sip.failure.code, + sipCodeStr: (sipStatusCodes[event.sip.failure.code] || 'Code ' + event.sip.failure.code), + }; + } else if (event.sip.accepted) { + this._status = { + ...this._status, + startedAt: Date.now(), + sipState: "Accepted", + sipCode: event.sip.accepted.code, + sipCodeStr: (sipStatusCodes[event.sip.accepted.code] || 'Code ' + event.sip.accepted.code), + }; + } else if (event.sip.bye) { + this._status = { + ...this._status, + sipState: "Bye", + sipCode: undefined, + sipCodeStr: undefined, + }; + } else { + console.warn("Invalid sip event", event.sip); + } + this.emit("status", this._status) + } else if (event.ended) { + + } else if (event.err) { + this.emit("error", event.err.message || 'Unknown error') + } + } else if (data.request) { + + } else if (data.response) { + const response = data.response; + if (response.reqId && this.reqs.has(response.reqId)) { + let [resolve, reject] = this.reqs.get(response.reqId)!; + this.reqs.delete(response.reqId); + if (response.error) { + reject(new Error(response.error.message)) + } else { + resolve() + } + } else { + console.error("Invalid response:", response); + } + } + }; + this.wsConn.onerror = (e) => { + this.emit("error", "WsConnectError"); + }; + this.wsConn.onclose = () => { + this._status = { + ...this._status, + wsState: "WsClosed", + }; + this.emit("status", this._status) + }; + } + + get status(): OutgoingSipCallStatus { + return this._status; + } + + async end() { + return new Promise((resolve, reject) => { + const buf = OutgoingCallData.encode({ + request: { + reqId: this.reqIdSeed, + end: {} + } + }).finish(); + this.reqs.set(this.reqIdSeed, [resolve, reject]); + this.reqIdSeed += 1; + this.wsConn.send(buf); + }); + } + + disconnect() { + this.wsConn.close(); + } +} + +const sipStatusCodes: Record = { + 100: "Trying", + 180: "Ringing", + 181: "Call Is Being Forwarded", + 182: "Queued", + 183: "Session Progress", + 200: "OK", + 202: "Accepted", + 300: "Multiple Choices", + 301: "Moved Permanently", + 302: "Moved Temporarily", + 305: "Use Proxy", + 380: "Alternative Service", + 400: "Bad Request", + 401: "Unauthorized", + 402: "Payment Required", + 403: "Forbidden", + 404: "Not Found", + 405: "Method Not Allowed", + 406: "Not Acceptable", + 407: "Proxy Authentication Required", + 408: "Request Timeout", + 409: "Conflict", + 410: "Gone", + 413: "Request Entity Too Large", + 414: "Request-URI Too Long", + 415: "Unsupported Media Type", + 416: "Unsupported URI Scheme", + 420: "Bad Extension", + 421: "Extension Required", + 423: "Interval Too Brief", + 480: "Temporarily Unavailable", + 481: "Call/Transaction Does Not Exist", + 482: "Loop Detected", + 483: "Too Many Hops", + 484: "Address Incomplete", + 485: "Ambiguous", + 486: "Busy Here", + 487: "Request Terminated", + 488: "Not Acceptable Here", + 489: "Bad Event", + 491: "Request Pending", + 493: "Undecipherable", + 500: "Server Internal Error", + 501: "Not Implemented", + 502: "Bad Gateway", + 503: "Service Unavailable", + 504: "Server Time-out", + 505: "Version Not Supported", + 513: "Message Too Large", + 580: "Precondition Failure", + 600: "Busy Everywhere", + 603: "Decline", + 604: "Does Not Exist Anywhere", + 606: "Not Acceptable" +}; \ No newline at end of file diff --git a/packages/sdk-react-hooks/src/context.ts b/packages/sdk-react-hooks/src/context.ts index 7456e6e..e331f67 100644 --- a/packages/sdk-react-hooks/src/context.ts +++ b/packages/sdk-react-hooks/src/context.ts @@ -30,7 +30,7 @@ export interface PublisherConfig { } export class Publisher { - constructor(private _sender: TrackSender) {} + constructor(private _sender: TrackSender) { } get sender() { return this._sender; diff --git a/packages/sdk-react-hooks/src/hooks/session.tsx b/packages/sdk-react-hooks/src/hooks/session.tsx index 5a4e98d..f2c3cba 100644 --- a/packages/sdk-react-hooks/src/hooks/session.tsx +++ b/packages/sdk-react-hooks/src/hooks/session.tsx @@ -6,7 +6,7 @@ import { JoinInfo } from "@atm0s-media-sdk/core"; const VERSION = "react@0.0.0"; //TODO auto version class SessionWrap { - constructor(private ctx: Context) {} + constructor(private ctx: Context) { } connect = () => { return this.ctx.connect(VERSION); }; diff --git a/packages/sdk-react-hooks/src/hooks/sip/sip_incoming.tsx b/packages/sdk-react-hooks/src/hooks/sip/sip_incoming.tsx new file mode 100644 index 0000000..0f4fb8e --- /dev/null +++ b/packages/sdk-react-hooks/src/hooks/sip/sip_incoming.tsx @@ -0,0 +1,22 @@ +import { IncomingSipCallStatus, SipIncomingCall } from "@atm0s-media-sdk/core"; +import { useEffect, useMemo, useState } from "react"; + +export function useSipIncomingCallStatus( + callWs: string, +): [IncomingSipCallStatus, string | null, SipIncomingCall] { + const call = useMemo(() => new SipIncomingCall(callWs), [callWs]) + const [status, setStatus] = useState(call.status); + const [err, setErr] = useState(null); + + useEffect(() => { + call.on('status', setStatus) + call.on('error', setErr) + + return () => { + call.disconnect() + }; + }, [call]); + + return [status, err, call]; +} + diff --git a/packages/sdk-react-hooks/src/hooks/sip/sip_outgoing.tsx b/packages/sdk-react-hooks/src/hooks/sip/sip_outgoing.tsx new file mode 100644 index 0000000..1e7a749 --- /dev/null +++ b/packages/sdk-react-hooks/src/hooks/sip/sip_outgoing.tsx @@ -0,0 +1,22 @@ +import { OutgoingSipCallStatus, SipOutgoingCall } from "@atm0s-media-sdk/core"; +import { useEffect, useMemo, useState } from "react"; + +export function useSipOutgoingCallStatus( + callWs: string, +): [OutgoingSipCallStatus, string | null, SipOutgoingCall] { + const call = useMemo(() => new SipOutgoingCall(callWs), [callWs]) + const [status, setStatus] = useState(call.status); + const [err, setErr] = useState(null); + + useEffect(() => { + call.on('status', setStatus) + call.on('error', setErr) + + return () => { + call.disconnect() + }; + }, [call]); + + return [status, err, call]; +} + diff --git a/packages/sdk-react-hooks/src/lib.tsx b/packages/sdk-react-hooks/src/lib.tsx index 160b042..9bee15c 100644 --- a/packages/sdk-react-hooks/src/lib.tsx +++ b/packages/sdk-react-hooks/src/lib.tsx @@ -25,3 +25,6 @@ export { export type { ConsumerConfig } from "./hooks/consumer"; export { useMessageChannel } from "./hooks/msg_channel"; + +export { useSipOutgoingCallStatus } from "./hooks/sip/sip_outgoing"; +export { useSipIncomingCallStatus } from "./hooks/sip/sip_incoming"; \ No newline at end of file diff --git a/packages/sdk-react-hooks/src/provider.tsx b/packages/sdk-react-hooks/src/provider.tsx index 0714dcd..ffda9d0 100644 --- a/packages/sdk-react-hooks/src/provider.tsx +++ b/packages/sdk-react-hooks/src/provider.tsx @@ -39,6 +39,6 @@ export function Atm0sMediaProvider({ {children} ) : ( -
+ <> ); } diff --git a/packages/sdk-react-ui/src/components/previews/camera.tsx b/packages/sdk-react-ui/src/components/previews/camera.tsx index c65ed03..19c3776 100644 --- a/packages/sdk-react-ui/src/components/previews/camera.tsx +++ b/packages/sdk-react-ui/src/components/previews/camera.tsx @@ -6,12 +6,12 @@ import { BitrateControlMode, Kind } from "@atm0s-media-sdk/core"; import { CameraIcon, CameraOffIcon } from "../icons/camera"; interface CameraPreviewProps { - source_name: string; + trackName: string; } -export function CameraPreview({ source_name }: CameraPreviewProps) { +export function CameraPreview({ trackName }: CameraPreviewProps) { const videoRef = useRef(null); - const stream = useDeviceStream(source_name); + const stream = useDeviceStream(trackName); useEffect(() => { if (stream && videoRef.current) { videoRef.current.srcObject = stream; @@ -38,8 +38,8 @@ export function CameraPreview({ source_name }: CameraPreviewProps) { } interface CameraSelectionProps { - source_name: string; - first_page?: boolean; + trackName: string; + defaultEnable?: boolean; } const PublisherConfig = { @@ -49,18 +49,18 @@ const PublisherConfig = { }; export function CameraSelection({ - source_name, - first_page, + trackName, + defaultEnable, }: CameraSelectionProps) { - const publisher = usePublisher(source_name, Kind.VIDEO, PublisherConfig); + const publisher = usePublisher(trackName, Kind.VIDEO, PublisherConfig); const [devices, setDevices] = useState<{ id: string; label: string }[]>([]); const ctx = useContext(Atm0sMediaUIContext); - const stream = useDeviceStream(source_name); + const stream = useDeviceStream(trackName); useEffect(() => { const init = async () => { - if (first_page) { - await ctx.requestDevice(source_name, "video"); + if (defaultEnable) { + await ctx.requestDevice(trackName, "video"); } const devices = await navigator.mediaDevices.enumerateDevices(); console.log(devices); @@ -74,7 +74,7 @@ export function CameraSelection({ }; init(); - }, [ctx, source_name, setDevices, first_page]); + }, [ctx, trackName, setDevices, defaultEnable]); useEffect(() => { let track = stream?.getVideoTracks()[0]; @@ -87,10 +87,10 @@ export function CameraSelection({ const onToggle = useCallback(() => { if (stream) { - ctx.turnOffDevice(source_name); + ctx.turnOffDevice(trackName); } else { ctx - .requestDevice(source_name, "video") + .requestDevice(trackName, "video") .then(console.log) .catch(console.error); } @@ -99,7 +99,7 @@ export function CameraSelection({ const onChange = useCallback((event: any) => { let selected = event.target.options[event.target.selectedIndex].value; ctx - .requestDevice(source_name, "video", selected) + .requestDevice(trackName, "video", selected) .then(console.log) .catch(console.error); }, []); diff --git a/packages/sdk-react-ui/src/components/previews/microphone.tsx b/packages/sdk-react-ui/src/components/previews/microphone.tsx index d27c110..82cacb5 100644 --- a/packages/sdk-react-ui/src/components/previews/microphone.tsx +++ b/packages/sdk-react-ui/src/components/previews/microphone.tsx @@ -6,12 +6,12 @@ import { Kind } from "@atm0s-media-sdk/core"; import { MicIcon, MicOffIcon } from "../icons/microphone"; interface MicrophonePreviewProps { - source_name: string; + trackName: string; } -export function MicrophonePreview({ source_name }: MicrophonePreviewProps) { +export function MicrophonePreview({ trackName }: MicrophonePreviewProps) { const audioRef = useRef(null); - const stream = useDeviceStream(source_name); + const stream = useDeviceStream(trackName); useEffect(() => { if (stream && audioRef.current) { audioRef.current.srcObject = stream; @@ -31,23 +31,23 @@ export function MicrophonePreview({ source_name }: MicrophonePreviewProps) { } interface MicrophoneSelectionProps { - source_name: string; - first_page?: boolean; + trackName: string; + defaultEnable?: boolean, } export function MicrophoneSelection({ - source_name, - first_page, + trackName, + defaultEnable, }: MicrophoneSelectionProps) { - const publisher = usePublisher(source_name, Kind.AUDIO); + const publisher = usePublisher(trackName, Kind.AUDIO); const [devices, setDevices] = useState<{ id: string; label: string }[]>([]); const ctx = useContext(Atm0sMediaUIContext); - const stream = useDeviceStream(source_name); + const stream = useDeviceStream(trackName); useEffect(() => { const init = async () => { - if (first_page) { - await ctx.requestDevice(source_name, "audio"); + if (defaultEnable) { + await ctx.requestDevice(trackName, "audio"); } const devices = await navigator.mediaDevices.enumerateDevices(); console.log(devices); @@ -61,7 +61,12 @@ export function MicrophoneSelection({ }; init(); - }, [ctx, source_name, setDevices, first_page]); + return () => { + if (defaultEnable) { //TODO more better way + ctx.turnOffDevice(trackName); + } + } + }, [ctx, trackName, setDevices, defaultEnable]); useEffect(() => { let track = stream?.getAudioTracks()[0]; @@ -74,10 +79,10 @@ export function MicrophoneSelection({ const onToggle = useCallback(() => { if (stream) { - ctx.turnOffDevice(source_name); + ctx.turnOffDevice(trackName); } else { ctx - .requestDevice(source_name, "audio") + .requestDevice(trackName, "audio") .then(console.log) .catch(console.error); } @@ -85,7 +90,7 @@ export function MicrophoneSelection({ const onChange = useCallback((event: any) => { let selected = event.target.options[event.target.selectedIndex].value; ctx - .requestDevice(source_name, "audio", selected) + .requestDevice(trackName, "audio", selected) .then(console.log) .catch(console.error); }, []); diff --git a/packages/sdk-react-ui/src/components/uis/clock_timer.tsx b/packages/sdk-react-ui/src/components/uis/clock_timer.tsx new file mode 100644 index 0000000..7d0c743 --- /dev/null +++ b/packages/sdk-react-ui/src/components/uis/clock_timer.tsx @@ -0,0 +1,27 @@ +import React, { useEffect, useState } from 'react'; + +interface ClockTimerProps { + started_at: number; // Timestamp in milliseconds +} + +const formatTime = (seconds: number) => { + const minutes = Math.floor(seconds / 60); + const remainingSeconds = seconds % 60; + return `${String(minutes).padStart(2, '0')}:${String(remainingSeconds).padStart(2, '0')}`; +}; + +export function ClockTimer({ started_at }: ClockTimerProps) { + const [secondsElapsed, setSecondsElapsed] = useState(formatTime(Math.floor((Date.now() - started_at) / 1000))); + + useEffect(() => { + const intervalId = setInterval(() => { + setSecondsElapsed(formatTime(Math.floor((Date.now() - started_at) / 1000))); + }, 1000); // Update every second + + return () => clearInterval(intervalId); // Cleanup on unmount + }, []); + + return ( +

{secondsElapsed}

+ ); +}; diff --git a/packages/sdk-react-ui/src/lib.tsx b/packages/sdk-react-ui/src/lib.tsx index b272daf..d29c6c1 100644 --- a/packages/sdk-react-ui/src/lib.tsx +++ b/packages/sdk-react-ui/src/lib.tsx @@ -10,3 +10,8 @@ export { PeersPanel } from "./panels/peers_panel"; export { DevicesSelection } from "./panels/devices_selection"; export { ControlsPanel } from "./panels/controls_panel"; export { ChatPanel } from "./panels/chat_panel"; +export type { SipOutgoingCallProps } from "./panels/sip_outgoing"; +export { SipOutgoingCallWidget } from "./panels/sip_outgoing"; + +export type { SipIncomingCallProps } from "./panels/sip_incoming"; +export { SipIncomingCallWidget } from "./panels/sip_incoming"; \ No newline at end of file diff --git a/packages/sdk-react-ui/src/panels/controls_panel.tsx b/packages/sdk-react-ui/src/panels/controls_panel.tsx index d9a77a0..34ce9f5 100644 --- a/packages/sdk-react-ui/src/panels/controls_panel.tsx +++ b/packages/sdk-react-ui/src/panels/controls_panel.tsx @@ -9,8 +9,8 @@ export function ControlsPanel({ audio_name, video_name }: Props) { return (
- - + +
); diff --git a/packages/sdk-react-ui/src/panels/devices_selection.tsx b/packages/sdk-react-ui/src/panels/devices_selection.tsx index 49807f3..6cb7308 100644 --- a/packages/sdk-react-ui/src/panels/devices_selection.tsx +++ b/packages/sdk-react-ui/src/panels/devices_selection.tsx @@ -10,11 +10,11 @@ export function DevicesSelection({ audio_name, video_name }: Props) { return (
- +
- - + +
); diff --git a/packages/sdk-react-ui/src/panels/sip_incoming.tsx b/packages/sdk-react-ui/src/panels/sip_incoming.tsx new file mode 100644 index 0000000..5713544 --- /dev/null +++ b/packages/sdk-react-ui/src/panels/sip_incoming.tsx @@ -0,0 +1,92 @@ +import { useCallback, useEffect, useState } from "react"; +import { useSession, useSipIncomingCallStatus } from "@atm0s-media-sdk/react-hooks"; +import { AudioMixerPlayer, MicrophoneSelection } from "../lib"; +import { ClockTimer } from "../components/uis/clock_timer"; + +export interface SipIncomingCallProps { + callFrom: string, + callWs: string; + room: string, + record: boolean, + onEnd: () => void; +} + +type AcceptState = "Connecting" | "Accepting" | "Accepted"; +type AcceptError = "MediaFailed" | "SipFailed"; + +export function SipIncomingCallWidget(props: SipIncomingCallProps): JSX.Element { + const [status, callErr, call] = useSipIncomingCallStatus(props.callWs); + const [acceptState, setAcceptState] = useState(null); + const [acceptError, setAcceptError] = useState(null); + const session = useSession(); + + const showAccept = !status.sipState; + const showReject = !status.sipState; + const showHangup = status.sipState == "Accepted"; + + useEffect(() => { + return () => { + session.disconnect(); + }; + }, [session]); + + const accept = useCallback(() => { + setAcceptState("Connecting") + session.connect().then(() => { + setAcceptState("Accepting") + return call.accept(props.room, props.callFrom, props.record).then(() => { + setAcceptState("Accepted") + }).catch(() => setAcceptError("SipFailed")) + }).catch(() => setAcceptError("MediaFailed")) + + }, [call]); + + const reject = useCallback(() => { + call.reject() + session.disconnect(); + props.onEnd() + }, [session, call, props.onEnd]); + + return ( +
+ {/* WebSocket Status Indicator */} +
+

+ Status: {acceptError || callErr || status.sipState || acceptState} +

+ + {/* Time Counting */} +
{status.startedAt && }
+ + {/* Destination Number Info */} +

Destination: {props.callFrom}

+ + + + + {/* Accept Button */} + {showAccept && } + + {/* Reject Button */} + {showReject && } + {/* Reject Button */} + {showHangup && } +
+ ); +} + diff --git a/packages/sdk-react-ui/src/panels/sip_outgoing.tsx b/packages/sdk-react-ui/src/panels/sip_outgoing.tsx new file mode 100644 index 0000000..5fe41b9 --- /dev/null +++ b/packages/sdk-react-ui/src/panels/sip_outgoing.tsx @@ -0,0 +1,55 @@ +import { useCallback, useEffect } from "react"; +import { useSipOutgoingCallStatus, useSession } from "@atm0s-media-sdk/react-hooks"; +import { AudioMixerPlayer, MicrophoneSelection } from "../lib"; +import { ClockTimer } from "../components/uis/clock_timer"; + +export interface SipOutgoingCallProps { + callTo: string, + callWs: string; + onEnd: () => void; +} + +export function SipOutgoingCallWidget(props: SipOutgoingCallProps): JSX.Element { + const [status, callErr] = useSipOutgoingCallStatus(props.callWs); + const session = useSession(); + + useEffect(() => { + session.connect(); + return () => { + session.disconnect(); + }; + }, [session]); + + const hangUp = useCallback(() => { + session.disconnect(); + props.onEnd() + }, [session, props.onEnd]); + + return ( +
+ {/* WebSocket Status Indicator */} +
+

+ SIP Status: {callErr || status.sipState} {status.sipCodeStr && '/ ' + status.sipCodeStr} +

+ + {/* Time Counting */} +
{status.startedAt && }
+ + {/* Destination Number Info */} +

Destination: {props.callTo}

+ + + + + {/* Hangup Button */} + +
+ ); +} +