first commit to transcode branch for supporting both nosteam celt and steam opus

This commit is contained in:
2026-05-31 00:13:47 +01:00
parent e6fb78cdf9
commit 2184fd917a
27 changed files with 1634 additions and 15 deletions
+48 -2
View File
@@ -34,6 +34,7 @@
#include <poll.h>
#include "smsdk_ext.h"
#include "celt_header.h"
#include "ringbuffer.h"
/**
@@ -139,6 +140,9 @@ public:
bool OnBroadcastVoiceData(IClient *pClient, int nBytes, char *data);
void ListenSocket();
void PushPlayerVoiceData(int playerSlot, int nBytes, char *data);
void BroadcastVoiceDataCelt(IClient *pClient, int16_t *pPCM, int nSamples);
void TranscodeNoSteamToSteam(int playerSlot, int nBytes, char *data);
private:
int m_ListenSocket;
@@ -161,16 +165,58 @@ private:
OpusEncoder *m_OpusEncoder;
double m_AvailableTime;
// Torchlight transcode state (48000 Hz stereo -> 22050 Hz mono -> CELT)
OpusDecoder *m_TorchlightOpusDecoder;
int16_t m_torchMonoAccum[4096];
int m_torchMonoAccumLen;
int m_torchResampleAccum;
// Player transcode state (24000 Hz mono -> 22050 Hz mono -> CELT)
OpusDecoder *m_PlayerOpusDecoder[SM_MAXPLAYERS + 1];
int m_playerResampleAccum[SM_MAXPLAYERS + 1];
double m_AvailableTime;
double m_playerAvailableTime[SM_MAXPLAYERS + 1];
// NoSteam->Steam transcode state per player
CRingBuffer m_nosteamOpusPCMBuffer[SM_MAXPLAYERS + 1];
int m_nosteamResampleAccum[SM_MAXPLAYERS + 1];
OpusEncoder *m_nosteamOpusEncoder[SM_MAXPLAYERS + 1];
// CELT encoder (shared by both paths, same output format)
struct CEncoderSettings
{
int32_t SampleRate_Hz;
int32_t TargetBitRate_Kbps;
int32_t FrameSize;
int32_t PacketSize;
int32_t Complexity;
double FrameTime;
} m_CeltEncoderSettings;
CELTMode *m_pCeltMode;
CELTEncoder *m_pCeltCodec;
CELTMode *m_pCeltModePlayer;
CELTEncoder *m_pCeltCodecPlayer[SM_MAXPLAYERS + 1];
CELTDecoder *m_pCeltDecoder[SM_MAXPLAYERS + 1];
CRingBuffer m_playerVoiceBuffer[SM_MAXPLAYERS + 1];
t_SV_BroadcastVoiceData m_SV_BroadcastVoiceData;
CDetour *m_VoiceDetour;
CDetour *m_ProcessVoiceDataDetour;
uint16_t m_nosteamSeqNum[SM_MAXPLAYERS + 1];
double m_nosteamAvailableTime[SM_MAXPLAYERS + 1];
void HandleNetwork();
void OnDataReceived(CClient *pClient, int16_t *pData, size_t Samples);
void HandleVoiceData();
void BroadcastVoiceData(IClient *pClient, int nBytes, unsigned char *pData);
void HandlePlayerVoiceData();
void HandleNoSteamVoiceData();
};
#endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_