Rtpcommon.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "Rtpcommon.h"
  2. #include <cstring> // for memset, strncpy
  3. RtpRecvClientInfo_t::RtpRecvClientInfo_t()
  4. {
  5. memset(clientIP, 0, 32);
  6. clientPort = 0;
  7. sessionID = 0;
  8. memset(sessionName, 0, 32);
  9. type = 0; // 默认类型为0
  10. }
  11. RtpRecvClientInfo_t::RtpRecvClientInfo_t(const RtpRecvClientInfo_t& other)
  12. {
  13. *this = other; // 使用赋值运算符重载来复制数据
  14. }
  15. RtpRecvClientInfo_t& RtpRecvClientInfo_t::operator=(const RtpRecvClientInfo_t& other)
  16. {
  17. if (this != &other)
  18. {
  19. strncpy(clientIP, other.clientIP, sizeof(clientIP) - 1);
  20. clientIP[sizeof(clientIP) - 1] = '\0';
  21. clientPort = other.clientPort;
  22. sessionID = other.sessionID;
  23. strncpy(sessionName, other.sessionName, sizeof(sessionName) - 1);
  24. sessionName[sizeof(sessionName) - 1] = '\0';
  25. type = other.type;
  26. }
  27. return *this;
  28. }
  29. RtpSendClientInfo_t::RtpSendClientInfo_t()
  30. {
  31. }
  32. RtpSendClientInfo_t::RtpSendClientInfo_t(const RtpSendClientInfo_t& other)
  33. {
  34. *this = other;
  35. }
  36. RtpSendClientInfo_t& RtpSendClientInfo_t::operator=(const RtpSendClientInfo_t& other)
  37. {
  38. if (this != &other)
  39. {
  40. localPort = other.localPort;
  41. clientIP = other.clientIP;
  42. clientPort = other.clientPort;
  43. sessionID = other.sessionID;
  44. sessionName = other.sessionName;
  45. // udpSocket = other.udpSocket; /* 不拷贝udp套接字 */
  46. }
  47. return *this;
  48. }