Interface: MediaProcessorInterface
Interface definition for media processor instances. When using Web workers the application should define and use a bridge class that implements this interface. See an example of using the library this way here.
Implemented by
Methods
transform
▸ transform(readable, writable): Promise<void>
Starts running the tranformation logic performed by the media processor instance.
In case of bridging to WebWorker the function should post message to the Worker with the readable and writable.
Parameters
| Name | Type | Description |
|---|---|---|
readable | ReadableStream<any> | Readable stream associated to the media source being processed. |
writable | WritableStream<any> | Writable stream associated to the resulting media once processed. |
Returns
Promise<void>
- In case of using a Web worker the promise should be completed only after the worker was completed.
▸ transform(track): Promise<MediaStreamTrack>
Starts running the tranformation logic performed by the media processor instance. In case of bridging to WebWorker the function should post message to the Worker with the track.
Parameters
| Name | Type | Description |
|---|---|---|
track | MediaStreamTrack | MeadiaStreamTrack (audio or video) to be processed. |
Returns
Promise<MediaStreamTrack>
- In case of using a Web worker the promise should be completed only after the worker was completed.
destroy
▸ destroy(): Promise<void>
Stops running the tranformation logic performed by the media processor instance. In case of using a Web worker the method should post a message to the Worker with the destroy message.
Returns
Promise<void>
- In case of using a Web worker the promise should be completed only after the worker was completed.
setSourceMetadata
▸ Optional setSourceMetadata(metadata): void | Promise<void>
Optional. Provides the processor with metadata about the source track that
cannot be recovered from the individual VideoFrames once processing has
begun. This is primarily used to preserve the source's display orientation:
on some platforms (notably WebKit inside a Web Worker) MediaStreamTrackProcessor
exposes frames in their raw coded orientation with no rotation metadata,
so the intended display dimensions — only known here on the main thread from
track.getSettings() — must be forwarded so the transformer can restore the
correct orientation on its output.
Implementations that do not need this metadata may omit the method.
Parameters
| Name | Type | Description |
|---|---|---|
metadata | SourceTrackMetadata | Source track metadata (currently the display width/height). |
Returns
void | Promise<void>