Gstreamer 0.10 how to pass gst buffer to nvjpegDecode()

Using Cuda 11.1 and gstreamer 0.10 how would I be able to pass a gst buffer containing the jpeg data to nvjpeg api functions. I’m following the single image decoding example in the nvjpeg documentation. I pass the gst buffer containing the jpeg data as an unsigned char* to functions such as nvjpegDecode(), nvjpegEncodeImage() and they return with error code NVJPEG_STATUS_JPEG_NOT_SUPPORTED (4) when decoding, or NVJPEG_STATUS_EXECUTION_FAILED (6) when encoding