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.
Public Member Functions | |
---|---|
~CBTAudioStreamSender() | |
void | DoPacketSent() |
void | DoSendError() |
CBTAudioStreamSender * | NewL(MBTAudioStreamSenderObserver &, RRtpSession &) |
void | PacketSent(CBTAudioStreamSender *, const TRtpEvent &) |
void | SendError(CBTAudioStreamSender *, const TRtpEvent &) |
TInt | SendThisBuffer(const TDesC8 &, TTimeIntervalMicroSeconds) |
TInt | SetNewFrameLength(TUint, const TUint, const TUint) |
void | StartL(TUint, const TUint, const TUint) |
void | Stop() |
Protected Member Functions | |
---|---|
CBTAudioStreamSender(MBTAudioStreamSenderObserver &, RRtpSession &) | |
TInt | AddBufferToSendPacket(const TDesC8 &) |
TInt | AddHeaderToSendPacket(TPtr8 &) |
void | AdjustTimestamp(TInt64 &) |
TUint | CalculateFrameDuration(const TUint, const TUint) |
TInt | CalculatePacketLength(TUint, const TUint) |
void | ConstructL() |
void | DoCancel() |
TInt | InitSender(RRtpSendPacket &, TPtr8 &, const TUint) |
TUint | MaxFramesPerPacket() |
TInt | PacketSendingCompleted(TPtr8 &) |
void | RunL() |
Private Member Functions | |
---|---|
void | ConsumeBuffer() |
void | ProceedToPacketSending() |
void | SwitchToNewSendPacket() |
Private Member Enumerations | |
---|---|
enum | TStreamerState { EStopped, EBuffering, ESending, EErrorSending } |
Inherited Enumerations | |
---|---|
CActive:TPriority |
Inherited Attributes | |
---|---|
CActive::iStatus |
CBTAudioStreamSender | ( | MBTAudioStreamSenderObserver & | aObserver, |
RRtpSession & | aSession | ||
) | [protected] |
MBTAudioStreamSenderObserver & aObserver | |
RRtpSession & aSession |
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.
const TDesC8 & aBuffer | contains the audio data frames. |
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.
TPtr8 & aPayloadDesC |
void | AdjustTimestamp | ( | 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.
TInt64 & aTimestamp | A 64 bit representation of the timestamp to adjust. This will change during the call. |
TUint | CalculateFrameDuration | ( | const TUint | aFrameLength, |
const TUint | aTargetBitrate | |||
) | [protected, pure virtual] |
This method calculates the playing time of one frame in microseconds. The result is encoder specific.
TInt | CalculatePacketLength | ( | TUint | aOutboundMTUSize, |
const TUint | aFrameLength | |||
) | [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.
void | ConsumeBuffer | ( | ) | [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.
void | DoCancel | ( | ) | [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().
void | DoPacketSent | ( | ) | [virtual] |
Method for actually handling the RTP API callbacks for sent packets.
void | DoSendError | ( | ) | [virtual] |
Method for actually handling the RTP API callback for send errors.
TInt | InitSender | ( | RRtpSendPacket & | aSendPacket, |
TPtr8 & | aPayloadDesC, | |||
const TUint | aTargetBitrate | |||
) | [protected, pure virtual] |
A pure virtual method that must be implemented by the encoder specific child class. This method handles the encoder specific initialisation.
RRtpSendPacket & aSendPacket | |
TPtr8 & aPayloadDesC | |
const TUint aTargetBitrate |
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.
CBTAudioStreamSender * | NewL | ( | MBTAudioStreamSenderObserver & | aObserver, |
RRtpSession & | aSession | |||
) | [static] |
MBTAudioStreamSenderObserver & aObserver | |
RRtpSession & aSession |
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.
TPtr8 & aPayloadDesC |
void | PacketSent | ( | CBTAudioStreamSender * | aPtr, |
const TRtpEvent & | aEvent | |||
) | [static] |
A callback for registering with RTP API
CBTAudioStreamSender * aPtr | An pointer to an instance that handles the callback. |
const TRtpEvent & aEvent | Handle to the event that occurred. |
void | ProceedToPacketSending | ( | ) | [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.
void | RunL | ( | ) | [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
void | SendError | ( | CBTAudioStreamSender * | aPtr, |
const TRtpEvent & | aEvent | |||
) | [static] |
A callback for registering with RTP API
CBTAudioStreamSender * aPtr | An instance who handles the callback. |
const TRtpEvent & aEvent | Handle to the event that occurred. |
TInt | SendThisBuffer | ( | const TDesC8 & | aBuffer, |
TTimeIntervalMicroSeconds | aTimestamp | |||
) | [virtual] |
An implementation of the buffer handling method.
const TDesC8 & aBuffer | contains the audio data frames. |
TTimeIntervalMicroSeconds aTimestamp | The timestamp of the audio data frames. |
TInt | SetNewFrameLength | ( | TUint | aOutboundMTUSize, |
const TUint | aFrameLength, | |||
const TUint | aTargetBitrate | |||
) | [virtual] |
void | StartL | ( | TUint | aOutboundMTUSize, |
const TUint | aFrameLength, | |||
const TUint | aTargetBitrate | |||
) | [virtual] |
This method prepares the Stream Sender for incoming audio buffers.
void | Stop | ( | ) | [virtual] |
This method contains the code for closing the RTP API and cleaning up.
void | SwitchToNewSendPacket | ( | ) | [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.
The possible states of the Streamer.
EStopped | |
EBuffering | |
ESending | |
EErrorSending |
RA2dpOptimiser | iA2DPOptimiser | [private] |
A2DP optimiser object that is needed for prioritising A2DP audio over other data.
TInt64 | iAdjustedTimestamp | [private] |
This stores the timestamp which we must place in the header.
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 | [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 | [private] |
These assist with creating RTP payloads with proper header and content.
TBool | iKeepPreviousTimestamp | [private] |
This tells whether we should keep the previous timestamp or overwrite it with the most recent one.
TBool | iLinkOptimiserAvailable | [private] |
This tells if the streaming optimiser service is available.
TInt | iNewFrameLength | [private] |
This stores the new framelength when the streaming parameters are changing.
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 | [private] |
This stores a reference to the observer of this class.
TPtr8 | iPayloadDesC | [private] |
A pointer to the send packet's contents. It is used to abstract away the container of the data.
RRtpSession & | iRtpSession | [private] |
RTP session reference, needed for creating the SendSource.
RRtpSendSource | iSendSrc | [private] |
RRtpSendSoure is needed for SendPacket management.
TStreamerState | iStreamerState | [private] |
This stores the current state of the streamer.
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 | [private] |
An instance of our thread. This is needed for self completing the requests, which forces the ActiveScheduler to call our RunL.
TInt64 | iTimestamp | [private] |
This stores the timestamp which we must place in the header.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.