Constructor
# new Media(logs, port, packetHandler) → {Media}
Init the media object
Parameters:
Name | Type | Default | Description |
---|---|---|---|
logs |
boolean
|
false | Wether or not to output logs |
port |
number
|
5030 | A ffmpeg rtp port that this instance will be using. |
packetHandler |
PacketHandler
|
(packet)=>{this.track.writeRtp(packet);} | The function that determines how audio packets are handled. |
The new Media object instance
Methods
# createFfmpegArgs(start) → {Array.<string>}
Returns an array of arguments that can be passed to ffmpeg
Parameters:
Name | Type | Default | Description |
---|---|---|---|
start |
string
|
"00:00:00" | The position in the audio to start the conversion. |
The arguments.
Array.<string>
# destroy() → {Promise.<void>}
Kill the ffmpeg instance and close the socket.
A promise resolving when the udp4 socket closed.
Promise.<void>
# getMediaTrack() → {MediaStreamTrack}
Returns the current mediasoup media track
The mediasoup MediaStreamTrack
MediaStreamTrack
# playFile(path) → {void}
Load and process an audio file
Parameters:
Name | Type | Description |
---|---|---|
path |
string
|
The file path of the file |
void
# playStream(stream) → {void}
Pipe a ReadStream into the ffmpeg process.
Parameters:
Name | Type | Description |
---|---|---|
stream |
ReadableStream
|
The stream to pipe. |
void
# writeStreamChunk(chunk) → {void}
Writes a chunk of data into the ffmpeg process.
Parameters:
Name | Type | Description |
---|---|---|
chunk |
object
|
The datachunk to write. |
void