GstRtp.RTPBuffer¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
buffer |
r/w |
pointer to RTP buffer |
|
data |
[ |
r/w |
array of data |
map |
r/w |
array of |
|
size |
[ |
r/w |
array of size |
state |
r/w |
internal state |
Methods¶
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class GstRtp.RTPBuffer¶
The
GstRtp.RTPBuffer
helper functions makes it easy to parse and create regularGst.Buffer
objects that contain RTP payloads. These buffers are typically of ‘application/x-rtp’Gst.Caps
.- classmethod allocate_data(buffer, payload_len, pad_len, csrc_count)[source]¶
- Parameters:
buffer (
Gst.Buffer
) – aGst.Buffer
payload_len (
int
) – the length of the payloadpad_len (
int
) – the amount of paddingcsrc_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
.
- classmethod 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:
Calculate the header length of an RTP packet with csrc_count CSRC entries. An RTP packet can have at most 15 CSRC entries.
- classmethod calc_packet_len(payload_len, pad_len, csrc_count)[source]¶
- Parameters:
- Returns:
The total length of an RTP header with given parameters.
- Return type:
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.
- classmethod calc_payload_len(packet_len, pad_len, csrc_count)[source]¶
- Parameters:
- Returns:
The length of the payload of an RTP packet with given parameters.
- Return type:
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.
- classmethod compare_seqnum(seqnum1, seqnum2)[source]¶
- Parameters:
- 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:
Compare two sequence numbers, taking care of wraparounds. This function returns the difference between seqnum1 and seqnum2.
- classmethod 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:
Get the default clock-rate for the static payload type payload_type.
- classmethod ext_timestamp(exttimestamp, timestamp)[source]¶
- Parameters:
- Returns:
The extended timestamp of timestamp or 0 if the result can’t go anywhere backwards.
- exttimestamp:
a previous extended timestamp
- Return type:
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.
- classmethod get_extension_onebyte_header_from_bytes(bytes, bit_pattern, id, nth)[source]¶
- 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:
Similar to
GstRtp.RTPBuffer.get_extension_onebyte_header
, but working on theGLib.Bytes
you get fromGstRtp.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.
- classmethod new_allocate(payload_len, pad_len, csrc_count)[source]¶
- Parameters:
- Returns:
A newly allocated buffer that can hold an RTP packet with given parameters.
- Return type:
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
.
- classmethod new_allocate_len(packet_len, pad_len, csrc_count)[source]¶
- Parameters:
- Returns:
A newly allocated buffer that can hold an RTP packet of packet_len.
- Return type:
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 withGstRtp.RTPBuffer.calc_payload_len
(). All RTP header fields will be set to 0/False
.
- classmethod 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:
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.
- classmethod 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:
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.
- add_extension_onebyte_header(id, data)[source]¶
- Parameters:
- Returns:
True
if header extension could be added- Return type:
Adds a RFC 5285 header extension with a one byte header to the end of the RTP header. If there is already a RFC 5285 header extension with a one byte header, the new extension will be appended. It will not work if there is already a header extension that does not follow the mechanism described in RFC 5285 or if there is a header extension with a two bytes header as described in RFC 5285. In that case, use
GstRtp.RTPBuffer.add_extension_twobytes_header
()
- add_extension_twobytes_header(appbits, id, data)[source]¶
- Parameters:
- Returns:
True
if header extension could be added- Return type:
Adds a RFC 5285 header extension with a two bytes header to the end of the RTP header. If there is already a RFC 5285 header extension with a two bytes header, the new extension will be appended. It will not work if there is already a header extension that does not follow the mechanism described in RFC 5285 or if there is a header extension with a one byte header as described in RFC 5285. In that case, use
GstRtp.RTPBuffer.add_extension_onebyte_header
()
- get_csrc(idx)[source]¶
- Parameters:
idx (
int
) – the index of the CSRC to get- Returns:
the CSRC at index idx in host order.
- Return type:
Get the CSRC at index idx in buffer.
- get_csrc_count()[source]¶
- Returns:
the CSRC count of buffer.
- Return type:
Get the CSRC count of the RTP packet in buffer.
- get_extension_data()[source]¶
- Returns:
A new
GLib.Bytes
if an extension header was present andNone
otherwise.- bits:
location for header bits
- Return type:
(
GLib.Bytes
orNone
, bits:int
)
Similar to
GstRtp.RTPBuffer.get_extension_data
, but more suitable for language bindings usage. bits will contain the extension 16 bits of custom data and the extension data (not including the extension header) is placed in a newGLib.Bytes
structure.If self did not contain an extension, this function will return
None
, with bits unchanged. If there is an extension header but no extension data then an emptyGLib.Bytes
will be returned.New in version 1.2.
- get_extension_onebyte_header(id, nth)[source]¶
- Parameters:
- Returns:
True
if buffer had the requested header extension- data:
location for data
- Return type:
Parses RFC 5285 style header extensions with a one byte header. It will return the nth extension with the requested id.
- get_extension_twobytes_header(id, nth)[source]¶
- Parameters:
- Returns:
True
if buffer had the requested header extension- appbits:
Application specific bits
- data:
location for data
- Return type:
Parses RFC 5285 style header extensions with a two bytes header. It will return the nth extension with the requested id.
- get_header_len()[source]¶
- Returns:
The total length of the header in buffer.
- Return type:
Return the total length of the header in buffer. This include the length of the fixed header, the CSRC list and the extension header.
- get_packet_len()[source]¶
- Returns:
The total length of the packet in buffer.
- Return type:
Return the total length of the packet in buffer.
- get_payload()[source]¶
- Returns:
A new
GLib.Bytes
containing the payload data in self.- Return type:
GLib.Bytes
orNone
Similar to
GstRtp.RTPBuffer.get_payload
, but more suitable for language bindings usage. The return value is a pointer to aGLib.Bytes
structure containing the payload data in self.New in version 1.2.
- get_payload_buffer()[source]¶
- Returns:
A new buffer with the data of the payload.
- Return type:
Create a buffer of the payload of the RTP packet in buffer. This function will internally create a subbuffer of buffer so that a memcpy can be avoided.
- get_payload_len()[source]¶
- Returns:
The length of the payload in buffer.
- Return type:
Get the length of the payload of the RTP packet in buffer.
- get_payload_subbuffer(offset, len)[source]¶
- Parameters:
- Returns:
A new buffer with the specified data of the payload.
- Return type:
Create a subbuffer of the payload of the RTP packet in buffer. offset bytes are skipped in the payload and the subbuffer will be of size len. If len is -1 the total payload starting from offset is subbuffered.
- get_payload_type()[source]¶
- Returns:
The payload type.
- Return type:
Get the payload type of the RTP packet in buffer.
- get_seq()[source]¶
- Returns:
The sequence number in host order.
- Return type:
Get the sequence number of the RTP packet in buffer.
- get_ssrc()[source]¶
- Returns:
the SSRC of buffer in host order.
- Return type:
Get the SSRC of the RTP packet in buffer.
- get_timestamp()[source]¶
- Returns:
The timestamp in host order.
- Return type:
Get the timestamp of the RTP packet in buffer.
- get_version()[source]¶
- Returns:
The version of buffer.
- Return type:
Get the version number of the RTP packet in buffer.
- pad_to(len)[source]¶
- Parameters:
len (
int
) – the new amount of padding
Set the amount of padding in the RTP packet in buffer to len. If len is 0, the padding is removed.
NOTE: This function does not work correctly.
- remove_extension_data()[source]¶
Unsets the extension bit of the RTP buffer and removes the extension header and data.
If the RTP buffer has no header extension data, the action has no effect. The RTP buffer must be mapped READWRITE only once and the underlying
Gst.Buffer
must be writable.New in version 1.20.
- set_extension(extension)[source]¶
- Parameters:
extension (
bool
) – the new extension
Set the extension bit on the RTP packet in buffer to extension.
- set_extension_data(bits, length)[source]¶
- Parameters:
- Returns:
True if done.
- Return type:
Set the extension bit of the rtp buffer and fill in the bits and length of the extension header. If the existing extension data is not large enough, it will be made larger.
Will also shorten the extension data from 1.20.
- set_marker(marker)[source]¶
- Parameters:
marker (
bool
) – the new marker
Set the marker bit on the RTP packet in buffer to marker.
- set_packet_len(len)[source]¶
- Parameters:
len (
int
) – the new packet length
Set the total self size to len. The data in the buffer will be made larger if needed. Any padding will be removed from the packet.
- set_padding(padding)[source]¶
- Parameters:
padding (
bool
) – the new padding
Set the padding bit on the RTP packet in buffer to padding.
- set_payload_type(payload_type)[source]¶
- Parameters:
payload_type (
int
) – the new type
Set the payload type of the RTP packet in buffer to payload_type.
- set_seq(seq)[source]¶
- Parameters:
seq (
int
) – the new sequence number
Set the sequence number of the RTP packet in buffer to seq.
- set_ssrc(ssrc)[source]¶
- Parameters:
ssrc (
int
) – the new SSRC
Set the SSRC on the RTP packet in buffer to ssrc.
- set_timestamp(timestamp)[source]¶
- Parameters:
timestamp (
int
) – the new timestamp
Set the timestamp of the RTP packet in buffer to timestamp.