Skip to content

nvcodec: add cuda stream context

Implements a CUDA stream GstContext to allow nvcodec elements to share the same CUDA stream, and so avoid unneeded stream synchronization if the streams are the same.

Applications can also set different CUDA stream contexts in different elements to make them run in different CUDA streams, and synchronization will only be done if streams are different.

The following is an example helper function that applications can use to make a given element run in a specific CUDA stream:

void element_set_cuda_stream (GstElement *element, gpointer cuda_stream)
{
  GstContext *context;
  GstStructure *s;

  context = gst_context_new ("gst.cuda.stream", TRUE);
  s = gst_context_writable_structure (context);
  gst_structure_set (s, "gst.cuda.stream", G_TYPE_POINTER, cuda_stream, NULL);

  gst_element_set_context (element, context);
  gst_context_unref (context);
}

cc @seungha.yang

Edited by Julian Bouzas

Merge request reports