Update contrib.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __AUDIOBUFFERARRAY_H__
17 #define __AUDIOBUFFERARRAY_H__
22 const TUint KMaxNumberOfSBCFramesPerRTPPacket = 15;
24 class TSBCFrameParameters;
25 class CA2dpAudioCodecConfiguration;
27 This class contains an array of RRtpSendPackets that contain
28 the audio to be sent to the headset over RTP
29 Note that the RRtpSendPackets are only created once upfront
30 it is assumed that these packets can be recycled
31 Each audio buffer consists of one CRtpSendPackets class instance,
32 however due to the underlying restrictions imposed by A2DP and
33 the BT L2CAP bearer MTU size limit- each CRtpSendPackets may
34 consist of one or more RRtpSendPacket
38 NONSHARABLE_CLASS(CRtpSendPackets) : public CBase
41 static CRtpSendPackets* NewL(RRtpSendSource& aRtpSendSource, TUint aNumberOfPackets);
43 void ConstructL(RRtpSendSource& aRtpSendSource, TUint aNumberOfPackets);
44 inline RRtpSendPacket& Packet(TUint aPacketNumber);
46 void CloseAndResetSendPackets();
48 RArray<RRtpSendPacket> iRtpSendPackets;
53 This function obtains the next free RTPsendPacket
54 that is available to be filled with audio data
56 @return RRtpSendPacket that is free and hence can be filled with audio
58 inline RRtpSendPacket& CRtpSendPackets::Packet(TUint aPacketNumber)
60 return iRtpSendPackets[aPacketNumber];
66 This class is used by CActiveRTPStreamer
67 It is a FIFO used to provide a buffer array of audio buffers.
68 Each audio buffer is contained in one CRtpSendPackets which
69 may itself be broken up into multiple RTP packets.
70 The size and number of packets each audio buffer is broken down is
71 calculated from the various input parameters provided to the NewL.
72 This class makes the assumption than provided the audio parameters
73 are unchanged, then the buffer length stays the same for each buffer sent,
74 (except the last buffer)
75 This assumption has been made, as by not assuming this, then the frame duration
76 and number of frames calculations would need to be recalculated for every audio buffer
77 and the RTPSendPackets would need to be created for every buffer.
81 NONSHARABLE_CLASS(CAudioBufferArray) : public CBase
84 static CAudioBufferArray* NewL(RRtpSendSource& aRtpSendSource,
85 TUint aNumberOfAudioBuffers,
86 TUint aAudioBufferSize,
88 TUint aTotalRTPHeaderLength,
91 void CurrentAudioBufferReadyToSend();
92 void CancelMostRecentAudioBuffer(TBool aSendInProgress);
93 void FlushPendingPackets();
94 RRtpSendPacket& CurrentSendPacket();
95 void CurrentSendPacketSent(TBool& aEntireAudioBufferSent);
96 inline CRtpSendPackets* CurrentAudioBufferRtpSendPackets() const;
97 inline TUint NumberOfAudioBuffersReadyToSend() const;
98 inline TUint MaxNumberOfAudioBuffers() const;
99 inline TUint InputBytesPerRTPPacket() const;
100 inline TUint NumberOfRtpPacketsPerAudioBuffer() const;
101 inline TUint NumberOfFramesPerRtpPacket() const;
103 void ConstructL(RRtpSendSource& aRtpSendSource,
104 TUint aNumberOfAudioBuffers,
105 TUint aAudioBufferSize,
107 TUint aTotalRTPHeaderLength,
110 RPointerArray<CRtpSendPackets> iAudioBufferArray;
111 TUint iAudioBufferBeingSent;
112 TUint iNextRtpPacketToSend;
113 TUint iNextAudioBufferToFill;
114 TUint iNumberOfReadyAudioBuffers;
115 TUint iNumberOfRtpPacketsPerAudioBuffer;
116 TUint iInputBytesPerRtpPacket;
118 TUint iNumberOfFramesPerRtpPacket;
123 This function obtains the current free audio buffer
124 in the form of a CRTPsendPackets
125 The CRTPsendPackets returned are available to be filled with audio data
127 @return CRtpSendPackets array that is free and hence can be filled with audio
129 inline CRtpSendPackets* CAudioBufferArray::CurrentAudioBufferRtpSendPackets() const
131 return iAudioBufferArray[iNextAudioBufferToFill];
136 This function returns the total number of audio buffers in the
137 audio buffer array that have been filled with audio and hence are
138 ready to be sent to the headset.
140 @return number of audio buffers ready to send
142 inline TUint CAudioBufferArray::NumberOfAudioBuffersReadyToSend() const
144 return iNumberOfReadyAudioBuffers;
149 This function returns the maximum number of audio buffers that
150 can be stored in the audio buffer array.
151 It is set by the aNumberOfAudioBuffers parameter in the constructor
153 @return max number of audio buffers that can be stored in the audio
156 inline TUint CAudioBufferArray::MaxNumberOfAudioBuffers() const
158 return iAudioBufferArray.Count();
163 This function returns the number of input bytes
164 ie bytes prior to any codec processing that will
165 (after possible codec processing) constitute an RTP packet
167 @return input bytes per RTP packet
169 inline TUint CAudioBufferArray::InputBytesPerRTPPacket() const
171 return iInputBytesPerRtpPacket;
176 This function returns the number of RTP packets that make up an audio buffer
178 @return number of RTP packets
180 inline TUint CAudioBufferArray::NumberOfRtpPacketsPerAudioBuffer() const
182 return iNumberOfRtpPacketsPerAudioBuffer;
187 This function returns the number of audio frames in a single RTP packet
188 ie the total number of audio frames in a single audio buffer is given by:
189 NumberOfFramesPerRtpPacket()*NumberOfRtpPacketsPerAudioBuffer()
191 @return number of audio frames in a single RTP packet
193 inline TUint CAudioBufferArray::NumberOfFramesPerRtpPacket() const
195 return iNumberOfFramesPerRtpPacket;