static GstPadLinkReturn
gst_videodrop_link (GstPad * pad, const GstCaps * caps)
{
  GstVideodrop *videodrop;
  GstStructure *structure;
  gboolean ret;
  double fps;
  GstPad *otherpad;

  videodrop = GST_VIDEODROP (gst_pad_get_parent (pad));

  otherpad = (pad == videodrop->srcpad) ? videodrop->sinkpad :
      videodrop->srcpad;

  structure = gst_caps_get_structure (caps, 0);
  ret = gst_structure_get_double (structure, "framerate", &fps);
  if (!ret)
    return GST_PAD_LINK_REFUSED;

  if (pad == videodrop->srcpad) {
    videodrop->to_fps = fps;
  } else {
    videodrop->from_fps = fps;
  }

  if (gst_pad_is_negotiated (otherpad)) {
    /* 
     * Ensure that the other side talks the format we're trying to set
     */
    GstCaps *newcaps = gst_caps_copy (caps);

    if (pad == videodrop->srcpad) {
      gst_caps_set_simple (newcaps,
          "framerate", G_TYPE_DOUBLE, videodrop->from_fps, NULL);
    } else {
      gst_caps_set_simple (newcaps,
          "framerate", G_TYPE_DOUBLE, videodrop->to_fps, NULL);
    }
    ret = gst_pad_try_set_caps (otherpad, newcaps);
    if (GST_PAD_LINK_FAILED (ret)) {
      return GST_PAD_LINK_REFUSED;
    }
  }

  return GST_PAD_LINK_OK;
}
コード例 #2
0
static gboolean
gst_overlay_sinkconnect (GstPad * pad, const GstCaps * caps)
{
  GstOverlay *overlay;
  GstStructure *structure;

  overlay = GST_OVERLAY (gst_pad_get_parent (pad));

  structure = gst_caps_get_structure (caps, 0);

  gst_structure_get_int (structure, "width", &overlay->width);
  gst_structure_get_int (structure, "height", &overlay->height);
  gst_structure_get_double (structure, "framerate", &overlay->framerate);

  /* forward to the next plugin */
  return gst_pad_try_set_caps (overlay->srcpad, caps);
}
コード例 #3
0
static GstPadLinkReturn
gst_negotiation_pad_link (GstPad * pad, const GstCaps * caps)
{
  GstNegotiation *negotiation = GST_NEGOTIATION (gst_pad_get_parent (pad));
  GstPad *otherpad;
  GstPadLinkReturn ret;

  otherpad = (pad == negotiation->sinkpad) ? negotiation->srcpad :
      negotiation->sinkpad;

  ret = gst_pad_try_set_caps (otherpad, caps);

  GST_ERROR ("pad_link called on %" GST_PTR_FORMAT " with caps %"
      GST_PTR_FORMAT ", returning %d", pad, caps, ret);
  gst_object_unref (negotiation);

  return ret;
}
コード例 #4
0
static gboolean
gst_snapshot_sinkconnect (GstPad * pad, const GstCaps * caps)
{
  GstSnapshot *filter;
  gdouble fps;
  GstStructure *structure;

  filter = GST_SNAPSHOT (gst_pad_get_parent (pad));

  structure = gst_caps_get_structure (caps, 0);
  gst_structure_get_int (structure, "width", &filter->width);
  gst_structure_get_int (structure, "height", &filter->height);
  gst_structure_get_double (structure, "framerate", &fps);
  gst_structure_get_fourcc (structure, "format", &filter->format);
  filter->to_bpp = 24;

  gst_pad_try_set_caps (filter->srcpad, caps);

  return GST_PAD_LINK_OK;
}
コード例 #5
0
static gboolean
gst_median_link (GstPad * pad, const GstCaps * caps)
{
  GstMedian *filter = GST_MEDIAN (gst_pad_get_parent (pad));
  GstPad *otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
  GstStructure *structure = gst_caps_get_structure (caps, 0);
  gint w, h;
  GstPadLinkReturn ret;

  gst_structure_get_int (structure, "width", &w);
  gst_structure_get_int (structure, "height", &h);

  ret = gst_pad_try_set_caps (otherpad, caps);
  if (GST_PAD_LINK_SUCCESSFUL (ret)) {
    filter->width = w;
    filter->height = h;
  }

  gst_object_unref (filter);

  return ret;
}
static GstPadLinkReturn
gst_hermes_colorspace_link (GstPad * pad, const GstCaps * caps)
{
  GstHermesColorspace *space;
  GstPad *otherpad;
  GstStructure *structure;
  GstPadLinkReturn link_ret;
  int width, height;
  double fps;
  int i;

  space = GST_HERMES_COLORSPACE (gst_pad_get_parent (pad));
  otherpad = (pad == space->sinkpad) ? space->srcpad : space->sinkpad;

  link_ret = gst_pad_try_set_caps (otherpad, caps);
  if (link_ret == GST_PAD_LINK_OK) {
    space->passthru = TRUE;
    return link_ret;
  }

  structure = gst_caps_get_structure (caps, 0);

  for (i = 0; i < G_N_ELEMENTS (gst_hermes_colorspace_formats); i++) {
    GstCaps *icaps;
    GstCaps *fcaps;

    fcaps =
        gst_caps_copy (gst_static_caps_get (&gst_hermes_colorspace_formats
            [i].caps));

    icaps = gst_caps_intersect (caps, fcaps);
    if (!gst_caps_is_empty (icaps)) {
      break;
    }
    gst_caps_free (icaps);
  }
  if (i == G_N_ELEMENTS (gst_hermes_colorspace_formats)) {
    g_assert_not_reached ();
    return GST_PAD_LINK_REFUSED;
  }

  gst_structure_get_int (structure, "width", &width);
  gst_structure_get_int (structure, "height", &height);
  gst_structure_get_double (structure, "framerate", &fps);

  GST_INFO ("size: %dx%d", space->width, space->height);

  if (gst_pad_is_negotiated (otherpad)) {
    GstCaps *othercaps;

    othercaps = gst_caps_copy (gst_pad_get_negotiated_caps (otherpad));

    gst_caps_set_simple (othercaps,
        "width", G_TYPE_INT, width,
        "height", G_TYPE_INT, height, "framerate", G_TYPE_DOUBLE, fps, NULL);

    link_ret = gst_pad_try_set_caps (otherpad, othercaps);
    if (link_ret != GST_PAD_LINK_OK) {
      return link_ret;
    }
  }

  if (pad == space->srcpad) {
    space->src_format_index = i;
    gst_hermes_colorspace_structure_to_hermes_format (&space->src_format,
        structure);
  } else {
    space->sink_format_index = i;
    gst_hermes_colorspace_structure_to_hermes_format (&space->sink_format,
        structure);
  }

  space->sink_stride = width * (space->sink_format.bits / 8);
  space->src_stride = width * (space->src_format.bits / 8);
  space->sink_size = space->sink_stride * height;
  space->src_size = space->src_stride * height;
  space->width = width;
  space->height = height;
  space->fps = fps;

  if (gst_pad_is_negotiated (otherpad)) {
    if (!Hermes_ConverterRequest (space->h_handle, &space->sink_format,
            &space->src_format)) {
      g_warning ("Hermes: could not get converter\n");
      return GST_PAD_LINK_REFUSED;
    }
    g_print ("inited\n");
  }

  return GST_PAD_LINK_OK;
}
コード例 #7
0
ファイル: gsttarkindec.c プロジェクト: JJCG/gst-plugins-bad
static void
gst_tarkindec_chain (GstPad * pad, GstData * _data)
{
  GstBuffer *buf = GST_BUFFER (_data);
  TarkinDec *tarkindec;

  g_return_if_fail (pad != NULL);
  g_return_if_fail (GST_IS_PAD (pad));
  g_return_if_fail (buf != NULL);

  tarkindec = GST_TARKINDEC (gst_pad_get_parent (pad));

  if (!tarkindec->setup) {
    GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL),
        ("decoder not initialized (input is not tarkin?)"));
    if (GST_IS_BUFFER (buf))
      gst_buffer_unref (buf);
    else
      gst_pad_event_default (pad, GST_EVENT (buf));
    return;
  }

  if (GST_IS_EVENT (buf)) {
    switch (GST_EVENT_TYPE (buf)) {
      case GST_EVENT_EOS:
      default:
        gst_pad_event_default (pad, GST_EVENT (buf));
        break;
    }
  } else {
    gchar *data;
    gulong size;
    gchar *buffer;
    guchar *rgb;
    TarkinTime date;
    TarkinVideoLayerDesc *layer;

    /* data to decode */
    data = GST_BUFFER_DATA (buf);
    size = GST_BUFFER_SIZE (buf);

    buffer = ogg_sync_buffer (&tarkindec->oy, size);
    memcpy (buffer, data, size);
    ogg_sync_wrote (&tarkindec->oy, size);

    if (ogg_sync_pageout (&tarkindec->oy, &tarkindec->og)) {
      ogg_stream_pagein (&tarkindec->os, &tarkindec->og);

      while (ogg_stream_packetout (&tarkindec->os, &tarkindec->op)) {
        if (tarkindec->op.e_o_s)
          break;
        if (tarkindec->nheader < 3) {   /* 3 first packets to headerin */
          tarkin_synthesis_headerin (&tarkindec->ti, &tarkindec->tc,
              &tarkindec->op);

          if (tarkindec->nheader == 2) {
            tarkin_synthesis_init (tarkindec->tarkin_stream, &tarkindec->ti);
          }
          tarkindec->nheader++;
        } else {
          tarkin_synthesis_packetin (tarkindec->tarkin_stream, &tarkindec->op);

          while (tarkin_synthesis_frameout (tarkindec->tarkin_stream, &rgb, 0,
                  &date) == 0) {
            GstBuffer *outbuf;

            layer = &tarkindec->tarkin_stream->layer->desc;

            if (!GST_PAD_CAPS (tarkindec->srcpad)) {
              if (gst_pad_try_set_caps (tarkindec->srcpad, GST_CAPS_NEW ("tarkin_raw", "video/x-raw-rgb", "bpp", GST_PROPS_INT (24), "depth", GST_PROPS_INT (24), "endianness", GST_PROPS_INT (G_BYTE_ORDER), "red_mask", GST_PROPS_INT (0xff0000), "green_mask", GST_PROPS_INT (0xff00), "blue_mask", GST_PROPS_INT (0xff), "width", GST_PROPS_INT (layer->width), "height", GST_PROPS_INT (layer->height), "framerate", GST_PROPS_FLOAT (0.)  /* FIXME!!! */
                      )) <= 0) {
                GST_ELEMENT_ERROR (tarkindec, CORE, NEGOTATION, (NULL),
                    ("could not output format"));
                gst_buffer_unref (buf);
                return;
              }
            }
            outbuf = gst_buffer_new ();
            GST_BUFFER_DATA (outbuf) = rgb;
            GST_BUFFER_SIZE (outbuf) = layer->width * layer->height * 3;
            GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_DONTFREE);
            gst_pad_push (tarkindec->srcpad, GST_DATA (outbuf));

            tarkin_synthesis_freeframe (tarkindec->tarkin_stream, rgb);
          }
        }
      }
    }
    gst_buffer_unref (buf);
  }
}