-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
978d95d
commit 9671b0c
Showing
8 changed files
with
73 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...s/p2p-media-loader-core/src/peer-utils.ts → ...media-loader-core/src/utils/peer-utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Segment, Stream, StreamWithSegments } from "../index"; | ||
|
||
export function getStreamExternalId( | ||
manifestResponseUrl: string, | ||
stream: Readonly<Stream> | ||
): string { | ||
const { type, index } = stream; | ||
return `${manifestResponseUrl}-${type}-${index}`; | ||
} | ||
|
||
export function getSegmentFullExternalId( | ||
externalStreamId: string, | ||
externalSegmentId: string | ||
) { | ||
return `${externalStreamId}|${externalSegmentId}`; | ||
} | ||
|
||
export function getSegmentFromStreamsMap( | ||
streams: Map<string, StreamWithSegments>, | ||
segmentId: string | ||
): { segment: Segment; stream: StreamWithSegments } | undefined { | ||
for (const stream of streams.values()) { | ||
const segment = stream.segments.get(segmentId); | ||
if (segment) return { segment, stream }; | ||
} | ||
} | ||
|
||
export function getControlledPromise<T>() { | ||
let resolve: (value: T) => void; | ||
let reject: (reason?: unknown) => void; | ||
const promise = new Promise<T>((res, rej) => { | ||
resolve = res; | ||
reject = rej; | ||
}); | ||
|
||
return { | ||
promise, | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
resolve: resolve!, | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
reject: reject!, | ||
}; | ||
} |