Class: MediaElement

(abstract) core/abstracts.MediaElement()

The basic building block of the media server, that can be interconnected inside a pipeline.

A MediaElement is a module that capability, and that is able to exchange media with other MediaElements through an internal element called pad.

A pad can be defined as an input or output interface. Input pads are called sinks, and it's where the media elements receive media from other media elements. Output interfaces are called sources, and it's the pad used by the media element to feed media to other media elements. There can be only one sink pad per media element. On the other hand, the number of source pads is unconstrained. This means that a certain media element can receive media only from one element at a time, while it can send media to many others. Pads are created on demand, when the connect method is invoked. When two media elements are connected, one media pad is created for each type of media connected. For example, if you connect AUDIO and VIDEO between two media elements, each one will need to create two new pads: one for AUDIO and one for VIDEO.

When media elements are connected, it can be the case that the encoding required in both input and output pads is not the same, and thus it needs to be transcoded. This is something that is handled transparently by the MediaElement internals, but such transcoding has a toll in the form of a higher CPU load, so connecting MediaElements that need media encoded in different formats is something to consider as a high load operation. The event `MediaTranscodingStateChange` allows to inform the client application of whether media transcoding is being enabled or not inside any MediaElement object.

Extends

Members

(static) constructorParams

Source:

(static) events

Source:

Methods

(static) connect(sink, mediaTypeopt, sourceMediaDescriptionopt, sinkMediaDescriptionopt, callbackopt) → {external:Promise}

Connects two elements, with the media flowing from left to right.

The element that invokes the connect will be the source of media, creating one sink pad for each type of media connected. The element given as parameter to the method will be the sink, and it will create one sink pad per media type connected.

If otherwise not specified, all types of media are connected by default (AUDIO, VIDEO and DATA). It is recommended to connect the specific types of media if not all of them will be used. For this purpose, the connect method can be invoked more than once on the same two elements, but with different media types.

The connection is unidirectional. If a bidirectional connection is desired, the position of the media elements must be inverted. For instance, webrtc1.connect(webrtc2) is connecting webrtc1 as source of webrtc2. In order to create a WebRTC one-2one conversation, the user would need to specify the connection on the other direction with webrtc2.connect(webrtc1).

Even though one media element can have one sink pad per type of media, only one media element can be connected to another at a given time. If a media element is connected to another, the former will become the source of the sink media element, regardless whether there was another element connected or not.

Parameters:
Name Type Attributes Description
sink module:core/abstracts.MediaElement the target MediaElement that will
mediaType module:core/complexTypes.MediaType <optional>
the MediaType of the pads that will be connected
sourceMediaDescription external:String <optional>
A textual description of the media source. Currently not used, aimed mainly for module:core/abstracts.MediaElement#MediaType.DATA sources
sinkMediaDescription external:String <optional>
A textual description of the media source. Currently not used, aimed mainly for module:core/abstracts.MediaElement#MediaType.DATA sources
callback module:core/abstracts.MediaElement~connectCallback <optional>
Source:
Returns:
Type
external:Promise

(static) disconnect(sink, mediaTypeopt, sourceMediaDescriptionopt, sinkMediaDescriptionopt, callbackopt) → {external:Promise}

Disconnects two media elements. This will release the source pads of the source media element, and the sink pads of the sink media element.
Parameters:
Name Type Attributes Description
sink module:core/abstracts.MediaElement the target MediaElement that will
mediaType module:core/complexTypes.MediaType <optional>
the MediaType of the pads that will be connected
sourceMediaDescription external:String <optional>
A textual description of the media source. Currently not used, aimed mainly for module:core/abstracts.MediaElement#MediaType.DATA sources
sinkMediaDescription external:String <optional>
A textual description of the media source. Currently not used, aimed mainly for module:core/abstracts.MediaElement#MediaType.DATA sources
callback module:core/abstracts.MediaElement~disconnectCallback <optional>
Source:
Returns:
Type
external:Promise

(static) getGstreamerDot(detailsopt, callbackopt) → {external:Promise}

Return a .dot file describing the topology of the media element.

The element can be queried for certain type of data:

  • SHOW_ALL: default value
  • SHOW_CAPS_DETAILS
  • SHOW_FULL_PARAMS
  • SHOW_MEDIA_TYPE
  • SHOW_NON_DEFAULT_PARAMS
  • SHOW_STATES
  • SHOW_VERBOSE
Parameters:
Name Type Attributes Description
details module:core/complexTypes.GstreamerDotDetails <optional>
Details of graph
callback module:core/abstracts.MediaElement~getGstreamerDotCallback <optional>
Source:
Returns:
Type
external:Promise

(static) getSinkConnections(mediaTypeopt, descriptionopt, callbackopt) → {external:Promise}

Gets information about the source pads of this media element.

Since source pads connect to other media element's sinks, this is formally the sink of media from the element's perspective. Media can be filtered by type, or by the description given to the pad though which both elements are connected.

Parameters:
Name Type Attributes Description
mediaType module:core/complexTypes.MediaType <optional>
One of module:core/abstracts.MediaElement#MediaType.AUDIO, module:core/abstracts.MediaElement#MediaType.VIDEO or module:core/abstracts.MediaElement#MediaType.DATA
description external:String <optional>
A textual description of the media source. Currently not used, aimed mainly for module:core/abstracts.MediaElement#MediaType.DATA sources
callback module:core/abstracts.MediaElement~getSinkConnectionsCallback <optional>
Source:
Returns:
Type
external:Promise

(static) getSourceConnections(mediaTypeopt, descriptionopt, callbackopt) → {external:Promise}

Gets information about the sink pads of this media element.

Since sink pads are the interface through which a media element gets it's media, whatever is connected to an element's sink pad is formally a source of media. Media can be filtered by type, or by the description given to the pad though which both elements are connected.

Parameters:
Name Type Attributes Description
mediaType module:core/complexTypes.MediaType <optional>
One of module:core/abstracts.MediaElement#MediaType.AUDIO, module:core/abstracts.MediaElement#MediaType.VIDEO or module:core/abstracts.MediaElement#MediaType.DATA
description external:String <optional>
A textual description of the media source. Currently not used, aimed mainly for module:core/abstracts.MediaElement#MediaType.DATA sources
callback module:core/abstracts.MediaElement~getSourceConnectionsCallback <optional>
Source:
Returns:
Type
external:Promise

(static) getStats(mediaTypeopt, callbackopt) → {external:Promise}

Gets the statistics related to an endpoint. If no media type is specified, it
Parameters:
Name Type Attributes Description
mediaType module:core/complexTypes.MediaType <optional>
One of module:core/abstracts.MediaElement#MediaType.AUDIO or module:core/abstracts.MediaElement#MediaType.VIDEO
callback module:core/abstracts.MediaElement~getStatsCallback <optional>
Source:
Returns:
Type
external:Promise

(static) isMediaFlowingIn(mediaType, sinkMediaDescriptionopt, callbackopt) → {external:Promise}

This method indicates whether the media element is receiving media of a certain type. The media sink pad can be identified individually, if needed. It is only supported for AUDIO and VIDEO types, raising a MEDIA_OBJECT_ILLEGAL_PARAM_ERROR otherwise. If the pad indicated does not exist, if will return false.
Parameters:
Name Type Attributes Description
mediaType module:core/complexTypes.MediaType One of module:core/abstracts.MediaElement#MediaType.AUDIO or module:core/abstracts.MediaElement#MediaType.VIDEO
sinkMediaDescription external:String <optional>
Description of the sink
callback module:core/abstracts.MediaElement~isMediaFlowingInCallback <optional>
Source:
Returns:
Type
external:Promise

(static) isMediaFlowingOut(mediaType, sourceMediaDescriptionopt, callbackopt) → {external:Promise}

This method indicates whether the media element is emitting media of a certain type. The media source pad can be identified individually, if needed.
Parameters:
Name Type Attributes Description
mediaType module:core/complexTypes.MediaType One of module:core/abstracts.MediaElement#MediaType.AUDIO or module:core/abstracts.MediaElement#MediaType.VIDEO
sourceMediaDescription external:String <optional>
Description of the source
callback module:core/abstracts.MediaElement~isMediaFlowingOutCallback <optional>
Source:
Returns:
Type
external:Promise

(static) isMediaTranscoding(mediaType, binNameopt, callbackopt) → {external:Promise}

Indicates whether this media element is actively transcoding between input and output pads. This operation is only supported for AUDIO and VIDEO media types, raising a MEDIA_OBJECT_ILLEGAL_PARAM_ERROR otherwise. The internal GStreamer processing bin can be indicated, if needed; if the bin doesn't exist, the return value will be FALSE.
Parameters:
Name Type Attributes Description
mediaType module:core/complexTypes.MediaType One of module:core/abstracts.MediaElement#MediaType.AUDIO or module:core/abstracts.MediaElement#MediaType.VIDEO
binName external:String <optional>
Internal name of the processing bin, as previously given by MediaTranscodingStateChange.
callback module:core/abstracts.MediaElement~isMediaTranscodingCallback <optional>
Source:
Returns:
Type
external:Promise

(static) setAudioFormat(caps, callbackopt) → {external:Promise}

Set the type of data for the audio stream.

MediaElements that do not support configuration of audio capabilities will throw a MEDIA_OBJECT_ILLEGAL_PARAM_ERROR exception.

NOTE: This method is not implemented yet by the Media Server to do anything useful.

Parameters:
Name Type Attributes Description
caps module:core/complexTypes.AudioCaps The format for the stream of audio
callback module:core/abstracts.MediaElement~setAudioFormatCallback <optional>
Source:
Returns:
Type
external:Promise

(static) setOutputBitrate(bitrate, callbackopt) → {external:Promise}

Parameters:
Name Type Attributes Description
bitrate external:Integer Configure the enconding media bitrate in bps
callback module:core/abstracts.MediaElement~setOutputBitrateCallback <optional>
Deprecated:
  • Allows change the target bitrate for the media output, if the media is encoded using VP8 or H264. This method only works if it is called before the media starts to flow.
Source:
Returns:
Type
external:Promise

(static) setVideoFormat(caps, callbackopt) → {external:Promise}

Set the type of data for the video stream.

MediaElements that do not support configuration of video capabilities will throw a MEDIA_OBJECT_ILLEGAL_PARAM_ERROR exception

NOTE: This method is not implemented yet by the Media Server to do anything useful.

Parameters:
Name Type Attributes Description
caps module:core/complexTypes.VideoCaps The format for the stream of video
callback module:core/abstracts.MediaElement~setVideoFormatCallback <optional>
Source:
Returns:
Type
external:Promise

getChildren(callbackopt) → {external:Promise}

Children of this MediaObject.
Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaObject~getChildrenCallback <optional>
Inherited From:
Source:
Returns:
Type
external:Promise

getChilds(callbackopt) → {external:Promise}

Children of this MediaObject.
Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaObject~getChildsCallback <optional>
Inherited From:
Deprecated:
  • Use children instead.
Source:
Returns:
Type
external:Promise

getCreationTime(callbackopt) → {external:Promise}

MediaObject creation time in seconds since Epoch.
Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaObject~getCreationTimeCallback <optional>
Inherited From:
Source:
Returns:
Type
external:Promise

getMaxOuputBitrate(callbackopt) → {external:Promise}

Maximum video bandwidth for transcoding.
Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaElement~getMaxOuputBitrateCallback <optional>
Deprecated:
  • Deprecated due to a typo. Use module:core/abstracts.MediaElement#maxOutputBitrate instead of this function.
Source:
Returns:
Type
external:Promise

getMaxOutputBitrate(callbackopt) → {external:Promise}

Maximum video bitrate for transcoding.
  • Unit: bps (bits per second).
  • Default: MAXINT.
  • 0 = unlimited.
Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaElement~getMaxOutputBitrateCallback <optional>
Source:
Returns:
Type
external:Promise

getMediaPipeline(callbackopt) → {external:Promise}

MediaPipeline to which this MediaObject belongs. It returns itself when invoked for a pipeline object.
Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaObject~getMediaPipelineCallback <optional>
Inherited From:
Source:
Returns:
Type
external:Promise

getMinOuputBitrate(callbackopt) → {external:Promise}

Minimum video bandwidth for transcoding.
Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaElement~getMinOuputBitrateCallback <optional>
Deprecated:
  • Deprecated due to a typo. Use module:core/abstracts.MediaElement#minOutputBitrate instead of this function.
Source:
Returns:
Type
external:Promise

getMinOutputBitrate(callbackopt) → {external:Promise}

Minimum video bitrate for transcoding.
  • Unit: bps (bits per second).
  • Default: 0.
Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaElement~getMinOutputBitrateCallback <optional>
Source:
Returns:
Type
external:Promise

getName(callbackopt) → {external:Promise}

This MediaObject's name.

This is just sugar to simplify developers' life debugging, it is not used internally for indexing nor identifying the objects. By default, it's the object's ID.

Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaObject~getNameCallback <optional>
Inherited From:
Source:
Returns:
Type
external:Promise

getParent(callbackopt) → {external:Promise}

Parent of this MediaObject.

The parent of a Hub or a MediaElement is its MediaPipeline. A MediaPipeline has no parent, so this property will be null.

Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaObject~getParentCallback <optional>
Inherited From:
Source:
Returns:
Type
external:Promise

getSendTagsInEvents(callbackopt) → {external:Promise}

Flag activating or deactivating sending the element's tags in fired events.
Parameters:
Name Type Attributes Description
callback module:core/abstracts.MediaObject~getSendTagsInEventsCallback <optional>
Inherited From:
Source:
Returns:
Type
external:Promise

setMaxOuputBitrate(maxOuputBitrate, callbackopt) → {external:Promise}

Maximum video bandwidth for transcoding.
Parameters:
Name Type Attributes Description
maxOuputBitrate external:Integer
callback module:core/abstracts.MediaElement~setMaxOuputBitrateCallback <optional>
Deprecated:
  • Deprecated due to a typo. Use module:core/abstracts.MediaElement#maxOutputBitrate instead of this function.
Source:
Returns:
Type
external:Promise

setMaxOutputBitrate(maxOutputBitrate, callbackopt) → {external:Promise}

Maximum video bitrate for transcoding.
  • Unit: bps (bits per second).
  • Default: MAXINT.
  • 0 = unlimited.
Parameters:
Name Type Attributes Description
maxOutputBitrate external:Integer
callback module:core/abstracts.MediaElement~setMaxOutputBitrateCallback <optional>
Source:
Returns:
Type
external:Promise

setMinOuputBitrate(minOuputBitrate, callbackopt) → {external:Promise}

Minimum video bandwidth for transcoding.
Parameters:
Name Type Attributes Description
minOuputBitrate external:Integer
callback module:core/abstracts.MediaElement~setMinOuputBitrateCallback <optional>
Deprecated:
  • Deprecated due to a typo. Use module:core/abstracts.MediaElement#minOutputBitrate instead of this function.
Source:
Returns:
Type
external:Promise

setMinOutputBitrate(minOutputBitrate, callbackopt) → {external:Promise}

Minimum video bitrate for transcoding.
  • Unit: bps (bits per second).
  • Default: 0.
Parameters:
Name Type Attributes Description
minOutputBitrate external:Integer
callback module:core/abstracts.MediaElement~setMinOutputBitrateCallback <optional>
Source:
Returns:
Type
external:Promise

setName(name, callbackopt) → {external:Promise}

This MediaObject's name.

This is just sugar to simplify developers' life debugging, it is not used internally for indexing nor identifying the objects. By default, it's the object's ID.

Parameters:
Name Type Attributes Description
name external:String
callback module:core/abstracts.MediaObject~setNameCallback <optional>
Inherited From:
Source:
Returns:
Type
external:Promise

setSendTagsInEvents(sendTagsInEvents, callbackopt) → {external:Promise}

Flag activating or deactivating sending the element's tags in fired events.
Parameters:
Name Type Attributes Description
sendTagsInEvents external:Boolean
callback module:core/abstracts.MediaObject~setSendTagsInEventsCallback <optional>
Inherited From:
Source:
Returns:
Type
external:Promise

Type Definitions

connectCallback(error)

Parameters:
Name Type Description
error external:Error
Source:

disconnectCallback(error)

Parameters:
Name Type Description
error external:Error
Source:

getGstreamerDotCallback(error, result)

Parameters:
Name Type Description
error external:Error
result external:String The dot graph.
Source:

getMaxOuputBitrateCallback(error, result)

Parameters:
Name Type Description
error external:Error
result external:Integer
Source:

getMaxOutputBitrateCallback(error, result)

Parameters:
Name Type Description
error external:Error
result external:Integer
Source:

getMinOuputBitrateCallback(error, result)

Parameters:
Name Type Description
error external:Error
result external:Integer
Source:

getMinOutputBitrateCallback(error, result)

Parameters:
Name Type Description
error external:Error
result external:Integer
Source:

getSinkConnectionsCallback(error, result)

Parameters:
Name Type Description
error external:Error
result module:core/complexTypes.ElementConnectionData A list of the connections information that are receiving media from this element. The list will be empty if no sources are found.
Source:

getSourceConnectionsCallback(error, result)

Parameters:
Name Type Description
error external:Error
result module:core/complexTypes.ElementConnectionData A list of the connections information that are sending media to this element. The list will be empty if no sources are found.
Source:

getStatsCallback(error, result)

Parameters:
Name Type Description
error external:Error
result Object.<string, module:core/complexTypes.Stats> Delivers a successful result in the form of a RTC stats report. A RTC stats report represents a map between strings, identifying the inspected objects (RTCStats.id), and their corresponding RTCStats objects.
Source:

isMediaFlowingInCallback(error, result)

Parameters:
Name Type Description
error external:Error
result external:Boolean TRUE if there is media, FALSE in other case.
Source:

isMediaFlowingOutCallback(error, result)

Parameters:
Name Type Description
error external:Error
result external:Boolean TRUE if there is media, FALSE in other case.
Source:

isMediaTranscodingCallback(error, result)

Parameters:
Name Type Description
error external:Error
result external:Boolean TRUE if media is being transcoded, FALSE otherwise.
Source:

setAudioFormatCallback(error)

Parameters:
Name Type Description
error external:Error
Source:

setMaxOuputBitrateCallback(error)

Parameters:
Name Type Description
error external:Error
Source:

setMaxOutputBitrateCallback(error)

Parameters:
Name Type Description
error external:Error
Source:

setMinOuputBitrateCallback(error)

Parameters:
Name Type Description
error external:Error
Source:

setMinOutputBitrateCallback(error)

Parameters:
Name Type Description
error external:Error
Source:

setOutputBitrateCallback(error)

Parameters:
Name Type Description
error external:Error
Source:

setVideoFormatCallback(error)

Parameters:
Name Type Description
error external:Error
Source: