Class

Media

Media(logs, port, packetHandler) → {Media}

Basic class to process audio streams

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.

View Source Media.js, line 11

The new Media object instance

Media

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.

View Source Media.js, line 65

The arguments.

Array.<string>

# destroy() → {Promise.<void>}

Kill the ffmpeg instance and close the socket.

View Source Media.js, line 112

A promise resolving when the udp4 socket closed.

Promise.<void>

# getMediaTrack() → {MediaStreamTrack}

Returns the current mediasoup media track

View Source Media.js, line 73

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

View Source Media.js, line 82

void

# playStream(stream) → {void}

Pipe a ReadStream into the ffmpeg process.

Parameters:
Name Type Description
stream ReadableStream

The stream to pipe.

View Source Media.js, line 103

void

# writeStreamChunk(chunk) → {void}

Writes a chunk of data into the ffmpeg process.

Parameters:
Name Type Description
chunk object

The datachunk to write.

View Source Media.js, line 93

void