Creating a SRTP Stream

SRTP library generates SRTP packets from the RTP or RTCP stream and forwards the packets to the receiver. SRTP transforms incoming SRTP packets to RTP/RTCP packets and passes them up the stack.

The cryptographic state information associated with each SRTP stream is termed the cryptographic context. The state information is maintained by both the sender and receiver of SRTP streams. If multiple SRTP streams exist within a given RTP session, then separate cryptographic contexts must be maintained for each stream. Each stream is identified by a Synchronisation Source (SSRC). The stream can be a incoming or outgoing.

Prior to stream creation:

  • A SRTP session must be created and initialised.

  • Values to populate the cryptographic context for the stream shall be available.

    The callback object (for MSRTPReKeyingObserver) shall be implemented .

  1. Create a SRTP stream (incoming) by invoking the NewL() of the class CSRTPStreamIn. The functions NewL() has six variants. Each of the variants are explained below.

    1. 
                           IMPORT_C static CSRTPStreamIn* NewL( CSRTPSession& aSession,
                                            TUint aSSRC);
      This API is appropriate when the stream uses the cryptographic context of the session. aSession is the input parameter that contains the session. The stream will use the cryptographic context of the session. aSSRC is the input parameter that contains the synchronization source ID of the SRTP stream. The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    2. 
                           IMPORT_C static CSRTPStreamIn* NewL( CSRTPSession& aSession,
                                            TUint aSSRC,
                                            CSRTPCryptoContext* aCon,
                                            MSRTPReKeyingObserver& aObs );
      This API is appropriate when the stream will have a cryptographic context of its own. aSession is the input parameter that contains the session. aSSRC is the input parameter that contains the synchronization source ID of the SRTP stream. aCon is the input parameter that contains cryptographic context of the SRTP stream. aObs is the callback object. The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    3. 
                           IMPORT_C static CSRTPStreamIn* NewL( CSRTPSession& aSession);
      This API is appropriate when the stream will use the cryptographic context of the session. No synchronisation source id is provided at the time of stream creation. The stream uses late binding. aSession is the input parameter that contains the session. The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    4. 
                           IMPORT_C static CSRTPStreamIn* NewL( CSRTPSession& aSession,
                                            CSRTPCryptoContext* aCon,
                                            MSRTPReKeyingObserver& aObs );
      This API is appropriate when the stream will have a cryptographic context of its own. No synchronisation source id is provided at the time of stream creation. The stream uses late binding. aSession is the input parameter that contains the session. aCon is the input parameter that contains cryptographic context of the SRTP stream. aObs is the callback object. The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    5. 
                          IMPORT_C static CSRTPStreamIn* NewL( CSRTPSession& aSession,
                                            TUint aSSRC,
                                            MSRTPReKeyingObserver& aObs );
      This API is appropriate when the stream will have a cryptographic context of its own. The cryptographic context is set later using SetCryptoInL(). aSession is the input parameter that contains the session. aSSRC is the input parameter that contains the synchronization source ID of the SRTP stream. aObs is the callback object. The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    6. 
                           IMPORT_C static CSRTPStreamIn* NewL( CSRTPSession& aSession,
                                            MSRTPReKeyingObserver& aObs ); 
      This API is appropriate when the stream will have a cryptographic context of its own. The cryptographic context is set later using SetCryptoInL(). No synchronisation source id is provided at the time of stream creation .The stream uses late binding. aSession is the input parameter that contains the session. aObs is the callback object. The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.
  2. Create a SRTP stream (outgoing) by invoking the NewL() of the class CSRTPStreamOut. The functions NewL() has three variants. Each of the variants are explained below.

    1. 
                           IMPORT_C static CSRTPStreamOut* NewL( CSRTPSession& aSession, TUint aSSRC );
      This API is appropriate when the stream uses the cryptographic context of the session. aSession is the input parameter that contains the session. The stream will use the cryptographic context of the session. aSSRC is the input parameter that contains the synchronization source ID of the SRTP stream. The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    2. 
                           IMPORT_C static CSRTPStreamOut* NewL( CSRTPSession& aSession,
                                             TUint aSSRC,
                                             CSRTPCryptoContext* aCon,
                                             MSRTPReKeyingObserver& aObs );
              
      This API is appropriate when the stream will have a cryptographic context of its own. aSession is the input parameter that contains the session. aSSRC is the input parameter that contains the synchronization source ID of the SRTP stream. aCon is the input parameter that contains cryptographic context of the SRTP stream. aObs is the callback object. The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

    3. 
                          IMPORT_C static CSRTPStreamOut* NewL( CSRTPSession& aSession,
                                             TUint aSSRC,
                                             MSRTPReKeyingObserver& aObs ); 
      This API is appropriate when the stream will have a cryptographic context of its own. The cryptographic context is set later using SetCryptoOutL(). aSession is the input parameter that contains the session. aSSRC is the input parameter that contains the synchronization source ID of the SRTP stream. aObs is the callback object. The API leaves with KErrNone if successfully executed, else returns a valid system-wide error code.

On successful execution of the API, a SRTP stream is created and initialized.

The cryptographic context of the stream can be deleted and the stream can be re-initialised using UpdateCryptoAndStatesL() .