Exemplo n.º 1
0
static GstStateChangeReturn
dxr3spusink_change_state (GstElement * element, GstStateChange transition)
{
  g_return_val_if_fail (GST_IS_DXR3SPUSINK (element), GST_STATE_CHANGE_FAILURE);

  switch (transition) {
    case GST_STATE_CHANGE_NULL_TO_READY:
      if (!GST_OBJECT_FLAG_IS_SET (element, DXR3SPUSINK_OPEN)) {
        if (!dxr3spusink_open (DXR3SPUSINK (element))) {
          return GST_STATE_CHANGE_FAILURE;
        }
      }
      break;
    case GST_STATE_CHANGE_READY_TO_PAUSED:
      break;
    case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
      break;
    case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
      break;
    case GST_STATE_CHANGE_PAUSED_TO_READY:
      break;
    case GST_STATE_CHANGE_READY_TO_NULL:
      if (GST_OBJECT_FLAG_IS_SET (element, DXR3SPUSINK_OPEN)) {
        dxr3spusink_close (DXR3SPUSINK (element));
      }
      break;
  }

  if (GST_ELEMENT_CLASS (parent_class)->change_state) {
    return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
  }

  return GST_STATE_CHANGE_SUCCESS;
}
Exemplo n.º 2
0
static void
print_clocking_info (GstElement * element)
{
  gboolean requires_clock, provides_clock;

  requires_clock =
      GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_REQUIRE_CLOCK);
  provides_clock =
      GST_OBJECT_FLAG_IS_SET (element, GST_ELEMENT_FLAG_PROVIDE_CLOCK);

  if (!requires_clock && !provides_clock) {
    n_print ("\n");
    n_print ("Element has no clocking capabilities.\n");
    return;
  }

  n_print ("\n");
  n_print ("Clocking Interaction:\n");
  if (requires_clock) {
    n_print ("  element requires a clock\n");
  }

  if (provides_clock) {
    GstClock *clock;

    clock = gst_element_get_clock (element);
    if (clock) {
      n_print ("  element provides a clock: %s\n", GST_OBJECT_NAME (clock));
      gst_object_unref (clock);
    } else
      n_print ("  element is supposed to provide a clock but returned NULL\n");
  }
}
static void
debug_dump_pad (GstPad * pad, const gchar * color_name,
    const gchar * element_name, GstDebugGraphDetails details, FILE * out,
    const gint indent)
{
  GstPadTemplate *pad_templ;
  GstPadPresence presence;
  gchar *pad_name;
  const gchar *style_name;
  const gchar *spc = &spaces[MAX (sizeof (spaces) - (1 + indent * 2), 0)];

  pad_name = debug_dump_make_object_name (GST_OBJECT (pad));

  /* pad availability */
  style_name = "filled,solid";
  if ((pad_templ = gst_pad_get_pad_template (pad))) {
    presence = GST_PAD_TEMPLATE_PRESENCE (pad_templ);
    if (presence == GST_PAD_SOMETIMES) {
      style_name = "filled,dotted";
    } else if (presence == GST_PAD_REQUEST) {
      style_name = "filled,dashed";
    }
  }
  if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
    gchar pad_flags[4];
    const gchar *activation_mode = "-><";

    /* check if pad flags */
    pad_flags[0] =
        GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED) ? 'B' : 'b';
    pad_flags[1] =
        GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING) ? 'F' : 'f';
    pad_flags[2] =
        GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING) ? 'B' : 'b';
    pad_flags[3] = '\0';

    fprintf (out,
        "%s  %s_%s [color=black, fillcolor=\"%s\", label=\"%s\\n[%c][%s]\", height=\"0.2\", style=\"%s\"];\n",
        spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
        activation_mode[pad->mode], pad_flags, style_name);
  } else {
    fprintf (out,
        "%s  %s_%s [color=black, fillcolor=\"%s\", label=\"%s\", height=\"0.2\", style=\"%s\"];\n",
        spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
        style_name);
  }

  g_free (pad_name);
}
Exemplo n.º 4
0
/**
 * gst_clock_wait_for_sync:
 * @clock: a GstClock
 * @timeout: timeout for waiting or %GST_CLOCK_TIME_NONE
 *
 * Waits until @clock is synced for reporting the current time. If @timeout
 * is %GST_CLOCK_TIME_NONE it will wait forever, otherwise it will time out
 * after @timeout nanoseconds.
 *
 * For asynchronous waiting, the GstClock::synced signal can be used.
 *
 *
 * This returns immediately with TRUE if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC
 * is not set on the clock, or if the clock is already synced.
 *
 * Returns: %TRUE if waiting was successful, or %FALSE on timeout
 *
 * Since: 1.6
 */
gboolean
gst_clock_wait_for_sync (GstClock * clock, GstClockTime timeout)
{
  gboolean timed_out = FALSE;

  g_return_val_if_fail (GST_IS_CLOCK (clock), FALSE);

  GST_OBJECT_LOCK (clock);
  if (!GST_OBJECT_FLAG_IS_SET (clock, GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC)
      || clock->priv->synced) {
    GST_OBJECT_UNLOCK (clock);
    return TRUE;
  }

  if (timeout != GST_CLOCK_TIME_NONE) {
    gint64 end_time = g_get_monotonic_time () + gst_util_uint64_scale (timeout,
        G_TIME_SPAN_SECOND, GST_SECOND);

    while (!clock->priv->synced && !timed_out) {
      timed_out =
          !g_cond_wait_until (&clock->priv->sync_cond,
          GST_OBJECT_GET_LOCK (clock), end_time);
    }
  } else {
    timed_out = FALSE;
    while (!clock->priv->synced) {
      g_cond_wait (&clock->priv->sync_cond, GST_OBJECT_GET_LOCK (clock));
    }
  }
  GST_OBJECT_UNLOCK (clock);

  return !timed_out;
}
Exemplo n.º 5
0
static GstElement *
gst_switch_select (GstSwitch * swit,
    GstPadTemplate * templ, const gchar * name, const GstCaps * caps)
{
  GList *item = GST_BIN_CHILDREN (GST_BIN (swit));
  GstElement *swcase = NULL;

  for (; item; item = g_list_next (item)) {
    GList *paditem = GST_ELEMENT_PADS (GST_ELEMENT (item->data));
    GstPad *basepad = NULL, *pad = NULL;
    for (; paditem; paditem = g_list_next (paditem)) {
      pad = GST_PAD (paditem->data);
      if (GST_PAD_IS_SINK (pad) && !gst_pad_is_linked (pad) &&
          !GST_OBJECT_FLAG_IS_SET (GST_OBJECT (pad),
              GST_SWITCH_PAD_FLAG_GHOSTED)) {
        basepad = pad;
        break;
      }
    }

    if (basepad) {
      swcase = GST_ELEMENT (item->data);
      break;
    }
  }

  if (!swcase) {
    swcase = gst_switch_request_new_case (swit, templ, caps);
  }

  return swcase;
}
Exemplo n.º 6
0
static gboolean
dxr3videosink_open (Dxr3VideoSink * sink)
{
  g_return_val_if_fail (!GST_OBJECT_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN),
      FALSE);

  /* Compute the name of the video device file. */
  sink->video_filename = g_strdup_printf ("/dev/em8300_mv-%d",
      sink->card_number);

  sink->video_fd = open (sink->video_filename, O_WRONLY);
  if (sink->video_fd < 0) {
    GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
        (_("Could not open video device \"%s\" for writing."),
            sink->video_filename), GST_ERROR_SYSTEM);
    return FALSE;
  }

  /* Open the control device. */
  sink->control_filename = g_strdup_printf ("/dev/em8300-%d",
      sink->card_number);

  sink->control_fd = open (sink->control_filename, O_WRONLY);
  if (sink->control_fd < 0) {
    GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
        (_("Could not open control device \"%s\" for writing."),
            sink->control_filename), GST_ERROR_SYSTEM);
    return FALSE;
  }

  GST_OBJECT_FLAG_SET (sink, DXR3VIDEOSINK_OPEN);

  return TRUE;
}
Exemplo n.º 7
0
static GstClock *
gst_pipeline_provide_clock_func (GstElement * element)
{
  GstClock *clock = NULL;
  GstPipeline *pipeline = GST_PIPELINE (element);

  /* if we have a fixed clock, use that one */
  GST_OBJECT_LOCK (pipeline);
  if (GST_OBJECT_FLAG_IS_SET (pipeline, GST_PIPELINE_FLAG_FIXED_CLOCK)) {
    clock = pipeline->fixed_clock;
    if (clock)
      gst_object_ref (clock);
    GST_OBJECT_UNLOCK (pipeline);

    GST_CAT_DEBUG (GST_CAT_CLOCK, "pipeline using fixed clock %p (%s)",
        clock, clock ? GST_STR_NULL (GST_OBJECT_NAME (clock)) : "-");
  } else {
    GST_OBJECT_UNLOCK (pipeline);
    /* let the parent bin select a clock */
    clock =
        GST_ELEMENT_CLASS (parent_class)->provide_clock (GST_ELEMENT
        (pipeline));
    /* no clock, use a system clock */
    if (!clock) {
      clock = gst_system_clock_obtain ();

      GST_CAT_DEBUG (GST_CAT_CLOCK, "pipeline obtained system clock: %p (%s)",
          clock, clock ? GST_STR_NULL (GST_OBJECT_NAME (clock)) : "-");
    } else {
      GST_CAT_DEBUG (GST_CAT_CLOCK, "pipeline obtained clock: %p (%s)",
          clock, clock ? GST_STR_NULL (GST_OBJECT_NAME (clock)) : "-");
    }
  }
  return clock;
}
Exemplo n.º 8
0
static GstMemory *
_fallback_mem_copy (GstMemory * mem, gssize offset, gssize size)
{
  GstMemory *copy;
  GstMapInfo sinfo, dinfo;
  GstAllocationParams params = { 0, mem->align, 0, 0, };
  GstAllocator *allocator;

  if (!gst_memory_map (mem, &sinfo, GST_MAP_READ))
    return NULL;

  if (size == -1)
    size = sinfo.size > offset ? sinfo.size - offset : 0;

  /* use the same allocator as the memory we copy  */
  allocator = mem->allocator;
  if (GST_OBJECT_FLAG_IS_SET (allocator, GST_ALLOCATOR_FLAG_CUSTOM_ALLOC))
    allocator = NULL;
  copy = gst_allocator_alloc (allocator, size, &params);

  if (!gst_memory_map (copy, &dinfo, GST_MAP_WRITE)) {
    GST_CAT_WARNING (GST_CAT_MEMORY, "could not write map memory %p", copy);
    gst_allocator_free (mem->allocator, copy);
    gst_memory_unmap (mem, &sinfo);
    return NULL;
  }

  GST_CAT_DEBUG (GST_CAT_PERFORMANCE,
      "memcpy %" G_GSSIZE_FORMAT " memory %p -> %p", size, mem, copy);
  memcpy (dinfo.data, sinfo.data + offset, size);
  gst_memory_unmap (copy, &dinfo);
  gst_memory_unmap (mem, &sinfo);

  return copy;
}
static void
gst_multi_file_src_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstMultiFileSrc *src = GST_MULTI_FILE_SRC (object);

  switch (prop_id) {
    case PROP_LOCATION:
      gst_multi_file_src_set_location (src, g_value_get_string (value));
      break;
    case PROP_INDEX:
      GST_OBJECT_LOCK (src);
      /* index was really meant to be read-only, but for backwards-compatibility
       * we set start_index to make it work as it used to */
      if (!GST_OBJECT_FLAG_IS_SET (src, GST_BASE_SRC_FLAG_STARTED))
        src->start_index = g_value_get_int (value);
      else
        src->index = g_value_get_int (value);
      GST_OBJECT_UNLOCK (src);
      break;
    case PROP_START_INDEX:
      src->start_index = g_value_get_int (value);
      break;
    case PROP_STOP_INDEX:
      src->stop_index = g_value_get_int (value);
      break;
    case PROP_CAPS:
    {
      GstStructure *st = NULL;
      const GstCaps *caps = gst_value_get_caps (value);
      GstCaps *new_caps;

      if (caps == NULL) {
        new_caps = gst_caps_new_any ();
      } else {
        new_caps = gst_caps_copy (caps);
      }
      gst_caps_replace (&src->caps, new_caps);
      gst_pad_set_caps (GST_BASE_SRC_PAD (src), new_caps);

      if (new_caps && gst_caps_get_size (new_caps) == 1 &&
          (st = gst_caps_get_structure (new_caps, 0))
          && gst_structure_get_fraction (st, "framerate", &src->fps_n,
              &src->fps_d)) {
        GST_INFO_OBJECT (src, "Seting framerate to %d/%d", src->fps_n,
            src->fps_d);
      } else {
        src->fps_n = -1;
        src->fps_d = -1;
      }
    }
      break;
    case PROP_LOOP:
      src->loop = g_value_get_boolean (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
static void
dxr3audiosink_close (Dxr3AudioSink * sink)
{
  g_return_if_fail (GST_OBJECT_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN));

  if (close (sink->audio_fd) != 0) {
    GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
        (_("Could not close audio device \"%s\"."), sink->audio_filename),
        GST_ERROR_SYSTEM);
    return;
  }

  if (close (sink->control_fd) != 0) {
    GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
        (_("Could not close control device \"%s\"."), sink->audio_filename),
        GST_ERROR_SYSTEM);
    return;
  }

  GST_OBJECT_FLAG_UNSET (sink, DXR3AUDIOSINK_OPEN);

  g_free (sink->audio_filename);
  sink->audio_filename = NULL;

  g_free (sink->control_filename);
  sink->control_filename = NULL;

  /* Get rid of the padder, if any. */
  if (sink->padder != NULL) {
    g_free (sink->padder);
    sink->padder = NULL;
  }
}
Exemplo n.º 11
0
/**
 * gst_clock_get_internal_time:
 * @clock: a #GstClock to query
 *
 * Gets the current internal time of the given clock. The time is returned
 * unadjusted for the offset and the rate.
 *
 * Returns: the internal time of the clock. Or GST_CLOCK_TIME_NONE when
 * given invalid input.
 *
 * MT safe.
 */
GstClockTime
gst_clock_get_internal_time (GstClock * clock)
{
  GstClockTime ret;
  GstClockClass *cclass;

  g_return_val_if_fail (GST_IS_CLOCK (clock), GST_CLOCK_TIME_NONE);

  if (G_UNLIKELY (GST_OBJECT_FLAG_IS_SET (clock,
              GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC) && !clock->priv->synced))
    GST_CAT_WARNING_OBJECT (GST_CAT_CLOCK, clock,
        "clocked is not synchronized yet");

  cclass = GST_CLOCK_GET_CLASS (clock);

  if (G_UNLIKELY (cclass->get_internal_time == NULL))
    goto not_supported;

  ret = cclass->get_internal_time (clock);

  GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock, "internal time %" GST_TIME_FORMAT,
      GST_TIME_ARGS (ret));

  return ret;

  /* ERRORS */
not_supported:
  {
    GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock,
        "internal time not supported, return 0");
    return G_GINT64_CONSTANT (0);
  }
}
Exemplo n.º 12
0
/**
 * gst_clock_is_synced:
 * @clock: a GstClock
 *
 * Checks if the clock is currently synced.
 *
 * This returns if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC is not set on the clock.
 *
 * Returns: %TRUE if the clock is currently synced
 *
 * Since: 1.6
 */
gboolean
gst_clock_is_synced (GstClock * clock)
{
  g_return_val_if_fail (GST_IS_CLOCK (clock), TRUE);

  return !GST_OBJECT_FLAG_IS_SET (clock, GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC)
      || clock->priv->synced;
}
Exemplo n.º 13
0
static void
send_flush_on_unlink (GstPad * pad, GstPad * peer, gpointer user_data)
{
  if (GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_EOS)) {
    gst_pad_send_event (pad, gst_event_new_flush_start ());
    gst_pad_send_event (pad, gst_event_new_flush_stop (FALSE));
  }
}
Exemplo n.º 14
0
static GstElement *
get_sink_element (GstBin * bin)
{
  GstElement *e;
  GList *node;

  GST_INFO_OBJECT (bin, "looking for audio_sink");
  for (node = GST_BIN_CHILDREN (bin); node; node = g_list_next (node)) {
    e = (GstElement *) node->data;
    if (GST_IS_BIN (e) && GST_OBJECT_FLAG_IS_SET (e, GST_ELEMENT_FLAG_SINK)) {
      return get_sink_element ((GstBin *) e);
    }
    if (GST_OBJECT_FLAG_IS_SET (e, GST_ELEMENT_FLAG_SINK)) {
      return e;
    }
  }
  return NULL;
}
Exemplo n.º 15
0
/**
 * gst_clock_set_master:
 * @clock: a #GstClock 
 * @master: (allow-none): a master #GstClock 
 *
 * Set @master as the master clock for @clock. @clock will be automatically
 * calibrated so that gst_clock_get_time() reports the same time as the
 * master clock.  
 * 
 * A clock provider that slaves its clock to a master can get the current
 * calibration values with gst_clock_get_calibration().
 *
 * @master can be %NULL in which case @clock will not be slaved anymore. It will
 * however keep reporting its time adjusted with the last configured rate 
 * and time offsets.
 *
 * Returns: %TRUE if the clock is capable of being slaved to a master clock. 
 * Trying to set a master on a clock without the 
 * #GST_CLOCK_FLAG_CAN_SET_MASTER flag will make this function return %FALSE.
 *
 * MT safe.
 */
gboolean
gst_clock_set_master (GstClock * clock, GstClock * master)
{
  GstClock **master_p;
  GstClockPrivate *priv;

  g_return_val_if_fail (GST_IS_CLOCK (clock), FALSE);
  g_return_val_if_fail (master != clock, FALSE);

  GST_OBJECT_LOCK (clock);
  /* we always allow setting the master to NULL */
  if (master && !GST_OBJECT_FLAG_IS_SET (clock, GST_CLOCK_FLAG_CAN_SET_MASTER))
    goto not_supported;
  GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock,
      "slaving %p to master clock %p", clock, master);
  GST_OBJECT_UNLOCK (clock);

  priv = clock->priv;

  GST_CLOCK_SLAVE_LOCK (clock);
  if (priv->clockid) {
    gst_clock_id_unschedule (priv->clockid);
    gst_clock_id_unref (priv->clockid);
    priv->clockid = NULL;
  }
  if (master) {
    priv->filling = TRUE;
    priv->time_index = 0;
    /* use the master periodic id to schedule sampling and
     * clock calibration. */
    priv->clockid = gst_clock_new_periodic_id (master,
        gst_clock_get_time (master), priv->timeout);
    gst_clock_id_wait_async (priv->clockid,
        (GstClockCallback) gst_clock_slave_callback,
        gst_object_ref (clock), (GDestroyNotify) gst_object_unref);
  }
  GST_CLOCK_SLAVE_UNLOCK (clock);

  GST_OBJECT_LOCK (clock);
  master_p = &priv->master;
  gst_object_replace ((GstObject **) master_p, (GstObject *) master);
  GST_OBJECT_UNLOCK (clock);

  return TRUE;

  /* ERRORS */
not_supported:
  {
    GST_CAT_DEBUG_OBJECT (GST_CAT_CLOCK, clock,
        "cannot be slaved to a master clock");
    GST_OBJECT_UNLOCK (clock);
    return FALSE;
  }
}
static void
calculate_latency (GstElement * parent, GstPad * pad, guint64 ts)
{
  if (parent && (!GST_IS_BIN (parent)) &&
      GST_OBJECT_FLAG_IS_SET (parent, GST_ELEMENT_FLAG_SINK)) {
    GstEvent *ev = g_object_get_qdata ((GObject *) pad, latency_probe_id);

    log_latency (gst_event_get_structure (ev), pad, ts);
    gst_event_unref (ev);
  }
}
Exemplo n.º 17
0
static GstStateChangeReturn
gst_artsdsink_change_state (GstElement * element, GstStateChange transition)
{
  g_return_val_if_fail (GST_IS_ARTSDSINK (element), FALSE);

  /* if going down into NULL state, close the stream if it's open */
  if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
    if (GST_OBJECT_FLAG_IS_SET (element, GST_ARTSDSINK_OPEN))
      gst_artsdsink_close_audio (GST_ARTSDSINK (element));
    /* otherwise (READY or higher) we need to open the stream */
  } else {
    if (!GST_OBJECT_FLAG_IS_SET (element, GST_ARTSDSINK_OPEN)) {
      if (!gst_artsdsink_open_audio (GST_ARTSDSINK (element)))
        return GST_STATE_CHANGE_FAILURE;
    }
  }

  if (GST_ELEMENT_CLASS (parent_class)->change_state)
    return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
  return GST_STATE_CHANGE_SUCCESS;
}
Exemplo n.º 18
0
/**
 * Process a pad for connecting or disconnecting, it should be always called
 * whint the agnostic lock hold.
 *
 * @self: The #KmsAgnosticBin2 owner of the pad
 * @pad: The pad to be processed
 */
static gboolean
kms_agnostic_bin2_process_pad (KmsAgnosticBin2 * self, GstPad * pad)
{
  GstPad *peer = NULL;

  if (!GST_OBJECT_FLAG_IS_SET (pad, KMS_AGNOSTIC_PAD_STARTED)) {
    return FALSE;
  }

  if (!self->priv->started) {
    return FALSE;
  }

  GST_DEBUG_OBJECT (self, "Processing pad: %" GST_PTR_FORMAT, pad);

  if (pad == NULL) {
    return FALSE;
  }

  peer = gst_pad_get_peer (pad);

  if (peer != NULL) {
    GstPad *target = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));

    if (target) {
      GstCaps *caps = gst_pad_get_current_caps (pad);

      if (caps != NULL) {
        gboolean accepted;

        accepted = gst_pad_query_accept_caps (peer, caps);
        gst_caps_unref (caps);

        if (accepted) {
          GST_DEBUG_OBJECT (self, "No need to reconfigure pad %" GST_PTR_FORMAT,
              pad);
          g_object_unref (target);
          g_object_unref (peer);
          return FALSE;
        }

        remove_target_pad (pad);
      }

      g_object_unref (target);
    }

    kms_agnostic_bin2_link_pad (self, pad, peer);
  }

  return TRUE;
}
Exemplo n.º 19
0
static void
send_latency_probe (GstElement * parent, GstPad * pad, guint64 ts)
{
  if (parent && (!GST_IS_BIN (parent)) &&
      GST_OBJECT_FLAG_IS_SET (parent, GST_ELEMENT_FLAG_SOURCE)) {
    GstEvent *latency_probe = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM,
        gst_structure_new_id (latency_probe_id,
            latency_probe_pad, GST_TYPE_PAD, pad,
            latency_probe_ts, G_TYPE_UINT64, ts,
            NULL));
    gst_pad_push_event (pad, latency_probe);
  }
}
Exemplo n.º 20
0
static void
on_notify_caps (GstPad * pad, GParamSpec * pspec, GstElement * pay)
{
  GstCaps *caps;

  g_object_get (pad, "caps", &caps, NULL);

  GST_DEBUG ("notify %" GST_PTR_FORMAT, caps);

  if (caps) {
    if (!GST_OBJECT_FLAG_IS_SET (pay, FLAG_HAVE_CAPS)) {
      g_signal_emit_by_name (pay, "pad-added", pad);
      g_signal_emit_by_name (pay, "no-more-pads", NULL);
      GST_OBJECT_FLAG_SET (pay, FLAG_HAVE_CAPS);
    }
    gst_caps_unref (caps);
  } else {
    if (GST_OBJECT_FLAG_IS_SET (pay, FLAG_HAVE_CAPS)) {
      g_signal_emit_by_name (pay, "pad-removed", pad);
      GST_OBJECT_FLAG_UNSET (pay, FLAG_HAVE_CAPS);
    }
  }
}
Exemplo n.º 21
0
static GstStateChangeReturn
gst_festival_change_state (GstElement * element, GstStateChange transition)
{
  g_return_val_if_fail (GST_IS_FESTIVAL (element), GST_STATE_CHANGE_FAILURE);

  if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
    if (GST_OBJECT_FLAG_IS_SET (element, GST_FESTIVAL_OPEN)) {
      GST_DEBUG ("Closing connection ");
      gst_festival_close (GST_FESTIVAL (element));
    }
  } else {
    if (!GST_OBJECT_FLAG_IS_SET (element, GST_FESTIVAL_OPEN)) {
      GST_DEBUG ("Opening connection ");
      if (!gst_festival_open (GST_FESTIVAL (element)))
        return GST_STATE_CHANGE_FAILURE;
    }
  }

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

  return GST_STATE_CHANGE_SUCCESS;
}
static GstStateChangeReturn
gst_sctp_base_sink_change_state (GstElement * element,
    GstStateChange transition)
{
  GstSCTPBaseSink *self = GST_SCTP_BASE_SINK (element);
  GstStateChangeReturn ret;

  if (transition == GST_STATE_CHANGE_NULL_TO_READY) {
    GST_SCTP_BASE_SINK_LOCK (self);
    gst_sctp_base_sink_create_socket (self);
    if (!GST_OBJECT_FLAG_IS_SET (self, GST_SCTP_BASE_SINK_OPEN)) {
      GST_SCTP_BASE_SINK_UNLOCK (self);
      return GST_STATE_CHANGE_FAILURE;
    }
    gst_sctp_base_sink_configure_sinks (self);
    GST_SCTP_BASE_SINK_UNLOCK (self);
  }

  /* Let parent class manage the state transition. Parent will initialize  */
  /* children when transitioning from NULL state onward or it will release */
  /* children's resources when transitioning from PLAYING state backwards  */
  ret =
      GST_ELEMENT_CLASS (gst_sctp_base_sink_parent_class)->change_state
      (element, transition);

  if (transition == GST_STATE_CHANGE_READY_TO_NULL) {
    GST_SCTP_BASE_SINK_LOCK (self);
    gst_sctp_base_sink_destroy_socket (self);
    if (GST_OBJECT_FLAG_IS_SET (self, GST_SCTP_BASE_SINK_OPEN)) {
      GST_SCTP_BASE_SINK_UNLOCK (self);
      return GST_STATE_CHANGE_FAILURE;
    }
    GST_SCTP_BASE_SINK_UNLOCK (self);
  }

  return ret;
}
static GstStateChangeReturn
dxr3audiosink_change_state (GstElement * element, GstStateChange transition)
{
  g_return_val_if_fail (GST_IS_DXR3AUDIOSINK (element),
      GST_STATE_CHANGE_FAILURE);

  if (GST_STATE_PENDING (element) == GST_STATE_NULL) {
    if (GST_OBJECT_FLAG_IS_SET (element, DXR3AUDIOSINK_OPEN)) {
      dxr3audiosink_close (DXR3AUDIOSINK (element));
    }
  } else {
    if (!GST_OBJECT_FLAG_IS_SET (element, DXR3AUDIOSINK_OPEN)) {
      if (!dxr3audiosink_open (DXR3AUDIOSINK (element))) {
        return GST_STATE_CHANGE_FAILURE;
      }
    }
  }

  if (GST_ELEMENT_CLASS (parent_class)->change_state) {
    return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
  }

  return GST_STATE_CHANGE_SUCCESS;
}
Exemplo n.º 24
0
/**
 * gst_clock_set_synced:
 * @clock: a GstClock
 * @synced: if the clock is synced
 *
 * Sets @clock to synced and emits the GstClock::synced signal, and wakes up any
 * thread waiting in gst_clock_wait_for_sync().
 *
 * This function must only be called if GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC
 * is set on the clock, and is intended to be called by subclasses only.
 *
 * Since: 1.6
 */
void
gst_clock_set_synced (GstClock * clock, gboolean synced)
{
  g_return_if_fail (GST_IS_CLOCK (clock));
  g_return_if_fail (GST_OBJECT_FLAG_IS_SET (clock,
          GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC));

  GST_OBJECT_LOCK (clock);
  if (clock->priv->synced != ! !synced) {
    clock->priv->synced = ! !synced;
    g_cond_signal (&clock->priv->sync_cond);
    GST_OBJECT_UNLOCK (clock);
    g_signal_emit (clock, gst_clock_signals[SIGNAL_SYNCED], 0, ! !synced);
  } else {
    GST_OBJECT_UNLOCK (clock);
  }
}
Exemplo n.º 25
0
static void
dxr3videosink_write_data (Dxr3VideoSink * sink, guint cut)
{
  guint size, written;
  guint8 *data;

  g_return_if_fail (sink->cur_buf != NULL);

  if (GST_OBJECT_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN)) {
    if (sink->cur_ts != GST_CLOCK_TIME_NONE) {
      guint pts;

/*       fprintf (stderr, "------ Video Time %.04f\n", */
/*                (double) sink->cur_ts / GST_SECOND); */

      pts = (guint) GSTTIME_TO_MPEGTIME (sink->cur_ts);
      ioctl (sink->video_fd, EM8300_IOCTL_VIDEO_SETPTS, &pts);
      sink->cur_ts = GST_CLOCK_TIME_NONE;
    }

    data = GST_BUFFER_DATA (sink->cur_buf);
    size = sink->scan_pos - cut;

    g_assert (size <= GST_BUFFER_SIZE (sink->cur_buf));

    /* We should always write data that corresponds to whole MPEG
       video sintactical elements.  They should always start with an
       MPEG start code. */
    g_assert (size >= 4 && data[0] == 0 && data[1] == 0 && data[2] == 1);

    while (size > 0) {
      written = write (sink->video_fd, data, size);
      if (written < 0) {
        GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
            (_("Could not write to device \"%s\"."), sink->video_filename),
            GST_ERROR_SYSTEM);
        break;
      }
      size = size - written;
      data = data + written;
    };
  }

  dxr3videosink_discard_data (sink, cut);
}
static void
gst_sctp_base_sink_destroy_socket (GstSCTPBaseSink * self)
{
  GError *err = NULL;

  if (!GST_OBJECT_FLAG_IS_SET (self, GST_SCTP_BASE_SINK_OPEN))
    return;

  if (self->priv->socket != NULL) {
    GST_DEBUG_OBJECT (self, "closing socket");

    if (!g_socket_close (self->priv->socket, &err)) {
      GST_ERROR_OBJECT (self, "Failed to close socket: %s", err->message);
      g_clear_error (&err);
    }
    g_clear_object (&self->priv->socket);
  }

  GST_OBJECT_FLAG_UNSET (self, GST_SCTP_BASE_SINK_OPEN);
}
Exemplo n.º 27
0
static void
do_push_event_pre (GstTracer * self, guint64 ts, GstPad * pad, GstEvent * ev)
{
  GstPad *peer_pad = GST_PAD_PEER (pad);
  GstElement *parent = get_real_pad_parent (peer_pad);

  if (parent && (!GST_IS_BIN (parent)) &&
      GST_OBJECT_FLAG_IS_SET (parent, GST_ELEMENT_FLAG_SINK)) {
    if (GST_EVENT_TYPE (ev) == GST_EVENT_CUSTOM_DOWNSTREAM) {
      const GstStructure *data = gst_event_get_structure (ev);

      if (gst_structure_get_name_id (data) == latency_probe_id) {
        /* store event and calculate latency when the buffer that follows
         * has been processed */
        g_object_set_qdata ((GObject *) peer_pad, latency_probe_id,
            gst_event_ref (ev));
      }
    }
  }
}
Exemplo n.º 28
0
static void
dxr3spusink_chain (GstPad * pad, GstData * _data)
{
  GstBuffer *buf = GST_BUFFER (_data);
  Dxr3SpuSink *sink;
  gint bytes_written = 0;

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

  sink = DXR3SPUSINK (gst_pad_get_parent (pad));

  if (GST_IS_EVENT (buf)) {
    dxr3spusink_handle_event (pad, GST_EVENT (buf));
    return;
  }

  if (GST_OBJECT_FLAG_IS_SET (sink, DXR3SPUSINK_OPEN)) {
    /* If we have PTS information for the SPU unit, register it now.
       The card needs the PTS to be written *before* the actual data. */
    if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) {
      guint pts = (guint) GSTTIME_TO_MPEGTIME (GST_BUFFER_TIMESTAMP (buf));

      ioctl (sink->spu_fd, EM8300_IOCTL_SPU_SETPTS, &pts);
    }

    bytes_written = write (sink->spu_fd, GST_BUFFER_DATA (buf),
        GST_BUFFER_SIZE (buf));
    if (bytes_written < GST_BUFFER_SIZE (buf)) {
      fprintf (stderr, "dxr3spusink: Warning: %d bytes should be written,"
          " only %d bytes written\n", GST_BUFFER_SIZE (buf), bytes_written);
    }
  }

  gst_buffer_unref (buf);
}
Exemplo n.º 29
0
static void
dxr3videosink_close (Dxr3VideoSink * sink)
{
  g_return_if_fail (GST_OBJECT_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN));

  if (close (sink->video_fd) != 0) {
    GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
        (_("Could not close video device \"%s\"."), sink->video_filename),
        GST_ERROR_SYSTEM);
    return;
  }

  if (close (sink->control_fd) != 0) {
    GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
        (_("Could not close control device \"%s\"."), sink->control_filename),
        GST_ERROR_SYSTEM);
    return;
  }

  GST_OBJECT_FLAG_UNSET (sink, DXR3VIDEOSINK_OPEN);

  free (sink->video_filename);
  sink->video_filename = NULL;
}
Exemplo n.º 30
0
static void
print_blacklist (void)
{
  GList *plugins, *cur;
  gint count = 0;

  g_print ("%s\n", _("Blacklisted files:"));

  plugins = gst_registry_get_plugin_list (gst_registry_get ());
  for (cur = plugins; cur != NULL; cur = g_list_next (cur)) {
    GstPlugin *plugin = (GstPlugin *) (cur->data);
    if (GST_OBJECT_FLAG_IS_SET (plugin, GST_PLUGIN_FLAG_BLACKLISTED)) {
      g_print ("  %s\n", gst_plugin_get_name (plugin));
      count++;
    }
  }

  g_print ("\n");
  g_print (_("Total count: "));
  g_print (ngettext ("%d blacklisted file", "%d blacklisted files", count),
      count);
  g_print ("\n");
  gst_plugin_list_free (plugins);
}