统一设置单字节对齐方式 (#2716)

__attribute__((packed)) 替换为 #pragma pack(push, 1)
This commit is contained in:
夏楚
2023-07-29 13:07:22 +08:00
committed by GitHub
parent 54194fe501
commit 73c8a5faf4
8 changed files with 32 additions and 67 deletions

View File

@@ -19,9 +19,7 @@
namespace mediakit {
#if defined(_WIN32)
#pragma pack(push, 1)
#endif // defined(_WIN32)
// http://www.networksorcery.com/enp/protocol/rtcp.htm
#define RTCP_PT_MAP(XX) \
@@ -235,7 +233,7 @@ private:
*/
void net2Host(size_t size);
} PACKED;
};
/////////////////////////////////////////////////////////////////////////////
@@ -272,7 +270,7 @@ private:
* 网络字节序转换为主机字节序
*/
void net2Host();
} PACKED;
};
/*
* 6.4.1 SR: Sender Report RTCP Packet
@@ -371,7 +369,7 @@ private:
* @param size 字节长度,防止内存越界
*/
void net2Host(size_t size);
} PACKED;
};
/////////////////////////////////////////////////////////////////////////////
@@ -441,7 +439,7 @@ private:
*/
std::string dumpString() const;
} PACKED;
};
/////////////////////////////////////////////////////////////////////////////
@@ -512,7 +510,7 @@ private:
* 网络字节序转换为主机字节序
*/
void net2Host();
} PACKED;
};
// Source description
class RtcpSdes : public RtcpHeader {
@@ -548,7 +546,7 @@ private:
* @param size 字节长度,防止内存越界
*/
void net2Host(size_t size);
} PACKED;
};
// https://tools.ietf.org/html/rfc4585#section-6.1
// 6.1. Common Packet Format for Feedback Messages
@@ -624,7 +622,7 @@ private:
private:
static std::shared_ptr<RtcpFB> create_l(RtcpType type, int fmt, const void *fci, size_t fci_len);
} PACKED;
};
// BYE
/*
@@ -684,7 +682,7 @@ private:
* @param size 字节长度,防止内存越界
*/
void net2Host(size_t size);
} PACKED;
};
/*
0 1 2 3
@@ -738,7 +736,7 @@ private:
*/
void net2Host(size_t size);
} PACKED;
};
/*
@@ -777,7 +775,7 @@ private:
* @param size 字节长度,防止内存越界
*/
void net2Host();
} PACKED;
};
class RtcpXRDLRR : public RtcpHeader {
public:
@@ -814,11 +812,9 @@ private:
*/
void net2Host(size_t size);
} PACKED;
};
#if defined(_WIN32)
#pragma pack(pop)
#endif // defined(_WIN32)
} // namespace mediakit
#endif // ZLMEDIAKIT_RTCP_H

View File

@@ -240,7 +240,7 @@ public:
RunLengthChunk(SymbolStatus status, uint16_t run_length);
// 打印本对象
string dumpString() const;
} PACKED;
};
RunLengthChunk::RunLengthChunk(SymbolStatus status, uint16_t run_length) {
type = 0;
@@ -291,7 +291,7 @@ public:
StatusVecChunk(bool symbol_bit, const vector<SymbolStatus> &status);
// 打印本对象
string dumpString() const;
} PACKED;
};
StatusVecChunk::StatusVecChunk(bool symbol_bit, const vector<SymbolStatus> &status) {
CHECK(status.size() << symbol_bit <= 14);

View File

@@ -55,7 +55,7 @@ public:
private:
uint32_t data;
} PACKED;
};
#if 0
//PSFB fmt = 3
@@ -97,7 +97,7 @@ public:
uint8_t padding;
static size_t constexpr kSize = 8;
} PACKED;
};
#endif
// PSFB fmt = 4
@@ -125,7 +125,7 @@ private:
uint32_t ssrc;
uint8_t seq_number;
uint8_t reserved[3];
} PACKED;
};
#if 0
//PSFB fmt = 5
@@ -147,7 +147,7 @@ public:
private:
uint8_t data[kSize];
} PACKED;
};
//PSFB fmt = 6
//https://tools.ietf.org/html/rfc5104#section-4.3.2.1
@@ -160,7 +160,7 @@ private:
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
class FCI_TSTN : public FCI_TSTR{
} PACKED;
};
//PSFB fmt = 7
//https://tools.ietf.org/html/rfc5104#section-4.3.4.1
@@ -183,7 +183,7 @@ public:
private:
uint8_t data[kSize];
} PACKED;
};
#endif
@@ -233,7 +233,7 @@ private:
// SSRC feedback (32 bits) Consists of one or more SSRC entries which
// this feedback message applies to.
uint32_t ssrc_feedback[1];
} PACKED;
};
/////////////////////////////////////////// RTPFB ////////////////////////////////////////////////////
@@ -265,7 +265,7 @@ private:
uint16_t pid;
// bitmask of following lost packets (BLP): 16 bits
uint16_t blp;
} PACKED;
};
#if 0
//RTPFB fmt = 3
@@ -300,7 +300,7 @@ private:
// to the description in section 4.2.1.2. The value is an
// unsigned integer [0..511].
uint32_t max_tbr;
} PACKED;
};
//RTPFB fmt = 4
// https://tools.ietf.org/html/rfc5104#section-4.2.2.1
@@ -314,7 +314,7 @@ private:
class FCI_TMMBN : public FCI_TMMBR{
public:
} PACKED;
};
#endif
enum class SymbolStatus : uint8_t {
@@ -374,7 +374,7 @@ private:
uint8_t ref_time[3];
// feedback packet count,反馈包号,本包是第几个transport-cc包每次加1 |
uint8_t fb_pkt_count;
} PACKED;
};
} // namespace mediakit
#endif // ZLMEDIAKIT_RTCPFCI_H