Constructor
new TransmuxerProxy(innerTransmuxernon-null, workerUrlopt)
A proxy transmuxer that delegates transmux() calls to a Web Worker. Synchronous methods (isSupported, convertCodecs, getOriginalMimeType) are handled on the main thread by the inner transmuxer. Only the heavy transmux() work is offloaded to the worker. The worker URL must be supplied by the integrating application via the `mediaSource.transmuxWorkerUrl` config option. The library does not attempt to discover it. If the URL is empty or the worker cannot be created, the proxy falls back to main-thread transmuxing.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
innerTransmuxer |
shaka.extern.Transmuxer | The real transmuxer to use for sync methods and as fallback. | |
workerUrl |
string |
<optional> |
URL of the standalone transmuxer worker script. When empty, the proxy uses main-thread transmuxing. |
- Implements:
- Source:
Members
activeInstances_ :Map<number, !shaka.transmuxer.TransmuxerProxy>
Map of active instances keyed by ID, for routing worker messages.
Type:
- Map<number, !shaka.transmuxer.TransmuxerProxy>
sharedWorker_ :Worker
Shared Worker instance used by all TransmuxerProxy instances.
Type:
- Worker
TIMEOUT_MS_ :number
Timeout in milliseconds for a worker transmux response. If the worker does
not respond within this time, the request is rejected and future calls fall
back to the main thread.
Type:
- number
innerTransmuxer_ :shaka.extern.Transmuxer
Type:
pendingRequests_ :Map<number, {resolve: function(*), reject: function(*), timer: shaka.util.Timer}>
Maps request IDs to pending promise resolvers and their timeout timers.
Type:
- Map<number, {resolve: function(*), reject: function(*), timer: shaka.util.Timer}>
Methods
getOrCreateWorker_(workerUrlOverride) → {Worker}
Gets or creates the shared worker. Returns null if the worker cannot be
created (unsupported device, missing script URL, or creation error).
Parameters:
| Name | Type | Description |
|---|---|---|
workerUrlOverride |
string |
Returns:
- Type
- Worker
terminateWorker_(message)
Marks all active instances as failed, rejects their pending requests, and
shuts down the shared worker.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
string | Error message for rejected promises. |
convertCodecs(contentType, mimeType) → {string}
For any stream, convert its codecs to MP4 codecs.
Parameters:
| Name | Type | Description |
|---|---|---|
contentType |
string | |
mimeType |
string |
- Implements:
- Source:
Returns:
- Type
- string
destroy()
Destroy
- Implements:
- Source:
getOriginalMimeType() → {string}
Returns the original mimetype of the transmuxer.
- Implements:
- Source:
Returns:
- Type
- string
isSupported(mimeType, contentTypeopt) → {boolean}
Check if the mime type and the content type is supported.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
mimeType |
string | ||
contentType |
string |
<optional> |
- Implements:
- Source:
Returns:
- Type
- boolean
onWorkerMessage_(msgnon-null)
Handles messages from the shared worker for this instance.
Parameters:
| Name | Type | Description |
|---|---|---|
msg |
Object |
transmux(data, stream, referencenullable, duration, contentType) → {Promise<(!Uint8Array|!shaka.extern.TransmuxerOutput)>}
Transmux a input data to MP4.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
BufferSource | ||
stream |
shaka.extern.Stream | ||
reference |
shaka.media.SegmentReference |
<nullable> |
The segment reference, or null for init segments |
duration |
number | ||
contentType |
string |
- Implements:
- Source:
Returns:
If you
only want to return the result, use Uint8Array, if you want to separate
the initialization segment and the data segment, you have to use
shaka.extern.TransmuxerOutput
- Type
- Promise<(!Uint8Array|!shaka.extern.TransmuxerOutput)>