Ejemplo n.º 1
0
static gboolean
gst_segment_clip_sink_setcaps (GstPad * pad, GstCaps * caps)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (gst_pad_get_parent (pad));
  GstSegmentClipClass *klass = GST_SEGMENT_CLIP_GET_CLASS (self);
  gboolean ret;

  GST_DEBUG_OBJECT (pad, "Setting caps: %" GST_PTR_FORMAT, caps);
  ret = klass->set_caps (self, caps);

  gst_object_unref (self);

  return ret;
}
Ejemplo n.º 2
0
static gboolean
gst_segment_clip_query (GstPad * pad, GstQuery * query)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (gst_pad_get_parent (pad));
  gboolean ret;
  GstPad *otherpad;

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

  GST_LOG_OBJECT (pad, "Handling query of type '%s'",
      gst_query_type_get_name (GST_QUERY_TYPE (query)));

  ret = gst_pad_peer_query (otherpad, query);

  gst_object_unref (self);
  return ret;
}
Ejemplo n.º 3
0
static const GstQueryType *
gst_segment_clip_query_type (GstPad * pad)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (gst_pad_get_parent (pad));
  GstPad *otherpad, *peer;
  const GstQueryType *types = NULL;

  otherpad = (pad == self->srcpad) ? self->sinkpad : self->srcpad;
  peer = gst_pad_get_peer (otherpad);
  if (peer) {
    types = gst_pad_get_query_types (peer);
    gst_object_unref (peer);
  }

  gst_object_unref (self);

  return types;
}
Ejemplo n.º 4
0
static gboolean
gst_segment_clip_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (parent);
  gboolean ret = TRUE;

  GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));

  switch (GST_EVENT_TYPE (event)) {
    case GST_EVENT_CAPS:
    {
      GstCaps *caps;

      /* should be only downstream */
      g_assert (pad == self->sinkpad);
      gst_event_parse_caps (event, &caps);
      ret = gst_segment_clip_sink_setcaps (self, caps);
      break;
    }
    case GST_EVENT_SEGMENT:
    {
      const GstSegment *segment;

      gst_event_parse_segment (event, &segment);
      GST_DEBUG_OBJECT (pad, "Got NEWSEGMENT event %" GST_SEGMENT_FORMAT,
          segment);
      gst_segment_copy_into (segment, &self->segment);
      break;
    }
    case GST_EVENT_FLUSH_STOP:
      gst_segment_clip_reset (self);
      break;
    default:
      break;
  }

  if (ret)
    ret = gst_pad_event_default (pad, parent, event);
  else
    gst_event_unref (event);

  return ret;
}
Ejemplo n.º 5
0
static GstFlowReturn
gst_segment_clip_sink_chain (GstPad * pad, GstBuffer * buffer)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (GST_PAD_PARENT (pad));
  GstFlowReturn ret;
  GstSegmentClipClass *klass = GST_SEGMENT_CLIP_GET_CLASS (self);
  GstBuffer *outbuf = NULL;

  GST_LOG_OBJECT (pad,
      "Handling buffer with timestamp %" GST_TIME_FORMAT " and duration %"
      GST_TIME_FORMAT, GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)),
      GST_TIME_ARGS (GST_BUFFER_DURATION (buffer)));

  ret = klass->clip_buffer (self, buffer, &outbuf);
  if (ret == GST_FLOW_OK && outbuf)
    ret = gst_pad_push (self->srcpad, outbuf);

  return ret;
}
Ejemplo n.º 6
0
static gboolean
gst_segment_clip_event (GstPad * pad, GstEvent * event)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (gst_pad_get_parent (pad));
  GstPad *otherpad;
  gboolean ret;

  GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));

  otherpad = (pad == self->srcpad) ? self->sinkpad : self->srcpad;
  ret = gst_pad_push_event (otherpad, event);

  if (ret) {
    switch (GST_EVENT_TYPE (event)) {
      case GST_EVENT_NEWSEGMENT:{
        GstFormat fmt;
        gboolean is_update;
        gint64 start, end, base;
        gdouble rate;

        gst_event_parse_new_segment (event, &is_update, &rate, &fmt, &start,
            &end, &base);
        GST_DEBUG_OBJECT (pad,
            "Got NEWSEGMENT event in %s format, passing on (%"
            GST_TIME_FORMAT " - %" GST_TIME_FORMAT ")",
            gst_format_get_name (fmt), GST_TIME_ARGS (start),
            GST_TIME_ARGS (end));
        gst_segment_set_newsegment (&self->segment, is_update, rate, fmt, start,
            end, base);
        break;
      }
      case GST_EVENT_FLUSH_STOP:
        gst_segment_clip_reset (self);
        break;
      default:
        break;
    }
  }

  gst_object_unref (self);
  return ret;
}
Ejemplo n.º 7
0
static GstStateChangeReturn
gst_segment_clip_change_state (GstElement * element, GstStateChange transition)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (element);
  GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;

  if (GST_ELEMENT_CLASS (parent_class)->change_state)
    ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);

  switch (transition) {
    case GST_STATE_CHANGE_READY_TO_PAUSED:
    case GST_STATE_CHANGE_PAUSED_TO_READY:
      gst_segment_clip_reset (self);
      break;
    default:
      break;
  }

  return ret;
}
Ejemplo n.º 8
0
static GstFlowReturn
gst_segment_clip_sink_bufferalloc (GstPad * pad, guint64 offset, guint size,
    GstCaps * caps, GstBuffer ** buf)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (gst_pad_get_parent (pad));
  GstFlowReturn ret = GST_FLOW_OK;

  GST_LOG_OBJECT (pad, "Allocating buffer with offset 0x%" G_GINT64_MODIFIER
      "x and size %u with caps: %" GST_PTR_FORMAT, offset, size, caps);

  *buf = NULL;

  ret = gst_pad_alloc_buffer (self->srcpad, offset, size, caps, buf);
  if (G_UNLIKELY (ret != GST_FLOW_OK))
    GST_ERROR_OBJECT (pad, "Allocating buffer failed: %s",
        gst_flow_get_name (ret));

  gst_object_unref (self);

  return ret;
}
Ejemplo n.º 9
0
static gboolean
gst_segment_clip_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (parent);
  gboolean ret;

  GST_LOG_OBJECT (pad, "Handling query of type '%s'",
      gst_query_type_get_name (GST_QUERY_TYPE (query)));

  if (GST_QUERY_TYPE (query) == GST_QUERY_CAPS) {
    GstCaps *caps;

    gst_query_parse_caps (query, &caps);
    caps = gst_segment_clip_getcaps (self, pad, caps);
    gst_query_set_caps_result (query, caps);
    gst_caps_unref (caps);
    ret = TRUE;
  } else {
    ret = gst_pad_query_default (pad, parent, query);
  }

  return ret;
}
Ejemplo n.º 10
0
static GstCaps *
gst_segment_clip_getcaps (GstPad * pad)
{
  GstSegmentClip *self = GST_SEGMENT_CLIP (gst_pad_get_parent (pad));
  GstPad *otherpad;
  GstCaps *tmp, *ret;

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

  tmp = gst_pad_peer_get_caps (otherpad);
  if (tmp) {
    ret = gst_caps_intersect (tmp, gst_pad_get_pad_template_caps (pad));
    gst_caps_unref (tmp);
  } else {
    ret = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
  }

  gst_object_unref (self);

  GST_LOG_OBJECT (pad, "Returning caps: %" GST_PTR_FORMAT, ret);

  return ret;
}