I am working with JsSIP for handling WebRTC calls in my application, and I'm trying to distinguish between incoming video and audio calls. I have implemented the following code snippet to handle incoming and outgoing calls:
const outgoingCall = async (session: RTCSession) => {
attachLocalStream(session, "videoRemote");
session.on("progress", () => {
setOutgoingCall(true);
});
session.on("connecting", () => {
console.log("outgoingCall call is in connecting ...");
});
session.on("ended", () => {
navigate("/");
setOutgoingCall(false);
});
session.on("confirmed", () => {
setOutgoingCall(false);
});
session.on("failed", () => {
navigate("/");
setOutgoingCall(false);
});
session.on("accepted", (e: any) => {
attachIncommingLocalStream(session, "videoLocal");
navigate("/answer");
});
};
const inCommingCall = (session: RTCSession) => {
console.log("inCommingCall session", session);
session.on("progress", () => {
setIncommingCall(true);
});
session.on("accepted", () => {
navigate("/answer");
setIncommingCall(false);
});
session.on("connecting", () => {
console.log("inCommingCall call is in connecting ...");
});
session.on("confirmed", () => {
attachIncommingLocalStream(session, "videoLocal");
setIncommingCall(false);
});
session.on("ended", () => {
setIncommingCall(false);
navigate("/");
});
session.on("failed", () => {
setIncommingCall(false);
});
session.on("peerconnection", (e) => {
attachRemoteStream(e.peerconnection, "videoRemote");
});
};
useEffect(() => {
sipClient?.on("newRTCSession", (data: RTCSessionEvent) => {
const session: RTCSession = data.session;
const direction = session.direction;
console.log("direction", direction);
setSession(session);
if (direction === "incoming") {
inCommingCall(session);
// SessionDirection?.OUTGOING
} else if (direction === "outgoing") {
outgoingCall(session);
}
});
}, [sipClient]);
The direction variable in the useEffect block gives me information about whether the call is incoming or outgoing, but I need to determine the call type (video or audio). Specifically, I want to identify whether an incoming call is a video call or an audio call.
Is there a way to extract this information from the JsSIP library? I have looked through the documentation, but I couldn't find a clear solution for this.
Any guidance or code examples would be greatly appreciated. Thank you!