Skip to content

Commit

Permalink
rebroadcast: simplify prebuffer sync frame search, remove dead code...
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Jul 22, 2023
1 parent 2501d14 commit 2f3529b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
20 changes: 1 addition & 19 deletions common/src/rtsp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,35 +195,17 @@ export function createRtspParser(options?: StreamParserOptions): RtspStreamParse
'-f', 'rtsp',
],
findSyncFrame(streamChunks: StreamChunk[]) {
let foundIndex: number;
let nonVideo: {
[codec: string]: StreamChunk,
} = {};

const createSyncFrame = () => {
const ret = streamChunks.slice(foundIndex);
// for (const nv of Object.values(nonVideo)) {
// ret.unshift(nv);
// }
return ret;
}

for (let prebufferIndex = 0; prebufferIndex < streamChunks.length; prebufferIndex++) {
const streamChunk = streamChunks[prebufferIndex];
if (streamChunk.type !== 'h264') {
nonVideo[streamChunk.type] = streamChunk;
continue;
}

if (findH264NaluType(streamChunk, H264_NAL_TYPE_SPS) || findH264NaluType(streamChunk, H264_NAL_TYPE_IDR)) {
foundIndex = prebufferIndex;
break;
return streamChunks.slice(prebufferIndex);
}
}

if (foundIndex !== undefined)
return createSyncFrame();

// oh well!
},
sdp: new Promise<string>(r => resolve = r),
Expand Down
4 changes: 2 additions & 2 deletions plugins/prebuffer-mixin/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/prebuffer-mixin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/prebuffer-mixin",
"version": "0.9.96",
"version": "0.9.97",
"description": "Video Stream Rebroadcast, Prebuffer, and Management Plugin for Scrypted.",
"author": "Scrypted",
"license": "Apache-2.0",
Expand Down

0 comments on commit 2f3529b

Please sign in to comment.