This class is the equivalent of a GStreamer element that represents one of the GStreamer plug-ins.
Under the link https://gstreamer.freedesktop.org/documentation/plugins_doc.html?gi-language=c you will find a list of the current GStreamer plugins - from 3gppmux to zebrastripe - with detailed descriptions (as of December 2023).
The class can be created. How to create a new MediaControl:
Dim hMediaControl As MediaControl hMediaControl = New MediaControl ( [ Parent As MediaContainer, Type As String ] ) [ As "EventName" ]
The class works like a read/write array.
Read: Returns the value of a MediaControl property based on its name. The properties supported by the control depend on its type.
Dim hMediaControl As MediaControl Dim vValue As Variant vValue = hMediaControl [ Property As String ]
Write: Defines the value of a MediaControl property by its name. The properties supported by the control depend on its type.
Dim hMediaControl As MediaControl Dim vValue As Variant hMediaControl [ Property As String ] = vValue
The MediaControl class has these properties:
Property | Data type | Description |
---|---|---|
Inputs | String[ ] | Returns the names of all inputs/inputs. |
Name | String | Returns or sets the name of the MediaControl. |
Outputs | String[ ] | Returns the names of all outputs/outputs. |
Parent | MediaContainer | Returns the parent element of the control. |
State | Integer | Returns or defines the state of a MediaControl. It can be one of the following constants: Media.Null (1), Media.Ready (2), Media.Paused (3) or Media.Playing (4). |
Type | String | Returns the type of the MediaControl. |
Table 23.9.3.1.1 : Properties of the MediaControl class
The MediaControl class has these methods:
Method | Return type | Description |
---|---|---|
GetLastImage ( ) | Image | Returns the last image displayed by a video output control. |
GetLink ( Name As String ) | MediaLink | Returns the description of an input or output by its name. |
LinkLaterTo ( Target As MediaControl ) | - | Links the current control to the target control as soon as a new output appears on it. Some controls have outputs that can appear spontaneously, i.e. when the data arrives. In this case, the LinkTo method fails because the output does not yet exist at the time of the call. You must therefore use LinkLaterTo. Note: This method did not work reliably up to Gambas 3.18. This has been fixed in Gambas 3.18.2. Now this method can be called multiple times: As soon as a control output is available, all targets are checked against the new output, keeping the order of the LinkLaterTo() calls. Only when a target can be linked to the output is the next target selected. |
LinkTo ( Target As MediaControl [ , Output As String, Input As String ] ) | - | Links an output of the current MediaControl with the input of the target MediaControl. `Target` is the target control, `Output` is the name of the output of the current control and `Input` is the name of the input of the target control. If output and input are not specified, GStreamer tries to find the best output and input that matches the link request, according to the type of source control and the type of target control. Some controls have outputs that may appear “on the fly”, i.e. when the data arrives. In this case, the LinkTo method will fail because the output is not present at the time of the call. You must use LinkLaterTo instead. |
SetWindow ( Control As Control [ , X As Integer, Y As Integer, Width As Integer, Height As Integer ] ) | - | This method instructs the MediaControl to draw its output within a specific GUI control. `Control` is the control to be drawn into. `X, Y, Width, Height` specify a target rectangle within the control. If it is not specified, the entire surface of the control is used. Only controls that implement the GStreamer-X-OVERLAY interface support this method. The target control must have its own window. To ensure this, use a DrawingArea with the property Cached. |
Table 23.9.3.2.1 : Methods of the MediaControl class
The MediaControl class only has one event:
Event | Description |
---|---|
State ( ) | This event is triggered when the state of the control has changed. |
Table 23.9.3.3.1 : Events of the MediaControl class
For the example below, the terminal command line for GStreamer is specified first:
gst-launch-1.0 \ uridecodebin uri="http://icecast.ndr.de/ndr/ndr1wellenord/kiel/mp3/128/stream.mp3" \ ! audioconvert \ ! autoaudiosink
Figure 23.9.3.4.1: MediaPipeline with MediaControls
Here is the implementation with Gambas. Source code section:
[1] Public Sub CreatePipeline() [2] [3] mpPipeline = New MediaPipeline As "PipeEvents" [4] [5] mcSource = New MediaControl(mpPipeline, "uridecodebin") [6] '-- ["uri"] is a property of the MediaControl 'mcSource' [7] mcSource["uri"] = "http://icecast.ndr.de/ndr/ndr1wellenord/kiel/mp3/128/stream.mp3" [8] mcConvert = New MediaControl(mpPipeline, "audioconvert") [9] mcSink = New MediaControl(mpPipeline, "autoaudiosink") [10] [11] mcSource.LinkLaterTo(mcConvert) [12] mcConvert.LinkTo(mcSink) [13] [14] End [15] Public Sub btnPlay_Click() [16] CreatePipeline() [17] mpPipeline.Play() [18] End
Comment
In the download area you will find the project archive for the complete source code.