mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-12 06:27:12 +03:00
big merge
This commit is contained in:
41
components/spotify/cspot/src/AudioChunk.cpp
Normal file
41
components/spotify/cspot/src/AudioChunk.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "AudioChunk.h"
|
||||
|
||||
std::vector<uint8_t> audioAESIV({0x72, 0xe0, 0x67, 0xfb, 0xdd, 0xcb, 0xcf, 0x77, 0xeb, 0xe8, 0xbc, 0x64, 0x3f, 0x63, 0x0d, 0x93});
|
||||
|
||||
AudioChunk::AudioChunk(uint16_t seqId, std::vector<uint8_t> &audioKey, uint32_t startPosition, uint32_t predictedEndPosition)
|
||||
{
|
||||
this->crypto = std::make_unique<Crypto>();
|
||||
this->seqId = seqId;
|
||||
this->audioKey = audioKey;
|
||||
this->startPosition = startPosition;
|
||||
this->endPosition = predictedEndPosition;
|
||||
this->decryptedData = std::vector<uint8_t>();
|
||||
this->isHeaderFileSizeLoadedSemaphore = std::make_unique<WrappedSemaphore>(2);
|
||||
this->isLoadedSemaphore = std::make_unique<WrappedSemaphore>(2);
|
||||
}
|
||||
|
||||
AudioChunk::~AudioChunk()
|
||||
{
|
||||
}
|
||||
|
||||
void AudioChunk::appendData(std::vector<uint8_t> &data)
|
||||
{
|
||||
this->decryptedData.insert(this->decryptedData.end(), data.begin(), data.end());
|
||||
}
|
||||
|
||||
void AudioChunk::decrypt()
|
||||
{
|
||||
// calculate the IV for right position
|
||||
auto calculatedIV = this->getIVSum(startPosition / 16);
|
||||
|
||||
crypto->aesCTRXcrypt(this->audioKey, calculatedIV, decryptedData);
|
||||
|
||||
this->startPosition = this->endPosition - this->decryptedData.size();
|
||||
this->isLoaded = true;
|
||||
}
|
||||
|
||||
// Basically just big num addition
|
||||
std::vector<uint8_t> AudioChunk::getIVSum(uint32_t n)
|
||||
{
|
||||
return bigNumAdd(audioAESIV, n);
|
||||
}
|
||||
Reference in New Issue
Block a user