-
Notifications
You must be signed in to change notification settings - Fork 0
/
pesPacketHeader.cpp
44 lines (37 loc) · 1.11 KB
/
pesPacketHeader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "pesPacketHeader.h"
void pesPacketHeader::Reset(){
PSCP = 0;
SID = 0;
PES_LEN = 0;
PES_HEADER_LEN = 0;
}
uint8_t* pesPacketHeader::Parse(const uint8_t* Input)
{
uint32_t* payloadPtr = (uint32_t*)Input; //32b is equal to packet start code prefix and stream id
uint16_t* payloadPtr2;
uint8_t* payloadPtr3;
uint32_t payloadVal = xSwapBytes32(*payloadPtr);
uint8_t sidMASK = 0b11111111;
uint32_t pscpMask = 0xFFFFFF;
SID = payloadVal bitand sidMASK;
PSCP = (payloadVal >> 8) bitand pscpMask;
payloadPtr++;
payloadPtr2 = (uint16_t*)payloadPtr;
PES_LEN = xSwapBytes16(*payloadPtr2);
payloadPtr2+=2;
PES_HEADER_LEN = (xSwapBytes16(*payloadPtr2) >> 8) bitand 0b0000000011111111;
payloadPtr3 = (uint8_t*)payloadPtr2;
payloadPtr3 += (PES_HEADER_LEN + 1);
return payloadPtr3;
}
void pesPacketHeader::Print()
{
printf("\n\t");
printf("\033[0;36m");
printf("PES:");
printf(" PSCP=%d", PSCP);
printf(" SID=%d", SID);
printf(" LEN=%d", PES_LEN);
printf("\033[0m");
printf(" Start assembling");
}