Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SivanA-Kaltura committed Jun 16, 2024
1 parent de15dbc commit dea51c9
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 87 deletions.
64 changes: 35 additions & 29 deletions src/dash-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,28 +790,28 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
// called when a resource is downloaded
this.shaka!.getNetworkingEngine()?.registerResponseFilter((type, response) => {
switch (type) {
case shaka.net.NetworkingEngine.RequestType.SEGMENT:
this._trigger(EventType.FRAG_LOADED, {
miliSeconds: response.timeMs,
bytes: response.data.byteLength,
url: response.uri
});
if (this.isLive()) {
this._dispatchNativeEvent(EventType.DURATION_CHANGE);
}
break;
case shaka.net.NetworkingEngine.RequestType.MANIFEST:
this._parseManifest(response.data);
this._playbackActualUri = response.uri;
this._trigger(EventType.MANIFEST_LOADED, {miliSeconds: response.timeMs});
setTimeout(() => {
this._isLive = this._isLive || (this.shaka?.isLive() as boolean);
if (this._isLive && !this.shaka?.isLive() && !this._isStaticLive && this._config.switchDynamicToStatic) {
case shaka.net.NetworkingEngine.RequestType.SEGMENT:

Check failure on line 793 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 6 spaces but found 8
this._trigger(EventType.FRAG_LOADED, {

Check failure on line 794 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 8 spaces but found 10
miliSeconds: response.timeMs,

Check failure on line 795 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 10 spaces but found 12
bytes: response.data.byteLength,

Check failure on line 796 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 10 spaces but found 12
url: response.uri

Check failure on line 797 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 10 spaces but found 12
});

Check failure on line 798 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 8 spaces but found 10
if (this.isLive()) {

Check failure on line 799 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 8 spaces but found 10
this._dispatchNativeEvent(EventType.DURATION_CHANGE);

Check failure on line 800 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 10 spaces but found 12
}

Check failure on line 801 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 8 spaces but found 10
break;

Check failure on line 802 in src/dash-adapter.ts

View workflow job for this annotation

GitHub Actions / lint / running-tests (ubuntu-latest)

Expected indentation of 8 spaces but found 10
case shaka.net.NetworkingEngine.RequestType.MANIFEST:
this._parseManifest(response.data);
this._playbackActualUri = response.uri;
this._trigger(EventType.MANIFEST_LOADED, {miliSeconds: response.timeMs});
setTimeout(() => {
this._isLive = this._isLive || (this.shaka?.isLive() as boolean);
if (this._isLive && !this.shaka?.isLive() && !this._isStaticLive && this._config.switchDynamicToStatic) {
this._sourceObj!.url = response.uri;
this._switchFromDynamicToStatic();
}
});
break;
}
});
break;
}
});
}
Expand Down Expand Up @@ -939,19 +939,25 @@ export default class DashAdapter extends BaseMediaSourceAdapter {
public destroy(): Promise<void> {
this._isDestroyInProgress = true;

let shakaInstanceToDestroy;
if (this.shaka) {
this.shaka.unload();
return new Promise(async (resolve, reject) => {
let shakaInstanceToDestroy;

if (!this.assetCache?.list().length) {
shakaInstanceToDestroy = this.shaka;
if (this.shaka) {
// explicitly pass undefined to restore the default drm configuration
this.shaka.configure('drm', undefined);

DashAdapter._shakaInstanceMap.delete(this._videoElement.id);
DashAdapter._assetCacheMap.delete(this._videoElement.id);
if (this.assetCache?.list().length) {
if (this._videoElement.src) {
await this.shaka.unload();
}
await this.shaka.detach();
} else {
shakaInstanceToDestroy = this.shaka;
DashAdapter._shakaInstanceMap.delete(this._videoElement.id);
DashAdapter._assetCacheMap.delete(this._videoElement.id);
}
}
}

return new Promise((resolve, reject) => {
super.destroy().then(() => {
DashAdapter._logger.debug('destroy');
this._loadPromise = undefined;
Expand Down
Loading

0 comments on commit dea51c9

Please sign in to comment.