예제 #1
0
/* FIXME */
static GstBuffer *
gst_sdlvideosink_buffer_new (GstBufferPool * pool,
    gint64 location, guint size, gpointer user_data)
{
  GstSDLVideoSink *sdlvideosink = GST_SDLVIDEOSINK (user_data);
  GstBuffer *buffer;

  if (!sdlvideosink->overlay)
    return NULL;

  if (!gst_sdlvideosink_lock (sdlvideosink)) {
    return NULL;
  }

  /* this protects the buffer from being written over multiple times */
  g_mutex_lock (sdlvideosink->lock);

  buffer = gst_buffer_new ();
  GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);
  GST_BUFFER_DATA (buffer) = sdlvideosink->overlay->pixels[0];
  if (sdlvideosink->format == SDL_YV12_OVERLAY ||
      sdlvideosink->format == SDL_IYUV_OVERLAY) {
    GST_BUFFER_SIZE (buffer) =
        sdlvideosink->width * sdlvideosink->height * 3 / 2;
  } else {
    GST_BUFFER_SIZE (buffer) = sdlvideosink->width * sdlvideosink->height * 2;
  }
  GST_BUFFER_MAXSIZE (buffer) = GST_BUFFER_SIZE (buffer);

  return buffer;
}
예제 #2
0
static GstBuffer *
gst_v4lmjpegsink_buffer_new (GstBufferPool * pool,
    guint64 offset, guint size, gpointer user_data)
{
  GstV4lMjpegSink *v4lmjpegsink = GST_V4LMJPEGSINK (user_data);
  GstBuffer *buffer = NULL;
  guint8 *data;
  gint num;

  if (!GST_V4L_IS_ACTIVE (GST_V4LELEMENT (v4lmjpegsink)))
    return NULL;
  if (v4lmjpegsink->breq.size < size) {
    GST_DEBUG ("Requested buffer size is too large (%d > %ld)",
        size, v4lmjpegsink->breq.size);
    return NULL;
  }
  if (!gst_v4lmjpegsink_wait_frame (v4lmjpegsink, &num))
    return NULL;
  data = gst_v4lmjpegsink_get_buffer (v4lmjpegsink, num);
  if (!data)
    return NULL;
  buffer = gst_buffer_new ();
  GST_BUFFER_DATA (buffer) = data;
  GST_BUFFER_MAXSIZE (buffer) = v4lmjpegsink->breq.size;
  GST_BUFFER_SIZE (buffer) = size;
  GST_BUFFER_POOL (buffer) = pool;
  GST_BUFFER_POOL_PRIVATE (buffer) = GINT_TO_POINTER (num);

  /* with this flag set, we don't need our own buffer_free() function */
  GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_DONTFREE);

  return buffer;
}
예제 #3
0
/** GstXineInput ***********************************************************/

enum
{
  ARG_0,
  ARG_LOCATION
};

GST_BOILERPLATE (GstXineInput, gst_xine_input, GstXine, GST_TYPE_XINE);

static void gst_xine_input_dispose (GObject * object);
static void gst_xine_input_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec);
static void gst_xine_input_get_property (GObject * object, guint prop_id,
    GValue * value, GParamSpec * pspec);
static GstStateChangeReturn
gst_xine_input_change_state (GstElement * element, GstStateChange transition);

static void
gst_xine_input_base_init (gpointer g_class)
{
}

static void
gst_xine_input_class_init (GstXineInputClass * klass)
{
  GstElementClass *element = GST_ELEMENT_CLASS (klass);
  GObjectClass *object = G_OBJECT_CLASS (klass);

  element->change_state = gst_xine_input_change_state;

  object->set_property = gst_xine_input_set_property;
  object->get_property = gst_xine_input_get_property;
  object->dispose = gst_xine_input_dispose;

  g_object_class_install_property (object, ARG_LOCATION,
      g_param_spec_string ("location", "location", "location",
          NULL, G_PARAM_READWRITE));
}

static void
gst_xine_input_init (GstXineInput * xine, GstXineInputClass * g_class)
{
}

static void
gst_xine_input_dispose (GObject * object)
{
  GstXineInput *xine = GST_XINE_INPUT (object);

  g_free (xine->location);
  xine->location = NULL;

  GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
}

static void
gst_xine_input_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstXineInput *xine = GST_XINE_INPUT (object);

  switch (prop_id) {
    case ARG_LOCATION:
      if (gst_element_get_state (GST_ELEMENT (xine)) != GST_STATE_NULL)
        return;
      if (xine->location)
        g_free (xine->location);
      xine->location = g_strdup (g_value_get_string (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      return;
  }
}

static void
gst_xine_input_get_property (GObject * object, guint prop_id, GValue * value,
    GParamSpec * pspec)
{
  GstXineInput *xine = GST_XINE_INPUT (object);

  switch (prop_id) {
    case ARG_LOCATION:
      g_value_set_string (value, xine->location);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      return;
  }
}

#define BUFFER_SIZE 4096        /* FIXME: what size? */
static GstData *
gst_xine_input_get (GstPad * pad)
{
  GstXineInput *xine =
      GST_XINE_INPUT (gst_object_get_parent (GST_OBJECT (pad)));
  GstBuffer *buf;
  gint real_size, position;

  /* FIXME: how does xine figure out EOS? */
  position = xine->input->get_current_pos (xine->input);
  if (position > 0 && position == xine->input->get_length (xine->input)) {
    gst_element_set_eos (GST_ELEMENT (xine));
    return GST_DATA (gst_event_new (GST_EVENT_EOS));
  }

  buf =
      gst_pad_alloc_buffer_and_set_caps (xine->srcpad, GST_BUFFER_OFFSET_NONE,
      xine->blocksize);
  GST_BUFFER_OFFSET (buf) = position;
  real_size =
      xine->input->read (xine->input, GST_BUFFER_DATA (buf),
      GST_BUFFER_MAXSIZE (buf));
  GST_BUFFER_SIZE (buf) = real_size;
  if (real_size < 0) {
    GST_ELEMENT_ERROR (xine, RESOURCE, READ, (NULL), ("error %d reading data",
            real_size));
    gst_data_unref (GST_DATA (buf));
    return NULL;
  } else if (real_size == 0) {
    buf_element_t *element;

    if (xine->input->get_capabilities (xine->input) & INPUT_CAP_BLOCK)
      element =
          xine->input->read_block (xine->input,
          gst_xine_get_stream (GST_XINE (xine))->audio_fifo, xine->blocksize);
    if (element == NULL) {
      /* FIXME: is this EOS? */
      gst_element_set_eos (GST_ELEMENT (xine));
      return GST_DATA (gst_event_new (GST_EVENT_EOS));
    } else {
      GST_BUFFER_SIZE (buf) = element->size;
      /* FIXME: put buf_element_t data in buffer */
      memcpy (GST_BUFFER_DATA (buf), element->mem, element->size);
      element->free_buffer (element);
    }
  }
  GST_BUFFER_OFFSET_END (buf) = xine->input->get_current_pos (xine->input);

  return GST_DATA (buf);
}
예제 #4
0
파일: xine.c 프로젝트: JJCG/gst-plugins-bad
void
gst_buffer_to_xine_buffer (buf_element_t * ret, GstBuffer * buffer)
{
  g_return_if_fail (ret != NULL);
  g_return_if_fail (buffer != NULL);

  /* FIXME: what's the difference? */
  ret->mem = GST_BUFFER_DATA (buffer);
  ret->content = GST_BUFFER_DATA (buffer);
  ret->size = GST_BUFFER_SIZE (buffer);
  ret->max_size = GST_BUFFER_MAXSIZE (buffer);
  /* FIXME: add more */
  ret->free_buffer = _free_xine_buf_element;
  ret->source = buffer;
}