mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-06 17:53:48 +02:00
codec pipeline working, zlib example
This commit is contained in:
parent
3c6447326e
commit
126e5c2926
5 changed files with 39 additions and 27 deletions
|
@ -496,6 +496,14 @@ void AudioMixer::handleNegotiateAudioFormat(QSharedPointer<ReceivedMessage> mess
|
|||
|
||||
auto clientData = dynamic_cast<AudioMixerClientData*>(sendingNode->getLinkedData());
|
||||
|
||||
// FIXME - why would we not have client data at this point??
|
||||
if (!clientData) {
|
||||
qDebug() << "UNEXPECTED -- didn't have node linked data in " << __FUNCTION__;
|
||||
sendingNode->setLinkedData(std::unique_ptr<NodeData> { new AudioMixerClientData(sendingNode->getUUID()) });
|
||||
clientData = dynamic_cast<AudioMixerClientData*>(sendingNode->getLinkedData());
|
||||
connect(clientData, &AudioMixerClientData::injectorStreamFinished, this, &AudioMixer::removeHRTFsForFinishedInjector);
|
||||
}
|
||||
|
||||
clientData->_codec = selectedCoded;
|
||||
clientData->_selectedCodecName = selectedCodecName;
|
||||
qDebug() << "selectedCodecName:" << selectedCodecName;
|
||||
|
|
|
@ -534,14 +534,13 @@ void AudioClient::negotiateAudioFormat() {
|
|||
void AudioClient::handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message) {
|
||||
qDebug() << __FUNCTION__;
|
||||
|
||||
// write them to our packet
|
||||
_selectedCodecName = message->readString();
|
||||
_receivedAudioStream._selectedCodecName = _selectedCodecName = message->readString();
|
||||
|
||||
qDebug() << "Selected Codec:" << _selectedCodecName;
|
||||
auto codecPlugins = PluginManager::getInstance()->getCodecPlugins();
|
||||
for (auto& plugin : codecPlugins) {
|
||||
if (_selectedCodecName == plugin->getName()) {
|
||||
_codec = plugin;
|
||||
_receivedAudioStream._codec = _codec = plugin;
|
||||
qDebug() << "Selected Codec Plugin:" << _codec.get();
|
||||
break;
|
||||
}
|
||||
|
@ -849,16 +848,7 @@ void AudioClient::handleRecordedAudioInput(const QByteArray& audio) {
|
|||
emitAudioPacket(encodedBuffer.data(), encodedBuffer.size(), _outgoingAvatarAudioSequenceNumber, audioTransform, PacketType::MicrophoneAudioWithEcho);
|
||||
}
|
||||
|
||||
void AudioClient::processReceivedSamples(const QByteArray& networkBuffer, QByteArray& outputBuffer) {
|
||||
|
||||
// TODO - codec decode goes here
|
||||
QByteArray decodedBuffer;
|
||||
if (_codec) {
|
||||
_codec->decode(networkBuffer, decodedBuffer);
|
||||
} else {
|
||||
decodedBuffer = networkBuffer;
|
||||
}
|
||||
|
||||
void AudioClient::processReceivedSamples(const QByteArray& decodedBuffer, QByteArray& outputBuffer) {
|
||||
const int numDecodecSamples = decodedBuffer.size() / sizeof(int16_t);
|
||||
const int numDeviceOutputSamples = _outputFrameSize;
|
||||
|
||||
|
|
|
@ -187,7 +187,16 @@ int InboundAudioStream::parseAudioData(PacketType type, const QByteArray& packet
|
|||
decodedBuffer = packetAfterStreamProperties;
|
||||
}
|
||||
|
||||
return _ringBuffer.writeData(decodedBuffer.data(), numAudioSamples * sizeof(int16_t)); // FIXME?
|
||||
auto actualSize = decodedBuffer.size();
|
||||
|
||||
/*
|
||||
auto expectedSize = numAudioSamples * sizeof(int16_t);
|
||||
if (expectedSize != actualSize) {
|
||||
qDebug() << "DECODED SIZE NOT EXPECTED!!!! ----- buffer size:" << actualSize << "expected:" << expectedSize;
|
||||
}
|
||||
*/
|
||||
|
||||
return _ringBuffer.writeData(decodedBuffer.data(), actualSize);
|
||||
}
|
||||
|
||||
int InboundAudioStream::writeDroppableSilentSamples(int silentSamples) {
|
||||
|
|
|
@ -44,10 +44,21 @@ int MixedProcessedAudioStream::writeLastFrameRepeatedWithFade(int samples) {
|
|||
|
||||
int MixedProcessedAudioStream::parseAudioData(PacketType type, const QByteArray& packetAfterStreamProperties, int networkSamples) {
|
||||
|
||||
emit addedStereoSamples(packetAfterStreamProperties);
|
||||
// TODO - codec decode goes here
|
||||
QByteArray decodedBuffer;
|
||||
if (_codec) {
|
||||
_codec->decode(packetAfterStreamProperties, decodedBuffer);
|
||||
} else {
|
||||
decodedBuffer = packetAfterStreamProperties;
|
||||
}
|
||||
|
||||
qDebug() << __FUNCTION__ << "packetAfterStreamProperties:" << packetAfterStreamProperties.size() << "networkSamples:" << networkSamples << "decodedBuffer:" << decodedBuffer.size();
|
||||
|
||||
|
||||
emit addedStereoSamples(decodedBuffer);
|
||||
|
||||
QByteArray outputBuffer;
|
||||
emit processSamples(packetAfterStreamProperties, outputBuffer);
|
||||
emit processSamples(decodedBuffer, outputBuffer);
|
||||
|
||||
_ringBuffer.writeData(outputBuffer.data(), outputBuffer.size());
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include "PCMCodecManager.h"
|
||||
|
||||
const QString PCMCodecManager::NAME = "PCM Codec";
|
||||
const QString PCMCodecManager::NAME = "zlib";
|
||||
|
||||
void PCMCodecManager::init() {
|
||||
}
|
||||
|
@ -39,17 +39,11 @@ bool PCMCodecManager::isSupported() const {
|
|||
|
||||
|
||||
void PCMCodecManager::decode(const QByteArray& encodedBuffer, QByteArray& decodedBuffer) {
|
||||
// this codec doesn't actually do anything....
|
||||
decodedBuffer = encodedBuffer;
|
||||
|
||||
//decodedBuffer = qUncompress(encodedBuffer);
|
||||
//qDebug() << __FUNCTION__ << "from:" << encodedBuffer.size() << " to:" << decodedBuffer.size();
|
||||
//decodedBuffer = encodedBuffer;
|
||||
decodedBuffer = qUncompress(encodedBuffer);
|
||||
}
|
||||
|
||||
void PCMCodecManager::encode(const QByteArray& decodedBuffer, QByteArray& encodedBuffer) {
|
||||
// this codec doesn't actually do anything....
|
||||
encodedBuffer = decodedBuffer;
|
||||
|
||||
//encodedBuffer = qCompress(decodedBuffer);
|
||||
//qDebug() << __FUNCTION__ << "from:" << decodedBuffer.size() << " to:" << encodedBuffer.size();
|
||||
//encodedBuffer = decodedBuffer;
|
||||
encodedBuffer = qCompress(decodedBuffer);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue