shinyoshiaki / werift-webrtc

WebRTC Implementation for TypeScript (Node.js), includes ICE/DTLS/SCTP/RTP/SRTP/WEBM/MP4

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support rtcp without address

tylerlong opened this issue · comments

function ipAddressFromSdp(sdp: string) {
  const m = sdp.match(/^IN (IP4|IP6) ([^ ]+)$/);
  if (!m) throw new Error("exception");
  return m[2];
}

According to https://www.ietf.org/rfc/rfc3605.txt

    m=audio 49170 RTP/AVP 0
    a=rtcp:53020

is valid. In such case, there is no IP address.

Suggested change:

function ipAddressFromSdp(sdp: string) {
  const m = sdp.match(/^IN (IP4|IP6) ([^ ]+)$/);
  if (!m) return undefined;
  return m[2];
}

Or

function ipAddressFromSdp(sdp: string) {
  const m = sdp.match(/^IN (IP4|IP6) ([^ ]+)$/);
  if (!m) return '0.0.0.0';
  return m[2];
}