Commit 73c8a5fa by 夏楚 Committed by GitHub

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

__attribute__((packed)) 替换为 #pragma pack(push, 1)
parent 54194fe5
......@@ -32,14 +32,6 @@
#define __LITTLE_ENDIAN LITTLE_ENDIAN
#endif
#ifndef PACKED
#if !defined(_WIN32)
#define PACKED __attribute__((packed))
#else
#define PACKED
#endif //! defined(_WIN32)
#endif
#ifndef CHECK
#define CHECK(exp, ...) ::mediakit::Assert_ThrowCpp(!(exp), #exp, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__)
#endif // CHECK
......
......@@ -13,9 +13,7 @@
namespace mediakit{
#if defined(_WIN32)
#pragma pack(push, 1)
#endif // defined(_WIN32)
class FuFlags {
public:
......@@ -30,11 +28,9 @@ public:
unsigned end_bit: 1;
unsigned start_bit: 1;
#endif
} PACKED;
};
#if defined(_WIN32)
#pragma pack(pop)
#endif // defined(_WIN32)
H264RtpDecoder::H264RtpDecoder() {
_frame = obtainFrame();
......
......@@ -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
......@@ -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);
......
......@@ -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
......@@ -18,13 +18,6 @@
#include "Network/Buffer.h"
#include "Extension/Track.h"
#if !defined(_WIN32)
#define PACKED __attribute__((packed))
#else
#define PACKED
#endif //!defined(_WIN32)
#define DEFAULT_CHUNK_LEN 128
#define HANDSHAKE_PLAINTEXT 0x03
#define RANDOM_LEN (1536 - 8)
......@@ -65,9 +58,7 @@
namespace mediakit {
#if defined(_WIN32)
#pragma pack(push, 1)
#endif // defined(_WIN32)
class RtmpHandshake {
public:
......@@ -81,7 +72,7 @@ public:
void create_complex_c0c1();
}PACKED;
};
class RtmpHeader {
public:
......@@ -97,7 +88,7 @@ public:
uint8_t body_size[3];
uint8_t type_id;
uint8_t stream_index[4]; /* Note, this is little-endian while others are BE */
}PACKED;
};
class FLVHeader {
public:
......@@ -130,7 +121,7 @@ public:
uint32_t length;
//固定为0
uint32_t previous_tag_size0;
} PACKED;
};
class RtmpTagHeader {
public:
......@@ -139,11 +130,9 @@ public:
uint8_t timestamp[3] = {0};
uint8_t timestamp_ex = 0;
uint8_t streamid[3] = {0}; /* Always 0. */
} PACKED;
};
#if defined(_WIN32)
#pragma pack(pop)
#endif // defined(_WIN32)
class RtmpPacket : public toolkit::Buffer{
public:
......
......@@ -65,9 +65,7 @@ typedef enum {
}; // namespace Rtsp
#if defined(_WIN32)
#pragma pack(push, 1)
#endif // defined(_WIN32)
class RtpHeader {
public:
......@@ -132,11 +130,9 @@ private:
size_t getPayloadOffset() const;
// 返回padding长度
size_t getPaddingSize(size_t rtp_size) const;
} PACKED;
};
#if defined(_WIN32)
#pragma pack(pop)
#endif // defined(_WIN32)
// 此rtp为rtp over tcp形式,需要忽略前4个字节
class RtpPacket : public toolkit::BufferRaw {
......
......@@ -11,9 +11,7 @@
#include "RtpExt.h"
#include "Sdp.h"
#if defined(_WIN32)
#pragma pack(push, 1)
#endif // defined(_WIN32)
using namespace std;
using namespace toolkit;
......@@ -51,7 +49,7 @@ private:
uint8_t id: 4;
#endif
uint8_t data[1];
} PACKED;
};
//0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
......@@ -77,11 +75,9 @@ private:
uint8_t id;
uint8_t len;
uint8_t data[1];
} PACKED;
};
#if defined(_WIN32)
#pragma pack(pop)
#endif // defined(_WIN32)
//////////////////////////////////////////////////////////////////
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论