Skip to content

Commit

Permalink
Revert "webrtc: startRtpForwarderProcess remove werift dependency"
Browse files Browse the repository at this point in the history
This reverts commit 143a0b2.
  • Loading branch information
koush committed Apr 3, 2023
1 parent cc40885 commit 2863756
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions plugins/webrtc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/webrtc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/webrtc",
"version": "0.1.39",
"version": "0.1.40",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",
"prescrypted-setup-project": "scrypted-package-json",
Expand Down
10 changes: 6 additions & 4 deletions plugins/webrtc/src/rtp-forwarders.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { RtpPacket } from "../../../external/werift/packages/rtp/src/rtp/rtp";
import { Deferred } from "@scrypted/common/src/deferred";
import { closeQuiet, createBindZero, listenZeroSingleClient, reserveUdpPort } from "@scrypted/common/src/listen-cluster";
import { ffmpegLogInitialOutput, safeKillFFmpeg, safePrintFFmpegArguments } from "@scrypted/common/src/media-helpers";
Expand Down Expand Up @@ -232,17 +233,17 @@ export async function startRtpForwarderProcess(console: Console, ffmpegInput: FF
// if the rtsp client is over tcp, then the restream server must also be tcp, as
// the rtp packets (which can be a max of 64k) may be too large for udp.
const clientIsTcp = await setupRtspClient(console, rtspClient, channel, audioSection, false, rtp => {
const payload = rtp.subarray(12);

// live555 sends rtp aac packets without AU header followed by ADTS packets (which contain codec info)
// which ffmpeg can not handle.
// the solution is to demux the adts and send that to ffmpeg raw.
// https://github.com/mpv-player/mpv/issues/5669#issuecomment-932519409
if (firstPacket) {
firstPacket = false;
if (audioSection.codec === 'aac') {
const packet = RtpPacket.deSerialize(rtp);
const buf = packet.payload;
// adts header is 12 bits of 1s
if (payload[0] == 0xff && (payload[1] & 0xf0) == 0xf0) {
if (buf[0] == 0xff && (buf[1] & 0xf0) == 0xf0) {
adts = true;
allowAudioTranscoderExit = true;
const ffmpegArgs = [
Expand Down Expand Up @@ -270,7 +271,8 @@ export async function startRtpForwarderProcess(console: Console, ffmpegInput: FF
rtspServer?.sendTrack(audioControl, rtp, false);
}
else {
audioPipe?.write(payload);
const packet = RtpPacket.deSerialize(rtp);
audioPipe?.write(packet.payload);
}
});

Expand Down

0 comments on commit 2863756

Please sign in to comment.