Skip to content

Commit

Permalink
Revert "fix(safari): video not starting because key are never conside…
Browse files Browse the repository at this point in the history
…red usable for a track"

This reverts commit 48c255d.
  • Loading branch information
peaBerberian committed Aug 12, 2024
1 parent 2402edf commit ac1d54c
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 36 deletions.
29 changes: 1 addition & 28 deletions src/main_thread/decrypt/content_decryptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import type { IMediaElement } from "../../compat/browser_compatibility_types";
import { isSafariDesktop } from "../../compat/browser_detection";
import type { ICustomMediaKeys, ICustomMediaKeySystemAccess } from "../../compat/eme";
import eme, { getInitData } from "../../compat/eme";
import config from "../../config";
Expand Down Expand Up @@ -59,10 +58,6 @@ import {
} from "./utils/key_id_comparison";
import type KeySessionRecord from "./utils/key_session_record";

export interface IContext {
isDirectFile: boolean;
}

/**
* Module communicating with the Content Decryption Module (or CDM) to be able
* to decrypt contents.
Expand Down Expand Up @@ -136,10 +131,6 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
*/
private _supportedCodecWhenEncrypted: ICodecSupportList;

/**
* Context information such a the transport being used.
*/
private _context: IContext;
/**
* `true` if the EME API are available on the current platform according to
* the default EME implementation used.
Expand All @@ -164,11 +155,7 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
* configurations. It will choose the appropriate one depending on user
* settings and browser support.
*/
constructor(
mediaElement: IMediaElement,
ksOptions: IKeySystemOption[],
context: IContext,
) {
constructor(mediaElement: IMediaElement, ksOptions: IKeySystemOption[]) {
super();

log.debug("DRM: Starting ContentDecryptor logic.");
Expand All @@ -184,7 +171,6 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
data: null,
};
this._supportedCodecWhenEncrypted = [];
this._context = context;
this.error = null;

eme.onEncrypted(
Expand Down Expand Up @@ -731,19 +717,6 @@ export default class ContentDecryptor extends EventEmitter<IContentDecryptorEven
mediaKeysData: IAttachedMediaKeysData,
): boolean {
const { stores, options } = mediaKeysData;
/**
* On Safari using Directfile, the old EME implementation triggers
* the "webkitneedkey" event instead of "encrypted". There's an issue in Safari
* where "webkitneedkey" fires too early before all tracks are added from an HLS playlist.
* Safari incorrectly assumes some keys are missing for these tracks,
* leading to repeated "webkitneedkey" events. Because RxPlayer recognizes
* it already has a session for these keys and ignores the events,
* the content remains frozen. To resolve this, we handle the event
* assuming no session exists for the key.
*/
if (this._context.isDirectFile && isSafariDesktop) {
return false;
}

/**
* If set, a currently-used key session is already compatible to this
Expand Down
1 change: 0 additions & 1 deletion src/main_thread/init/directfile_content_initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export default class DirectFileContentInitializer extends ContentInitializer {
onBlackListProtectionData: noop,
onKeyIdsCompatibilityUpdate: noop,
},
{ isDirectFile: true },
cancelSignal,
);

Expand Down
1 change: 0 additions & 1 deletion src/main_thread/init/media_source_content_initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ export default class MediaSourceContentInitializer extends ContentInitializer {
}
},
},
{ isDirectFile: false },
initCanceller.signal,
);

Expand Down
4 changes: 1 addition & 3 deletions src/main_thread/init/multi_thread_content_initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1173,9 +1173,7 @@ export default class MultiThreadContentInitializer extends ContentInitializer {
return createEmeDisabledReference("EME API not available on the current page.");
}
log.debug("MTCI: Creating ContentDecryptor");
const contentDecryptor = new ContentDecryptor(mediaElement, keySystems, {
isDirectFile: false,
});
const contentDecryptor = new ContentDecryptor(mediaElement, keySystems);
const drmStatusRef = new SharedReference<IDrmInitializationStatus>(
{
initializationState: { type: "uninitialized", value: null },
Expand Down
4 changes: 1 addition & 3 deletions src/main_thread/init/utils/initialize_content_decryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type { CancellationSignal } from "../../../utils/task_canceller";
import { ContentDecryptorState } from "../../decrypt";
import type IContentDecryptor from "../../decrypt";
import type { IProcessedProtectionData } from "../../decrypt";
import type { IContext } from "../../decrypt/content_decryptor";

/**
* Initialize content decryption capabilities on the given `HTMLMediaElement`.
Expand Down Expand Up @@ -47,7 +46,6 @@ export default function initializeContentDecryption(
}) => void;
onCodecSupportUpdate?: () => void;
},
context: IContext,
cancelSignal: CancellationSignal,
): {
statusRef: IReadOnlySharedReference<IDrmInitializationStatus>;
Expand Down Expand Up @@ -84,7 +82,7 @@ export default function initializeContentDecryption(
}

log.debug("Init: Creating ContentDecryptor");
const contentDecryptor = new ContentDecryptor(mediaElement, keySystems, context);
const contentDecryptor = new ContentDecryptor(mediaElement, keySystems);

const onStateChange = (state: ContentDecryptorState) => {
if (state > ContentDecryptorState.Initializing) {
Expand Down

0 comments on commit ac1d54c

Please sign in to comment.