static void
test_rtxsender_packet_retention (gboolean test_with_time)
{
  guint master_ssrc = 1234567;
  guint master_pt = 96;
  guint rtx_ssrc = 7654321;
  guint rtx_pt = 99;
  gint num_buffers = test_with_time ? 30 : 10;
  gint half_buffers = num_buffers / 2;
  guint timestamp_delta = 90000 / 30;
  guint timestamp = G_MAXUINT32 - half_buffers * timestamp_delta;
  GstHarness *h;
  GstStructure *pt_map = gst_structure_new ("application/x-rtp-pt-map",
      "96", G_TYPE_UINT, rtx_pt, NULL);
  GstStructure *ssrc_map = gst_structure_new ("application/x-rtp-ssrc-map",
      "1234567", G_TYPE_UINT, rtx_ssrc, NULL);

  h = gst_harness_new ("rtprtxsend");

  /* In both cases we want the rtxsend queue to store 'half_buffers'
     amount of buffers at most. In max-size-packets mode, it's trivial.
     In max-size-time mode, we specify almost half a second, which is
     the equivalent of 15 frames in a 30fps video stream.
   */
  g_object_set (h->element,
      "max-size-packets", test_with_time ? 0 : half_buffers,
      "max-size-time", test_with_time ? 499 : 0,
      "payload-type-map", pt_map, "ssrc-map", ssrc_map, NULL);

  gst_harness_set_src_caps_str (h, "application/x-rtp, "
      "media = (string)video, payload = (int)96, "
      "ssrc = (uint)1234567, clock-rate = (int)90000, "
      "encoding-name = (string)RAW");

  /* Now push all buffers and request retransmission every time for all of them */
  for (gint i = 0; i < num_buffers; ++i, timestamp += timestamp_delta) {
    /* Request to retransmit all the previous ones */
    for (gint j = 0; j < i; ++j) {
      guint rtx_seqnum = 0x100 + j;
      gst_harness_push_upstream_event (h,
          create_rtx_event (master_ssrc, master_pt, rtx_seqnum));

      /* Pull only the ones supposed to be retransmited */
      if (j >= i - half_buffers)
        pull_and_verify (h, TRUE, rtx_ssrc, rtx_pt, rtx_seqnum);
    }
    /* Check there no extra buffers in the harness queue */
    fail_unless_equals_int (gst_harness_buffers_in_queue (h), 0);

    /* We create RTP buffers with timestamps that will eventualy wrap around 0
       to be sure, rtprtxsend can handle it properly */
    push_pull_and_verify (h,
        create_rtp_buffer_with_timestamp (master_ssrc, master_pt, 0x100 + i,
            timestamp), FALSE, master_ssrc, master_pt, 0x100 + i);
  }

  gst_structure_free (pt_map);
  gst_structure_free (ssrc_map);
  gst_harness_teardown (h);
}
static void
gst_test_http_src_reset_input (GstTestHTTPSrc * src)
{
  src->input.context = NULL;
  src->input.size = 0;
  src->input.status_code = 0;
  if (src->input.request_headers) {
    gst_structure_free (src->input.request_headers);
    src->input.request_headers = NULL;
  }
  if (src->input.response_headers) {
    gst_structure_free (src->input.response_headers);
    src->input.response_headers = NULL;
  }
  if (src->http_headers_event) {
    gst_event_unref (src->http_headers_event);
    src->http_headers_event = NULL;
  }
  if (src->extra_headers) {
    gst_structure_free (src->extra_headers);
    src->extra_headers = NULL;
  }
  g_free (src->http_method_name);
  src->http_method_name = NULL;
  g_free (src->user_agent);
  src->user_agent = NULL;
  src->duration_changed = FALSE;
}
void ImageOverlayFilterImpl::addImage (const std::string &id,
                                       const std::string &uri, float offsetXPercent, float offsetYPercent,
                                       float widthPercent, float heightPercent,
                                       bool keepAspectRatio, bool center)
{
  GstStructure *imagesLayout, *imageSt;

  imageSt = gst_structure_new ("image_position",
                               "id", G_TYPE_STRING, id.c_str (),
                               "uri", G_TYPE_STRING, uri.c_str (),
                               "offsetXPercent", G_TYPE_FLOAT, float (offsetXPercent),
                               "offsetYPercent", G_TYPE_FLOAT, float (offsetYPercent),
                               "widthPercent", G_TYPE_FLOAT, float (widthPercent),
                               "heightPercent", G_TYPE_FLOAT, float (heightPercent),
                               "keepAspectRatio", G_TYPE_BOOLEAN, keepAspectRatio,
                               "center", G_TYPE_BOOLEAN, center,
                               NULL);

  /* The function obtains the actual window list */
  g_object_get (G_OBJECT (imageOverlay), IMAGES_TO_OVERLAY, &imagesLayout,
                NULL);
  gst_structure_set (imagesLayout,
                     id.c_str(), GST_TYPE_STRUCTURE,
                     imageSt, NULL);

  g_object_set (G_OBJECT (imageOverlay), IMAGES_TO_OVERLAY, imagesLayout, NULL);

  gst_structure_free (imagesLayout);
  gst_structure_free (imageSt);
}
void
PointerDetectorFilter::addWindow (KmsMediaPointerDetectorWindow window)
{
  GstStructure *buttonsLayout, *buttonsLayoutAux;

  buttonsLayoutAux = gst_structure_new (
                       window.id.c_str(),
                       "upRightCornerX", G_TYPE_INT, window.topRightCornerX,
                       "upRightCornerY", G_TYPE_INT, window.topRightCornerY,
                       "width", G_TYPE_INT, window.width,
                       "height", G_TYPE_INT, window.height,
                       "id", G_TYPE_STRING, window.id.c_str(),
                       NULL);

  /* The function obtains the actual window list */
  g_object_get (G_OBJECT (pointerDetector), WINDOWS_LAYOUT, &buttonsLayout, NULL);
  gst_structure_set (buttonsLayout,
                     window.id.c_str(), GST_TYPE_STRUCTURE, buttonsLayoutAux,
                     NULL);

  g_object_set (G_OBJECT (pointerDetector), WINDOWS_LAYOUT, buttonsLayout, NULL);

  gst_structure_free (buttonsLayout);
  gst_structure_free (buttonsLayoutAux);
}
Example #5
0
static gboolean
gst_v4l2sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
{
  GstV4l2Sink *v4l2sink = GST_V4L2SINK (bsink);
  GstV4l2Object *obj = v4l2sink->v4l2object;
  GstBufferPool *pool;
  guint size = 0;
  GstCaps *caps;
  gboolean need_pool;

  gst_query_parse_allocation (query, &caps, &need_pool);

  if (caps == NULL)
    goto no_caps;

  if ((pool = obj->pool))
    gst_object_ref (pool);

  if (pool != NULL) {
    GstCaps *pcaps;
    GstStructure *config;

    /* we had a pool, check caps */
    config = gst_buffer_pool_get_config (pool);
    gst_buffer_pool_config_get_params (config, &pcaps, &size, NULL, NULL);

    GST_DEBUG_OBJECT (v4l2sink,
        "we had a pool with caps %" GST_PTR_FORMAT, pcaps);
    if (!gst_caps_is_equal (caps, pcaps)) {
      gst_structure_free (config);
      gst_object_unref (pool);
      goto different_caps;
    }
    gst_structure_free (config);
  }
  /* we need at least 2 buffers to operate */
  gst_query_add_allocation_pool (query, pool, size, 2, 0);

  /* we also support various metadata */
  gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL);
  gst_query_add_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE, NULL);

  if (pool)
    gst_object_unref (pool);

  return TRUE;

  /* ERRORS */
no_caps:
  {
    GST_DEBUG_OBJECT (v4l2sink, "no caps specified");
    return FALSE;
  }
different_caps:
  {
    /* different caps, we can't use this pool */
    GST_DEBUG_OBJECT (v4l2sink, "pool has different caps");
    return FALSE;
  }
}
/**
 * gst_buffer_pool_set_config:
 * @pool: a #GstBufferPool
 * @config: (transfer full): a #GstStructure
 *
 * Set the configuration of the pool. The pool must be inactive and all buffers
 * allocated form this pool must be returned or else this function will do
 * nothing and return FALSE.
 *
 * @config is a #GstStructure that contains the configuration parameters for
 * the pool. A default and mandatory set of parameters can be configured with
 * gst_buffer_pool_config_set_params(), gst_buffer_pool_config_set_allocator()
 * and gst_buffer_pool_config_add_option().
 *
 * If the parameters in @config can not be set exactly, this function returns
 * FALSE and will try to update as much state as possible. The new state can
 * then be retrieved and refined with gst_buffer_pool_get_config().
 *
 * This function takes ownership of @config.
 *
 * Returns: TRUE when the configuration could be set.
 */
gboolean
gst_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
{
  gboolean result;
  GstBufferPoolClass *pclass;
  GstBufferPoolPrivate *priv;

  g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), FALSE);
  g_return_val_if_fail (config != NULL, FALSE);

  priv = pool->priv;

  GST_BUFFER_POOL_LOCK (pool);
  /* can't change the settings when active */
  if (priv->active)
    goto was_active;

  /* we can't change when outstanding buffers */
  if (g_atomic_int_get (&priv->outstanding) != 0)
    goto have_outstanding;

  pclass = GST_BUFFER_POOL_GET_CLASS (pool);

  /* set the new config */
  if (G_LIKELY (pclass->set_config))
    result = pclass->set_config (pool, config);
  else
    result = FALSE;

  if (result) {
    if (priv->config)
      gst_structure_free (priv->config);
    priv->config = config;

    /* now we are configured */
    priv->configured = TRUE;
  } else {
    gst_structure_free (config);
  }
  GST_BUFFER_POOL_UNLOCK (pool);

  return result;

  /* ERRORS */
was_active:
  {
    gst_structure_free (config);
    GST_WARNING_OBJECT (pool, "can't change config, we are active");
    GST_BUFFER_POOL_UNLOCK (pool);
    return FALSE;
  }
have_outstanding:
  {
    gst_structure_free (config);
    GST_WARNING_OBJECT (pool, "can't change config, have outstanding buffers");
    GST_BUFFER_POOL_UNLOCK (pool);
    return FALSE;
  }
}
static GstStructure *
get_structure_from_roi (std::shared_ptr<RegionOfInterest> roi)
{
  GstStructure *roiStructure, *configRoiSt;
  std::shared_ptr<RegionOfInterestConfig> config;
  int pointCount = 0;

  roiStructure = gst_structure_new_empty (roi->getId().c_str() );

  if (roiStructure == NULL) {
    throw KurentoException (MEDIA_OBJECT_ILLEGAL_PARAM_ERROR,
                            "Invalid roi name");
  }

  for (std::shared_ptr<RelativePoint> point : roi->getPoints() ) {
    GstStructure *pointSt;
    std::string name = "point" + std::to_string (pointCount ++);

    pointSt = gst_structure_new (name.c_str(),
                                 "x", G_TYPE_FLOAT, point->getX(),
                                 "y", G_TYPE_FLOAT, point->getY(),
                                 NULL);

    gst_structure_set (roiStructure,
                       name.c_str(), GST_TYPE_STRUCTURE, pointSt,
                       NULL);

    gst_structure_free (pointSt);
  }

  config = roi->getRegionOfInterestConfig();
  configRoiSt = gst_structure_new ("config",
                                   "id", G_TYPE_STRING, roi->getId().c_str(),
                                   "occupancy_level_min", G_TYPE_INT, config->getOccupancyLevelMin(),
                                   "occupancy_level_med", G_TYPE_INT, config->getOccupancyLevelMed(),
                                   "occupancy_level_max", G_TYPE_INT, config->getOccupancyLevelMax(),
                                   "occupancy_num_frames_to_event", G_TYPE_INT,
                                   config->getOccupancyNumFramesToEvent(),
                                   "fluidity_level_min", G_TYPE_INT, config->getFluidityLevelMin(),
                                   "fluidity_level_med", G_TYPE_INT, config->getFluidityLevelMed(),
                                   "fluidity_level_max", G_TYPE_INT, config->getFluidityLevelMax(),
                                   "fluidity_num_frames_to_event", G_TYPE_INT,
                                   config->getFluidityNumFramesToEvent(),
                                   "send_optical_flow_event", G_TYPE_BOOLEAN, config->getSendOpticalFlowEvent(),
                                   "optical_flow_num_frames_to_event", G_TYPE_INT,
                                   config->getOpticalFlowNumFramesToEvent(),
                                   "optical_flow_num_frames_to_reset", G_TYPE_INT,
                                   config->getOpticalFlowNumFramesToReset(),
                                   "optical_flow_angle_offset", G_TYPE_INT, config->getOpticalFlowAngleOffset(),
                                   NULL);
  gst_structure_set (roiStructure,
                     "config", GST_TYPE_STRUCTURE, configRoiSt,
                     NULL);

  gst_structure_free (configRoiSt);

  return roiStructure;
}
static void
_free_pending_effect (PendingEffects * pend)
{
  g_free (pend->track_id);
  gst_object_unref (pend->trackelement);
  if (pend->children_properties)
    gst_structure_free (pend->children_properties);
  if (pend->properties)
    gst_structure_free (pend->properties);

  g_slice_free (PendingEffects, pend);
}
Example #9
0
static GstFlowReturn
kms_image_overlay_transform_frame_ip (GstVideoFilter * filter,
    GstVideoFrame * frame)
{
  KmsImageOverlay *imageoverlay = KMS_IMAGE_OVERLAY (filter);
  GstMapInfo info;
  GstStructure *faces;
  GSList *faces_list;

  gst_buffer_map (frame->buffer, &info, GST_MAP_READ);

  kms_image_overlay_initialize_images (imageoverlay, frame);
  imageoverlay->priv->cvImage->imageData = (char *) info.data;

  GST_OBJECT_LOCK (imageoverlay);
  faces = g_queue_pop_head (imageoverlay->priv->events_queue);

  while (faces != NULL) {

    kms_image_overlay_get_timestamp (imageoverlay, faces);
    GST_DEBUG ("buffer pts %" G_GUINT64_FORMAT, frame->buffer->pts);
    GST_DEBUG ("event pts %" G_GUINT64_FORMAT, imageoverlay->priv->pts);
    GST_DEBUG ("queue length %d",
        g_queue_get_length (imageoverlay->priv->events_queue));

    if (imageoverlay->priv->pts == frame->buffer->pts) {
      faces_list = get_faces (faces);

      if (faces_list != NULL) {
        if (imageoverlay->priv->costume != NULL) {
          kms_image_overlay_display_detections_overlay_img (imageoverlay,
              faces_list);
        }
        g_slist_free_full (faces_list, cvrect_free);
      }
      gst_structure_free (faces);
      break;
    } else if (imageoverlay->priv->pts < frame->buffer->pts) {
      gst_structure_free (faces);
    } else {
      g_queue_push_head (imageoverlay->priv->events_queue, faces);
      break;
    }
    faces = g_queue_pop_head (imageoverlay->priv->events_queue);
  }

  GST_OBJECT_UNLOCK (imageoverlay);

  gst_buffer_unmap (frame->buffer, &info);

  return GST_FLOW_OK;
}
Example #10
0
void GstEnginePipeline::SourceSetupCallback(GstURIDecodeBin* bin,
                                            GParamSpec* pspec, gpointer self) {
  GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self);
  GstElement* element;
  g_object_get(bin, "source", &element, nullptr);
  if (!element) {
    return;
  }

  if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "device") &&
      !instance->source_device().isEmpty()) {
    // Gstreamer is not able to handle device in URL (refering to Gstreamer
    // documentation, this might be added in the future). Despite that, for now
    // we include device inside URL: we decompose it during Init and set device
    // here, when this callback is called.
    g_object_set(element, "device",
                 instance->source_device().toLocal8Bit().constData(), nullptr);
  }
  if (g_object_class_find_property(G_OBJECT_GET_CLASS(element),
                                   "extra-headers") &&
      instance->url().host().contains("grooveshark")) {
    // Grooveshark streaming servers will answer with a 400 error 'Bad request'
    // if we don't specify 'Range' field in HTTP header.
    // Maybe it could be usefull in some other cases, but for now, I prefer to
    // keep this grooveshark specific.
    GstStructure* headers;
    headers = gst_structure_new("extra-headers", "Range", G_TYPE_STRING,
                                "bytes=0-", nullptr);
    g_object_set(element, "extra-headers", headers, nullptr);
    gst_structure_free(headers);
  }

  if (g_object_class_find_property(G_OBJECT_GET_CLASS(element),
                                   "extra-headers") &&
      instance->url().host().contains("files.one.ubuntu.com")) {
    GstStructure* headers;
    headers =
        gst_structure_new("extra-headers", "Authorization", G_TYPE_STRING,
                          instance->url().fragment().toAscii().data(), nullptr);
    g_object_set(element, "extra-headers", headers, nullptr);
    gst_structure_free(headers);
  }

  if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "user-agent")) {
    QString user_agent =
        QString("%1 %2").arg(QCoreApplication::applicationName(),
                             QCoreApplication::applicationVersion());
    g_object_set(element, "user-agent", user_agent.toUtf8().constData(),
                 nullptr);
  }
}
static void
_free_pending_children_props (PendingChildProperties * pend)
{
  g_free (pend->track_id);
  if (pend->structure)
    gst_structure_free (pend->structure);
}
void
PointerDetectorFilter::removeWindow (std::string id)
{
  GstStructure *buttonsLayout;
  gint len;

  /* The function obtains the actual window list */
  g_object_get (G_OBJECT (pointerDetector), WINDOWS_LAYOUT, &buttonsLayout, NULL);
  len = gst_structure_n_fields (buttonsLayout);

  if (len == 0) {
    GST_WARNING ("There are no windows in the layout");
    return;
  }

  for (int i = 0; i < len; i++) {
    const gchar *name;
    name = gst_structure_nth_field_name (buttonsLayout, i);

    if ( g_strcmp0 (name, id.c_str() ) == 0) {
      /* this window will be removed */
      gst_structure_remove_field (buttonsLayout, name);
    }
  }

  /* Set the buttons layout list without the window with id = id */
  g_object_set (G_OBJECT (pointerDetector), WINDOWS_LAYOUT, buttonsLayout, NULL);

  gst_structure_free (buttonsLayout);
}
Example #13
0
static GstCaps *
gst_gl_filter_transform_caps (GstBaseTransform * bt,
    GstPadDirection direction, GstCaps * caps)
{
  //GstGLFilter* filter = GST_GL_FILTER (bt);
  GstStructure *structure = gst_caps_get_structure (caps, 0);
  GstCaps *ret = gst_caps_copy (caps);
  const GValue *par = NULL;

  structure = gst_structure_copy (gst_caps_get_structure (ret, 0));

  gst_structure_set (structure,
      "width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
      "height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);

  gst_caps_merge_structure (ret, gst_structure_copy (structure));

  if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
    gst_structure_set (structure,
        "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);
    gst_caps_merge_structure (ret, structure);
  } else
    gst_structure_free (structure);

  GST_DEBUG_OBJECT (bt, "returning caps: %" GST_PTR_FORMAT, ret);

  return ret;
}
Example #14
0
static void
gst_element_factory_cleanup (GstElementFactory * factory)
{
  GList *item;

  if (factory->metadata) {
    gst_structure_free ((GstStructure *) factory->metadata);
    factory->metadata = NULL;
  }
  if (factory->type) {
    factory->type = G_TYPE_INVALID;
  }

  for (item = factory->staticpadtemplates; item; item = item->next) {
    GstStaticPadTemplate *templ = item->data;

    gst_static_caps_cleanup (&templ->static_caps);
    g_slice_free (GstStaticPadTemplate, templ);
  }
  g_list_free (factory->staticpadtemplates);
  factory->staticpadtemplates = NULL;
  factory->numpadtemplates = 0;
  factory->uri_type = GST_URI_UNKNOWN;
  if (factory->uri_protocols) {
    g_strfreev (factory->uri_protocols);
    factory->uri_protocols = NULL;
  }

  g_list_free (factory->interfaces);
  factory->interfaces = NULL;
}
Example #15
0
static void
kms_alpha_blending_set_property (GObject * object, guint property_id,
    const GValue * value, GParamSpec * pspec)
{
  KmsAlphaBlending *self = KMS_ALPHA_BLENDING (object);

  KMS_ALPHA_BLENDING_LOCK (self);

  switch (property_id) {
    case PROP_SET_MASTER:
    {
      GstStructure *master;

      master = g_value_dup_boxed (value);
      gst_structure_get (master, "port", G_TYPE_INT,
          &self->priv->master_port, NULL);
      gst_structure_get (master, "z_order", G_TYPE_INT,
          &self->priv->z_master, NULL);

      kms_alpha_blending_set_master_port (self);
      gst_structure_free (master);
      break;
    }
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
  }

  KMS_ALPHA_BLENDING_UNLOCK (self);
}
Example #16
0
static void
dvb_base_bin_pmt_info_cb (DvbBaseBin * dvbbasebin, GstStructure * pmt)
{
  DvbBaseBinProgram *program;
  guint program_number;

  gst_structure_get_uint (pmt, "program-number", &program_number);

  program = dvb_base_bin_get_program (dvbbasebin, program_number);
  if (program == NULL) {
    GST_WARNING ("got PMT for program %d but program not in PAT",
        program_number);
    program = dvb_base_bin_add_program (dvbbasebin, program_number);
  }

  program->old_pmt = program->pmt;
  program->pmt = gst_structure_copy (pmt);

  /* activate the program if it's selected and either it's not active or its pmt
   * changed */
  if (program->selected && (!program->active || program->old_pmt != NULL))
    dvb_base_bin_activate_program (dvbbasebin, program);

  if (program->old_pmt) {
    gst_structure_free (program->old_pmt);
    program->old_pmt = NULL;
  }
}
/**
 * ensure_sinkpad_buffer_pool:
 * @plugin: a #GstVaapiPluginBase
 * @caps: the initial #GstCaps for the resulting buffer pool
 *
 * Makes sure the sink pad video buffer pool is created with the
 * appropriate @caps.
 *
 * Returns: %TRUE if successful, %FALSE otherwise.
 */
static gboolean
ensure_sinkpad_buffer_pool (GstVaapiPluginBase * plugin, GstCaps * caps)
{
  GstBufferPool *pool;
  GstCaps *pool_caps;
  GstStructure *config;
  GstVideoInfo vi;
  gboolean need_pool;

  if (!gst_vaapi_plugin_base_ensure_display (plugin))
    return FALSE;

  if (plugin->sinkpad_buffer_pool) {
    config = gst_buffer_pool_get_config (plugin->sinkpad_buffer_pool);
    gst_buffer_pool_config_get_params (config, &pool_caps, NULL, NULL, NULL);
    need_pool = !gst_caps_is_equal (caps, pool_caps);
    gst_structure_free (config);
    if (!need_pool)
      return TRUE;
    g_clear_object (&plugin->sinkpad_buffer_pool);
    plugin->sinkpad_buffer_size = 0;
  }

  pool = gst_vaapi_video_buffer_pool_new (plugin->display);
  if (!pool)
    goto error_create_pool;

  gst_video_info_init (&vi);
  gst_video_info_from_caps (&vi, caps);
  if (GST_VIDEO_INFO_FORMAT (&vi) == GST_VIDEO_FORMAT_ENCODED) {
    GST_DEBUG ("assume video buffer pool format is NV12");
    gst_video_info_set_format (&vi, GST_VIDEO_FORMAT_NV12,
        GST_VIDEO_INFO_WIDTH (&vi), GST_VIDEO_INFO_HEIGHT (&vi));
  }
  plugin->sinkpad_buffer_size = vi.size;

  config = gst_buffer_pool_get_config (pool);
  gst_buffer_pool_config_set_params (config, caps,
      plugin->sinkpad_buffer_size, 0, 0);
  gst_buffer_pool_config_add_option (config,
      GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META);
  gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
  if (!gst_buffer_pool_set_config (pool, config))
    goto error_pool_config;
  plugin->sinkpad_buffer_pool = pool;
  return TRUE;

  /* ERRORS */
error_create_pool:
  {
    GST_ERROR ("failed to create buffer pool");
    return FALSE;
  }
error_pool_config:
  {
    GST_ERROR ("failed to reset buffer pool config");
    gst_object_unref (pool);
    return FALSE;
  }
}
Example #18
0
static void
gst_pulsesrc_set_property (GObject * object,
    guint prop_id, const GValue * value, GParamSpec * pspec)
{

  GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (object);

  switch (prop_id) {
    case PROP_SERVER:
      g_free (pulsesrc->server);
      pulsesrc->server = g_value_dup_string (value);
      if (pulsesrc->probe)
        gst_pulseprobe_set_server (pulsesrc->probe, pulsesrc->server);
      break;
    case PROP_DEVICE:
      g_free (pulsesrc->device);
      pulsesrc->device = g_value_dup_string (value);
      break;
    case PROP_STREAM_PROPERTIES:
      if (pulsesrc->properties)
        gst_structure_free (pulsesrc->properties);
      pulsesrc->properties =
          gst_structure_copy (gst_value_get_structure (value));
      if (pulsesrc->proplist)
        pa_proplist_free (pulsesrc->proplist);
      pulsesrc->proplist = gst_pulse_make_proplist (pulsesrc->properties);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
Example #19
0
static void
gst_pulsesrc_finalize (GObject * object)
{
  GstPulseSrc *pulsesrc = GST_PULSESRC_CAST (object);

  g_free (pulsesrc->server);
  g_free (pulsesrc->device);

  if (pulsesrc->properties)
    gst_structure_free (pulsesrc->properties);
  if (pulsesrc->proplist)
    pa_proplist_free (pulsesrc->proplist);

  if (pulsesrc->mixer) {
    gst_pulsemixer_ctrl_free (pulsesrc->mixer);
    pulsesrc->mixer = NULL;
  }

  if (pulsesrc->probe) {
    gst_pulseprobe_free (pulsesrc->probe);
    pulsesrc->probe = NULL;
  }

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
Example #20
0
static gboolean
gst_analyzer_sink_propose_allocation (GstBaseSink * base_sink, GstQuery * query)
{
  GstStructure *param;
  const gchar *mime_type = NULL;
  GstAnalyzerSink *analyzersink = GST_ANALYZER_SINK (base_sink);
  CodecInfo *info = analyzersink->codec_info;

  if (!info) {
    mime_type = get_mime_type (analyzersink);
    if (!mime_type) {
      GST_ERROR_OBJECT (analyzersink, "Failed to identify the mime type");
      return FALSE;
    }

    info = gst_codec_info_new_from_mime_type (mime_type);
    if (!info) {
      GST_ERROR_OBJECT (analyzersink, "Failed to create the CodecInfo");
      return FALSE;
    }

    g_free ((gchar *) mime_type);
    analyzersink->codec_info = info;
  }

  param =
      gst_structure_new (info->query_param_name, "need-slice-header",
      G_TYPE_BOOLEAN, TRUE, NULL);
  gst_query_add_allocation_meta (query, info->get_codec_meta_api_type (),
      param);
  gst_structure_free (param);

  return TRUE;
}
void
ges_base_xml_formatter_set_timeline_properties (GESBaseXmlFormatter * self,
    GESTimeline * timeline, const gchar * properties, const gchar * metadatas)
{
  GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self);
  gboolean auto_transition = FALSE;

  if (properties) {
    GstStructure *props = gst_structure_from_string (properties, NULL);

    if (props) {
      if (gst_structure_get_boolean (props, "auto-transition",
              &auto_transition))
        gst_structure_remove_field (props, "auto-transition");

      gst_structure_foreach (props,
          (GstStructureForeachFunc) set_property_foreach, timeline);
      gst_structure_free (props);
    }
  }

  if (metadatas) {
    ges_meta_container_add_metas_from_string (GES_META_CONTAINER (timeline),
        metadatas);
  };

  priv->timeline_auto_transition = auto_transition;
}
Example #22
0
static GstStructure *
make_player_clients_list_msg (SnraManager * manager)
{
  GstStructure *msg;
  GValue p = { 0, };
  GList *cur;

  g_value_init (&p, GST_TYPE_ARRAY);

  msg = gst_structure_new ("json",
      "msg-type", G_TYPE_STRING, "player-clients", NULL);

  for (cur = manager->player_info; cur != NULL; cur = g_list_next (cur)) {
    SnraPlayerInfo *info = (SnraPlayerInfo *) (cur->data);
    if (info->conn != NULL) {
      GValue tmp = { 0, };
      GstStructure *cur_struct = gst_structure_new ("client",
          "client-id", G_TYPE_INT64, (gint64) info->id,
          "enabled", G_TYPE_BOOLEAN, info->enabled,
          "volume", G_TYPE_DOUBLE, info->volume,
          "host", G_TYPE_STRING, info->host,
          NULL);

      g_value_init (&tmp, GST_TYPE_STRUCTURE);
      gst_value_set_structure (&tmp, cur_struct);
      gst_value_array_append_value (&p, &tmp);
      g_value_unset (&tmp);
      gst_structure_free (cur_struct);
    }
  }
  gst_structure_take_value (msg, "player-clients", &p);

  return msg;
}
static void
kms_crowd_detector_release_data (KmsCrowdDetector * crowddetector)
{
  int it;

  if (crowddetector->priv->curves != NULL) {
    for (it = 0; it < crowddetector->priv->num_rois; it++) {
      g_free (crowddetector->priv->curves[it]);
    }
    g_free (crowddetector->priv->curves);
    crowddetector->priv->curves = NULL;
  }

  if (crowddetector->priv->rois != NULL) {
    gst_structure_free (crowddetector->priv->rois);
    crowddetector->priv->rois = NULL;
  }

  if (crowddetector->priv->n_points != NULL) {
    g_free (crowddetector->priv->n_points);
    crowddetector->priv->n_points = NULL;
  }

  if (crowddetector->priv->rois_data != NULL) {
    for (it = 0; it < crowddetector->priv->num_rois; it++) {
      g_free (crowddetector->priv->rois_data[it].name);
    }
    g_free (crowddetector->priv->rois_data);
    crowddetector->priv->rois_data = NULL;
  }
}
void ImageOverlayFilterImpl::removeImage (const std::string &id)
{
  GstStructure *imagesLayout;
  gint len;

  /* The function obtains the actual window list */
  g_object_get (G_OBJECT (imageOverlay), IMAGES_TO_OVERLAY, &imagesLayout,
                NULL);
  len = gst_structure_n_fields (imagesLayout);

  if (len == 0) {
    GST_WARNING ("There are no images in the layout");
    return;
  }

  for (int i = 0; i < len; i++) {
    const gchar *name;
    name = gst_structure_nth_field_name (imagesLayout, i);

    if (strcmp (id.c_str (), name) == 0) {
      /* this image will be removed */
      gst_structure_remove_field (imagesLayout, name);
      break;
    }
  }

  /* Set the buttons layout list without the window with id = id */
  g_object_set (G_OBJECT (imageOverlay), IMAGES_TO_OVERLAY, imagesLayout, NULL);

  gst_structure_free (imagesLayout);
}
static GstStructure *
kms_recorder_endpoint_stats (KmsElement * obj, gchar * selector)
{
  KmsRecorderEndpoint *self = KMS_RECORDER_ENDPOINT (obj);
  GstStructure *stats, *e_stats, *l_stats;

  /* chain up */
  stats =
      KMS_ELEMENT_CLASS (kms_recorder_endpoint_parent_class)->stats (obj,
      selector);

  if (!self->priv->stats.enabled) {
    return stats;
  }

  e_stats = kms_stats_get_element_stats (stats);

  if (e_stats == NULL) {
    return stats;
  }

  l_stats = kms_element_get_e2e_latency_stats (self, selector);

  /* Add end to end latency */
  gst_structure_set (e_stats, "e2e-latencies", GST_TYPE_STRUCTURE, l_stats,
      NULL);
  gst_structure_free (l_stats);

  GST_DEBUG_OBJECT (self, "Stats: %" GST_PTR_FORMAT, stats);

  return stats;
}
Example #26
0
static void
kms_image_overlay_set_property (GObject * object, guint property_id,
    const GValue * value, GParamSpec * pspec)
{
  KmsImageOverlay *imageoverlay = KMS_IMAGE_OVERLAY (object);

  GST_OBJECT_LOCK (imageoverlay);

  switch (property_id) {
    case PROP_SHOW_DEBUG_INFO:
      imageoverlay->priv->show_debug_info = g_value_get_boolean (value);
      break;
    case PROP_IMAGE_TO_OVERLAY:
      if (imageoverlay->priv->image_to_overlay != NULL)
        gst_structure_free (imageoverlay->priv->image_to_overlay);

      imageoverlay->priv->image_to_overlay = g_value_dup_boxed (value);
      kms_image_overlay_load_image_to_overlay (imageoverlay);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
  }
  GST_OBJECT_UNLOCK (imageoverlay);
}
Example #27
0
static GstStructure *
kms_element_stats_impl (KmsElement * self, gchar * selector)
{
  GstStructure *stats;

  stats = gst_structure_new_empty ("stats");

  if (self->priv->stats_enabled) {
    GstStructure *e_stats;

    /* Video and audio latencies are measured in nano seconds. They */
    /* are such an small values so there is no harm in casting them */
    /* to uint64 even we might lose a bit of preccision.            */

    e_stats = gst_structure_new (KMS_ELEMENT_STATS_STRUCT_NAME,
        "input-video-latency", G_TYPE_UINT64, (guint64) self->priv->stats.vi,
        "input-audio-latency", G_TYPE_UINT64, (guint64) self->priv->stats.ai,
        NULL);

    gst_structure_set (stats, KMS_MEDIA_ELEMENT_FIELD, GST_TYPE_STRUCTURE,
        e_stats, NULL);

    gst_structure_free (e_stats);
  }

  return stats;
}
Example #28
0
static GSList *
get_faces (GstStructure * faces)
{
  gint len, aux;
  GSList *list = NULL;

  len = gst_structure_n_fields (faces);

  for (aux = 0; aux < len; aux++) {
    GstStructure *face;
    gboolean ret;

    const gchar *name = gst_structure_nth_field_name (faces, aux);

    if (g_strcmp0 (name, "timestamp") == 0) {
      continue;
    }

    ret = gst_structure_get (faces, name, GST_TYPE_STRUCTURE, &face, NULL);

    if (ret) {
      CvRect *aux = g_slice_new0 (CvRect);

      gst_structure_get (face, "x", G_TYPE_UINT, &aux->x, NULL);
      gst_structure_get (face, "y", G_TYPE_UINT, &aux->y, NULL);
      gst_structure_get (face, "width", G_TYPE_UINT, &aux->width, NULL);
      gst_structure_get (face, "height", G_TYPE_UINT, &aux->height, NULL);
      gst_structure_free (face);
      list = g_slist_append (list, aux);
    }
  }
  return list;
}
Example #29
0
static void
kms_alpha_blending_get_property (GObject * object, guint property_id,
    GValue * value, GParamSpec * pspec)
{
  KmsAlphaBlending *self = KMS_ALPHA_BLENDING (object);

  KMS_ALPHA_BLENDING_LOCK (self);

  switch (property_id) {
    case PROP_SET_MASTER:
    {
      GstStructure *data;

      data = gst_structure_new ("data",
          "master", G_TYPE_INT, self->priv->master_port,
          "z_order", G_TYPE_INT, self->priv->z_master, NULL);
      g_value_set_boxed (value, data);
      gst_structure_free (data);
      break;
    }
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
  }

  KMS_ALPHA_BLENDING_UNLOCK (self);
}
void
RecorderEndpointImpl::collectEndpointStats (std::map
    <std::string, std::shared_ptr<Stats>>
    &statsReport, std::string id, const GstStructure *stats,
    double timestamp)
{
  std::shared_ptr<Stats> endpointStats;
  GstStructure *e2e_stats;

  std::vector<std::shared_ptr<MediaLatencyStat>> inputStats;
  std::vector<std::shared_ptr<MediaLatencyStat>> e2eStats;

  if (gst_structure_get (stats, "e2e-latencies", GST_TYPE_STRUCTURE,
                         &e2e_stats, NULL) ) {
    collectLatencyStats (e2eStats, e2e_stats);
    gst_structure_free (e2e_stats);
  }

  endpointStats = std::make_shared <EndpointStats> (id,
                  std::make_shared <StatsType> (StatsType::endpoint), timestamp,
                  0.0, 0.0, inputStats, 0.0, 0.0, e2eStats);

  setDeprecatedProperties (std::dynamic_pointer_cast <EndpointStats>
                           (endpointStats) );

  statsReport[id] = endpointStats;
}