SmolRTSP  0.1.3
A small, portable, extensible RTSP 1.0 implementation in C99
nal.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <smolrtsp/nal/h264.h>
11 #include <smolrtsp/nal/h265.h>
12 
13 #include <stdbool.h>
14 #include <stdint.h>
15 
16 #include <datatype99.h>
17 #include <slice99.h>
18 
19 #include <smolrtsp/priv/compiler_attrs.h>
20 
27 // clang-format off
29  SmolRTSP_NalHeader,
30  (SmolRTSP_NalHeader_H264, SmolRTSP_H264NalHeader),
31  (SmolRTSP_NalHeader_H265, SmolRTSP_H265NalHeader)
32 );
33 // clang-format on
34 
38 uint8_t
39 SmolRTSP_NalHeader_unit_type(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE;
40 
44 size_t SmolRTSP_NalHeader_size(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE;
45 
54 size_t
55 SmolRTSP_NalHeader_fu_size(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE;
56 
60 bool SmolRTSP_NalHeader_is_vps(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE;
61 
65 bool SmolRTSP_NalHeader_is_sps(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE;
66 
70 bool SmolRTSP_NalHeader_is_pps(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE;
71 
75 bool SmolRTSP_NalHeader_is_coded_slice_idr(SmolRTSP_NalHeader self)
76  SMOLRTSP_PRIV_MUST_USE;
77 
81 bool SmolRTSP_NalHeader_is_coded_slice_non_idr(SmolRTSP_NalHeader self)
82  SMOLRTSP_PRIV_MUST_USE;
83 
92  SmolRTSP_NalHeader self, uint8_t buffer[restrict]);
93 
109  SmolRTSP_NalHeader self, uint8_t buffer[restrict], bool is_first_fragment,
110  bool is_last_fragment);
111 
115 typedef struct {
119  SmolRTSP_NalHeader header;
120 
124  U8Slice99 payload;
126 
131  bool is_first_fragment, bool is_last_fragment,
132  uint8_t unit_type) SMOLRTSP_PRIV_MUST_USE;
133 
143 typedef size_t (*SmolRTSP_NalStartCodeTester)(U8Slice99 data);
144 
157 smolrtsp_determine_start_code(U8Slice99 data) SMOLRTSP_PRIV_MUST_USE;
158 
162 size_t smolrtsp_test_start_code_3b(U8Slice99 data);
163 
167 size_t smolrtsp_test_start_code_4b(U8Slice99 data);
H.264 NAL representation.
H.265 NAL representation.
bool SmolRTSP_NalHeader_is_coded_slice_idr(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE
Checks whether self is a coded slice IDR.
uint8_t SmolRTSP_NalHeader_unit_type(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE
Returns the NAL unit type of self.
SmolRTSP_NalStartCodeTester smolrtsp_determine_start_code(U8Slice99 data) SMOLRTSP_PRIV_MUST_USE
Returns a start code tester for data.
size_t SmolRTSP_NalHeader_fu_size(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE
Computes the size of a fragmentation unit (FU) header self.
size_t SmolRTSP_NalHeader_size(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE
Computes the size of self in bytes.
size_t(* SmolRTSP_NalStartCodeTester)(U8Slice99 data)
A function that tests whether data starts with some start code.
Definition: nal.h:143
void SmolRTSP_NalHeader_write_fu_header(SmolRTSP_NalHeader self, uint8_t buffer[restrict], bool is_first_fragment, bool is_last_fragment)
Writes a FU header of self to buffer.
bool SmolRTSP_NalHeader_is_sps(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE
Checks whether self is SPS.
void SmolRTSP_NalHeader_serialize(SmolRTSP_NalHeader self, uint8_t buffer[restrict])
Writes the binary representation of self into buffer.
uint8_t smolrtsp_nal_fu_header(bool is_first_fragment, bool is_last_fragment, uint8_t unit_type) SMOLRTSP_PRIV_MUST_USE
Creates a generic NAL FU header.
bool SmolRTSP_NalHeader_is_vps(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE
Checks whether self is VPS.
bool SmolRTSP_NalHeader_is_pps(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE
Checks whether self is PPS.
size_t smolrtsp_test_start_code_3b(U8Slice99 data)
The 3-byte start code tester (0x000001).
size_t smolrtsp_test_start_code_4b(U8Slice99 data)
The 3-byte start code tester (0x00000001).
datatype99(SmolRTSP_NalHeader,(SmolRTSP_NalHeader_H264, SmolRTSP_H264NalHeader),(SmolRTSP_NalHeader_H265, SmolRTSP_H265NalHeader))
A generic NAL header (either H.264 or H.265).
bool SmolRTSP_NalHeader_is_coded_slice_non_idr(SmolRTSP_NalHeader self) SMOLRTSP_PRIV_MUST_USE
Checks whether self is a coded slice non-IDR.
An H.264 NAL header.
Definition: h264.h:34
An H.265 NAL header.
Definition: h265.h:33
A generic NAL unit (either H.264 or H.265).
Definition: nal.h:115
SmolRTSP_NalHeader header
The header of this NAL unit.
Definition: nal.h:119
U8Slice99 payload
The payload data of this NAL unit (not including the header).
Definition: nal.h:124