diff --git a/plugins/webrtc/package-lock.json b/plugins/webrtc/package-lock.json index d96df8182..045efc37a 100644 --- a/plugins/webrtc/package-lock.json +++ b/plugins/webrtc/package-lock.json @@ -1,12 +1,12 @@ { "name": "@scrypted/webrtc", - "version": "0.0.112", + "version": "0.0.113", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@scrypted/webrtc", - "version": "0.0.112", + "version": "0.0.113", "dependencies": { "@koush/werift": "file:../../external/werift/packages/webrtc", "@scrypted/common": "file:../../common", diff --git a/plugins/webrtc/package.json b/plugins/webrtc/package.json index df3e6782d..579adcb4e 100644 --- a/plugins/webrtc/package.json +++ b/plugins/webrtc/package.json @@ -1,6 +1,6 @@ { "name": "@scrypted/webrtc", - "version": "0.0.112", + "version": "0.0.113", "scripts": { "scrypted-setup-project": "scrypted-setup-project", "prescrypted-setup-project": "scrypted-package-json", diff --git a/plugins/webrtc/src/ffmpeg-to-wrtc.ts b/plugins/webrtc/src/ffmpeg-to-wrtc.ts index 884cfc913..9a1f41b09 100644 --- a/plugins/webrtc/src/ffmpeg-to-wrtc.ts +++ b/plugins/webrtc/src/ffmpeg-to-wrtc.ts @@ -34,7 +34,7 @@ function getDebugModeH264EncoderArgs() { export async function createTrackForwarder(options: { timeStart: number, - isPrivate: boolean, destinationId: string, + isPrivate: boolean, destinationId: string, ipv4: boolean, requestMediaStream: RequestMediaStream, videoTransceiver: RTCRtpTransceiver, audioTransceiver: RTCRtpTransceiver, sessionSupportsH264High: boolean, maximumCompatibilityMode: boolean, transcodeWidth: number, @@ -187,7 +187,11 @@ export async function createTrackForwarder(options: { }, }; - const videoPacketSize = 1300; + // ipv4 mtu is 1500 + // so max usable packet size is 1500 - rtp header - tcp header - ip header + // 1500 - 12 - 20 - 20 = 1448. + // but set to 1440 cause that's what cameras seem to use for some reason. + const videoPacketSize = options.ipv4 ? 1440 : 1300; let h264Repacketizer: H264Repacketizer; let spsPps: ReturnType; diff --git a/plugins/webrtc/src/rtp-forwarders.ts b/plugins/webrtc/src/rtp-forwarders.ts index 7895bec44..51147a40d 100644 --- a/plugins/webrtc/src/rtp-forwarders.ts +++ b/plugins/webrtc/src/rtp-forwarders.ts @@ -69,6 +69,7 @@ async function setupRtspClient(console: Console, rtspClient: RtspClient, channel onRtp: (rtspHeader, rtp) => deliver(rtp), }); console.log('rtsp/udp', section.codec, result); + return false; } } catch (e) { diff --git a/plugins/webrtc/src/werift-util.ts b/plugins/webrtc/src/werift-util.ts index 01fcc5cb5..a02226666 100644 --- a/plugins/webrtc/src/werift-util.ts +++ b/plugins/webrtc/src/werift-util.ts @@ -57,8 +57,11 @@ export function logIsPrivateIceTransport(console: Console, pc: RTCPeerConnection console.warn('Turn server is in use. For optimal performance ensure that your router supports source NAT.'); } console.log('Connection is local network:', isPrivate); + const destinationId = pc.iceTransports[0]?.connection?.remoteAddr?.[0]; + const ipv4 = ip.isV4Format(destinationId); return { + ipv4, isPrivate, - destinationId: pc.iceTransports[0]?.connection?.remoteAddr?.[0], + destinationId, }; }