Skip to content

Commit 02064de

Browse files
committed
more
1 parent 7b34f2b commit 02064de

File tree

5 files changed

+267
-159
lines changed

5 files changed

+267
-159
lines changed

worker/include/RTC/SCTP/Chunk.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ namespace RTC
7979
* must include padding if needed).
8080
*/
8181
static Chunk* Parse(const uint8_t* data, size_t len, bool exactLen);
82+
8283
static const std::string& ChunkType2String(ChunkType chunkType);
8384

8485
private:

worker/test/include/RTC/TestSerializable/FooItem.hpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "common.hpp"
55
#include "RTC/Serializable.hpp"
6+
#include <string>
7+
#include <unordered_map>
68

79
using namespace RTC;
810

@@ -30,16 +32,27 @@ using namespace RTC;
3032
class FooItem : public Serializable
3133
{
3234
public:
35+
/**
36+
* Item Id.
37+
*/
38+
enum class ItemId : uint8_t
39+
{
40+
NONE = 0x0,
41+
DATA = 0x1,
42+
EVENT = 0x2,
43+
CONTROL = 0x3,
44+
};
45+
3346
/**
3447
* Struct of a the FooItem Header.
3548
*/
3649
struct ItemHeader
3750
{
3851
#if defined(MS_LITTLE_ENDIAN)
3952
uint8_t flags : 4;
40-
uint8_t id : 4;
53+
ItemId id : 4;
4154
#elif defined(MS_BIG_ENDIAN)
42-
uint8_t id : 4;
55+
ItemId id : 4;
4356
uint8_t flags : 4;
4457
#endif
4558
uint8_t valueLength;
@@ -60,11 +73,16 @@ class FooItem : public Serializable
6073
static std::unique_ptr<FooItem> Factory(
6174
const uint8_t* buffer,
6275
size_t bufferLength,
63-
uint8_t id,
76+
ItemId id,
6477
uint8_t flags,
6578
const uint8_t* value,
6679
uint8_t valueLength);
6780

81+
static const std::string& ItemId2String(ItemId id);
82+
83+
private:
84+
static std::unordered_map<ItemId, std::string> itemId2String;
85+
6886
private:
6987
/**
7088
* Constructor is private because we only want to create FooItem instances
@@ -79,12 +97,12 @@ class FooItem : public Serializable
7997

8098
std::unique_ptr<Serializable> Clone(const uint8_t* buffer, size_t bufferLength) const override;
8199

82-
uint8_t GetId() const
100+
ItemId GetId() const
83101
{
84102
return GetHeaderPointer()->id;
85103
}
86104

87-
void SetId(uint8_t id)
105+
void SetId(ItemId id)
88106
{
89107
GetHeaderPointer()->id = id;
90108
}

0 commit comments

Comments
 (0)