|
@@ -38,21 +38,46 @@ enum ts_scrambled_type {
|
38
|
38
|
// Packet manipulation
|
39
|
39
|
void ts_packet_init_null (uint8_t *ts_packet);
|
40
|
40
|
|
41
|
|
-int ts_packet_is_pusi (uint8_t *ts_packet);
|
|
41
|
+static inline int ts_packet_is_pusi(uint8_t *ts_packet) {
|
|
42
|
+ return (ts_packet[1] &~ 0xbf) >> 6;
|
|
43
|
+}
|
42
|
44
|
|
43
|
|
-uint16_t ts_packet_get_pid (uint8_t *ts_packet);
|
44
|
|
-void ts_packet_set_pid (uint8_t *ts_packet, uint16_t new_pid);
|
|
45
|
+static inline uint16_t ts_packet_get_pid(uint8_t *ts_packet) {
|
|
46
|
+ return (ts_packet[1] &~ 0xE0) << 8 | ts_packet[2];
|
|
47
|
+}
|
45
|
48
|
|
46
|
|
-uint8_t ts_packet_get_cont (uint8_t *ts_packet);
|
47
|
|
-void ts_packet_set_cont (uint8_t *ts_packet, uint8_t value);
|
48
|
|
-void ts_packet_inc_cont (uint8_t *ts_packet, uint8_t increment);
|
|
49
|
+static inline void ts_packet_set_pid(uint8_t *ts_packet, uint16_t new_pid) {
|
|
50
|
+ ts_packet[1] = (ts_packet[1] &~ 0x1f) | (new_pid >> 8); // 111xxxxx xxxxxxxx
|
|
51
|
+ ts_packet[2] = new_pid &~ 0xff00;
|
|
52
|
+}
|
49
|
53
|
|
50
|
|
-uint8_t ts_packet_get_payload_offset(uint8_t *ts_packet);
|
|
54
|
+static inline uint8_t ts_packet_get_cont(uint8_t *ts_packet) {
|
|
55
|
+ return (ts_packet[3] &~ 0xF0); // 1111xxxx
|
|
56
|
+}
|
|
57
|
+
|
|
58
|
+static inline void ts_packet_set_cont(uint8_t *ts_packet, uint8_t value) {
|
|
59
|
+ // Mask the last 4 bits (continuity), then set the continuity
|
|
60
|
+ ts_packet[3] = (ts_packet[3] &~ 0x0F) | (value &~ 0xF0);
|
|
61
|
+}
|
|
62
|
+
|
|
63
|
+static inline void ts_packet_inc_cont(uint8_t *ts_packet, uint8_t increment) {
|
|
64
|
+ ts_packet_set_cont(ts_packet, ts_packet_get_cont(ts_packet) + increment);
|
|
65
|
+}
|
|
66
|
+
|
|
67
|
+static inline int ts_packet_get_scrambled(uint8_t *ts_packet) {
|
|
68
|
+ return ts_packet[3] >> 6; // 0 is not scamlbed, 1 is reserved, 2 or 3 mean scrambled
|
|
69
|
+}
|
|
70
|
+
|
|
71
|
+static inline int ts_packet_is_scrambled(uint8_t *ts_packet) {
|
|
72
|
+ return ts_packet_get_scrambled(ts_packet) > 1;
|
|
73
|
+}
|
|
74
|
+
|
|
75
|
+static inline void ts_packet_set_not_scrambled(uint8_t *ts_packet) {
|
|
76
|
+ ts_packet[3] = ts_packet[3] &~ 0xc0; // Mask top two bits (11xxxxxx)
|
|
77
|
+}
|
51
|
78
|
|
52
|
|
-int ts_packet_is_scrambled(uint8_t *ts_packet);
|
53
|
|
-int ts_packet_get_scrambled(uint8_t *ts_packet);
|
54
|
|
-void ts_packet_set_not_scrambled(uint8_t *ts_packet);
|
55
|
79
|
void ts_packet_set_scrambled(uint8_t *ts_packet, enum ts_scrambled_type stype);
|
|
80
|
+uint8_t ts_packet_get_payload_offset(uint8_t *ts_packet);
|
56
|
81
|
|
57
|
82
|
int ts_packet_has_pcr (uint8_t *ts_packet);
|
58
|
83
|
uint64_t ts_packet_get_pcr_ex (uint8_t *ts_packet, uint64_t *pcr_base, uint16_t *pcr_ext);
|