To implement this via Gstreamer, Rather than having a callback, it might be easier to have your data flow as GstBuffer via an element and use h264parse, avdec_h264 and videoconvert elements to parse, decode and convert color space to BGR then via a simple custom element you can write a chain function to convert the Gstbuffer to cv::Mat.
This should help you out
https://stackoverflow.com/questions/65308163/converting-gstreamer-yuv-420-i420-raw-frame-to-opencv-cvmatIf you wanna do it in your callback function, then I would suggest using ffmpeg/libav to do so. Though you will obtain your frames in AvFrame, you can still convert them back to cv::Mat via sws_scale converter