#include "Rtpcommon.h" #include // for memset, strncpy RtpRecvClientInfo_t::RtpRecvClientInfo_t() { memset(clientIP, 0, 32); clientPort = 0; compareItemID = 0; compareItemRoadNum = 0; // memset(sessionName, 0, 32); type = 0; // 默认类型为0 } RtpRecvClientInfo_t::RtpRecvClientInfo_t(const RtpRecvClientInfo_t& other) { *this = other; // 使用赋值运算符重载来复制数据 } RtpRecvClientInfo_t& RtpRecvClientInfo_t::operator=(const RtpRecvClientInfo_t& other) { if (this != &other) { strncpy(clientIP, other.clientIP, sizeof(clientIP) - 1); clientIP[sizeof(clientIP) - 1] = '\0'; clientPort = other.clientPort; compareItemID = other.compareItemID; compareItemRoadNum = other.compareItemRoadNum; // strncpy(sessionName, other.sessionName, sizeof(sessionName) - 1); // sessionName[sizeof(sessionName) - 1] = '\0'; type = other.type; } return *this; } RtpSendClientInfo_t::RtpSendClientInfo_t() { } RtpSendClientInfo_t::RtpSendClientInfo_t(const RtpSendClientInfo_t& other) { *this = other; } RtpSendClientInfo_t& RtpSendClientInfo_t::operator=(const RtpSendClientInfo_t& other) { if (this != &other) { localIP = other.localIP; localPort = other.localPort; clientIP = other.clientIP; clientPort = other.clientPort; // compareItemID = other.compareItemID; // compareItemRoadNum = other.compareItemRoadNum; SoundCardNum = other.SoundCardNum; SoundCardRoadNum = other.SoundCardRoadNum; // udpSocket = other.udpSocket; /* 不拷贝udp套接字 */ } return *this; } bool RtpClientKey_t::operator==(const RtpClientKey_t& other) const { return (clientIP == other.clientIP && clientPort == other.clientPort && SoundCardNum == other.SoundCardNum && SoundCardRoadNum == other.SoundCardRoadNum); } bool RtpClientKey_t::operator<(const RtpClientKey_t& other) const { if (clientPort < other.clientPort) return true; if (clientPort > other.clientPort) return false; if (SoundCardNum < other.SoundCardNum) return true; if (SoundCardNum > other.SoundCardNum) return false; if (SoundCardRoadNum < other.SoundCardRoadNum) return true; if (SoundCardRoadNum > other.SoundCardRoadNum) return false; return clientIP < other.clientIP; // 最后比较IP地址 }