static gboolean
gst_vdp_output_src_pad_setcaps (GstPad * pad, GstCaps * caps)
{
  GstVdpOutputSrcPad *vdp_pad = GST_VDP_OUTPUT_SRC_PAD (pad);
  const GstStructure *structure;

  structure = gst_caps_get_structure (caps, 0);

  if (!gst_structure_get_int (structure, "width", &vdp_pad->width))
    return FALSE;
  if (!gst_structure_get_int (structure, "height", &vdp_pad->height))
    return FALSE;

  if (gst_structure_has_name (structure, "video/x-raw-rgb")) {
    if (!gst_vdp_caps_to_rgba_format (caps, &vdp_pad->rgba_format))
      return FALSE;

    /* create buffer pool if we dont't have one */
    if (!vdp_pad->bpool)
      vdp_pad->bpool = gst_vdp_output_buffer_pool_new (vdp_pad->device);

    if (vdp_pad->output_caps)
      gst_caps_unref (vdp_pad->output_caps);

    vdp_pad->output_caps = gst_caps_new_simple ("video/x-vdpau-output",
        "rgba-format", G_TYPE_INT, vdp_pad->rgba_format,
        "width", G_TYPE_INT, vdp_pad->width, "height", G_TYPE_INT,
        vdp_pad->height, NULL);
    gst_vdp_buffer_pool_set_caps (vdp_pad->bpool, vdp_pad->output_caps);

    vdp_pad->output_format = GST_VDP_OUTPUT_SRC_PAD_FORMAT_RGB;
  } else if (gst_structure_has_name (structure, "video/x-vdpau-output")) {
    if (!gst_structure_get_int (structure, "rgba-format",
            (gint *) & vdp_pad->rgba_format))
      return FALSE;

    /* don't need the buffer pool */
    if (vdp_pad->bpool) {
      gst_object_unref (vdp_pad->bpool);
      vdp_pad->bpool = NULL;
    }

    vdp_pad->output_format = GST_VDP_OUTPUT_SRC_PAD_FORMAT_VDPAU;
  } else
    return FALSE;

  return TRUE;
}
Beispiel #2
0
static gboolean
gst_vdp_sink_open_device (VdpSink * vdp_sink)
{
  gboolean res;
  GstVdpDevice *device;
  GError *err;

  g_mutex_lock (vdp_sink->device_lock);
  if (vdp_sink->device) {
    res = TRUE;
    goto done;
  }

  err = NULL;
  vdp_sink->device = device = gst_vdp_get_device (vdp_sink->display_name, &err);
  if (!device)
    goto device_error;

  vdp_sink->bpool = gst_vdp_output_buffer_pool_new (device);

  vdp_sink->caps = gst_vdp_sink_get_allowed_caps (device, vdp_sink->par);
  GST_DEBUG ("runtime calculated caps: %" GST_PTR_FORMAT, vdp_sink->caps);

  /* call XSynchronize with the current value of synchronous */
  GST_DEBUG_OBJECT (vdp_sink, "XSynchronize called with %s",
      vdp_sink->synchronous ? "TRUE" : "FALSE");
  XSynchronize (device->display, vdp_sink->synchronous);

  /* Setup our event listening thread */
  vdp_sink->running = TRUE;
  vdp_sink->event_thread = g_thread_create (
      (GThreadFunc) gst_vdp_sink_event_thread, vdp_sink, TRUE, NULL);

  res = TRUE;

done:
  g_mutex_unlock (vdp_sink->device_lock);
  return res;

device_error:
  gst_vdp_sink_post_error (vdp_sink, err);
  res = FALSE;
  goto done;
}