store voice chat silence periods
This commit is contained in:
parent
e2b31d00ac
commit
292c4c3b24
@ -66,6 +66,11 @@ void Logic::Finish(bool dirty)
|
|||||||
data["voice"]["total_time"] = voiceTotalTime;
|
data["voice"]["total_time"] = voiceTotalTime;
|
||||||
data["voice"]["active_time"] = voiceActiveTime;
|
data["voice"]["active_time"] = voiceActiveTime;
|
||||||
|
|
||||||
|
for(const auto& o : context->voiceWriter->m_silence)
|
||||||
|
{
|
||||||
|
data["voice"]["silence"] += json({o.first, o.second});
|
||||||
|
}
|
||||||
|
|
||||||
std::string out = data.dump(2, ' ', false, json::error_handler_t::replace);
|
std::string out = data.dump(2, ' ', false, json::error_handler_t::replace);
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
fwrite(out.c_str(), out.size(), 1, context->outputFp);
|
fwrite(out.c_str(), out.size(), 1, context->outputFp);
|
||||||
|
@ -64,8 +64,8 @@ void SourceGameContext::Start()
|
|||||||
|
|
||||||
void SourceGameContext::Finish(bool dirty)
|
void SourceGameContext::Finish(bool dirty)
|
||||||
{
|
{
|
||||||
logic->Finish(dirty);
|
|
||||||
voiceWriter->Finish();
|
voiceWriter->Finish();
|
||||||
|
logic->Finish(dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceGameContext::StartCommandPacket(const CommandPacket& packet)
|
void SourceGameContext::StartCommandPacket(const CommandPacket& packet)
|
||||||
|
@ -149,6 +149,12 @@ void VoiceDataWriter::Start()
|
|||||||
|
|
||||||
void VoiceDataWriter::Finish()
|
void VoiceDataWriter::Finish()
|
||||||
{
|
{
|
||||||
|
if(m_isSilenced)
|
||||||
|
{
|
||||||
|
m_isSilenced = false;
|
||||||
|
m_silence.back().second = m_curTick;
|
||||||
|
}
|
||||||
|
|
||||||
for(auto& state : m_playerVoiceStates)
|
for(auto& state : m_playerVoiceStates)
|
||||||
{
|
{
|
||||||
state.second.celt_decoder.Destroy();
|
state.second.celt_decoder.Destroy();
|
||||||
@ -180,7 +186,19 @@ void VoiceDataWriter::EndCommandPacket(const PacketTrailingBits& trailingBits)
|
|||||||
|
|
||||||
// Skip silence if noone talks for at least 3 seconds
|
// Skip silence if noone talks for at least 3 seconds
|
||||||
if((m_curTick - m_lastVoiceTick) / context->fTickRate > 3.0)
|
if((m_curTick - m_lastVoiceTick) / context->fTickRate > 3.0)
|
||||||
|
{
|
||||||
|
if(!m_isSilenced)
|
||||||
|
{
|
||||||
|
m_isSilenced = true;
|
||||||
|
m_silence.emplace_back(std::make_pair(m_curTick, 0));
|
||||||
|
}
|
||||||
m_silenceTicks += (m_curTick - m_lastTick);
|
m_silenceTicks += (m_curTick - m_lastTick);
|
||||||
|
}
|
||||||
|
else if(m_isSilenced)
|
||||||
|
{
|
||||||
|
m_isSilenced = false;
|
||||||
|
m_silence.back().second = m_curTick;
|
||||||
|
}
|
||||||
|
|
||||||
for(auto& state : m_playerVoiceStates)
|
for(auto& state : m_playerVoiceStates)
|
||||||
{
|
{
|
||||||
|
@ -92,4 +92,8 @@ private:
|
|||||||
|
|
||||||
static const int sQuality = 3;
|
static const int sQuality = 3;
|
||||||
eCodec m_Codec = CODEC_NONE;
|
eCodec m_Codec = CODEC_NONE;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool m_isSilenced = false;
|
||||||
|
std::vector<std::pair<int32_t, int32_t>> m_silence;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user