On Fri Sep 6 02:31:15 2024 +0000, Ziqing Hui wrote:
Before the codec format patch, we are always returning config->stream->format in stream_props_GetMediaType(). So at least it's safe to return it for uncompressed format like things before.
OK, I think I find out the reason why preferred_format is different from what the actual output format.
We are calling wg_parser_stream_enable() in init_stream() to set our desired output format. And wg_parser_stream_enable() will send a reconfigure event to upstream, and we expect upstream element send a GST_EVENT_CAPS event downstream to my_sink pad, and we only set preferred_format to the actual output format when we are handling GST_EVENT_CAPS in sink_event_cb().
The problem is, the GST_EVENT_CAPS is not synced with wg_parser_stream_enable(). If we try to use preferred_format after wg_parser_stream_enable() and before GST_EVENT_CAPS, it will be wrong format.