mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 01:15:46 +00:00
Fix strict aliasing violation (and save a byteswap on each packet)
This commit is contained in:
parent
fe205d838d
commit
bce9f82844
@ -14,6 +14,7 @@ static PLT_THREAD receiveThread;
|
|||||||
static PLT_THREAD decoderThread;
|
static PLT_THREAD decoderThread;
|
||||||
|
|
||||||
static PPLT_CRYPTO_CONTEXT audioDecryptionCtx;
|
static PPLT_CRYPTO_CONTEXT audioDecryptionCtx;
|
||||||
|
static uint32_t avRiKeyId;
|
||||||
|
|
||||||
static unsigned short lastSeq;
|
static unsigned short lastSeq;
|
||||||
|
|
||||||
@ -76,6 +77,10 @@ int initializeAudioStream(void) {
|
|||||||
firstReceiveTime = 0;
|
firstReceiveTime = 0;
|
||||||
audioDecryptionCtx = PltCreateCryptoContext();
|
audioDecryptionCtx = PltCreateCryptoContext();
|
||||||
|
|
||||||
|
// Copy and byte-swap the AV RI key ID used for the audio encryption IV
|
||||||
|
memcpy(&avRiKeyId, StreamConfig.remoteInputAesIv, sizeof(avRiKeyId));
|
||||||
|
avRiKeyId = BE32(avRiKeyId);
|
||||||
|
|
||||||
// For GFE 3.22 compatibility, we must start the audio ping thread before the RTSP handshake.
|
// For GFE 3.22 compatibility, we must start the audio ping thread before the RTSP handshake.
|
||||||
// It will not reply to our RTSP PLAY request until the audio ping has been received.
|
// It will not reply to our RTSP PLAY request until the audio ping has been received.
|
||||||
rtpSocket = bindUdpSocket(RemoteAddr.ss_family, RTP_RECV_BUFFER);
|
rtpSocket = bindUdpSocket(RemoteAddr.ss_family, RTP_RECV_BUFFER);
|
||||||
@ -165,9 +170,7 @@ static void decodeInputData(PQUEUED_AUDIO_PACKET packet) {
|
|||||||
|
|
||||||
// The IV is the avkeyid (equivalent to the rikeyid) +
|
// The IV is the avkeyid (equivalent to the rikeyid) +
|
||||||
// the RTP sequence number, in big endian.
|
// the RTP sequence number, in big endian.
|
||||||
uint32_t ivSeq = BE32(*(uint32_t*)StreamConfig.remoteInputAesIv);
|
uint32_t ivSeq = BE32(avRiKeyId + rtp->sequenceNumber);
|
||||||
ivSeq += rtp->sequenceNumber;
|
|
||||||
ivSeq = BE32(ivSeq);
|
|
||||||
|
|
||||||
memcpy(iv, &ivSeq, sizeof(ivSeq));
|
memcpy(iv, &ivSeq, sizeof(ivSeq));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user