123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #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;
- cardPCMInfo = other.cardPCMInfo;
- // udpSocket = other.udpSocket; /* 不拷贝udp套接字 */
- }
- return *this;
- }
- bool RtpClientKey_t::operator==(const RtpClientKey_t& other) const
- {
- return (clientIP == other.clientIP && clientPort == other.clientPort &&
- cardPCMInfo == other.cardPCMInfo);
- }
- bool RtpClientKey_t::operator<(const RtpClientKey_t& other) const
- {
- if (clientPort < other.clientPort)
- return true;
- if (clientPort > other.clientPort)
- return false;
- if (cardPCMInfo.pcmInfo.strPCMName < other.cardPCMInfo.pcmInfo.strPCMName)
- return true;
- if (cardPCMInfo.pcmInfo.strPCMName > other.cardPCMInfo.pcmInfo.strPCMName)
- return false;
- if (cardPCMInfo.strSoundCardName < other.cardPCMInfo.strSoundCardName)
- return true;
- if (cardPCMInfo.strSoundCardName > other.cardPCMInfo.strSoundCardName)
- return false;
- return clientIP < other.clientIP; // 最后比较IP地址
- }
|