GDP cannot support custom GstEvent payloading
When trying to use gdppay/gdpdepay to serialize events over a shmsink/shmsrc interface, I discovered that the GDP 1.0 protocol header format cannot support accurate serialization of GstEvent types that use event numbers higher than 255, which includes GST_EVENT_SELECT_STREAMS and all of the GST_EVENT_CUSTOM_* entries.
The GstEvent type is constructed by shifting the event number left by 8 bits and storing the event flags in the lower 8 bits. From gstevent.h:
#define GST_EVENT_NUM_SHIFT (8)
#define GST_EVENT_MAKE_TYPE(num,flags) \
(((num) << GST_EVENT_NUM_SHIFT) | (flags))
For event numbers greater than 255, this will result in GstEvent type values of 0x10000 and higher. The problem is that the GDP 1.0 protocol header allocates only 2 bytes for the payload type which is where the GstEvent type is stored. The most significant bit of the event type will be truncated and these higher-numbered events will not be properly identified when deserialized.
I guess the most logical possible solution would be one of:
- Change the GDP header format to accommodate a payload type of 3 bytes (or more), or
- Change the GstEvent numbering scheme to ensure all the event types can be specified using only 2 bytes.