Skip to content

Commit

Permalink
V1.3.0
Browse files Browse the repository at this point in the history
1000 commits
  • Loading branch information
Andrews54757 committed Mar 14, 2024
1 parent d9b757b commit f54a2f5
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"default_locale": "en",
"name": "__MSG_extension_name__",
"description": "__MSG_extension_description__",
"version": "1.2.25.1",
"version": "1.3.0",
"author": "Andrew S",
"options_ui": {
"page": "player/options/index.html",
Expand Down
3 changes: 2 additions & 1 deletion chrome/player/FastStreamClient.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {Utils} from './utils/Utils.mjs';
import {DefaultToolSettings} from './options/defaults/ToolSettings.mjs';
import {AudioAnalyzer} from './modules/analyzer/AudioAnalyzer.mjs';
import {PreviewFrameExtractor} from './modules/analyzer/PreviewFrameExtractor.mjs';
import {ReferenceTypes} from './enums/ReferenceTypes.mjs';


export class FastStreamClient extends EventEmitter {
Expand Down Expand Up @@ -390,7 +391,7 @@ export class FastStreamClient extends EventEmitter {
if (!newHasDownloadSpace && this.hasDownloadSpace) {
fragments.forEach((fragment) => {
if (fragment && fragment.status === DownloadStatus.DOWNLOAD_COMPLETE) {
fragment.addReference(1); // Don't free already downloaded fragments
fragment.addReference(ReferenceTypes.GRANDFATHERED); // Don't free already downloaded fragments
}
});
this.interfaceController.setStatusMessage('info', Localize.getMessage('player_buffer_storage_warning', [this.options.bufferBehind + this.options.bufferAhead]), 'warning', 5000);
Expand Down
6 changes: 6 additions & 0 deletions chrome/player/enums/ReferenceTypes.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const ReferenceTypes = {
GRANDFATHERED: 0,
ANALYZER: 1,
SAVER: 2,
MP4PLAYER: 3,
};
5 changes: 3 additions & 2 deletions chrome/player/modules/analyzer/VideoAnalyzer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {PlayerModes} from '../../enums/PlayerModes.mjs';
import {EventEmitter} from '../eventemitter.mjs';
import {EnvUtils} from '../../utils/EnvUtils.mjs';
import {VideoAligner} from './VideoAligner.mjs';
import {ReferenceTypes} from '../../enums/ReferenceTypes.mjs';

const AnalyzerStatus = {
IDLE: 'idle',
Expand Down Expand Up @@ -203,7 +204,7 @@ export class VideoAnalyzer extends EventEmitter {

dereferenceFragments(fragments) {
for (let i = 0; i < fragments.length; i++) {
fragments[i].removeReference(0);
fragments[i].removeReference(ReferenceTypes.ANALYZER);
}
fragments.length = 0;
}
Expand All @@ -228,7 +229,7 @@ export class VideoAnalyzer extends EventEmitter {
if (fragments[i].end > timeEnd) {
break;
}
fragments[i].addReference(0);
fragments[i].addReference(ReferenceTypes.ANALYZER);
reserved.push(fragments[i]);
}
return reserved;
Expand Down
4 changes: 2 additions & 2 deletions chrome/player/players/Fragment.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export class Fragment {
this.dataSize = null;
}

addReference(id) {
if (!this.references.includes(id)) {
addReference(id, duplicate = false) {
if (duplicate || !this.references.includes(id)) {
this.references.push(id);
}
}
Expand Down
7 changes: 4 additions & 3 deletions chrome/player/players/dash/DashPlayer.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {DefaultPlayerEvents} from '../../enums/DefaultPlayerEvents.mjs';
import {DownloadStatus} from '../../enums/DownloadStatus.mjs';
import {ReferenceTypes} from '../../enums/ReferenceTypes.mjs';
import {DashJS} from '../../modules/dash.mjs';
import {EmitterRelay, EventEmitter} from '../../modules/eventemitter.mjs';
import {Utils} from '../../utils/Utils.mjs';
Expand Down Expand Up @@ -395,12 +396,12 @@ export default class DashPlayer extends EventEmitter {
}

zippedFragments.forEach((data) => {
data.fragment.addReference(2);
data.fragment.addReference(ReferenceTypes.SAVER);
data.getEntry = async () => {
if (data.fragment.status !== DownloadStatus.DOWNLOAD_COMPLETE) {
await this.downloadFragment(data.fragment, -1);
}
data.fragment.removeReference(2);
data.fragment.removeReference(ReferenceTypes.SAVER);
return this.client.downloadManager.getEntry(data.fragment.getContext());
};
});
Expand Down Expand Up @@ -436,7 +437,7 @@ export default class DashPlayer extends EventEmitter {
};
} catch (e) {
zippedFragments.forEach((data) => {
data.fragment.removeReference(2);
data.fragment.removeReference(ReferenceTypes.SAVER);
});
throw e;
}
Expand Down
7 changes: 4 additions & 3 deletions chrome/player/players/hls/HLSPlayer.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {DefaultPlayerEvents} from '../../enums/DefaultPlayerEvents.mjs';
import {DownloadStatus} from '../../enums/DownloadStatus.mjs';
import {ReferenceTypes} from '../../enums/ReferenceTypes.mjs';
import {EmitterRelay, EventEmitter} from '../../modules/eventemitter.mjs';
import {Hls} from '../../modules/hls.mjs';
import {Utils} from '../../utils/Utils.mjs';
Expand Down Expand Up @@ -124,12 +125,12 @@ export default class HLSPlayer extends EventEmitter {
}

zippedFragments.forEach((data) => {
data.fragment.addReference(2);
data.fragment.addReference(ReferenceTypes.SAVER);
data.getEntry = async () => {
if (data.fragment.status !== DownloadStatus.DOWNLOAD_COMPLETE) {
await this.downloadFragment(data.fragment, -1);
}
data.fragment.removeReference(2);
data.fragment.removeReference(ReferenceTypes.SAVER);
return this.client.downloadManager.getEntry(data.fragment.getContext());
};
});
Expand Down Expand Up @@ -187,7 +188,7 @@ export default class HLSPlayer extends EventEmitter {
}
} catch (e) {
zippedFragments.forEach((data) => {
data.fragment.removeReference(2);
data.fragment.removeReference(ReferenceTypes.SAVER);
});
throw e;
}
Expand Down
18 changes: 10 additions & 8 deletions chrome/player/players/mp4/MP4Player.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {DefaultPlayerEvents} from '../../enums/DefaultPlayerEvents.mjs';
import {DownloadStatus} from '../../enums/DownloadStatus.mjs';
import {ReferenceTypes} from '../../enums/ReferenceTypes.mjs';
import {EmitterCancel, EmitterRelay, EventEmitter} from '../../modules/eventemitter.mjs';
import {MP4Box} from '../../modules/mp4box.mjs';
import {Utils} from '../../utils/Utils.mjs';
Expand Down Expand Up @@ -351,7 +352,7 @@ export default class MP4Player extends EventEmitter {

if (frag.end < time - this.options.backBufferLength) {
this.currentFragments.splice(i, 1);
frag.removeReference(3);
frag.removeReference(ReferenceTypes.MP4PLAYER);
i--;
}
}
Expand Down Expand Up @@ -392,17 +393,18 @@ export default class MP4Player extends EventEmitter {
if (!rangeHeader) {
console.log(entry.responseHeaders);
this.running = false;
this.emit(DefaultPlayerEvents.ERROR, 'No content range');
throw new Error('No content length');
} else {
this.fileLength = parseInt(rangeHeader.split('/')[1]);
}

this.fileLength = parseInt(rangeHeader.split('/')[1]);

this.initializeFragments();
}
// console.log("append", frag)
this.mp4box.appendBuffer(data);
this.currentFragments.push(frag);
frag.addReference(3);
frag.addReference(ReferenceTypes.MP4PLAYER, true);
this.runLoad();
},
onProgress: (stats, context, data, xhr) => {
Expand Down Expand Up @@ -507,7 +509,7 @@ export default class MP4Player extends EventEmitter {
}

this.currentFragments.forEach((frag) => {
frag.removeReference(3);
frag.removeReference(ReferenceTypes.MP4PLAYER);
});

this.currentFragments.length = 0;
Expand Down Expand Up @@ -711,7 +713,7 @@ export default class MP4Player extends EventEmitter {
if (!options.partialSave) {
for (let i = 0; i < lastFrag; i++) {
const frag = frags[i];
frag.addReference(2);
frag.addReference(ReferenceTypes.SAVER);
}
}

Expand All @@ -720,7 +722,7 @@ export default class MP4Player extends EventEmitter {
const frag = frags[i];
if (!options.partialSave) {
await this.downloadFragment(frag, -1);
frag.removeReference(2);
frag.removeReference(ReferenceTypes.SAVER);
}
if (frag.status === DownloadStatus.DOWNLOAD_COMPLETE) {
const entry = this.client.downloadManager.getEntry(frag.getContext());
Expand All @@ -743,7 +745,7 @@ export default class MP4Player extends EventEmitter {
} catch (e) {
for (let i = 0; i < lastFrag; i++) {
const frag = frags[i];
frag.removeReference(2);
frag.removeReference(ReferenceTypes.SAVER);
}
writer.abort();
throw e;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "faststream",
"version": "1.2.25.1",
"version": "1.3.0",
"description": "Stream videos without buffering",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down

0 comments on commit f54a2f5

Please sign in to comment.