# API Reference

class `pylibsrtp.``Error`

  Error that occurred making a libsrtp API call.

class `pylibsrtp.``Policy`(key=None, ssrc_type=0, ssrc_value=0)

  Policy for single SRTP stream.

  `SSRC_ANY_INBOUND` = 2

    Indicates any inbound SSRC value

  `SSRC_ANY_OUTBOUND` = 3

    Indicates any inbound SSRC value

  `SSRC_SPECIFIC` = 1

    Indicates a specific SSRC value

  `SSRC_UNDEFINED` = 0

    Indicates an undefined SSRC type

  `allow_repeat_tx`

    Whether retransmissions of packets with the same sequence number are allowed.

  `key`

    The SRTP master key.

  `ssrc_type`

    The SSRC type.

  `ssrc_value`

    The SSRC value, if it is not a wildcard.

  `window_size`

    The window size to use for replay protection.

class `pylibsrtp.``Session`(policy=None)

  SRTP session, which may comprise several streams.

  If policy is not specified, streams should be added later using the `add_stream()` method.

  `add_stream`(policy)

    Add a stream to the SRTP session, applying the given policy to the stream.

    Parameters: | policy – `Policy`

  `protect`(packet)

    Apply SRTP protection to the RTP packet.

    Parameters: | packet – `bytes`
    Return type: | `bytes`

  `protect_rtcp`(packet)

    Apply SRTCP protection to the RTCP packet.

    Parameters: | packet – `bytes`
    Return type: | `bytes`

  `remove_stream`(ssrc)

    Remove the stream with the given ssrc from the SRTP session.

    Parameters: | ssrc – `int`

  `unprotect`(packet)

    Verify SRTP protection of the SRTP packet.

    Parameters: | packet – `bytes`
    Return type: | `bytes`

  `unprotect_rtcp`(packet)

    Verify SRTCP protection of the SRTCP packet.

    Parameters: | packet – `bytes`
    Return type: | `bytes`