示例#1
0
static void
convert_frame_new_buffer_callback (GstElement * sink,
    GstVideoConvertFrameContext * context)
{
  GstBuffer *buf = NULL;
  GError *error = NULL;

  g_mutex_lock (context->mutex);

  if (context->finished)
    goto done;

  g_signal_emit_by_name (sink, "pull-preroll", &buf);

  if (!buf) {
    error = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
        "Could not get converted video frame");
  }

  convert_frame_finish (context, buf, error);

  g_signal_handlers_disconnect_by_func (sink, convert_frame_need_data_callback,
      context);

done:
  g_mutex_unlock (context->mutex);
}
示例#2
0
static void
convert_frame_need_data_callback (GstElement * src, guint size,
    GstVideoConvertFrameContext * context)
{
  GstFlowReturn ret = GST_FLOW_ERROR;
  GError *error;

  g_mutex_lock (context->mutex);

  if (context->finished)
    goto done;

  g_signal_emit_by_name (src, "push-buffer", context->buffer, &ret);
  gst_buffer_unref (context->buffer);
  context->buffer = NULL;

  if (ret != GST_FLOW_OK) {
    GST_ERROR ("Could not push video frame: %s", gst_flow_get_name (ret));

    error = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
        "Could not push video frame: %s", gst_flow_get_name (ret));

    convert_frame_finish (context, NULL, error);
  }

  g_signal_handlers_disconnect_by_func (src, convert_frame_need_data_callback,
      context);

done:
  g_mutex_unlock (context->mutex);
}
示例#3
0
static gboolean
convert_frame_bus_callback (GstBus * bus, GstMessage * message,
    GstVideoConvertFrameContext * context)
{
  g_mutex_lock (context->mutex);

  if (context->finished)
    goto done;

  switch (GST_MESSAGE_TYPE (message)) {
    case GST_MESSAGE_ERROR:{
      GError *error;
      gchar *dbg = NULL;

      gst_message_parse_error (message, &error, &dbg);

      GST_ERROR ("Could not convert video frame: %s", error->message);
      GST_DEBUG ("%s [debug: %s]", error->message, GST_STR_NULL (dbg));

      convert_frame_finish (context, NULL, error);

      g_free (dbg);
      break;
    }
    default:
      break;
  }

done:
  g_mutex_unlock (context->mutex);

  return FALSE;
}
static GstFlowReturn
convert_frame_new_preroll_callback (GstElement * sink,
    GstVideoConvertSampleContext * context)
{
  GstSample *sample = NULL;
  GError *error = NULL;

  g_mutex_lock (&context->mutex);

  if (context->finished)
    goto done;

  g_signal_emit_by_name (sink, "pull-preroll", &sample);

  if (!sample) {
    error = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
        "Could not get converted video sample");
  }
  convert_frame_finish (context, sample, error);

  g_signal_handlers_disconnect_by_func (sink, convert_frame_need_data_callback,
      context);

done:
  g_mutex_unlock (&context->mutex);

  return GST_FLOW_OK;
}
示例#5
0
static gboolean
convert_frame_timeout_callback (GstVideoConvertFrameContext * context)
{
  GError *error;

  g_mutex_lock (context->mutex);

  if (context->finished)
    goto done;

  GST_ERROR ("Could not convert video frame: timeout");

  error = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
      "Could not convert video frame: timeout");

  convert_frame_finish (context, NULL, error);

done:
  g_mutex_unlock (context->mutex);
  return FALSE;
}