Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compat/__tests__/change_source_buffer_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe("Compat - tryToChangeSourceBufferType", () => {
expect(tryToChangeSourceBufferType(fakeSourceBuffer, "toto")).toBe(false);
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(
"mse",
"Could not call 'changeType' on the given SourceBuffer:",
err,
);
Expand Down
3 changes: 2 additions & 1 deletion src/compat/__tests__/clear_element_src.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ describe("Compat - clearElementSrc", () => {
expect(spyRemoveChild).toHaveBeenCalledTimes(2);
expect(mockLogWarn).toHaveBeenCalledTimes(2);
expect(mockLogWarn).toHaveBeenCalledWith(
"Compat: Could not remove text track child from element.",
"media",
"Could not remove text track child from element.",
);
});

Expand Down
9 changes: 8 additions & 1 deletion src/compat/__tests__/make_vtt_cue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ describe("Compat - makeVTTCue", () => {
const result = makeCue(12, 10, "toto");
expect(result).toBeNull();
expect(mockLog.warn).toHaveBeenCalledTimes(1);
expect(mockLog.warn).toHaveBeenCalledWith("Compat: Invalid cue times: 12 - 10");
expect(mockLog.warn).toHaveBeenCalledWith(
"text",
"Invalid cue times: start after end.",
{
endTime: 10,
startTime: 12,
},
);
});

it("should create a new VTT Cue in other cases", async () => {
Expand Down
6 changes: 4 additions & 2 deletions src/compat/__tests__/remove_cue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ describe("compat - removeCue", () => {
expect(fakeTrack.mode).toBe("showing");
expect(mocks.logWarn).toHaveBeenCalledTimes(1);
expect(mocks.logWarn).toHaveBeenCalledWith(
"Compat: Could not remove cue from text track.",
"text",
"Could not remove cue from text track.",
);
expect(mockRemoveCue).toHaveBeenCalledTimes(1);
expect(mockRemoveCue).toHaveBeenLastCalledWith(fakeCue);
Expand All @@ -196,7 +197,8 @@ describe("compat - removeCue", () => {
expect(fakeTrack.mode).toBe("showing");
expect(mocks.logWarn).toHaveBeenCalledTimes(1);
expect(mocks.logWarn).toHaveBeenCalledWith(
"Compat: Could not remove cue from text track.",
"text",
"Could not remove cue from text track.",
);
expect(mockRemoveCue).toHaveBeenCalledTimes(1);
expect(mockRemoveCue).toHaveBeenLastCalledWith({ id: "1" });
Expand Down
5 changes: 4 additions & 1 deletion src/compat/browser_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import EnvDetector from "./env_detector";
*/
function getFirefoxVersion(): number | null {
if (EnvDetector.browser !== EnvDetector.BROWSERS.Firefox) {
log.warn("Compat: Can't access Firefox version on no firefox browser.");
log.warn(
"utils",
"getFirefoxVersion: Can't access Firefox version. Not a firefox browser.",
);
return null;
}
const userAgent = navigator.userAgent;
Expand Down
1 change: 1 addition & 0 deletions src/compat/change_source_buffer_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default function tryToChangeSourceBufferType(
sourceBuffer.changeType(codec);
} catch (e) {
log.warn(
"mse",
"Could not call 'changeType' on the given SourceBuffer:",
e instanceof Error ? e : "",
);
Expand Down
2 changes: 1 addition & 1 deletion src/compat/clear_element_src.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function clearElementSrc(element: IMediaElement): void {
try {
element.removeChild(childNodes[j]);
} catch (_err) {
log.warn("Compat: Could not remove text track child from element.");
log.warn("media", "Could not remove text track child from element.");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/compat/eme/close_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function closeSession(session: IMediaKeySession): Promise<void> {
err instanceof Error
? err.message
: "Unknown error made it impossible to close the session";
log.error(`DRM: ${message}`);
log.error(`DRM`, "Error made it impossible to close the session", `${message}`);
}
}

Expand Down
22 changes: 12 additions & 10 deletions src/compat/eme/generate_key_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { PSSH_TO_INTEGER } from "./constants";
* @returns {Uint8Array} - Initialization data, patched
*/
export function patchInitData(initData: Uint8Array): Uint8Array {
log.info("Compat: Trying to move CENC PSSH from init data at the end of it.");
log.info("DRM", "Trying to move CENC PSSH from init data at the end of it.");
let foundCencV1 = false;
let concatenatedCencs = new Uint8Array();
let resInitData = new Uint8Array();
Expand All @@ -58,13 +58,13 @@ export function patchInitData(initData: Uint8Array): Uint8Array {
initData.length < offset + 8 ||
be4toi(initData, offset + 4) !== PSSH_TO_INTEGER
) {
log.warn("Compat: unrecognized initialization data. Cannot patch it.");
log.warn("DRM", "unrecognized initialization data. Cannot patch it.");
throw new Error("Compat: unrecognized initialization data. Cannot patch it.");
}

const len = be4toi(new Uint8Array(initData), offset);
if (offset + len > initData.length) {
log.warn("Compat: unrecognized initialization data. Cannot patch it.");
log.warn("DRM", "unrecognized initialization data. Cannot patch it.");
throw new Error("Compat: unrecognized initialization data. Cannot patch it.");
}

Expand All @@ -90,20 +90,21 @@ export function patchInitData(initData: Uint8Array): Uint8Array {
) {
const cencOffsets = getNextBoxOffsets(currentPSSH);
const version = cencOffsets === null ? undefined : currentPSSH[cencOffsets[1]];
log.info("Compat: CENC PSSH found with version", version);
log.info("DRM", "CENC PSSH found with version", version);
if (version === undefined) {
log.warn("Compat: could not read version of CENC PSSH");
log.warn("DRM", "could not read version of CENC PSSH");
} else if (foundCencV1 === (version === 1)) {
// Either `concatenatedCencs` only contains v1 or does not contain any
concatenatedCencs = concat(concatenatedCencs, currentPSSH);
} else if (version === 1) {
log.warn(
"Compat: cenc version 1 encountered, " + "removing every other cenc pssh box.",
"DRM",
"cenc version 1 encountered, " + "removing every other cenc pssh box.",
);
concatenatedCencs = currentPSSH;
foundCencV1 = true;
} else {
log.warn("Compat: filtering out cenc pssh box with wrong version", version);
log.warn("DRM", "filtering out cenc pssh box with wrong version", version);
}
} else {
resInitData = concat(resInitData, currentPSSH);
Expand All @@ -112,7 +113,7 @@ export function patchInitData(initData: Uint8Array): Uint8Array {
}

if (offset !== initData.length) {
log.warn("Compat: unrecognized initialization data. Cannot patch it.");
log.warn("DRM", "unrecognized initialization data. Cannot patch it.");
throw new Error("Compat: unrecognized initialization data. Cannot patch it.");
}
return concat(resInitData, concatenatedCencs);
Expand All @@ -133,7 +134,7 @@ export default function generateKeyRequest(
initializationDataType: string | undefined,
initializationData: Uint8Array,
): Promise<unknown> {
log.debug("Compat: Calling generateRequest on the MediaKeySession");
log.debug("DRM", "Calling generateRequest on the MediaKeySession");
let patchedInit: Uint8Array;
try {
patchedInit = patchInitData(initializationData);
Expand All @@ -152,7 +153,8 @@ export default function generateKeyRequest(
// Retry with a default "cenc" value for initialization data type if
// we're in that condition.
log.warn(
"Compat: error while calling `generateRequest` with an empty " +
"DRM",
"error while calling `generateRequest` with an empty " +
'initialization data type. Retrying with a default "cenc" value.',
error,
);
Expand Down
10 changes: 5 additions & 5 deletions src/compat/eme/get_init_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ function getInitializationDataValues(
initData.length < offset + 8 ||
be4toi(initData, offset + 4) !== PSSH_TO_INTEGER
) {
log.warn("Compat: Unrecognized initialization data. Use as is.");
log.warn("DRM", "Unrecognized initialization data. Use as is.");
return [{ systemId: undefined, data: initData }];
}

const len = be4toi(new Uint8Array(initData), offset);
if (offset + len > initData.length) {
log.warn("Compat: Unrecognized initialization data. Use as is.");
log.warn("DRM", "Unrecognized initialization data. Use as is.");
return [{ systemId: undefined, data: initData }];
}
const currentPSSH = initData.subarray(offset, offset + len);
Expand All @@ -94,15 +94,15 @@ function getInitializationDataValues(
// event (but not when the corresponding segment has been pushed to the
// SourceBuffer).
// We prefer filtering them out, to avoid further issues.
log.warn("Compat: Duplicated PSSH found in initialization data, removing it.");
log.warn("DRM", "Duplicated PSSH found in initialization data, removing it.");
} else {
result.push(currentItem);
}
offset += len;
}

if (offset !== initData.length) {
log.warn("Compat: Unrecognized initialization data. Use as is.");
log.warn("DRM", "Unrecognized initialization data. Use as is.");
return [{ systemId: undefined, data: initData }];
}
return result;
Expand Down Expand Up @@ -151,7 +151,7 @@ export default function getInitData(
): IEncryptedEventData | null {
const { initData, initDataType, forceSessionRecreation } = encryptedEvent;
if (isNullOrUndefined(initData)) {
log.warn("Compat: No init data found on media encrypted event.");
log.warn("DRM", "No init data found on media encrypted event.");
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/compat/eme/load_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default async function loadSession(
session: IMediaKeySession,
sessionId: string,
): Promise<boolean> {
log.info("DRM: Load persisted session", sessionId);
log.info("DRM", "Load persisted session", { sessionId });
const isLoaded = await session.load(sessionId);

if (!isLoaded || session.keyStatuses.size > 0) {
Expand Down
8 changes: 5 additions & 3 deletions src/compat/eme/set_media_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ export function setMediaKeys(
const prom = emeImplementation
.setMediaKeys(mediaElement, mediaKeys)
.then(() => {
log.info("Compat: MediaKeys updated with success");
log.info("DRM", "MediaKeys updated with success");
})
.catch((err) => {
if (mediaKeys === null) {
log.error(
"Compat: Could not reset MediaKeys",
"DRM",
"Could not reset MediaKeys",
err instanceof Error ? err : "Unknown Error",
);
return;
}
log.error(
"Compat: Could not update MediaKeys",
"DRM",
"Could not update MediaKeys",
err instanceof Error ? err : "Unknown Error",
);
throw err;
Expand Down
3 changes: 2 additions & 1 deletion src/compat/event_listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ function createCompatibleEventListener(
});
} else {
log.warn(
`compat: element ${element.tagName}` +
"utils",
`element ${element.tagName}` +
" does not support any of these events: " +
prefixedEvents.join(", "),
);
Expand Down
2 changes: 1 addition & 1 deletion src/compat/is_codec_supported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const supportMap: Map<string, boolean> = new Map();
export default function isCodecSupported(mimeType: string): boolean {
if (isNullOrUndefined(MediaSource_)) {
if (isWorker) {
log.error("Compat: Cannot request codec support in a worker without MSE.");
log.error("mse", "Cannot request codec support in a worker without MSE.");
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/compat/make_vtt_cue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function makeCue(
if (startTime >= endTime) {
// IE/Edge will throw in this case.
// See issue #501
log.warn(`Compat: Invalid cue times: ${startTime} - ${endTime}`);
log.warn("text", `Invalid cue times: start after end.`, { startTime, endTime });
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/compat/on_height_width_change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function onHeightWidthChange(
if (_ResizeObserver !== undefined) {
const resizeObserver = new _ResizeObserver((entries) => {
if (entries.length === 0) {
log.error("Compat: Resized but no observed element.");
log.error("utils", "Resized but no observed element.");
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/compat/remove_cue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ export default function removeCue(
try {
track.removeCue(cue as TextTrackCue);
} catch (_err) {
log.warn("Compat: Could not remove cue from text track.");
log.warn("text", "Could not remove cue from text track.");
}
track.mode = trackMode;
return;
}
try {
track.removeCue(cue as TextTrackCue);
} catch (_err) {
log.warn("Compat: Could not remove cue from text track.");
log.warn("text", "Could not remove cue from text track.");
}
}
3 changes: 2 additions & 1 deletion src/core/adaptive/__tests__/buffer_based_chooser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ describe("BufferBasedChooser", () => {
expect(bbc.getLastEstimate()).toEqual(10);
expect(logger.info).toHaveBeenCalledTimes(1);
expect(logger.info).toHaveBeenCalledWith(
"ABR: Current Bitrate not found in the calculated levels",
"ABR",
"Current Bitrate not found in the calculated levels",
);
});

Expand Down
29 changes: 13 additions & 16 deletions src/core/adaptive/adaptive_representation_selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function createAdaptiveRepresentationSelector(
function _getBandwidthEstimator(bufferType: IBufferType): BandwidthEstimator {
const originalBandwidthEstimator = bandwidthEstimators[bufferType];
if (isNullOrUndefined(originalBandwidthEstimator)) {
log.debug("ABR: Creating new BandwidthEstimator for ", bufferType);
log.debug("ABR", "Creating new BandwidthEstimator", { bufferType });
const bandwidthEstimator = new BandwidthEstimator();
bandwidthEstimators[bufferType] = bandwidthEstimator;
return bandwidthEstimator;
Expand Down Expand Up @@ -426,11 +426,10 @@ function getEstimateReference(
chosenRepFromGuessMode !== null &&
chosenRepFromGuessMode.bitrate > currentBestBitrate
) {
log.debug(
"ABR: Choosing representation with guess-based estimation.",
chosenRepFromGuessMode.bitrate,
chosenRepFromGuessMode.id,
);
log.debug("ABR", "new guess-based estimate", {
bitrate: chosenRepFromGuessMode.bitrate,
representation: chosenRepFromGuessMode.id,
});
prevEstimate.update(
chosenRepFromGuessMode,
bandwidthEstimate,
Expand All @@ -445,11 +444,10 @@ function getEstimateReference(
knownStableBitrate,
};
} else if (chosenRepFromBufferSize !== null) {
log.debug(
"ABR: Choosing representation with buffer-based estimation.",
chosenRepFromBufferSize.bitrate,
chosenRepFromBufferSize.id,
);
log.debug("ABR", "new buffer-based estimate", {
bitrate: chosenRepFromBufferSize.bitrate,
representation: chosenRepFromBufferSize.id,
});
prevEstimate.update(
chosenRepFromBufferSize,
bandwidthEstimate,
Expand All @@ -467,11 +465,10 @@ function getEstimateReference(
knownStableBitrate,
};
} else {
log.debug(
"ABR: Choosing representation with bandwidth estimation.",
chosenRepFromBandwidth.bitrate,
chosenRepFromBandwidth.id,
);
log.debug("ABR", "new bandwidth estimate", {
bitrate: chosenRepFromBandwidth.bitrate,
representation: chosenRepFromBandwidth.id,
});
prevEstimate.update(
chosenRepFromBandwidth,
bandwidthEstimate,
Expand Down
Loading
Loading