GstBuffer* gst_omxbuffertransport_new (GOmxPort *port, OMX_BUFFERHEADERTYPE *buffer)
{
    GstOmxBufferTransport *tdt_buf;

    tdt_buf = (GstOmxBufferTransport*)
              gst_mini_object_new(GST_TYPE_OMXBUFFERTRANSPORT);

    g_return_val_if_fail(tdt_buf != NULL, NULL);

    GST_BUFFER_SIZE(tdt_buf) = buffer->nFilledLen;
    GST_BUFFER_DATA(tdt_buf) = buffer->pBuffer;
    gst_buffer_set_caps(GST_BUFFER (tdt_buf), port->caps);

    if (GST_BUFFER_DATA(tdt_buf) == NULL) {
        gst_mini_object_unref(GST_MINI_OBJECT(tdt_buf));
        return NULL;
    }

    tdt_buf->omxbuffer  = buffer;
    tdt_buf->port       = port;

    GST_LOG("end new\n");

    return GST_BUFFER(tdt_buf);
}
static GstOverlayBuffer *
gst_overlay_buffer_new (GstOverlayBufferPool * pool, guint index, GstCaps * caps, 
	guint8 *data,guint32 size)
{
  GstOverlayBuffer *ret;


  ret = (GstOverlayBuffer *) gst_mini_object_new (GST_TYPE_OVERLAY_BUFFER);


  ret->pool =
      (GstOverlayBufferPool *) gst_mini_object_ref (GST_MINI_OBJECT (pool));

  ret->index = index;
  GST_BUFFER_DATA (ret) = data;
  GST_BUFFER_SIZE (ret) = size;

  GST_BUFFER_FLAG_SET (ret, GST_BUFFER_FLAG_READONLY);

  gst_buffer_set_caps (GST_BUFFER (ret), caps);

  GST_DEBUG_OBJECT (pool->overlayelem, "creating buffer %u, %p in pool %p,size %u ,buffer address is %p", index,
      ret, pool, GST_BUFFER_SIZE (ret) ,GST_BUFFER_DATA (ret));

  return ret;
}
/**
 * gst_video_overlay_composition_new:
 * @rectangle: (transfer none): a #GstVideoOverlayRectangle to add to the
 *     composition
 *
 * Creates a new video overlay composition object to hold one or more
 * overlay rectangles.
 *
 * Returns: (transfer full): a new #GstVideoOverlayComposition. Unref with
 *     gst_video_overlay_composition_unref() when no longer needed.
 *
 * Since: 0.10.36
 */
GstVideoOverlayComposition *
gst_video_overlay_composition_new (GstVideoOverlayRectangle * rectangle)
{
    GstVideoOverlayComposition *comp;


    /* FIXME: should we allow empty compositions? Could also be expressed as
     * buffer without a composition on it. Maybe there are cases where doing
     * an empty new + _add() in a loop is easier? */
    g_return_val_if_fail (GST_IS_VIDEO_OVERLAY_RECTANGLE (rectangle), NULL);

    comp = (GstVideoOverlayComposition *)
           gst_mini_object_new (GST_TYPE_VIDEO_OVERLAY_COMPOSITION);

    comp->rectangles = g_new0 (GstVideoOverlayRectangle *, RECTANGLE_ARRAY_STEP);
    comp->rectangles[0] = gst_video_overlay_rectangle_ref (rectangle);
    comp->num_rectangles = 1;

    comp->seq_num = gst_video_overlay_get_seqnum ();

    /* since the rectangle was created earlier, its seqnum is smaller than ours */
    comp->min_seq_num_used = rectangle->seq_num;

    GST_LOG ("new composition %p: seq_num %u with rectangle %p", comp,
             comp->seq_num, rectangle);

    return comp;
}
Ejemplo n.º 4
0
GstVdpVideoBuffer *
gst_vdp_video_buffer_new (GstVdpDevice * device, VdpChromaType chroma_type,
    gint width, gint height, GError ** error)
{
  GstVdpVideoBuffer *buffer;
  VdpStatus status;
  VdpVideoSurface surface;

  g_return_val_if_fail (GST_IS_VDP_DEVICE (device), NULL);


  status = device->vdp_video_surface_create (device->device, chroma_type, width,
      height, &surface);
  if (status != VDP_STATUS_OK)
    goto create_error;

  buffer =
      (GstVdpVideoBuffer *) gst_mini_object_new (GST_TYPE_VDP_VIDEO_BUFFER);

  buffer->device = g_object_ref (device);
  buffer->surface = surface;

  return buffer;

create_error:
  g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ,
      "Couldn't create a VdpVideoSurface, error returned from vdpau was: %s",
      device->vdp_get_error_string (status));
  return NULL;
}
GstAiurStreamCache *
gst_aiur_stream_cache_new (guint64 threshold_max, guint64 threshold_pre,
    void *context)
{
  GstAiurStreamCache *cache =
      (GstAiurStreamCache *) gst_mini_object_new (GST_TYPE_AIURSTREAMCACHE);

  cache->pad = NULL;

  cache->adapter = gst_adapter_new ();
  cache->mutex = g_mutex_new ();
  cache->consume_cond = g_cond_new ();
  cache->produce_cond = g_cond_new ();

  cache->threshold_max = threshold_max;
  cache->threshold_pre = threshold_pre;

  cache->start = 0;
  cache->offset = 0;
  cache->ignore_size = 0;

  cache->eos = FALSE;
  cache->seeking = FALSE;
  cache->closed = FALSE;

  cache->context = context;

  return cache;
}
Ejemplo n.º 6
0
static GstDucatiBuffer *
gst_ducati_buffer_new (GstPvrBufferPool * pool)
{
  PVR2DERROR pvr_error;
  GstDucatiBuffer *self = (GstDucatiBuffer *)
      gst_mini_object_new (GST_TYPE_DUCATIBUFFER);

  GST_LOG_OBJECT (pool->element, "creating buffer %p in pool %p", self, pool);

  self->pool = (GstPvrBufferPool *)
      gst_mini_object_ref (GST_MINI_OBJECT (pool));

  GST_BUFFER_DATA (self) = gst_ducati_alloc_1d (pool->size);
  GST_BUFFER_SIZE (self) = pool->size;
  GST_LOG_OBJECT (pool->element, "width=%d, height=%d and size=%d",
      pool->padded_width, pool->padded_height, pool->size);

  pvr_error =
      PVR2DMemWrap (pool->pvr_context, GST_BUFFER_DATA (self), 0, pool->size,
      NULL, &(self->src_mem));
  if (pvr_error != PVR2D_OK) {
    GST_LOG_OBJECT (pool->element, "Failed to Wrap buffer memory"
        "returned %d", pvr_error);
  } else {
    self->wrapped = TRUE;
  }

  gst_buffer_set_caps (GST_BUFFER (self), pool->caps);

  return self;
}
Ejemplo n.º 7
0
GstVdpOutputBuffer *
gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format,
    gint width, gint height)
{
  GstVdpOutputBuffer *buffer;
  VdpStatus status;
  VdpOutputSurface surface;

  status =
      device->vdp_output_surface_create (device->device, rgba_format, width,
      height, &surface);
  if (status != VDP_STATUS_OK) {
    GST_ERROR ("Couldn't create a VdpOutputSurface, error returned was: %s",
        device->vdp_get_error_string (status));
    return NULL;
  }

  buffer =
      (GstVdpOutputBuffer *) gst_mini_object_new (GST_TYPE_VDP_OUTPUT_BUFFER);

  buffer->device = g_object_ref (device);
  buffer->surface = surface;

  return buffer;
}
static void
_setup_locked (GstDiscoverer * dc)
{
  GstStateChangeReturn ret;

  GST_DEBUG ("Setting up");

  /* Pop URI off the pending URI list */
  dc->priv->current_info =
      (GstDiscovererInfo *) gst_mini_object_new (GST_TYPE_DISCOVERER_INFO);
  dc->priv->current_info->uri = (gchar *) dc->priv->pending_uris->data;
  dc->priv->pending_uris =
      g_list_delete_link (dc->priv->pending_uris, dc->priv->pending_uris);

  /* set uri on uridecodebin */
  g_object_set (dc->priv->uridecodebin, "uri", dc->priv->current_info->uri,
      NULL);

  GST_DEBUG ("Current is now %s", dc->priv->current_info->uri);

  dc->priv->processing = TRUE;

  /* set pipeline to PAUSED */
  DISCO_UNLOCK (dc);
  GST_DEBUG ("Setting pipeline to PAUSED");
  ret =
      gst_element_set_state ((GstElement *) dc->priv->pipeline,
      GST_STATE_PAUSED);
  DISCO_LOCK (dc);

  GST_DEBUG_OBJECT (dc, "Pipeline going to PAUSED : %s",
      gst_element_state_change_return_get_name (ret));
}
Ejemplo n.º 9
0
GstGralloc *
gst_gralloc_new ()
{
  hw_module_t *hwmod = NULL;
  gralloc_module_t *gralloc_module = NULL;
  alloc_device_t *alloc_device = NULL;
  GstGralloc *gralloc = NULL;

  int err =
      hw_get_module (GRALLOC_HARDWARE_MODULE_ID, (const hw_module_t **) &hwmod);

  if (err != 0) {
    g_warning ("Failed to load gralloc");
    goto out;
  }

  gralloc_module = (gralloc_module_t *) hwmod;
  err = gralloc_open ((const hw_module_t *) gralloc_module, &alloc_device);
  if (err != 0) {
    g_warning ("Failed to open gralloc");
    goto out;
  }

  gralloc = (GstGralloc *) gst_mini_object_new (GST_TYPE_GRALLOC);
  gralloc->gralloc = gralloc_module;
  gralloc->allocator = alloc_device;

out:
  return gralloc;
}
Ejemplo n.º 10
0
GstVdpMpegFrame *
gst_vdp_mpeg_frame_new (void)
{
  GstVdpMpegFrame *frame;

  frame = (GstVdpMpegFrame *) gst_mini_object_new (GST_TYPE_VDP_MPEG_FRAME);

  return frame;
}
Ejemplo n.º 11
0
GstBuffer*
gst_goo_buffer_new ()
{
	GstBuffer* buffer = GST_BUFFER (
		gst_mini_object_new (GST_TYPE_GOO_BUFFER)
		);

	return buffer;
}
Ejemplo n.º 12
0
static GstBuffer *
gst_file_src_map_region (GstFileSrc * src, off_t offset, gsize size,
    gboolean testonly)
{
  GstBuffer *buf;
  void *mmapregion;

  g_return_val_if_fail (offset >= 0, NULL);

  /* FIXME ? use goffset and friends if we require glib >= 2.20 */
  GST_LOG_OBJECT (src, "mapping region %08" G_GINT64_MODIFIER "x+%08lx "
      "from file into memory", (gint64) offset, (gulong) size);

  mmapregion = mmap (NULL, size, PROT_READ, MAP_SHARED, src->fd, offset);

  if (mmapregion == NULL || mmapregion == MAP_FAILED)
    goto mmap_failed;

  GST_LOG_OBJECT (src, "mapped region %08lx+%08lx from file into memory at %p",
      (gulong) offset, (gulong) size, mmapregion);

  /* time to allocate a new mapbuf */
  buf = (GstBuffer *) gst_mini_object_new (GST_TYPE_MMAP_BUFFER);
  /* mmap() the data into this new buffer */
  GST_BUFFER_DATA (buf) = mmapregion;
  GST_MMAP_BUFFER (buf)->filesrc = src;

#ifdef MADV_SEQUENTIAL
  if (src->sequential) {
    /* madvise to tell the kernel what to do with it */
    if (madvise (mmapregion, size, MADV_SEQUENTIAL) < 0) {
      GST_WARNING_OBJECT (src, "warning: madvise failed: %s",
          g_strerror (errno));
    }
  }
#endif

  /* fill in the rest of the fields */
  GST_BUFFER_SIZE (buf) = size;
  GST_BUFFER_OFFSET (buf) = offset;
  GST_BUFFER_OFFSET_END (buf) = offset + size;
  GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;

  return buf;

  /* ERROR */
mmap_failed:
  {
    if (!testonly) {
      GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
          ("mmap (0x%08lx, %d, 0x%" G_GINT64_MODIFIER "x) failed: %s",
              (gulong) size, src->fd, (guint64) offset, g_strerror (errno)));
    }
    return NULL;
  }
}
Ejemplo n.º 13
0
static GstBuffer *
my_recycle_buffer_new (MyBufferPool * pool)
{
  MyRecycleBuffer *buf;

  buf = MY_RECYCLE_BUFFER (gst_mini_object_new (MY_TYPE_RECYCLE_BUFFER));
  buf->pool = pool;

  return GST_BUFFER_CAST (buf);
}
GstMozVideoBuffer*
gst_moz_video_buffer_new(void)
{
  GstMozVideoBuffer *self;

  self =(GstMozVideoBuffer*)gst_mini_object_new(GST_TYPE_MOZ_VIDEO_BUFFER);
  self->data = nullptr;

  return self;
}
Ejemplo n.º 15
0
static MXFMetadataFileDescriptor *
mxf_jpeg2000_get_descriptor (GstPadTemplate * tmpl, GstCaps * caps,
    MXFEssenceElementWriteFunc * handler, gpointer * mapping_data)
{
  MXFMetadataRGBAPictureEssenceDescriptor *ret;
  GstStructure *s;
  guint32 fourcc;

  s = gst_caps_get_structure (caps, 0);
  if (strcmp (gst_structure_get_name (s), "image/x-jpc") != 0 ||
      !gst_structure_get_fourcc (s, "fourcc", &fourcc)) {
    GST_ERROR ("Invalid caps %" GST_PTR_FORMAT, caps);
    return NULL;
  }

  ret = (MXFMetadataRGBAPictureEssenceDescriptor *)
      gst_mini_object_new (MXF_TYPE_METADATA_RGBA_PICTURE_ESSENCE_DESCRIPTOR);

  memcpy (&ret->parent.parent.essence_container, &jpeg2000_essence_container_ul,
      16);
  memcpy (&ret->parent.picture_essence_coding, &jpeg2000_picture_essence_coding,
      16);

  if (fourcc == GST_MAKE_FOURCC ('s', 'R', 'G', 'B')) {
    ret->n_pixel_layout = 3;
    ret->pixel_layout = g_new0 (guint8, 6);
    ret->pixel_layout[0] = 'R';
    ret->pixel_layout[1] = 8;
    ret->pixel_layout[2] = 'G';
    ret->pixel_layout[3] = 8;
    ret->pixel_layout[4] = 'B';
    ret->pixel_layout[5] = 8;
  } else if (fourcc == GST_MAKE_FOURCC ('s', 'Y', 'U', 'V')) {
    ret->n_pixel_layout = 3;
    ret->pixel_layout = g_new0 (guint8, 6);
    ret->pixel_layout[0] = 'Y';
    ret->pixel_layout[1] = 8;
    ret->pixel_layout[2] = 'U';
    ret->pixel_layout[3] = 8;
    ret->pixel_layout[4] = 'V';
    ret->pixel_layout[5] = 8;
  } else {
    g_assert_not_reached ();
  }

  if (!mxf_metadata_generic_picture_essence_descriptor_from_caps (&ret->parent,
          caps)) {
    gst_mini_object_unref (GST_MINI_OBJECT_CAST (ret));
    return NULL;
  }

  *handler = mxf_jpeg2000_write_func;

  return (MXFMetadataFileDescriptor *) ret;
}
Ejemplo n.º 16
0
static MXFMetadataFileDescriptor *
mxf_up_get_rgba_descriptor (GstPadTemplate * tmpl, GstCaps * caps,
    MXFEssenceElementWriteFunc * handler, gpointer * mapping_data)
{
  MXFMetadataRGBAPictureEssenceDescriptor *ret;
  guint i;
  GstCaps *tmp, *intersection;
  MXFUPMappingData *md = g_new0 (MXFUPMappingData, 1);

  *mapping_data = md;

  ret = (MXFMetadataRGBAPictureEssenceDescriptor *)
      gst_mini_object_new (MXF_TYPE_METADATA_RGBA_PICTURE_ESSENCE_DESCRIPTOR);

  for (i = 0; i < G_N_ELEMENTS (_rgba_mapping_table); i++) {
    tmp = gst_caps_from_string (_rgba_mapping_table[i].caps);
    intersection = gst_caps_intersect (caps, tmp);
    gst_caps_unref (tmp);

    if (!gst_caps_is_empty (intersection)) {
      gst_caps_unref (intersection);
      ret->n_pixel_layout = _rgba_mapping_table[i].n_pixel_layout;
      ret->pixel_layout = g_new0 (guint8, ret->n_pixel_layout * 2);
      md->fourcc = _rgba_mapping_table[i].fourcc;
      md->bpp = _rgba_mapping_table[i].n_pixel_layout;
      memcpy (ret->pixel_layout, _rgba_mapping_table[i].pixel_layout,
          ret->n_pixel_layout * 2);
      break;
    }
    gst_caps_unref (intersection);
  }

  if (md->fourcc == 0) {
    GST_ERROR ("Invalid caps %" GST_PTR_FORMAT, caps);
    gst_mini_object_unref (GST_MINI_OBJECT_CAST (ret));
    return NULL;
  }


  memcpy (&ret->parent.parent.essence_container, &up_essence_container_ul, 16);

  if (!mxf_metadata_generic_picture_essence_descriptor_from_caps (&ret->parent,
          caps)) {
    gst_mini_object_unref (GST_MINI_OBJECT_CAST (ret));
    return NULL;
  }

  md->width = ret->parent.stored_width;
  md->height = ret->parent.stored_height;

  *handler = mxf_up_write_func;

  return (MXFMetadataFileDescriptor *) ret;
}
Ejemplo n.º 17
0
/**
 * gst_buffer_new:
 *
 * Creates a newly allocated buffer without any data.
 *
 * MT safe.
 * Returns: the new #GstBuffer.
 */
GstBuffer *
gst_buffer_new (void)
{
  GstBuffer *newbuf;

  newbuf = (GstBuffer *) gst_mini_object_new (_gst_buffer_type);

  GST_CAT_LOG (GST_CAT_BUFFER, "new %p", newbuf);

  return newbuf;
}
Ejemplo n.º 18
0
/**
 * gst_buffer_list_new:
 *
 * Creates a new, empty #GstBufferList. The caller is responsible for unreffing
 * the returned #GstBufferList.
 *
 * Returns: the new #GstBufferList. gst_buffer_list_unref() after usage.
 *
 * Since: 0.10.24
 */
GstBufferList *
gst_buffer_list_new (void)
{
  GstBufferList *list;

  list = (GstBufferList *) gst_mini_object_new (_gst_buffer_list_type);

  GST_LOG ("new %p", list);

  return list;
}
Ejemplo n.º 19
0
static GstBuffer *
gst_swfdec_buffer_from_swf (SwfdecBuffer * buffer)
{
  GstSwfdecBuffer *buf;

  buf = (GstSwfdecBuffer *) gst_mini_object_new (gst_swfdecbuffer_get_type ());
  GST_BUFFER_DATA (buf) = buffer->data;
  GST_BUFFER_SIZE (buf) = buffer->length;
  buf->swfdec_buffer = buffer;

  return GST_BUFFER (buf);
}
Ejemplo n.º 20
0
void QGstXvImageBufferPool::doAlloc()
{
    //should be always called from the main thread with m_poolMutex locked
    //Q_ASSERT(QThread::currentThread() == thread());

    XSync(QX11Info::display(), false);

    QGstXvImageBuffer *xvBuffer = (QGstXvImageBuffer *)gst_mini_object_new(QGstXvImageBuffer::get_type());

    quint64 portId = m_format.property("portId").toULongLong();
    int xvFormatId = m_format.property("xvFormatId").toInt();

    xvBuffer->xvImage = XvShmCreateImage(
            QX11Info::display(),
            portId,
            xvFormatId,
            0,
            m_format.frameWidth(),
            m_format.frameHeight(),
            &xvBuffer->shmInfo
            );

    if (!xvBuffer->xvImage) {
        qWarning() << "QGstXvImageBufferPool: XvShmCreateImage failed";
        return;
    }

    XSync(QX11Info::display(), false);

    xvBuffer->shmInfo.shmid = shmget(IPC_PRIVATE, xvBuffer->xvImage->data_size, IPC_CREAT | 0777);
    xvBuffer->shmInfo.shmaddr = xvBuffer->xvImage->data = (char*)shmat(xvBuffer->shmInfo.shmid, 0, 0);
    xvBuffer->shmInfo.readOnly = False;

    if (!XShmAttach(QX11Info::display(), &xvBuffer->shmInfo)) {
        qWarning() << "QGstXvImageBufferPool: XShmAttach failed";
        return;
    }

    XSync(QX11Info::display(), false);

    shmctl (xvBuffer->shmInfo.shmid, IPC_RMID, NULL);

    xvBuffer->pool = this;
    GST_MINI_OBJECT_CAST(xvBuffer)->flags = 0;
    gst_buffer_set_caps(GST_BUFFER_CAST(xvBuffer), m_caps);
    GST_BUFFER_DATA(xvBuffer) = (uchar*)xvBuffer->xvImage->data;
    GST_BUFFER_SIZE(xvBuffer) = xvBuffer->xvImage->data_size;

    m_allBuffers.append(xvBuffer);
    m_pool.append(xvBuffer);

    XSync(QX11Info::display(), false);
}
static GstWlBuffer *
wayland_buffer_create (GstWaylandSink * sink)
{
  char filename[1024];
  int fd, size, stride;
  static void *data;
  static int init = 0;
  GstWlBuffer *wbuffer;
  struct wl_shm_pool *shm_pool;

  GST_DEBUG_OBJECT (sink, "Creating wayland-shm buffers");

  wbuffer = (GstWlBuffer *) gst_mini_object_new (GST_TYPE_WLBUFFER);
  wbuffer->wlsink = gst_object_ref (sink);

  snprintf (filename, 256, "%s-%d-%s", "/tmp/wayland-shm", init++, "XXXXXX");

  fd = mkstemp (filename);
  if (fd < 0) {
    GST_ERROR_OBJECT (sink, "open %s failed:", filename);
    exit (0);
  }

  stride = sink->video_width * 4;
  size = stride * sink->video_height;

  if (ftruncate (fd, size) < 0) {
    GST_ERROR_OBJECT (sink, "ftruncate failed:");
    close (fd);
    exit (0);
  }

  data = mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  unlink (filename);
  if (data == MAP_FAILED) {
    GST_ELEMENT_ERROR (sink, LIBRARY, SHUTDOWN, (NULL),
        ("mmap() failed: %s", strerror (errno)));
    close (fd);
    exit (0);
  }

  shm_pool = wl_shm_create_pool (sink->display->shm, fd, size);
  wbuffer->wbuffer = wl_shm_pool_create_buffer (shm_pool, 0,
      sink->video_width, sink->video_height, stride, WL_SHM_FORMAT_XRGB8888);
  wbuffer->pool = shm_pool;

  close (fd);

  GST_BUFFER_DATA (wbuffer) = data;
  GST_BUFFER_SIZE (wbuffer) = size;

  return wbuffer;
}
Ejemplo n.º 22
0
GType
gst_ducati_buffer_get_type (void)
{
  static GType type;

  if (G_UNLIKELY (type == 0)) {
    static const GTypeInfo info = {
      .class_size = sizeof (GstBufferClass),
      .class_init = gst_ducati_buffer_class_init,
      .instance_size = sizeof (GstDucatiBuffer),
    };
    type = g_type_register_static (GST_TYPE_BUFFER,
        "GstDucatiBufferPvrsink", &info, 0);
  }
  return type;
}

/*
 * GstDucatiBufferPool
 */

static GstMiniObjectClass *bufferpool_parent_class = NULL;

/** create new bufferpool
 * @element : the element that owns this pool
 * @caps:  the caps to set on the buffer
 * @num_buffers:  the requested number of buffers in the pool
 */
GstPvrBufferPool *
gst_pvr_bufferpool_new (GstElement * element, GstCaps * caps, gint num_buffers,
    gint size, PVR2DCONTEXTHANDLE pvr_context)
{
  GstPvrBufferPool *self = (GstPvrBufferPool *)
      gst_mini_object_new (GST_TYPE_PVRBUFFERPOOL);
  GstStructure *s = gst_caps_get_structure (caps, 0);

  self->element = gst_object_ref (element);
  gst_structure_get_int (s, "width", &self->padded_width);
  gst_structure_get_int (s, "height", &self->padded_height);
  self->caps = gst_caps_ref (caps);
  self->size = size;
  self->pvr_context = pvr_context;

  self->free_buffers = g_queue_new ();
  self->used_buffers = g_queue_new ();
  self->lock = g_mutex_new ();
  self->running = TRUE;

  return self;
}
Ejemplo n.º 23
0
static GstBuffer *
create_read_only_buffer (void)
{
  GstBuffer *buf;

  buf = (GstBuffer *) gst_mini_object_new (GST_TYPE_BUFFER);

  /* assign some read-only data to the new buffer */
  GST_BUFFER_DATA (buf) = (guint8 *) ro_memory;
  GST_BUFFER_SIZE (buf) = sizeof (ro_memory);

  GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);

  return buf;
}
Ejemplo n.º 24
0
EXPORT_C GstBuffer *
gst_app_buffer_new (void *data, int length,
    GstAppBufferFinalizeFunc finalize, void *priv)
{
  GstAppBuffer *buffer;

  buffer = (GstAppBuffer *) gst_mini_object_new (GST_TYPE_APP_BUFFER);

  GST_BUFFER_DATA (buffer) = data;
  GST_BUFFER_SIZE (buffer) = length;

  buffer->finalize = finalize;
  buffer->priv = priv;

  return GST_BUFFER (buffer);
}
Ejemplo n.º 25
0
GstBuffer *gst_dsp_buffer_new(GstDspBase *base, struct td_buffer *tb)
{
	GstBuffer *buf;
	GstDspBuffer *dsp_buf;
	dmm_buffer_t *b = tb->data;
	buf = (GstBuffer *) gst_mini_object_new(type);
	gst_buffer_set_caps(buf, GST_PAD_CAPS(base->srcpad));
	if (!tb->pinned)
		GST_BUFFER_MALLOCDATA(buf) = b->allocated_data;
	GST_BUFFER_DATA(buf) = b->data;
	GST_BUFFER_SIZE(buf) = b->len;
	dsp_buf = (GstDspBuffer *) buf;
	dsp_buf->tb = tb;
	dsp_buf->base = base;
	return buf;
}
Ejemplo n.º 26
0
static GstEvent *
gst_event_new (GstEventType type)
{
  GstEvent *event;

  event = (GstEvent *) gst_mini_object_new (GST_TYPE_EVENT);

  GST_CAT_DEBUG (GST_CAT_EVENT, "creating new event %p %s %d", event,
      gst_event_type_get_name (type), type);

  event->type = type;
  event->src = NULL;
  event->structure = NULL;
  GST_EVENT_SEQNUM (event) = gst_util_seqnum_next ();

  return event;
}
Ejemplo n.º 27
0
static GstQuery *
_gst_query_copy (GstQuery * query)
{
  GstQuery *copy;

  copy = (GstQuery *) gst_mini_object_new (GST_TYPE_QUERY);

  copy->type = query->type;

  if (query->structure) {
    copy->structure = gst_structure_copy (query->structure);
    gst_structure_set_parent_refcount (copy->structure,
        &query->mini_object.refcount);
  }

  return copy;
}
Ejemplo n.º 28
0
/**
 * gst_overlay_buffer_pool_new:
 * @overlayelem:  the overlay element (src or sink) that owns this pool
 * @fd:   the video device file descriptor
 * @num_buffers:  the requested number of buffers in the pool
 * @caps:  the caps to set on the buffer
 * @requeuebuf: if %TRUE, and if the pool is still in the running state, a
 *  buffer with no remaining references is immediately passed back to overlay
 *  (VIDIOC_QBUF), otherwise it is returned to the pool of available buffers
 *  (which can be accessed via gst_overlay_buffer_pool_get().
 *
 * Construct a new buffer pool.
 *
 * Returns: the new pool, use gst_overlay_buffer_pool_destroy() to free resources
 */
GstOverlayBufferPool *
gst_overlay_buffer_pool_new (GstElement * overlayelem, gint num_buffers,
    GstCaps * caps)
{
  GstOverlayBufferPool *pool;
  gint n;
  guint32 size;
  guint8 *data;

  GstSurfaceFlingerSink *surfacesink = GST_SURFACEFLINGERSINK (overlayelem);

  pool = (GstOverlayBufferPool *) gst_mini_object_new (GST_TYPE_OVERLAY_BUFFER_POOL);

  g_return_val_if_fail(pool != NULL, NULL);

  /* first, lets request buffers, and see how many we can get: */
  GST_WARNING_OBJECT (overlayelem, "STREAMING, requesting %d MMAP buffers",
      num_buffers);

  pool->overlayelem = overlayelem;
  pool->buffer_count = num_buffers;
  pool->buffers = g_new0 (GstOverlayBuffer *, num_buffers);
  pool->avail_buffers = g_async_queue_new ();
  /* now, mmap the buffers: */
  for (n = 0; n < num_buffers; n++) {
    size = videoflinger_device_get_overlay_buf_length(surfacesink->videodev);
    data = (guint8 *)videoflinger_device_get_overlay_address(surfacesink->videodev,n);
    pool->buffers[n] = gst_overlay_buffer_new (pool, n, caps,
		data,size);
    if (!pool->buffers[n])
      goto buffer_new_failed;
    pool->num_live_buffers++;
    g_async_queue_push (pool->avail_buffers, pool->buffers[n]);
  }
  return pool;
  /* ERRORS */
buffer_new_failed:
  {
    gint errnosave = errno;

    gst_overlay_buffer_pool_destroy (pool);

    errno = errnosave;
    return NULL;
  }
}
Ejemplo n.º 29
0
/******************************************************************************
 * gst_ticircbuffer_new
 *     Create a circular buffer to store an encoded input stream.  Increasing
 *     the number of windows stored in the buffer can help performance if
 *     adequate memory is available.
 ******************************************************************************/
GstTICircBuffer* gst_ticircbuffer_new(Int32 windowSize, Int32 numWindows,
                     Bool fixedBlockSize)
{
    GstTICircBuffer *circBuf;
    Buffer_Attrs     bAttrs  = Buffer_Attrs_DEFAULT;
    Int32            bufSize;

    circBuf = (GstTICircBuffer*)gst_mini_object_new(GST_TYPE_TICIRCBUFFER);

    g_return_val_if_fail(circBuf != NULL, NULL);

    GST_INFO("requested windowSize:  %ld\n", windowSize);
    circBuf->windowSize = windowSize;

    GST_INFO("fixed block size is %s\n", fixedBlockSize ? "ON" : "OFF");
    circBuf->fixedBlockSize = fixedBlockSize;

    /* We need to have at least 2 windows allocated for us to be able
     * to copy buffer data while the consumer is running.
     */
    if (numWindows < 3 && circBuf->fixedBlockSize != TRUE) {
        GST_ERROR("numWindows must be at least 3 when fixedBlockSize=FALSE");
        return NULL;
    }

    /* Set the read ahead size to be 1/4 of a window */
    circBuf->readAheadSize = (fixedBlockSize) ? 0 : windowSize >> 2;

    /* Allocate the circular buffer */
    bufSize = (numWindows * windowSize) + (circBuf->readAheadSize << 1);

    GST_LOG("creating circular input buffer of size %lu\n", bufSize);
    circBuf->hBuf = Buffer_create(bufSize, &bAttrs);

    if (circBuf->hBuf == NULL) {
        GST_ERROR("failed to create buffer");
        gst_object_unref(circBuf);
        return NULL;
    }

    circBuf->readPtr = circBuf->writePtr = Buffer_getUserPtr(circBuf->hBuf);

    return circBuf;
}
Ejemplo n.º 30
0
static GstFlowReturn 
gst_sh_video_sink_buffer_alloc (GstBaseSink *bsink, guint64 offset, guint size,
				GstCaps *caps, GstBuffer **buf)
{
	GstStructure *structure = NULL;
	GstSHVideoSink *sink = GST_SH_VIDEO_SINK (bsink);
	gint width, height;

	GST_LOG_OBJECT(sink,"Buffer requested. Offset: %lld, size: %d",offset,size);

	if(size<=0)
	{
		GST_DEBUG_OBJECT(sink,"%s failed (no size for buffer)",__FUNCTION__);
		return GST_FLOW_UNEXPECTED;
	}  

	if(size > sink->veu.mem.size)
	{
		GST_DEBUG_OBJECT(sink,"%s not enough space in VEU mem",__FUNCTION__);
		return GST_FLOW_UNEXPECTED;
	}  

	structure = gst_caps_get_structure (caps, 0);

	if (!(gst_structure_get_int (structure, "width",  &width)
	&& gst_structure_get_int (structure, "height", &height))) 
	{
		GST_DEBUG_OBJECT(sink,"%s failed (no width/height)",__FUNCTION__);
		return GST_FLOW_UNEXPECTED;
	}

	GST_LOG_OBJECT(sink,"Frame width: %d heigth: %d",width,height);

        // Using HW buffer from VEU
	*buf = (GstBuffer *) gst_mini_object_new (GST_TYPE_SH_VIDEO_BUFFER);
	GST_BUFFER_DATA(*buf) = GST_BUFFER_MALLOCDATA(*buf) = sink->veu.mem.iomem;    
	GST_BUFFER_SIZE(*buf) = size;    
	GST_SH_VIDEO_BUFFER_Y_DATA(*buf) = (guint8*)sink->veu.mem.address; 
	GST_SH_VIDEO_BUFFER_Y_SIZE(*buf) = width*height; 
	GST_SH_VIDEO_BUFFER_C_DATA(*buf) = (guint8*)(sink->veu.mem.address+GST_SH_VIDEO_BUFFER_Y_SIZE(*buf)); 
	GST_SH_VIDEO_BUFFER_C_SIZE(*buf) = GST_SH_VIDEO_BUFFER_Y_SIZE(*buf)/2; 

	return GST_FLOW_OK;
}