// But we don't own the NNG socket in CodecStream (CTCServer owns it), so we can't close it here.
// Actually, CTCServer::Close() is called globally.
// For per-stream shutdown, we rely on the fact that CodecStream is usually destroyed when the call ends,
// but the NNG socket remains open for other calls.
// Wait, RxThread performs `g_TCServer.Receive`. If that blocks forever, we can't join.
// However, `keep_running` is checked. We need to wake up `Receive`.
// The only way to wake up `Receive` on a shared socket without closing it is if we used a timeout/poller or if we send a dummy packet to ourselves?
// Ah, the Implementation Plan says "Close NNG socket to unblock RxThread".
// **Correction**: `CTCServer` owns the socket. If we are just destroying one `CCodecStream` (e.g. one call ending), we CANNOT close the global socket.
// This implies `RxThread` CANNOT assume it owns the socket.
// BUT, `CodecStream` exists for the duration of a Module's lifecycle effectively?
// No, `CCodecStream` is created per stream? No, `CCodecStream` is created in `Reflector.cpp` at startup for each module!
// `g_Reflector.m_CodecStreams[c] = new CCodecStream(...)`
// So `CCodecStream` lives practically forever (until shutdown).
// Therefore, safe shutdown happens only when app exits, so closing global socket is fine.
std::cout<<"Transcoder packet received but CodecStream["<<m_CSModule<<"] is closed: Module='"<<pack.module<<"' StreamID="<<std::hex<<std::showbase<<ntohs(pack.streamid)<<std::endl;
}
}
}
}
// anything in our queue, then get it to the transcoder!
while(!m_Queue.IsEmpty())
voidCCodecStream::TxThread(void)
{
while(keep_running)
{
auto&Frame=m_Queue.Front();
// Block until packet available or poison pill (nullptr)