Functions

buffer_add_rtp_source_meta (buffer, ssrc, csrc)

buffer_get_rtp_source_meta (buffer)

rtcp_buffer_map (buffer, flags, rtcp)

rtcp_buffer_new (mtu)

rtcp_buffer_new_copy_data (data)

rtcp_buffer_new_take_data (data)

rtcp_buffer_validate (buffer)

rtcp_buffer_validate_data (data)

rtcp_buffer_validate_data_reduced (data)

rtcp_buffer_validate_reduced (buffer)

rtcp_ntp_to_unix (ntptime)

rtcp_sdes_name_to_type (name)

rtcp_sdes_type_to_name (type)

rtcp_unix_to_ntp (unixtime)

rtp_buffer_allocate_data (buffer, payload_len, pad_len, csrc_count)

rtp_buffer_calc_header_len (csrc_count)

rtp_buffer_calc_packet_len (payload_len, pad_len, csrc_count)

rtp_buffer_calc_payload_len (packet_len, pad_len, csrc_count)

rtp_buffer_compare_seqnum (seqnum1, seqnum2)

rtp_buffer_default_clock_rate (payload_type)

rtp_buffer_ext_timestamp (exttimestamp, timestamp)

rtp_buffer_get_extension_onebyte_header_from_bytes (bytes, bit_pattern, id, nth)

rtp_buffer_map (buffer, flags)

rtp_buffer_new_allocate (payload_len, pad_len, csrc_count)

rtp_buffer_new_allocate_len (packet_len, pad_len, csrc_count)

rtp_buffer_new_copy_data (data)

rtp_buffer_new_take_data (data)

rtp_get_header_extension_list ()

rtp_hdrext_get_ntp_56 (data)

rtp_hdrext_get_ntp_64 (data)

rtp_hdrext_set_ntp_56 (data, size, ntptime)

rtp_hdrext_set_ntp_64 (data, size, ntptime)

rtp_payload_info_for_name (media, encoding_name)

rtp_payload_info_for_pt (payload_type)

rtp_source_meta_api_get_type ()

rtp_source_meta_get_info ()

Details

GstRtp.buffer_add_rtp_source_meta(buffer, ssrc, csrc)
Parameters:
Returns:

the GstRtp.RTPSourceMeta on buffer.

Return type:

GstRtp.RTPSourceMeta

Attaches RTP source information to buffer.

New in version 1.16.

GstRtp.buffer_get_rtp_source_meta(buffer)
Parameters:

buffer (Gst.Buffer) – a Gst.Buffer

Returns:

the GstRtp.RTPSourceMeta or None when there is no such metadata on buffer.

Return type:

GstRtp.RTPSourceMeta or None

Find the GstRtp.RTPSourceMeta on buffer.

New in version 1.16.

GstRtp.rtcp_buffer_map(buffer, flags, rtcp)
Parameters:
Return type:

bool

Open buffer for reading or writing, depending on flags. The resulting RTCP buffer state is stored in rtcp.

GstRtp.rtcp_buffer_new(mtu)
Parameters:

mtu (int) – the maximum mtu size.

Returns:

A newly allocated buffer.

Return type:

Gst.Buffer

Create a new buffer for constructing RTCP packets. The packet will have a maximum size of mtu.

GstRtp.rtcp_buffer_new_copy_data(data)
Parameters:

data (bytes) – data for the new buffer

Returns:

A newly allocated buffer with a copy of data and of size len.

Return type:

Gst.Buffer

Create a new buffer and set the data to a copy of len bytes of data and the size to len. The data will be freed when the buffer is freed.

GstRtp.rtcp_buffer_new_take_data(data)
Parameters:

data (bytes) – data for the new buffer

Returns:

A newly allocated buffer with data and of size len.

Return type:

Gst.Buffer

Create a new buffer and set the data and size of the buffer to data and len respectively. data will be freed when the buffer is unreffed, so this function transfers ownership of data to the new buffer.

GstRtp.rtcp_buffer_validate(buffer)
Parameters:

buffer (Gst.Buffer) – the buffer to validate

Returns:

True if buffer is a valid RTCP packet.

Return type:

bool

Check if the data pointed to by buffer is a valid RTCP packet using GstRtp.RTCPBuffer.validate_data().

GstRtp.rtcp_buffer_validate_data(data)
Parameters:

data (bytes) – the data to validate

Returns:

True if the data points to a valid RTCP packet.

Return type:

bool

Check if the data and size point to the data of a valid compound, non-reduced size RTCP packet. Use this function to validate a packet before using the other functions in this module.

GstRtp.rtcp_buffer_validate_data_reduced(data)
Parameters:

data (bytes) – the data to validate

Returns:

True if the data points to a valid RTCP packet.

Return type:

bool

Check if the data and size point to the data of a valid RTCP packet. Use this function to validate a packet before using the other functions in this module.

This function is updated to support reduced size rtcp packets according to RFC 5506 and will validate full compound RTCP packets as well as reduced size RTCP packets.

New in version 1.6.

GstRtp.rtcp_buffer_validate_reduced(buffer)
Parameters:

buffer (Gst.Buffer) – the buffer to validate

Returns:

True if buffer is a valid RTCP packet.

Return type:

bool

Check if the data pointed to by buffer is a valid RTCP packet using GstRtp.RTCPBuffer.validate_reduced().

New in version 1.6.

GstRtp.rtcp_ntp_to_unix(ntptime)
Parameters:

ntptime (int) – an NTP timestamp

Returns:

the UNIX time for ntptime in nanoseconds.

Return type:

int

Converts an NTP time to UNIX nanoseconds. ntptime can typically be the NTP time of an SR RTCP message and contains, in the upper 32 bits, the number of seconds since 1900 and, in the lower 32 bits, the fractional seconds. The resulting value will be the number of nanoseconds since 1970.

GstRtp.rtcp_sdes_name_to_type(name)
Parameters:

name (str) – a SDES name

Returns:

the GstRtp.RTCPSDESType for name or GstRtp.RTCPSDESType.PRIV when name is a private sdes item.

Return type:

GstRtp.RTCPSDESType

Convert name into a GstRTCPSDESType. name is typically a key in a Gst.Structure containing SDES items.

GstRtp.rtcp_sdes_type_to_name(type)
Parameters:

type (GstRtp.RTCPSDESType) – a GstRtp.RTCPSDESType

Returns:

the string equivalent of type

Return type:

str

Converts type to the string equivalent. The string is typically used as a key in a Gst.Structure containing SDES items.

GstRtp.rtcp_unix_to_ntp(unixtime)
Parameters:

unixtime (int) – an UNIX timestamp in nanoseconds

Returns:

the NTP time for unixtime.

Return type:

int

Converts a UNIX timestamp in nanoseconds to an NTP time. The caller should pass a value with nanoseconds since 1970. The NTP time will, in the upper 32 bits, contain the number of seconds since 1900 and, in the lower 32 bits, the fractional seconds. The resulting value can be used as an ntptime for constructing SR RTCP packets.

GstRtp.rtp_buffer_allocate_data(buffer, payload_len, pad_len, csrc_count)
Parameters:
  • buffer (Gst.Buffer) – a Gst.Buffer

  • payload_len (int) – the length of the payload

  • pad_len (int) – the amount of padding

  • csrc_count (int) – the number of CSRC entries

Allocate enough data in buffer to hold an RTP packet with csrc_count CSRCs, a payload length of payload_len and padding of pad_len. buffer must be writable and all previous memory in buffer will be freed. If pad_len is >0, the padding bit will be set. All other RTP header fields will be set to 0/False.

GstRtp.rtp_buffer_calc_header_len(csrc_count)
Parameters:

csrc_count (int) – the number of CSRC entries

Returns:

The length of an RTP header with csrc_count CSRC entries.

Return type:

int

Calculate the header length of an RTP packet with csrc_count CSRC entries. An RTP packet can have at most 15 CSRC entries.

GstRtp.rtp_buffer_calc_packet_len(payload_len, pad_len, csrc_count)
Parameters:
  • payload_len (int) – the length of the payload

  • pad_len (int) – the amount of padding

  • csrc_count (int) – the number of CSRC entries

Returns:

The total length of an RTP header with given parameters.

Return type:

int

Calculate the total length of an RTP packet with a payload size of payload_len, a padding of pad_len and a csrc_count CSRC entries.

GstRtp.rtp_buffer_calc_payload_len(packet_len, pad_len, csrc_count)
Parameters:
  • packet_len (int) – the length of the total RTP packet

  • pad_len (int) – the amount of padding

  • csrc_count (int) – the number of CSRC entries

Returns:

The length of the payload of an RTP packet with given parameters.

Return type:

int

Calculate the length of the payload of an RTP packet with size packet_len, a padding of pad_len and a csrc_count CSRC entries.

GstRtp.rtp_buffer_compare_seqnum(seqnum1, seqnum2)
Parameters:
  • seqnum1 (int) – a sequence number

  • seqnum2 (int) – a sequence number

Returns:

a negative value if seqnum1 is bigger than seqnum2, 0 if they are equal or a positive value if seqnum1 is smaller than segnum2.

Return type:

int

Compare two sequence numbers, taking care of wraparounds. This function returns the difference between seqnum1 and seqnum2.

GstRtp.rtp_buffer_default_clock_rate(payload_type)
Parameters:

payload_type (int) – the static payload type

Returns:

the default clock rate or -1 if the payload type is not static or the clock-rate is undefined.

Return type:

int

Get the default clock-rate for the static payload type payload_type.

GstRtp.rtp_buffer_ext_timestamp(exttimestamp, timestamp)
Parameters:
  • exttimestamp (int) – a previous extended timestamp

  • timestamp (int) – a new timestamp

Returns:

The extended timestamp of timestamp or 0 if the result can’t go anywhere backwards.

exttimestamp:

a previous extended timestamp

Return type:

(int, exttimestamp: int)

Update the exttimestamp field with the extended timestamp of timestamp For the first call of the method, exttimestamp should point to a location with a value of -1.

This function is able to handle both forward and backward timestamps taking into account:

  • timestamp wraparound making sure that the returned value is properly increased.

  • timestamp unwraparound making sure that the returned value is properly decreased.

GstRtp.rtp_buffer_get_extension_onebyte_header_from_bytes(bytes, bit_pattern, id, nth)
Parameters:
  • bytes (GLib.Bytes) – GLib.Bytes

  • bit_pattern (int) – The bit-pattern. Anything but 0xBEDE is rejected.

  • id (int) – The ID of the header extension to be read (between 1 and 14).

  • nth (int) – Read the nth extension packet with the requested ID

Returns:

True if bytes had the requested header extension

data:

location for data

Return type:

(bool, data: bytes)

Similar to GstRtp.RTPBuffer.get_extension_onebyte_header, but working on the GLib.Bytes you get from GstRtp.RTPBuffer.get_extension_data. Parses RFC 5285 style header extensions with a one byte header. It will return the nth extension with the requested id.

New in version 1.18.

GstRtp.rtp_buffer_map(buffer, flags)
Parameters:
Returns:

True if buffer could be mapped.

rtp:

a GstRtp.RTPBuffer

Return type:

(bool, rtp: GstRtp.RTPBuffer)

Map the contents of buffer into rtp.

GstRtp.rtp_buffer_new_allocate(payload_len, pad_len, csrc_count)
Parameters:
  • payload_len (int) – the length of the payload

  • pad_len (int) – the amount of padding

  • csrc_count (int) – the number of CSRC entries

Returns:

A newly allocated buffer that can hold an RTP packet with given parameters.

Return type:

Gst.Buffer

Allocate a new Gst.Buffer with enough data to hold an RTP packet with csrc_count CSRCs, a payload length of payload_len and padding of pad_len. All other RTP header fields will be set to 0/False.

GstRtp.rtp_buffer_new_allocate_len(packet_len, pad_len, csrc_count)
Parameters:
  • packet_len (int) – the total length of the packet

  • pad_len (int) – the amount of padding

  • csrc_count (int) – the number of CSRC entries

Returns:

A newly allocated buffer that can hold an RTP packet of packet_len.

Return type:

Gst.Buffer

Create a new Gst.Buffer that can hold an RTP packet that is exactly packet_len long. The length of the payload depends on pad_len and csrc_count and can be calculated with GstRtp.RTPBuffer.calc_payload_len(). All RTP header fields will be set to 0/False.

GstRtp.rtp_buffer_new_copy_data(data)
Parameters:

data (bytes) – data for the new buffer

Returns:

A newly allocated buffer with a copy of data and of size len.

Return type:

Gst.Buffer

Create a new buffer and set the data to a copy of len bytes of data and the size to len. The data will be freed when the buffer is freed.

GstRtp.rtp_buffer_new_take_data(data)
Parameters:

data (bytes) – data for the new buffer

Returns:

A newly allocated buffer with data and of size len.

Return type:

Gst.Buffer

Create a new buffer and set the data and size of the buffer to data and len respectively. data will be freed when the buffer is unreffed, so this function transfers ownership of data to the new buffer.

GstRtp.rtp_get_header_extension_list()
Returns:

a GLib.List of Gst.ElementFactory's. Use Gst.PluginFeature.list_free() after use

Return type:

[Gst.ElementFactory]

Retrieve all the factories of the currently registered RTP header extensions. Call Gst.ElementFactory.create() with each factory to create the associated GstRtp.RTPHeaderExtension.

New in version 1.20.

GstRtp.rtp_hdrext_get_ntp_56(data)
Parameters:

data (bytes) – the data to read from

Returns:

True on success.

ntptime:

the result NTP time

Return type:

(bool, ntptime: int)

Reads the NTP time from the size NTP-56 extension bytes in data and store the result in ntptime.

GstRtp.rtp_hdrext_get_ntp_64(data)
Parameters:

data (bytes) – the data to read from

Returns:

True on success.

ntptime:

the result NTP time

Return type:

(bool, ntptime: int)

Reads the NTP time from the size NTP-64 extension bytes in data and store the result in ntptime.

GstRtp.rtp_hdrext_set_ntp_56(data, size, ntptime)
Parameters:
  • data (object or None) – the data to write to

  • size (int) – the size of data

  • ntptime (int) – the NTP time

Returns:

True on success.

Return type:

bool

Writes the NTP time in ntptime to the format required for the NTP-56 header extension. data must hold at least GstRtp.RTP_HDREXT_NTP_56_SIZE bytes.

GstRtp.rtp_hdrext_set_ntp_64(data, size, ntptime)
Parameters:
  • data (object or None) – the data to write to

  • size (int) – the size of data

  • ntptime (int) – the NTP time

Returns:

True on success.

Return type:

bool

Writes the NTP time in ntptime to the format required for the NTP-64 header extension. data must hold at least GstRtp.RTP_HDREXT_NTP_64_SIZE bytes.

GstRtp.rtp_payload_info_for_name(media, encoding_name)
Parameters:
  • media (str) – the media to find

  • encoding_name (str) – the encoding name to find

Returns:

a GstRtp.RTPPayloadInfo or None when no info could be found.

Return type:

GstRtp.RTPPayloadInfo or None

Get the GstRtp.RTPPayloadInfo for media and encoding_name. This function is mostly used to get the default clock-rate and bandwidth for dynamic payload types specified with media and encoding name.

The search for encoding_name will be performed in a case insensitive way.

GstRtp.rtp_payload_info_for_pt(payload_type)
Parameters:

payload_type (int) – the payload_type to find

Returns:

a GstRtp.RTPPayloadInfo or None when no info could be found.

Return type:

GstRtp.RTPPayloadInfo or None

Get the GstRtp.RTPPayloadInfo for payload_type. This function is mostly used to get the default clock-rate and bandwidth for static payload types specified with payload_type.

GstRtp.rtp_source_meta_api_get_type()
Return type:

GObject.GType

GstRtp.rtp_source_meta_get_info()
Return type:

Gst.MetaInfo