User Tools

Site Tools


Sidebar

Multimedia

k23:k23.9:k23.9.6:start

23.9.6 MediaMessage (gb.media)

The MediaMessage class cannot be created. The class behaves like a read-only array and can be enumerated with the keyword pair 'For Each'. This returns the value that is linked to a key name stored in the message:

Dim hMediaMessage As MediaMessage
Dim vValue As Variant

vValue = hMediaMessage [ Name As String ]

All values stored in a message are enumerated in this way:

Dim hMediaMessage As MediaMessage
Dim vValue As Variant

For Each vValue In hMediaMessage
    ...
Next

23.9.6.1 Properties

The MediaMessage class has these five properties:

PropertyData typeDescription
CountIntegerReturns the number of key/value pairs stored in the message.
NameStringReturns the name of the message. It can also be NULL!
KeysString[ ]Returns an array with the keys of all values stored in the message.
KeyStringReturns the key of the last value stored in the message.
TypeIntegerReturns the type of the event as a MediaMessage constant.

Table 23.9.6.1.1 : Properties of the MediaMessage class

23.9.6.2 Constants of the MediaMessage class

The MediaMessage class has the following constants:

  • AsyncDone, AsyncStart, Buffering, ClockLost, DurationChanged, Element, Eos
  • Error, Info, Latency, NewClock, Progress, Qos, RequestState, SegmentDone, Start
  • StateAsync, StateChanged, Status, StepDone, StepStart, StreamStart, StreamStatus
  • Tag, Toc, Warning

You can find the integer values associated with the constants on the website https://gambaswiki.org/wiki/comp/gb.media/mediamessage

23.9.6.3 Example

In the following source code section, the messages are read from the data stream and displayed in the console of the IDE:

Public Sub hPipeline_Event(Message As MediaMessage)
 
  Dim vVariant As Variant
 
  Print "MESSAGE.NAME = "; Message.Name
  Print "------------------------------------------"
  For Each vVariant In Message
      Print "KEY = "; Message.Key; " -->> VALUE = "; Message[Message.Key]
  Next
  Print "------------------------------------------" 
 
End

This is an excerpt of the continuously read messages - without filters:

...
------------------------------------------
MESSAGE.NAME = GstMessageStateChanged
------------------------------------------
KEY = old-state -->> VALUE = null
KEY = new-state -->> VALUE = ready
KEY = pending-state -->> VALUE = paused
------------------------------------------
MESSAGE.NAME = GstMessageNeedContext
------------------------------------------
KEY = context-type -->> VALUE = gst.soup.session
------------------------------------------
MESSAGE.NAME = GstMessageHaveContext
------------------------------------------
KEY = context -->> VALUE =
------------------------------------------
MESSAGE.NAME = GstMessageStreamStatus
------------------------------------------
KEY = type -->> VALUE = create
KEY = owner -->> VALUE =
KEY = object -->> VALUE =
------------------------------------------
MESSAGE.NAME = GstMessageStateChanged
------------------------------------------
KEY = old-state -->> VALUE = ready
KEY = new-state -->> VALUE = paused
KEY = pending-state -->> VALUE = void-pending
------------------------------------------
MESSAGE.NAME = GstMessageStreamStatus
------------------------------------------
KEY = type -->> VALUE = enter
KEY = owner -->> VALUE =
KEY = object -->> VALUE =
------------------------------------------
MESSAGE.NAME = http-headers
------------------------------------------
KEY = uri -->> VALUE = http://icecast.ndr.de/ndr/ndr1wellenord/kiel/mp3/128/stream.mp3
KEY = http-status-code -->> VALUE = 200
KEY = redirection-uri -->> VALUE = http://f141.rndfnk.com/ard/ndr/ndr1wellenord/kiel/mp3/128/stream.mp3?cid=01FBQ1T52FB81EDG99JE36KN5J&sid=2aluMgAc2xEGJVo7hUwbHeTv3gl&token=MUkpI-R3L45S55UKaBf6NJtcAZ8ysRIr3sg9wLhh3DY&tvf=6CRHShweqRdmMTQxLnJuZGZuay5jb20
KEY = request-headers -->> VALUE =
KEY = response-headers -->> VALUE =
------------------------------------------
...

In the alternative source code section, a message filter with a freely defined message name is used → Message.Name = GstMessageStateChanged:

Public Sub hPipeline_Event(Message As MediaMessage)
 
    Dim i As Integer
 
    If Message.Name = "GstMessageStateChanged" Then
       Print
       Print "MESSAGE.NAME = "; Message.Name
       Print "--------------------------------------"
    Endif
    For i = 0 To Message.Count - 1
        If Message.Name = "GstMessageStateChanged" Then
           Print "KEY = "; Message.Keys[i]; " -->> VALUE = "; Message[Message.Keys[i]]
        Endif
    Next
 
End

Here is an excerpt of the continuously read messages - with filter:

...
MESSAGE.NAME = GstMessageStateChanged
--------------------------------------
KEY = old-state -->> VALUE = null
KEY = new-state -->> VALUE = ready
KEY = pending-state -->> VALUE = paused

MESSAGE.NAME = GstMessageStateChanged
--------------------------------------
KEY = old-state -->> VALUE = ready
KEY = new-state -->> VALUE = paused
KEY = pending-state -->> VALUE = void-pending
...
The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k23/k23.9/k23.9.6/start.txt · Last modified: 13.01.2024 by emma

Page Tools