MPEG-TS pointer_field max value - mpeg2-ts

What is the max value for the Pointer_filed (ISO/IEC 13818-1 2.4.4.1) in MPEG 2 standart?
I write my own library on C# for parsing ts files and found this:
As we can see here pointer_field for this table is 0xb5 bytes. EIT table header begin with 0x4E 0xF2 but end in another table and i can't get EIT section length for this table.
ps I get this EIT stream from Eutelsat 36B satellite.

It is an 8-bit field, so the max value would be 255.
Reading ISO/IEC 13818-1 2.4.4.1:
pointer_field – This is an 8-bit field whose value shall be the number
of bytes, immediately following the pointer_field until the first byte
of the first section that is present in the payload of the Transport
Stream packet (so a value of 0x00 in the pointer_field indicates that
the section starts immediately after the pointer_field). When at least
one section begins in a given Transport Stream packet, then the
payload_unit_start_indicator (refer to 2.4.3.2) shall be set to 1 and
the first byte of the payload of that Transport Stream packet shall
contain the pointer. When no section begins in a given Transport
Stream packet, then the payload_unit_start_indicator shall be set to 0
and no pointer shall be sent in the payload of that packet.
The rest of your EIT table is contained in the following packet.

Related

How are strings written down in FlatBuffers

I am researching FlatBuffers file structure and I want to know how are strings written down. From what I could gather, the string orc (for example) is written down as letters count in little endian (0x3 0x0 0x0 0x0) followed by the actual letters and followed by something else. I am trying to understand what the something else is. What bytes follow the letters? I am only asking about the presentation of this specific string in buffer/file.
According to the FlatBuffer documentation:
"Strings are simply a vector of bytes, and are always null-terminated. Vectors are stored as contiguous aligned scalar elements prefixed by a 32bit element count (not including any null termination). Neither is stored inline in their parent, but are referred to by offset. A vector may consist of more than one offset pointing to the same value if the user explicitly serializes the same offset twice."
Thus, the 4 bytes at the front are the 32 bit element count, and 0x3 0x0 0x0 0x0 would mean that there are 3 bytes in the string excluding zero termination. (FlatBuffer defaults to little-endian; see link above.)

How to send/receive variable length protocol messages independently on the transmission layer

I'm writing a very specific application protocol to enable communication between 2 nodes. Node 1 is an embedded platform (a microcontroller), while node 2 is a common computer.
Such protocol defines messages of variable length. This means that sometimes node 1 sends a message of 100 bytes to node 2, while another time it sends a message of 452 bytes.
Such protocol shall be independent on how the messages are transmitted. For instance, the same message can be sent over USB, Bluetooth, etc.
Let's assume that a protocol message is defined as:
| Length (4 bytes) | ...Payload (variable length)... |
I'm struggling about how the receiver can recognise how long is the incoming message. So far, I have thought about 2 approaches.
1st approach
The sender sends the length first (4 bytes, always fixed size), and the message afterwards.
For instance, the sender does something like this:
// assuming that the parameters of send() are: data, length of data
send(msg_length, 4)
send(msg, msg_length - 4)
While the receiver side does:
msg_length = receive(4)
msg = receive(msg_length)
This may be ok with some "physical protocols" (e.g. UART), but with more complex ones (e.g. USB) transmitting the length with a separate packet may introduce some overhead. The reason being that an additional USB packet (with control data, ACK packets as well) is required to be transmitted for only 4 bytes.
However, with this approach the receiver side is pretty simple.
2nd approach
The alternative would be that the receiver keeps receiving data into a buffer, and at some point tries to find a valid message. Valid means: finding the length of the message first, and then its payload.
Most likely this approach requires adding some "start message" byte(s) at the beginning of the message, such that the receiver can use them to identify where a message is starting.

How to find the first NALunit of one complete video frame in raw HEVC/H.265 stream?

In a raw HEVC/H265 elementary stream, how to find the first NALunit of one video frame? Access unit delimiter/access_unit_delimiter_rbsp() seems to be a good choice, but it is optional in the video stream.
I think you should read the hevc specification . I never did but I can help a little by my experience in the HM codec.
in the beginning the current pos in bitstream is 0, the decoder extracts and discards all bytes ( leading_zero_8bits ) until he finds 0x00000001 or 0x000001 then he discard 3 or 4 bytes mentioned before ( zero_byte and start_code_prefix_one_3bytes ), then he reads all 3 bytes ( in loop ) until he finds 0x000003 or the end of the stream , this is the actual data . then if it’s not end of stream and not 0x00000001 or 0x00001 he will discard all bytes (trailing_zero_8bits) until he finds them , which means new NALu or end of stream. However, a frame could be represented with more then 1 NALu.
After that he convert the payload To RBSP by clearing EmulationPreventionByte and removing cabac_zero_word before the decoding starts.

Get the length of the data received in a buffer with ReadExisting

I need get the length of the received buffer in a serial port in VB. I am using serial1.ReadExisting(). The length of the data is variable and does not have a delimiter byte established is a reader rfid. The result of serial1.ReadExisting() should be an array. How can I put this into variable that changes length, or how get the length of of serial1.ReadExisting()?

UDP message size difference

Say that A sends B a UDP message of size N like
sockaddr_in to;
to.sin_family=AF_INET;
to.sin_port=htons(port);
to.sin_addr.s_addr=inet_addr(address);
sendto(sock,(const char*)buffer,N,0,(sockaddr*)&to,sizeof(to));
Now B receives this message expecting it to be of size N_1
sockaddr from;
socklen_t length_from=sizeof(from);
recvfrom(sock,(char*)buffer,N_1,0,&from,&length_from);
What happens when N_1!=N ?
What happens when N_1!=N ?
If the receive buffer is larger than the incoming datagram, the entire datagram is transferred into the buffer and the actual length is returned as the return value of recfvrom(). You're presently ignoring it. Don't do that.
If the receive buffer is smaller than the incoming datagram, it is truncated to fit into the receive buffer and he excess beyond that is discarded. The actual length of data transferred into the buffer is returned.