Functions

  buffer_add_rtp_source_meta (buffer, ssrc, csrc, csrc_count)
  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_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_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, csrc_count)[source]
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)[source]
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

Find the GstRtp.RTPSourceMeta on buffer.

New in version 1.16.

GstRtp.rtcp_buffer_map(buffer, flags, rtcp)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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_map(buffer, flags)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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_hdrext_get_ntp_56(data)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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

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 insensitve way.

GstRtp.rtp_payload_info_for_pt(payload_type)[source]
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

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()[source]
Return type:GObject.GType
GstRtp.rtp_source_meta_get_info()[source]
Return type:Gst.MetaInfo