示例#1
0
static gboolean
gst_gl_mixer_src_query (GstAggregator * agg, GstQuery * query)
{
    gboolean res = FALSE;
    GstGLMixer *mix = GST_GL_MIXER (agg);
    GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_CONTEXT:
    {
        res = gst_gl_handle_context_query ((GstElement *) mix, query,
                                           &mix->display, &mix->other_context);
        if (mix->display)
            gst_gl_display_filter_gl_api (mix->display,
                                          mix_class->supported_gl_api);
        break;
    }
    case GST_QUERY_CAPS:
        res = gst_gl_mixer_query_caps (agg->srcpad, agg, query);
        break;
    default:
        res = GST_AGGREGATOR_CLASS (parent_class)->src_query (agg, query);
        break;
    }

    return res;
}
示例#2
0
static gboolean
gst_gl_filter_query (GstBaseTransform * trans, GstPadDirection direction,
    GstQuery * query)
{
  GstGLFilter *filter;
  gboolean res;

  filter = GST_GL_FILTER (trans);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_CONTEXT:
    {
      res = gst_gl_handle_context_query ((GstElement *) filter, query,
          &filter->display);
      break;
    }
    default:
      res =
          GST_BASE_TRANSFORM_CLASS (parent_class)->query (trans, direction,
          query);
      break;
  }

  return res;
}
static gboolean webkitVideoSinkQuery(GstBaseSink* baseSink, GstQuery* query)
{
    WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(baseSink);
    WebKitVideoSinkPrivate* priv = sink->priv;

    switch (GST_QUERY_TYPE(query)) {
    case GST_QUERY_DRAIN:
    {
#if USE(OPENGL_ES_2) && GST_CHECK_VERSION(1, 3, 0)
        GST_OBJECT_LOCK (sink);
        if (priv->last_buffer)
            gst_buffer_replace (&priv->last_buffer, NULL);
        g_signal_emit(sink, webkitVideoSinkSignals[DRAIN], 0);
        GST_OBJECT_UNLOCK (sink);
#endif
        return TRUE;
    }
    case GST_QUERY_CONTEXT:
    {
        return gst_gl_handle_context_query(GST_ELEMENT(sink), query, &priv->display);
      break;
    }
    default:
        return GST_CALL_PARENT_WITH_DEFAULT(GST_BASE_SINK_CLASS, query, (baseSink, query), TRUE);
      break;
    }
}
示例#4
0
static gboolean
gst_gl_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad,
    GstQuery * query)
{
  gboolean ret = FALSE;
  GstGLMixer *mix = GST_GL_MIXER (agg);

  GST_TRACE ("QUERY %" GST_PTR_FORMAT, query);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_ALLOCATION:
    {
      GstQuery *decide_query = NULL;
      gboolean negotiated;

      GST_OBJECT_LOCK (mix);
      if (G_UNLIKELY (!(negotiated = mix->priv->negotiated))) {
        GST_DEBUG_OBJECT (mix,
            "not negotiated yet, can't answer ALLOCATION query");
        GST_OBJECT_UNLOCK (mix);
        return FALSE;
      }
      if ((decide_query = mix->priv->query))
        gst_query_ref (decide_query);
      GST_OBJECT_UNLOCK (mix);

      GST_DEBUG_OBJECT (mix,
          "calling propose allocation with query %" GST_PTR_FORMAT,
          decide_query);

      /* pass the query to the propose_allocation vmethod if any */
      ret = gst_gl_mixer_propose_allocation (mix, decide_query, query);

      if (decide_query)
        gst_query_unref (decide_query);

      GST_DEBUG_OBJECT (mix, "ALLOCATION ret %d, %" GST_PTR_FORMAT, ret, query);
      break;
    }
    case GST_QUERY_CONTEXT:
    {
      ret = gst_gl_handle_context_query ((GstElement *) mix, query,
          &mix->display);
      break;
    }
    default:
      ret = GST_AGGREGATOR_CLASS (parent_class)->sink_query (agg, bpad, query);
      break;
  }

  return ret;
}
static gboolean
gst_gl_base_mixer_src_query (GstAggregator * agg, GstQuery * query)
{
    gboolean res = FALSE;
    GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg);
    GstGLBaseMixerClass *mix_class = GST_GL_BASE_MIXER_GET_CLASS (mix);

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_CONTEXT:
    {
        const gchar *context_type;
        GstContext *context, *old_context;

        res = gst_gl_handle_context_query ((GstElement *) mix, query,
                                           &mix->display, &mix->priv->other_context);
        if (mix->display)
            gst_gl_display_filter_gl_api (mix->display,
                                          mix_class->supported_gl_api);
        gst_query_parse_context_type (query, &context_type);

        if (g_strcmp0 (context_type, "gst.gl.local_context") == 0) {
            GstStructure *s;

            gst_query_parse_context (query, &old_context);

            if (old_context)
                context = gst_context_copy (old_context);
            else
                context = gst_context_new ("gst.gl.local_context", FALSE);

            s = gst_context_writable_structure (context);
            gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT, mix->context,
                               NULL);
            gst_query_set_context (query, context);
            gst_context_unref (context);

            res = mix->context != NULL;
        }
        GST_LOG_OBJECT (mix, "context query of type %s %i", context_type, res);

        if (res)
            return res;

        break;
    }
    default:
        break;
    }

    return GST_AGGREGATOR_CLASS (parent_class)->src_query (agg, query);
}
示例#6
0
static gboolean
gst_gtk_gl_sink_query (GstBaseSink * bsink, GstQuery * query)
{
    GstGtkGLSink *gtk_sink = GST_GTK_GL_SINK (bsink);
    gboolean res = FALSE;

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_CONTEXT:
    {
        const gchar *context_type;
        GstContext *context, *old_context;

        res = gst_gl_handle_context_query ((GstElement *) gtk_sink, query,
                                           &gtk_sink->display, &gtk_sink->gtk_context);

        if (gtk_sink->display)
            gst_gl_display_filter_gl_api (gtk_sink->display, GST_GL_API_OPENGL3);

        gst_query_parse_context_type (query, &context_type);

        if (g_strcmp0 (context_type, "gst.gl.local_context") == 0) {
            GstStructure *s;

            gst_query_parse_context (query, &old_context);

            if (old_context)
                context = gst_context_copy (old_context);
            else
                context = gst_context_new ("gst.gl.local_context", FALSE);

            s = gst_context_writable_structure (context);
            gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT, gtk_sink->context,
                               NULL);
            gst_query_set_context (query, context);
            gst_context_unref (context);

            res = gtk_sink->context != NULL;
        }
        GST_LOG_OBJECT (gtk_sink, "context query of type %s %i", context_type,
                        res);
        break;
    }
    default:
        res = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
        break;
    }

    return res;
}
static gboolean
stereosplit_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
  GstGLStereoSplit *split = GST_GL_STEREOSPLIT (parent);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_CONTEXT:
    {
      const gchar *context_type;
      GstContext *context, *old_context;
      gboolean ret;

      ret = gst_gl_handle_context_query ((GstElement *) split, query,
          &split->display, &split->other_context);
      if (split->display)
        gst_gl_display_filter_gl_api (split->display, SUPPORTED_GL_APIS);
      gst_query_parse_context_type (query, &context_type);

      if (g_strcmp0 (context_type, "gst.gl.local_context") == 0) {
        GstStructure *s;

        gst_query_parse_context (query, &old_context);

        if (old_context)
          context = gst_context_copy (old_context);
        else
          context = gst_context_new ("gst.gl.local_context", FALSE);

        s = gst_context_writable_structure (context);
        gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT, split->context,
            NULL);
        gst_query_set_context (query, context);
        gst_context_unref (context);

        ret = split->context != NULL;
      }
      GST_LOG_OBJECT (split, "context query of type %s %i", context_type, ret);

      if (ret)
        return ret;

      return gst_pad_query_default (pad, parent, query);
    }
      /* FIXME: Handle caps query */
    default:
      return gst_pad_query_default (pad, parent, query);
  }
}
示例#8
0
文件: testegl.c 项目: ryumiel/gst-omx
static GstPadProbeReturn
query_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
    APP_STATE_T *state = (APP_STATE_T *) user_data;
    GstQuery *query = GST_PAD_PROBE_INFO_QUERY (info);
    GstStructure *external_gl_context_desc = NULL;
    gchar *platform = NULL;
    gchar *gl_apis = NULL;

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_ALLOCATION:
    {
        platform = gst_gl_platform_to_string (GST_GL_PLATFORM_EGL);
        gl_apis = gst_gl_api_to_string (GST_GL_API_GLES2);

        external_gl_context_desc =
            gst_structure_new ("GstVideoGLTextureUploadMeta",
                               "gst.gl.context.handle", G_TYPE_POINTER, state->context,
                               "gst.gl.context.type", G_TYPE_STRING, platform,
                               "gst.gl.context.apis", G_TYPE_STRING, gl_apis, NULL);
        gst_query_add_allocation_meta (query,
                                       GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE, external_gl_context_desc);
        gst_structure_free (external_gl_context_desc);

        g_free (gl_apis);
        g_free (platform);

        GST_DEBUG ("done alocation");
        return GST_PAD_PROBE_OK;
        break;
    }
    case GST_QUERY_CONTEXT:
    {
        return gst_gl_handle_context_query (state->pipeline, query,
                                            (GstGLDisplay **) & state->gst_display);
        break;
    }
    case GST_QUERY_DRAIN:
    {
        flush_internal (state);
        break;
    }
    default:
        break;
    }

    return GST_PAD_PROBE_OK;
}
static gboolean
gst_glimage_sink_query (GstBaseSink * bsink, GstQuery * query)
{
  GstGLImageSink *glimage_sink = GST_GLIMAGE_SINK (bsink);
  gboolean res = FALSE;

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_CONTEXT:
    {
      return gst_gl_handle_context_query ((GstElement *) glimage_sink, query,
          &glimage_sink->display);
      break;
    }
    default:
      res = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
      break;
  }

  return res;
}
示例#10
0
gboolean
gst_vaapi_handle_context_query (GstElement * element, GstQuery * query)
{
  GstVaapiPluginBase *const plugin = GST_VAAPI_PLUGIN_BASE (element);
  const gchar *type = NULL;
  GstContext *context, *old_context;

  g_return_val_if_fail (query != NULL, FALSE);

#if USE_GST_GL_HELPERS
  if (plugin->gl_display && plugin->gl_context && plugin->gl_other_context) {
    if (gst_gl_handle_context_query (element, query,
            (GstGLDisplay *) plugin->gl_display,
            (GstGLContext *) plugin->gl_context,
            (GstGLContext *) plugin->gl_other_context))
      return TRUE;
  }
#endif

  if (!plugin->display)
    return FALSE;

  if (!gst_query_parse_context_type (query, &type))
    return FALSE;

  if (g_strcmp0 (type, GST_VAAPI_DISPLAY_CONTEXT_TYPE_NAME))
    return FALSE;

  gst_query_parse_context (query, &old_context);
  if (old_context) {
    context = gst_context_copy (old_context);
    gst_vaapi_video_context_set_display (context, plugin->display);
  } else {
    context = gst_vaapi_video_context_new_with_display (plugin->display, FALSE);
  }

  gst_query_set_context (query, context);
  gst_context_unref (context);

  return TRUE;
}
示例#11
0
static gboolean
gst_gl_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad,
                         GstQuery * query)
{
    gboolean ret = FALSE;
    GstGLMixer *mix = GST_GL_MIXER (agg);
    GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);

    GST_TRACE ("QUERY %" GST_PTR_FORMAT, query);

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_CAPS:
    {
        GstCaps *filter, *caps;

        gst_query_parse_caps (query, &filter);
        caps = gst_gl_mixer_pad_sink_getcaps (GST_PAD (bpad), mix, filter);
        gst_query_set_caps_result (query, caps);
        gst_caps_unref (caps);
        ret = TRUE;
        break;
    }
    case GST_QUERY_ACCEPT_CAPS:
    {
        GstCaps *caps;

        gst_query_parse_accept_caps (query, &caps);
        ret = gst_gl_mixer_pad_sink_acceptcaps (GST_PAD (bpad), mix, caps);
        gst_query_set_accept_caps_result (query, ret);
        ret = TRUE;
        break;
    }
    case GST_QUERY_ALLOCATION:
    {
        GstQuery *decide_query = NULL;

        GST_OBJECT_LOCK (mix);
        if (G_UNLIKELY (!mix->priv->negotiated)) {
            GST_DEBUG_OBJECT (mix,
                              "not negotiated yet, can't answer ALLOCATION query");
            GST_OBJECT_UNLOCK (mix);
            return FALSE;
        }
        if ((decide_query = mix->priv->query))
            gst_query_ref (decide_query);
        GST_OBJECT_UNLOCK (mix);

        GST_DEBUG_OBJECT (mix,
                          "calling propose allocation with query %" GST_PTR_FORMAT,
                          decide_query);

        /* pass the query to the propose_allocation vmethod if any */
        ret = gst_gl_mixer_propose_allocation (mix, decide_query, query);

        if (decide_query)
            gst_query_unref (decide_query);

        GST_DEBUG_OBJECT (mix, "ALLOCATION ret %d, %" GST_PTR_FORMAT, ret, query);
        break;
    }
    case GST_QUERY_CONTEXT:
    {
        ret = gst_gl_handle_context_query ((GstElement *) mix, query,
                                           &mix->display, &mix->other_context);
        if (mix->display)
            gst_gl_display_filter_gl_api (mix->display,
                                          mix_class->supported_gl_api);
        break;
    }
    default:
        ret = GST_AGGREGATOR_CLASS (parent_class)->sink_query (agg, bpad, query);
        break;
    }

    return ret;
}
static gboolean
gst_gl_base_mixer_sink_query (GstAggregator * agg, GstAggregatorPad * bpad,
                              GstQuery * query)
{
    gboolean ret = FALSE;
    GstGLBaseMixer *mix = GST_GL_BASE_MIXER (agg);
    GstGLBaseMixerClass *mix_class = GST_GL_BASE_MIXER_GET_CLASS (mix);
    GstGLBaseMixerPad *pad = GST_GL_BASE_MIXER_PAD (bpad);

    GST_TRACE ("QUERY %" GST_PTR_FORMAT, query);

    switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_ALLOCATION:
    {
        GstQuery *decide_query = NULL;

        GST_OBJECT_LOCK (mix);
        if (G_UNLIKELY (!mix->priv->negotiated)) {
            GST_DEBUG_OBJECT (mix,
                              "not negotiated yet, can't answer ALLOCATION query");
            GST_OBJECT_UNLOCK (mix);
            return FALSE;
        }
        if ((decide_query = mix->priv->query))
            gst_query_ref (decide_query);
        GST_OBJECT_UNLOCK (mix);

        GST_DEBUG_OBJECT (mix,
                          "calling propose allocation with query %" GST_PTR_FORMAT,
                          decide_query);

        /* pass the query to the propose_allocation vmethod if any */
        if (mix_class->propose_allocation)
            ret = mix_class->propose_allocation (mix, pad, decide_query, query);
        else
            ret = FALSE;

        if (decide_query)
            gst_query_unref (decide_query);

        GST_DEBUG_OBJECT (mix, "ALLOCATION ret %d, %" GST_PTR_FORMAT, ret, query);
        return ret;
    }
    case GST_QUERY_CONTEXT:
    {
        const gchar *context_type;
        GstContext *context, *old_context;

        ret = gst_gl_handle_context_query ((GstElement *) mix, query,
                                           &mix->display, &mix->priv->other_context);
        if (mix->display)
            gst_gl_display_filter_gl_api (mix->display,
                                          mix_class->supported_gl_api);
        gst_query_parse_context_type (query, &context_type);

        if (g_strcmp0 (context_type, "gst.gl.local_context") == 0) {
            GstStructure *s;

            gst_query_parse_context (query, &old_context);

            if (old_context)
                context = gst_context_copy (old_context);
            else
                context = gst_context_new ("gst.gl.local_context", FALSE);

            s = gst_context_writable_structure (context);
            gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT, mix->context,
                               NULL);
            gst_query_set_context (query, context);
            gst_context_unref (context);

            ret = mix->context != NULL;
        }
        GST_LOG_OBJECT (mix, "context query of type %s %i", context_type, ret);

        if (ret)
            return ret;

        break;
    }
    default:
        break;
    }

    return GST_AGGREGATOR_CLASS (parent_class)->sink_query (agg, bpad, query);;
}
static gboolean
stereosplit_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
{
  GstGLStereoSplit *split = GST_GL_STEREOSPLIT (parent);

  GST_DEBUG_OBJECT (split, "sink query %s",
      gst_query_type_get_name (GST_QUERY_TYPE (query)));

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_CONTEXT:
    {
      const gchar *context_type;
      GstContext *context, *old_context;
      gboolean ret;

      ret = gst_gl_handle_context_query ((GstElement *) split, query,
          &split->display, &split->other_context);
      if (split->display)
        gst_gl_display_filter_gl_api (split->display, SUPPORTED_GL_APIS);
      gst_query_parse_context_type (query, &context_type);

      if (g_strcmp0 (context_type, "gst.gl.local_context") == 0) {
        GstStructure *s;

        gst_query_parse_context (query, &old_context);

        if (old_context)
          context = gst_context_copy (old_context);
        else
          context = gst_context_new ("gst.gl.local_context", FALSE);

        s = gst_context_writable_structure (context);
        gst_structure_set (s, "context", GST_GL_TYPE_CONTEXT, split->context,
            NULL);
        gst_query_set_context (query, context);
        gst_context_unref (context);

        ret = split->context != NULL;
      }
      GST_LOG_OBJECT (split, "context query of type %s %i", context_type, ret);

      if (ret)
        return ret;

      return gst_pad_query_default (pad, parent, query);
    }
    case GST_QUERY_ALLOCATION:
    {
      return stereosplit_propose_allocation (split, query);
    }
    case GST_QUERY_ACCEPT_CAPS:
    {
      GstCaps *possible, *caps;
      gboolean allowed;

      gst_query_parse_accept_caps (query, &caps);

      if (!(possible = gst_pad_query_caps (split->sink_pad, caps)))
        return FALSE;

      allowed = gst_caps_is_subset (caps, possible);
      gst_caps_unref (possible);

      gst_query_set_accept_caps_result (query, allowed);
      return allowed;
    }
    case GST_QUERY_CAPS:
    {
      GstCaps *filter, *left, *right, *combined, *ret, *templ_caps;

      gst_query_parse_caps (query, &filter);

      /* Calculate what downstream can collectively support */
      if (!(left = gst_pad_peer_query_caps (split->left_pad, NULL)))
        return FALSE;
      if (!(right = gst_pad_peer_query_caps (split->right_pad, NULL)))
        return FALSE;

      /* Strip out multiview mode and flags that might break the
       * intersection, since we can convert.
       * We could keep downstream preferred flip/flopping and list
       * separated as preferred in the future which might
       * theoretically allow us an easier conversion, but it's not essential
       */
      left = strip_mview_fields (left, GST_VIDEO_MULTIVIEW_FLAGS_NONE);
      right = strip_mview_fields (right, GST_VIDEO_MULTIVIEW_FLAGS_NONE);

      combined = gst_caps_intersect (left, right);
      gst_caps_unref (left);
      gst_caps_unref (right);

      /* Intersect peer caps with our template formats */
      templ_caps = gst_pad_get_pad_template_caps (split->left_pad);
      ret =
          gst_caps_intersect_full (combined, templ_caps,
          GST_CAPS_INTERSECT_FIRST);
      gst_caps_unref (templ_caps);

      gst_caps_unref (combined);
      combined = ret;

      if (!combined || gst_caps_is_empty (combined)) {
        gst_caps_unref (combined);
        return FALSE;
      }

      /* Convert from the src pad caps to input formats we support */
      ret = stereosplit_transform_caps (split, GST_PAD_SRC, combined, filter);
      gst_caps_unref (combined);
      combined = ret;

      /* Intersect with the sink pad template then */
      templ_caps = gst_pad_get_pad_template_caps (split->sink_pad);
      ret =
          gst_caps_intersect_full (combined, templ_caps,
          GST_CAPS_INTERSECT_FIRST);
      gst_caps_unref (templ_caps);

      GST_LOG_OBJECT (split, "Returning sink pad caps %" GST_PTR_FORMAT, ret);

      gst_query_set_caps_result (query, ret);
      return !gst_caps_is_empty (ret);
    }
    default:
      return gst_pad_query_default (pad, parent, query);
  }
}
static gboolean
gst_gl_test_src_query (GstBaseSrc * bsrc, GstQuery * query)
{
  gboolean res = FALSE;
  GstGLTestSrc *src;

  src = GST_GL_TEST_SRC (bsrc);

  switch (GST_QUERY_TYPE (query)) {
    case GST_QUERY_CONTEXT:
    {
      const gchar *context_type;
      GstContext *context, *old_context;

      res = gst_gl_handle_context_query ((GstElement *) src, query,
          &src->display, &src->other_context);
      if (src->display)
        gst_gl_display_filter_gl_api (src->display, SUPPORTED_GL_APIS);

      gst_query_parse_context_type (query, &context_type);

      if (g_strcmp0 (context_type, "gst.gl.local_context") == 0) {
        GstStructure *s;

        gst_query_parse_context (query, &old_context);

        if (old_context)
          context = gst_context_copy (old_context);
        else
          context = gst_context_new ("gst.gl.local_context", FALSE);

        s = gst_context_writable_structure (context);
        gst_structure_set (s, "context", GST_TYPE_GL_CONTEXT, src->context,
            NULL);
        gst_query_set_context (query, context);
        gst_context_unref (context);

        res = src->context != NULL;
      }
      GST_LOG_OBJECT (src, "context query of type %s %i", context_type, res);

      if (res)
        return res;

      break;
    }
    case GST_QUERY_CONVERT:
    {
      GstFormat src_fmt, dest_fmt;
      gint64 src_val, dest_val;

      gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
      res =
          gst_video_info_convert (&src->out_info, src_fmt, src_val, dest_fmt,
          &dest_val);
      gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);

      return res;
    }
    default:
      break;
  }

  return GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
}