Skip to content

Commit

Permalink
always nullify samples
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger committed Jan 9, 2025
1 parent bce4286 commit e0305e4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 20 deletions.
18 changes: 8 additions & 10 deletions packages/media-parser/src/boxes/webm/parse-ebml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export const postprocessEbml = async ({
if (ebml.type === 'Block' || ebml.type === 'SimpleBlock') {
const sample = getSampleFromBlock(ebml, state, offset);

if (sample.type === 'video-sample' && state.nullifySamples) {
if (sample.type === 'video-sample') {
await state.callbacks.onVideoSample(
sample.videoSample.trackId,
sample.videoSample,
Expand All @@ -193,7 +193,7 @@ export const postprocessEbml = async ({
};
}

if (sample.type === 'audio-sample' && state.nullifySamples) {
if (sample.type === 'audio-sample') {
await state.callbacks.onAudioSample(
sample.audioSample.trackId,
sample.audioSample,
Expand All @@ -205,7 +205,7 @@ export const postprocessEbml = async ({
};
}

if (sample.type === 'no-sample' && state.nullifySamples) {
if (sample.type === 'no-sample') {
return {
type: 'Block',
value: new Uint8Array([]),
Expand Down Expand Up @@ -247,13 +247,11 @@ export const postprocessEbml = async ({
);
}

if (state.nullifySamples) {
return {
type: 'BlockGroup',
value: [],
minVintWidth: ebml.minVintWidth,
};
}
return {
type: 'BlockGroup',
value: [],
minVintWidth: ebml.minVintWidth,
};
}

return ebml;
Expand Down
3 changes: 0 additions & 3 deletions packages/media-parser/src/parse-media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ export const parseMedia: ParseMedia = async function <
fields,
onAudioTrack: onAudioTrack ?? null,
onVideoTrack: onVideoTrack ?? null,
nullifySamples: !(
typeof process !== 'undefined' && typeof process.env !== 'undefined'
),
supportsContentRange,
});

Expand Down
3 changes: 0 additions & 3 deletions packages/media-parser/src/state/parser-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const makeParserState = ({
signal,
getIterator,
fields,
nullifySamples,
onAudioTrack,
onVideoTrack,
supportsContentRange,
Expand All @@ -36,7 +35,6 @@ export const makeParserState = ({
signal: AbortSignal | undefined;
getIterator: () => BufferIterator | null;
fields: Options<ParseMediaFields>;
nullifySamples: boolean;
supportsContentRange: boolean;
onAudioTrack: OnAudioTrack | null;
onVideoTrack: OnVideoTrack | null;
Expand Down Expand Up @@ -71,7 +69,6 @@ export const makeParserState = ({
increaseSkippedBytes,
keyframes,
structure,
nullifySamples,
onAudioTrack,
onVideoTrack,
supportsContentRange,
Expand Down
1 change: 0 additions & 1 deletion packages/webcodecs/src/test/create-matroska.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const state = MediaParserInternals.makeParserState({
fields: {},
onAudioTrack: null,
onVideoTrack: null,
nullifySamples: false,
supportsContentRange: true,
});

Expand Down
3 changes: 0 additions & 3 deletions packages/webcodecs/src/test/stsd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ test('Should be able to parse a STSD audio box correctly', async () => {
signal: undefined,
getIterator: () => null,
fields: {},
nullifySamples: false,
supportsContentRange: true,
}),
signal: null,
Expand Down Expand Up @@ -218,8 +217,6 @@ test('Should be able to parse a STSD video box correctly', async () => {
fields: {
structure: true,
},

nullifySamples: false,
supportsContentRange: true,
}),

Expand Down

0 comments on commit e0305e4

Please sign in to comment.