CBTAudioStreamSender Class Reference

class CBTAudioStreamSender : public CActive

This class handles the sending of RTP frames on general level.

This class takes care of all the operations related to an RTP frame that are common to all formats. Such operations are e.g. timestamp handling and frame sending.

The child classes of this are used for handling the encoder specific frame handling. This class specifies and calls pure virtual methods that must be implemented by an encoder specific child class.

btaudiostreamer.lib
Since
S60 v3.1

Inherits from

Public Member Functions
~CBTAudioStreamSender()
voidDoPacketSent()
voidDoSendError()
CBTAudioStreamSender *NewL(MBTAudioStreamSenderObserver &, RRtpSession &)
voidPacketSent(CBTAudioStreamSender *, const TRtpEvent &)
voidSendError(CBTAudioStreamSender *, const TRtpEvent &)
TInt SendThisBuffer(const TDesC8 &, TTimeIntervalMicroSeconds)
TInt SetNewFrameLength(TUint, const TUint, const TUint)
voidStartL(TUint, const TUint, const TUint)
voidStop()
Protected Member Functions
CBTAudioStreamSender(MBTAudioStreamSenderObserver &, RRtpSession &)
TInt AddBufferToSendPacket(const TDesC8 &)
TInt AddHeaderToSendPacket(TPtr8 &)
voidAdjustTimestamp(TInt64 &)
TUint CalculateFrameDuration(const TUint, const TUint)
TInt CalculatePacketLength(TUint, const TUint)
voidConstructL()
voidDoCancel()
TInt InitSender(RRtpSendPacket &, TPtr8 &, const TUint)
TUint MaxFramesPerPacket()
TInt PacketSendingCompleted(TPtr8 &)
voidRunL()
Private Member Functions
voidConsumeBuffer()
voidProceedToPacketSending()
voidSwitchToNewSendPacket()
Inherited Functions
CActive::CActive(TInt)
CActive::Cancel()
CActive::Deque()
CActive::Extension_(TUint,TAny *&,TAny *)
CActive::IsActive()const
CActive::IsAdded()const
CActive::Priority()const
CActive::RunError(TInt)
CActive::SetActive()
CActive::SetPriority(TInt)
CActive::~CActive()
CBase::CBase()
CBase::Delete(CBase *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Private Member Enumerations
enumTStreamerState { EStopped, EBuffering, ESending, EErrorSending }
Inherited Enumerations
CActive:TPriority
Private Attributes
RA2dpOptimiser iA2DPOptimiser
TInt64 iAdjustedTimestamp
const TDesC8 *iBuffer
TBool iChangingFrameLength
RRtpSendPacket *iCurrentSendPacket
TBool iKeepPreviousTimestamp
TBool iLinkOptimiserAvailable
TInt iNewFrameLength
TBool iNonprocessedDataInBuffer
MBTAudioStreamSenderObserver &iObserver
TPtr8 iPayloadDesC
RRtpSession &iRtpSession
RRtpSendSource iSendSrc
RRtpSendPacket *iSpareSendPacket
TStreamerState iStreamerState
TUint iTargetBitrate
RThread iThread
TInt64 iTimestamp
Inherited Attributes
CActive::iStatus

Constructor & Destructor Documentation

CBTAudioStreamSender(MBTAudioStreamSenderObserver &, RRtpSession &)

CBTAudioStreamSender(MBTAudioStreamSenderObserver &aObserver,
RRtpSession &aSession
)[protected]

Parameters

MBTAudioStreamSenderObserver & aObserver
RRtpSession & aSession

~CBTAudioStreamSender()

~CBTAudioStreamSender()

Member Functions Documentation

AddBufferToSendPacket(const TDesC8 &)

TInt AddBufferToSendPacket(const TDesC8 &aBuffer)[protected, pure virtual]

A pure virtual method that must be implemented by the encoder specific child class. This method moves the audio frames from buffer to SendPacket in encoder specific way.

Since
S60 v3.1

Parameters

const TDesC8 & aBuffercontains the audio data frames.

AddHeaderToSendPacket(TPtr8 &)

TInt AddHeaderToSendPacket(TPtr8 &aPayloadDesC)[protected, pure virtual]

A pure virtual method that must be implemented by the encoder specific child class. This method places a header to SendPacket in encoder specific way.

Since
S60 v3.1

Parameters

TPtr8 & aPayloadDesC

AdjustTimestamp(TInt64 &)

voidAdjustTimestamp(TInt64 &aTimestamp)[protected, pure virtual]

A pure virtual method that must be implemented by the encoder specific child class. This method adjusts the incoming timestamp if buffers don't fill the SendPacket exactly.

Since
S60 v5.0

Parameters

TInt64 & aTimestampA 64 bit representation of the timestamp to adjust. This will change during the call.

CalculateFrameDuration(const TUint, const TUint)

TUint CalculateFrameDuration(const TUintaFrameLength,
const TUintaTargetBitrate
)[protected, pure virtual]

This method calculates the playing time of one frame in microseconds. The result is encoder specific.

Since
S60 Timebox 9.2

Parameters

const TUint aFrameLength
const TUint aTargetBitrate

CalculatePacketLength(TUint, const TUint)

TInt CalculatePacketLength(TUintaOutboundMTUSize,
const TUintaFrameLength
)[protected, pure virtual]

A pure virtual method that must be implemented by the encoder specific child class. This method handles the encoder specific packet length calculation.

Since
S60 v3.1

Parameters

TUint aOutboundMTUSizeThe MTU size for outgoing L2CAP link.
const TUint aFrameLengthThe length of one audio data frame.

ConstructL()

voidConstructL()[protected]

ConsumeBuffer()

voidConsumeBuffer()[private, inline]

An inline method that empties the received buffer. This method uses encoder specific inherited class to handles the encoder specific data. and then decides whether to send the data out or request for more data.

Since
S60 v3.1

DoCancel()

voidDoCancel()[protected, virtual]

Implements cancellation of an outstanding request.

This function is called as part of the active object's Cancel().

It must call the appropriate cancel function offered by the active object's asynchronous service provider. The asynchronous service provider's cancel is expected to act immediately.

DoCancel() must not wait for event completion; this is handled by Cancel().

CActive::Cancel

DoPacketSent()

voidDoPacketSent()[virtual]

Method for actually handling the RTP API callbacks for sent packets.

Since
S60 v3.1

DoSendError()

voidDoSendError()[virtual]

Method for actually handling the RTP API callback for send errors.

Since
S60 v3.1

InitSender(RRtpSendPacket &, TPtr8 &, const TUint)

TInt InitSender(RRtpSendPacket &aSendPacket,
TPtr8 &aPayloadDesC,
const TUintaTargetBitrate
)[protected, pure virtual]

A pure virtual method that must be implemented by the encoder specific child class. This method handles the encoder specific initialisation.

Since
S60 v3.1

Parameters

RRtpSendPacket & aSendPacket
TPtr8 & aPayloadDesC
const TUint aTargetBitrate

MaxFramesPerPacket()

TUint MaxFramesPerPacket()[protected, pure virtual]

A pure virtual method that must be implemented by the encoder specific child class. This method returns the maximum number of frames in one outgoing packet.

Since
S60 Timebox 9.2

NewL(MBTAudioStreamSenderObserver &, RRtpSession &)

CBTAudioStreamSender *NewL(MBTAudioStreamSenderObserver &aObserver,
RRtpSession &aSession
)[static]

Parameters

MBTAudioStreamSenderObserver & aObserver
RRtpSession & aSession

PacketSendingCompleted(TPtr8 &)

TInt PacketSendingCompleted(TPtr8 &aPayloadDesC)[protected, pure virtual]

A pure virtual method that must be implemented by the encoder specific child class. This method handles the encoder specific operations that should be done after the packet has been sent.

Since
S60 v3.1

Parameters

TPtr8 & aPayloadDesC

PacketSent(CBTAudioStreamSender *, const TRtpEvent &)

voidPacketSent(CBTAudioStreamSender *aPtr,
const TRtpEvent &aEvent
)[static]

A callback for registering with RTP API

Since
S60 v3.1

Parameters

CBTAudioStreamSender * aPtrAn pointer to an instance that handles the callback.
const TRtpEvent & aEventHandle to the event that occurred.

ProceedToPacketSending()

voidProceedToPacketSending()[private, inline]

An inline method that self completes this active object. The purpose of this is to set the data provider thread free and continue execution in this thread's context.

Since
S60 v3.1

RunL()

voidRunL()[protected, virtual]

Handles an active object's request completion event.

A derived class must provide an implementation to handle the completed request. If appropriate, it may issue another request.

The function is called by the active scheduler when a request completion event occurs, i.e. after the active scheduler's WaitForAnyRequest() function completes.

Before calling this active object's RunL() function, the active scheduler has:

1. decided that this is the highest priority active object with a completed request

2. marked this active object's request as complete (i.e. the request is no longer outstanding)

RunL() runs under a trap harness in the active scheduler. If it leaves, then the active scheduler calls RunError() to handle the leave.

Note that once the active scheduler's Start() function has been called, all user code is run under one of the program's active object's RunL() or RunError() functions.

CActiveScheduler::Start CActiveScheduler::Error CActiveScheduler::WaitForAnyRequest TRAPD

SendError(CBTAudioStreamSender *, const TRtpEvent &)

voidSendError(CBTAudioStreamSender *aPtr,
const TRtpEvent &aEvent
)[static]

A callback for registering with RTP API

Since
S60 v3.1

Parameters

CBTAudioStreamSender * aPtrAn instance who handles the callback.
const TRtpEvent & aEventHandle to the event that occurred.

SendThisBuffer(const TDesC8 &, TTimeIntervalMicroSeconds)

TInt SendThisBuffer(const TDesC8 &aBuffer,
TTimeIntervalMicroSecondsaTimestamp
)[virtual]

An implementation of the buffer handling method.

Since
S60 v3.1

Parameters

const TDesC8 & aBuffercontains the audio data frames.
TTimeIntervalMicroSeconds aTimestampThe timestamp of the audio data frames.

SetNewFrameLength(TUint, const TUint, const TUint)

TInt SetNewFrameLength(TUintaOutboundMTUSize,
const TUintaFrameLength,
const TUintaTargetBitrate
)[virtual]

Parameters

TUint aOutboundMTUSize
const TUint aFrameLength
const TUint aTargetBitrate

StartL(TUint, const TUint, const TUint)

voidStartL(TUintaOutboundMTUSize,
const TUintaFrameLength,
const TUintaTargetBitrate
)[virtual]

This method prepares the Stream Sender for incoming audio buffers.

Since
S60 v3.1

Parameters

TUint aOutboundMTUSizeThe MTU size for outgoing L2CAP link.
const TUint aFrameLengthThe length of one audio data frame.
const TUint aTargetBitrate

Stop()

voidStop()[virtual]

This method contains the code for closing the RTP API and cleaning up.

Since
S60 v3.1

SwitchToNewSendPacket()

voidSwitchToNewSendPacket()[private, inline]

An inline method that switches to new sendpacket when the length of frame has changed. This method also initializes the sender to use the new packet.

Since
S60 v3.1

Member Enumerations Documentation

Enum TStreamerState

The possible states of the Streamer.

Enumerators

EStopped
EBuffering
ESending
EErrorSending

Member Data Documentation

RA2dpOptimiser iA2DPOptimiser

RA2dpOptimiser iA2DPOptimiser[private]

A2DP optimiser object that is needed for prioritising A2DP audio over other data.

TInt64 iAdjustedTimestamp

TInt64 iAdjustedTimestamp[private]

This stores the timestamp which we must place in the header.

const TDesC8 * iBuffer

const TDesC8 *iBuffer[private]

This stores a reference to the buffer until it has been emptied and can be given back to the audio adaptation.

TBool iChangingFrameLength

TBool iChangingFrameLength[private]

This tells if the frame length is changing. If it is, then we won't put frames of new length into the same packet with the old frames. After sending the old frames a new sendpacket is taken into use.

RRtpSendPacket * iCurrentSendPacket

RRtpSendPacket *iCurrentSendPacket[private]

These assist with creating RTP payloads with proper header and content.

TBool iKeepPreviousTimestamp

TBool iKeepPreviousTimestamp[private]

This tells whether we should keep the previous timestamp or overwrite it with the most recent one.

TBool iLinkOptimiserAvailable

TBool iLinkOptimiserAvailable[private]

This tells if the streaming optimiser service is available.

TInt iNewFrameLength

TInt iNewFrameLength[private]

This stores the new framelength when the streaming parameters are changing.

TBool iNonprocessedDataInBuffer

TBool iNonprocessedDataInBuffer[private]

This tells whether we should keep moving data from buffer to an incoming frame. The value is set to ETrue when new frame arrives and when the buffer was completely consumed and sent, this value is set to EFalse.

MBTAudioStreamSenderObserver & iObserver

MBTAudioStreamSenderObserver &iObserver[private]

This stores a reference to the observer of this class.

TPtr8 iPayloadDesC

TPtr8 iPayloadDesC[private]

A pointer to the send packet's contents. It is used to abstract away the container of the data.

RRtpSession & iRtpSession

RRtpSession &iRtpSession[private]

RTP session reference, needed for creating the SendSource.

RRtpSendSource iSendSrc

RRtpSendSource iSendSrc[private]

RRtpSendSoure is needed for SendPacket management.

RRtpSendPacket * iSpareSendPacket

RRtpSendPacket *iSpareSendPacket[private]

TStreamerState iStreamerState

TStreamerState iStreamerState[private]

This stores the current state of the streamer.

TUint iTargetBitrate

TUint iTargetBitrate[private]

This stores the target bitrate. The reason for this is that it is not applied immediately, but after the current packet is sent.

RThread iThread

RThread iThread[private]

An instance of our thread. This is needed for self completing the requests, which forces the ActiveScheduler to call our RunL.

TInt64 iTimestamp

TInt64 iTimestamp[private]

This stores the timestamp which we must place in the header.