12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include "Rtpcommon.h"
- #include <cstring> // 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地址
- }
|