Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add support for custom swarmId via URL Search Parameters in Demo Component #417

Merged
merged 48 commits into from
Sep 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
54ed8fd
refactor: segment-storage.ts
DimaDemchenko Aug 16, 2024
36097e3
refactor: optimize segment storage deletion logic
DimaDemchenko Aug 16, 2024
750c76c
refactor: Implemented segments-storage interface
DimaDemchenko Aug 19, 2024
bf96747
refactor: update segment locking logic in HybridLoader
DimaDemchenko Aug 19, 2024
7772e57
refactor: hasSegment function
DimaDemchenko Aug 19, 2024
5bd7497
refactor: Remove unused segment storage related code
DimaDemchenko Aug 20, 2024
b15651b
refactor: Update segment storage initialization
DimaDemchenko Aug 21, 2024
562cd4e
refactor: P2P configuration
DimaDemchenko Aug 21, 2024
6c5e3cd
refactor: Custom segment storage handling
DimaDemchenko Aug 22, 2024
7532a4e
refactor: Remove async keyword from destroy method in segments-storag…
DimaDemchenko Aug 22, 2024
290bdd3
fix: lint error
DimaDemchenko Aug 22, 2024
7c6ed7b
refactor: Update segment storage initialization and handling
DimaDemchenko Aug 23, 2024
66452fd
refactor: Segments storage clear logic
DimaDemchenko Aug 23, 2024
d8b9a2e
refactor: segments-storage-interface
DimaDemchenko Aug 23, 2024
4fbb299
refactor: Files structure
DimaDemchenko Aug 23, 2024
206c526
refactor: Improve clear segments storage logic
DimaDemchenko Aug 23, 2024
ec011f1
docs: Add ISegmentStorage docs
DimaDemchenko Aug 23, 2024
590c755
refactor: Improve stream time window handling in SegmentsMemoryStorage
DimaDemchenko Aug 23, 2024
091ee45
refactor: segments-storage interface
DimaDemchenko Aug 27, 2024
d0d318c
refactor: Update initialize segment storage logic
DimaDemchenko Aug 27, 2024
1a0f65a
refactor: Update SegmentsStorage interface
DimaDemchenko Sep 6, 2024
4c3b74f
refactor: Added validation of customSegmentStorage from config
DimaDemchenko Sep 6, 2024
a2d14e8
refactor: Swap func params in correct order
DimaDemchenko Sep 6, 2024
f22e27a
refactor: Update segment storage classes and interfaces
DimaDemchenko Sep 9, 2024
631dfd2
fix: imports
DimaDemchenko Sep 9, 2024
213c32a
refactor: Naming
DimaDemchenko Sep 9, 2024
337d264
refactor: Improve segment storage event handling
DimaDemchenko Sep 9, 2024
60b4e2e
refactor: Optimize segment memory storage
DimaDemchenko Sep 13, 2024
ddeec04
refactor: Optimize segment memory storage and update segment storage …
DimaDemchenko Sep 13, 2024
84efce1
refactor: Update segment memory storage limit configuration
DimaDemchenko Sep 13, 2024
531e866
refactor: Add segment categories in clear logic
DimaDemchenko Sep 16, 2024
cf801ca
refactor: Update segment memory storage limit description
DimaDemchenko Sep 16, 2024
806b608
refactor: Simplify segment memory storage limit configuration
DimaDemchenko Sep 16, 2024
9322fea
refactor: Simplify segment memory storage limit configuration and opt…
DimaDemchenko Sep 17, 2024
b3ce95a
refactor: Improve clear logic and added getAvailableSpace func
DimaDemchenko Sep 19, 2024
a3f49a8
refactor: Simplify segment memory storage limit configuration and opt…
DimaDemchenko Sep 19, 2024
c504d89
refactor: Disable random http downloads if memory storage is running …
DimaDemchenko Sep 19, 2024
8a631e7
refactor: Clear logic
DimaDemchenko Sep 20, 2024
a8a7e11
Revert "refactor: Clear logic"
DimaDemchenko Sep 20, 2024
2a60c3d
refactor: Improve segment memory storage and clear logic
DimaDemchenko Sep 20, 2024
e3588dd
refactor: Improve segment memory storage
DimaDemchenko Sep 23, 2024
074cfe4
refactor: Naming
DimaDemchenko Sep 24, 2024
ff3645d
refactor: Improve segment memory storage interface and getUsage() logic
DimaDemchenko Sep 24, 2024
e93de6b
Refactor segment-memory-storage.ts: Swap parameters in getStoredSegme…
DimaDemchenko Sep 24, 2024
6be67bc
refactor: Swap parameters in getSegmentData()
DimaDemchenko Sep 24, 2024
dbb2480
refactor: Update setSegmentChangeCallback parameter name
DimaDemchenko Sep 24, 2024
9afd2b5
feat: Support custom swarmId from URL Search Params
DimaDemchenko Sep 26, 2024
4a6ea5f
Merge branch 'main' into feat/swarmIdFromUrlInDemo
DimaDemchenko Sep 26, 2024
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
Prev Previous commit
Next Next commit
refactor: Improve stream time window handling in SegmentsMemoryStorage
DimaDemchenko committed Aug 23, 2024
commit 590c75521c79fc75a27632032fcd4812745870f9
Original file line number Diff line number Diff line change
@@ -156,15 +156,20 @@ export class SegmentsMemoryStorage implements ISegmentsStorage {

for (const [storageId, segmentData] of this.cache.entries()) {
const { endTime, streamType, streamId } = segmentData;
const highDemandTimeWindow = this.getHighDemandTimeWindow(streamType);
const highDemandTimeWindow = this.getStreamTimeWindow(
streamType,
"highDemandTimeWindow",
);

let shouldRemove = false;

if (isLiveStream) {
shouldRemove = currentPlayback > highDemandTimeWindow + endTime;
} else {
const httpDownloadTimeWindow =
this.getHttpDownloadTimeWindow(streamType);
const httpDownloadTimeWindow = this.getStreamTimeWindow(
streamType,
"httpDownloadTimeWindow",
);
shouldRemove =
currentPlayback > endTime + httpDownloadTimeWindow * 1.05;
}
@@ -235,24 +240,19 @@ export class SegmentsMemoryStorage implements ISegmentsStorage {
this.eventTarget.dispatchEvent(`onStorageUpdated-${streamId}`);
}

private getHighDemandTimeWindow(streamType: string) {
if (!this.mainStreamConfig || !this.secondaryStreamConfig) {
return 0;
}

return streamType === "main"
? this.mainStreamConfig.highDemandTimeWindow
: this.secondaryStreamConfig.highDemandTimeWindow;
}

private getHttpDownloadTimeWindow(streamType: string) {
private getStreamTimeWindow(
streamType: string,
configKey: "highDemandTimeWindow" | "httpDownloadTimeWindow",
): number {
if (!this.mainStreamConfig || !this.secondaryStreamConfig) {
return 0;
}

return streamType === "main"
? this.mainStreamConfig.httpDownloadTimeWindow
: this.secondaryStreamConfig.httpDownloadTimeWindow;
const config =
streamType === "main"
? this.mainStreamConfig
: this.secondaryStreamConfig;
return config[configKey];
}

public destroy() {