- changes to library
This commit is contained in:
parent
c34bcdc058
commit
c303b6f09d
|
|
@ -56,7 +56,8 @@ SpeexResampler::~SpeexResampler()
|
|||
stop();
|
||||
}
|
||||
|
||||
size_t SpeexResampler::processBuffer(const void* src, size_t sourceLength, size_t& sourceProcessed, void* dest, size_t destCapacity)
|
||||
size_t SpeexResampler::processBuffer(const void* src, size_t sourceLength, size_t& sourceProcessed,
|
||||
void* dest, size_t destCapacity)
|
||||
{
|
||||
assert(mSourceRate != 0 && mDestRate != 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,14 +24,15 @@ namespace Audio
|
|||
|
||||
void start(int channels, int sourceRate, int destRate);
|
||||
void stop();
|
||||
int processBuffer(const void* source, int sourceLength, int& sourceProcessed, void* dest, int destCapacity);
|
||||
size_t processBuffer(const void* source, size_t sourceLength, size_t& sourceProcessed,
|
||||
void* dest, size_t destCapacity);
|
||||
int sourceRate();
|
||||
int destRate();
|
||||
int getDestLength(int sourceLen);
|
||||
int getSourceLength(int destLen);
|
||||
size_t getDestLength(size_t sourceLen);
|
||||
size_t getSourceLength(size_t destLen);
|
||||
|
||||
// Returns instance + speex encoder size in bytes
|
||||
int getSize() const;
|
||||
size_t getSize() const;
|
||||
|
||||
protected:
|
||||
void* mContext;
|
||||
|
|
@ -59,9 +60,10 @@ namespace Audio
|
|||
UniversalResampler();
|
||||
~UniversalResampler();
|
||||
|
||||
int resample(int sourceRate, const void* sourceBuffer, int sourceLength, int& sourceProcessed, int destRate, void* destBuffer, int destCapacity);
|
||||
int getDestLength(int sourceRate, int destRate, int sourceLength);
|
||||
int getSourceLength(int sourceRate, int destRate, int destLength);
|
||||
size_t resample(int sourceRate, const void* sourceBuffer, size_t sourceLength, size_t& sourceProcessed,
|
||||
int destRate, void* destBuffer, size_t destCapacity);
|
||||
size_t getDestLength(int sourceRate, int destRate, size_t sourceLength);
|
||||
size_t getSourceLength(int sourceRate, int destRate, size_t destLength);
|
||||
|
||||
protected:
|
||||
typedef std::pair<int, int> RatePair;
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ public:
|
|||
struct PacketData
|
||||
{
|
||||
const uint8_t* mData;
|
||||
int mLength;
|
||||
size_t mLength;
|
||||
|
||||
PacketData(const uint8_t* data, int length)
|
||||
PacketData(const uint8_t* data, size_t length)
|
||||
:mData(data), mLength(length)
|
||||
{}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ struct RtcpHeader
|
|||
uint32_t ssrc; /* synchronization source */
|
||||
};
|
||||
|
||||
bool RtpHelper::isRtp(const void* buffer, int length)
|
||||
bool RtpHelper::isRtp(const void* buffer, size_t length)
|
||||
{
|
||||
if (length < 12)
|
||||
return false;
|
||||
|
|
@ -49,7 +49,7 @@ bool RtpHelper::isRtp(const void* buffer, int length)
|
|||
}
|
||||
|
||||
|
||||
bool RtpHelper::isRtpOrRtcp(const void* buffer, int length)
|
||||
bool RtpHelper::isRtpOrRtcp(const void* buffer, size_t length)
|
||||
{
|
||||
if (length < 12)
|
||||
return false;
|
||||
|
|
@ -58,12 +58,12 @@ bool RtpHelper::isRtpOrRtcp(const void* buffer, int length)
|
|||
return (b & 0xC0 ) == 128;
|
||||
}
|
||||
|
||||
bool RtpHelper::isRtcp(const void* buffer, int length)
|
||||
bool RtpHelper::isRtcp(const void* buffer, size_t length)
|
||||
{
|
||||
return (isRtpOrRtcp(buffer, length) && !isRtp(buffer, length));
|
||||
}
|
||||
|
||||
unsigned RtpHelper::findSsrc(const void* buffer, int length)
|
||||
unsigned RtpHelper::findSsrc(const void* buffer, size_t length)
|
||||
{
|
||||
if (isRtp(buffer, length))
|
||||
return reinterpret_cast<const RtpHeader*>(buffer)->ssrc;
|
||||
|
|
@ -71,7 +71,7 @@ unsigned RtpHelper::findSsrc(const void* buffer, int length)
|
|||
return reinterpret_cast<const RtcpHeader*>(buffer)->ssrc;
|
||||
}
|
||||
|
||||
int RtpHelper::findPtype(const void* buffer, int length)
|
||||
int RtpHelper::findPtype(const void* buffer, size_t length)
|
||||
{
|
||||
if (isRtp(buffer, length))
|
||||
return reinterpret_cast<const RtpHeader*>(buffer)->pt;
|
||||
|
|
@ -79,7 +79,7 @@ int RtpHelper::findPtype(const void* buffer, int length)
|
|||
return -1;
|
||||
}
|
||||
|
||||
int RtpHelper::findPayloadLength(const void* buffer, int length)
|
||||
int RtpHelper::findPayloadLength(const void* buffer, size_t length)
|
||||
{
|
||||
if (isRtp(buffer, length))
|
||||
{
|
||||
|
|
@ -90,7 +90,7 @@ int RtpHelper::findPayloadLength(const void* buffer, int length)
|
|||
}
|
||||
|
||||
RtpDump::RtpDump(const char *filename)
|
||||
:mFilename(filename)
|
||||
:mFilename(filename)
|
||||
{}
|
||||
|
||||
RtpDump::~RtpDump()
|
||||
|
|
@ -123,17 +123,17 @@ void RtpDump::load()
|
|||
}
|
||||
}
|
||||
|
||||
int RtpDump::count() const
|
||||
size_t RtpDump::count() const
|
||||
{
|
||||
return mPacketList.size();
|
||||
}
|
||||
|
||||
jrtplib::RTPPacket& RtpDump::packetAt(int index)
|
||||
jrtplib::RTPPacket& RtpDump::packetAt(size_t index)
|
||||
{
|
||||
return *mPacketList[index].mPacket;
|
||||
}
|
||||
|
||||
void RtpDump::add(const void* buffer, int len)
|
||||
void RtpDump::add(const void* buffer, size_t len)
|
||||
{
|
||||
RtpData data;
|
||||
data.mData = malloc(len);
|
||||
|
|
|
|||
|
|
@ -33,12 +33,12 @@ struct RtpPair
|
|||
class RtpHelper
|
||||
{
|
||||
public:
|
||||
static bool isRtp(const void* buffer, int length);
|
||||
static int findPtype(const void* buffer, int length);
|
||||
static bool isRtpOrRtcp(const void* buffer, int length);
|
||||
static bool isRtcp(const void* buffer, int length);
|
||||
static unsigned findSsrc(const void* buffer, int length);
|
||||
static int findPayloadLength(const void* buffer, int length);
|
||||
static bool isRtp(const void* buffer, size_t length);
|
||||
static int findPtype(const void* buffer, size_t length);
|
||||
static bool isRtpOrRtcp(const void* buffer, size_t length);
|
||||
static bool isRtcp(const void* buffer, size_t length);
|
||||
static unsigned findSsrc(const void* buffer, size_t length);
|
||||
static int findPayloadLength(const void* buffer, size_t length);
|
||||
};
|
||||
|
||||
class RtpDump
|
||||
|
|
@ -48,7 +48,7 @@ protected:
|
|||
{
|
||||
jrtplib::RTPPacket* mPacket;
|
||||
void* mData;
|
||||
unsigned mLength;
|
||||
size_t mLength;
|
||||
};
|
||||
|
||||
typedef std::vector<RtpData> PacketList;
|
||||
|
|
@ -60,9 +60,9 @@ public:
|
|||
~RtpDump();
|
||||
|
||||
void load();
|
||||
int count() const;
|
||||
jrtplib::RTPPacket& packetAt(int index);
|
||||
void add(const void* data, int len);
|
||||
size_t count() const;
|
||||
jrtplib::RTPPacket& packetAt(size_t index);
|
||||
void add(const void* data, size_t len);
|
||||
void flush();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -583,7 +583,7 @@ void AudioReceiver::makeMonoAndResample(int rate, int channels)
|
|||
return;
|
||||
}
|
||||
|
||||
int processedInput = 0;
|
||||
size_t processedInput = 0;
|
||||
mResampledLength = r->processBuffer(frames, length, processedInput, mResampledFrame, r->getDestLength(length));
|
||||
// processedInput result value is ignored - it is always equal to length as internal sample rate is 8/16/32/48K
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ void AudioStream::addData(const void* buffer, int bytes)
|
|||
assert(0);
|
||||
}
|
||||
|
||||
int processedInput = 0;
|
||||
size_t processedInput = 0;
|
||||
dstlen = r->processBuffer(buffer, bytes, processedInput, mResampleBuffer, dstlen);
|
||||
// ProcessedInput output value is ignored - because sample rate of input is always 8/16/32/48K - so all buffer is processed
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue