示例#1
0
void Caps::unref()
{
    if (Private::ObjectStore::take(this)) {
        gst_caps_unref(GST_CAPS(m_object));
        delete this;
    }
}
示例#2
0
void Caps::ref(bool increaseRef)
{
    if (Private::ObjectStore::put(this)) {
        if (increaseRef) {
            gst_caps_ref(GST_CAPS(m_object));
        }
    }
}
示例#3
0
/* reset video frame size to what is stored in server->conf */
void video_server_reset_frame_size(video_server_t * server)
{
    fprintf(stderr, "Video server playing -> ready\n");
    gst_element_set_state(server->pipeline, GST_STATE_READY);
    fprintf(stderr, "New video frame size: %dx%d\n",
            server->conf->width, server->conf->height);
    gst_caps_set_simple(GST_CAPS(server->h264caps),
                        "width", G_TYPE_INT, server->conf->width,
                        "height", G_TYPE_INT, server->conf->height,
                        NULL);
    fprintf(stderr, "Video server ready -> playing\n");
    gst_element_set_state(server->pipeline, GST_STATE_PLAYING);
}
示例#4
0
void video_server_set_framerate(video_server_t * server, unsigned int value)
{
    server->conf->framerate = get_closest_framerate(value);

    fprintf(stderr, "Video server playing -> ready\n");
    gst_element_set_state(server->pipeline, GST_STATE_READY);
    fprintf(stderr, "New video framerate: %d fps\n", server->conf->framerate);
    gst_caps_set_simple(GST_CAPS(server->h264caps),
                        "framerate", GST_TYPE_FRACTION, server->conf->framerate, 1,
                        NULL);
    fprintf(stderr, "Video server ready -> playing\n");
    gst_element_set_state(server->pipeline, GST_STATE_PLAYING);

}
static gint
find_matching_pad (gconstpointer a, gconstpointer b)
{
  GstPad *pad = GST_PAD (a);
  GstCaps *caps = GST_CAPS (b);
  GstCaps *padcaps = NULL;
  gint ret = 1;

  padcaps = gst_pad_get_caps_reffed (pad);

  if (gst_caps_can_intersect (caps, padcaps))
    ret = 0;

  gst_caps_unref (padcaps);
  gst_object_unref (pad);

  return ret;
}
/* For each raw video structure, adds a variant with format unset */
static gboolean
fix_video_caps_format(GstCapsFeatures *f, GstStructure *s, gpointer user_data)
{
    GstCaps *ret = GST_CAPS(user_data);
    OWR_UNUSED(f);

    gst_caps_append_structure(ret, gst_structure_copy(s));

    /* Don't mess with non-raw structures */
    if (!gst_structure_has_name(s, "video/x-raw"))
        goto done;

    if (gst_structure_has_field(s, "format")) {
        GstStructure *tmp = gst_structure_copy(s);
        gst_structure_remove_field(tmp, "format");
        gst_caps_append_structure(ret, tmp);
    }

done:
    return TRUE;
}
/* For each raw video structure, adds a variant with framerate unset */
static gboolean
fix_video_caps_framerate(GstCapsFeatures *f, GstStructure *s, gpointer user_data)
{
    GstCaps *ret = GST_CAPS(user_data);
    gint fps_n, fps_d;

    gst_caps_append_structure_full(ret, gst_structure_copy(s), f ? gst_caps_features_copy(f) : NULL);

    /* Don't mess with non-raw structures */
    if (!gst_structure_has_name(s, "video/x-raw"))
        goto done;

    /* If possible try to limit the framerate at the source already */
    if (gst_structure_get_fraction(s, "framerate", &fps_n, &fps_d)) {
        GstStructure *tmp = gst_structure_copy(s);
        gst_structure_remove_field(tmp, "framerate");
        gst_caps_append_structure_full(ret, tmp, f ? gst_caps_features_copy(f) : NULL);
    }

done:
    return TRUE;
}
示例#8
0
int
main (int argc, char **argv)
{
    static const GOptionEntry test_goptions[] = {
        {   "videosink", '\0', 0, G_OPTION_ARG_STRING, &opt_videosink_str,
            "videosink to use (default: " DEFAULT_VIDEOSINK ")", NULL
        },
        {   "caps", '\0', 0, G_OPTION_ARG_STRING, &opt_filtercaps_str,
            "filter caps to narrow down formats to test", NULL
        },
        {   "with-ffmpegcolorspace", '\0', 0, G_OPTION_ARG_NONE,
            &opt_with_ffmpegcolorspace,
            "whether to add an ffmpegcolorspace element in front of the sink",
            NULL
        },
        {NULL, '\0', 0, 0, NULL, NULL, NULL}
    };
    GOptionContext *ctx;
    GError *opt_err = NULL;

    GstElement *pipeline, *src, *filter1, *crop, *scale, *filter2, *csp, *sink;
    GMainLoop *loop;
    GstCaps *filter_caps = NULL;
    GList *caps_list, *l;

    if (!g_thread_supported ())
        g_thread_init (NULL);

    /* command line option parsing */
    ctx = g_option_context_new ("");
    g_option_context_add_group (ctx, gst_init_get_option_group ());
    g_option_context_add_main_entries (ctx, test_goptions, NULL);

    if (!g_option_context_parse (ctx, &argc, &argv, &opt_err)) {
        g_error ("Error parsing command line options: %s", opt_err->message);
        return -1;
    }

    GST_DEBUG_CATEGORY_INIT (videocrop_test_debug, "videocroptest", 0, "vctest");

    loop = g_main_loop_new (NULL, FALSE);

    pipeline = gst_pipeline_new ("pipeline");
    src = gst_element_factory_make ("videotestsrc", "videotestsrc");
    g_assert (src != NULL);
    filter1 = gst_element_factory_make ("capsfilter", "capsfilter1");
    g_assert (filter1 != NULL);
    crop = gst_element_factory_make ("videocrop", "videocrop");
    g_assert (crop != NULL);
    scale = gst_element_factory_make ("videoscale", "videoscale");
    g_assert (scale != NULL);
    filter2 = gst_element_factory_make ("capsfilter", "capsfilter2");
    g_assert (filter2 != NULL);

    if (opt_with_ffmpegcolorspace) {
        g_print ("Adding ffmpegcolorspace\n");
        csp = gst_element_factory_make ("ffmpegcolorspace", "colorspace");
    } else {
        csp = gst_element_factory_make ("identity", "colorspace");
    }
    g_assert (csp != NULL);

    if (opt_filtercaps_str) {
        filter_caps = gst_caps_from_string (opt_filtercaps_str);
        if (filter_caps == NULL) {
            g_error ("Invalid filter caps string '%s'", opt_filtercaps_str);
        } else {
            g_print ("Using filter caps '%s'\n", opt_filtercaps_str);
        }
    }

    if (opt_videosink_str) {
        g_print ("Trying videosink '%s' ...", opt_videosink_str);
        sink = gst_element_factory_make (opt_videosink_str, "sink");
        g_print ("%s\n", (sink) ? "ok" : "element couldn't be created");
    } else {
        sink = NULL;
    }

    if (sink == NULL) {
        g_print ("Trying videosink '%s' ...", DEFAULT_VIDEOSINK);
        sink = gst_element_factory_make (DEFAULT_VIDEOSINK, "sink");
        g_print ("%s\n", (sink) ? "ok" : "element couldn't be created");
    }
    if (sink == NULL) {
        g_print ("Trying videosink '%s' ...", "xvimagesink");
        sink = gst_element_factory_make ("xvimagesink", "sink");
        g_print ("%s\n", (sink) ? "ok" : "element couldn't be created");
    }
    if (sink == NULL) {
        g_print ("Trying videosink '%s' ...", "ximagesink");
        sink = gst_element_factory_make ("ximagesink", "sink");
        g_print ("%s\n", (sink) ? "ok" : "element couldn't be created");
    }

    g_assert (sink != NULL);

    gst_bin_add_many (GST_BIN (pipeline), src, filter1, crop, scale, filter2,
                      csp, sink, NULL);

    if (!gst_element_link (src, filter1))
        g_error ("Failed to link videotestsrc to capsfilter1");

    if (!gst_element_link (filter1, crop))
        g_error ("Failed to link capsfilter1 to videocrop");

    if (!gst_element_link (crop, scale))
        g_error ("Failed to link videocrop to videoscale");

    if (!gst_element_link (scale, filter2))
        g_error ("Failed to link videoscale to capsfilter2");

    if (!gst_element_link (filter2, csp))
        g_error ("Failed to link capsfilter2 to ffmpegcolorspace");

    if (!gst_element_link (csp, sink))
        g_error ("Failed to link ffmpegcolorspace to video sink");

    caps_list = video_crop_get_test_caps (crop);
    for (l = caps_list; l != NULL; l = l->next) {
        GstStateChangeReturn ret;
        GstCaps *caps, *out_caps;
        gboolean skip = FALSE;
        gchar *s;

        if (filter_caps) {
            GstCaps *icaps;

            icaps = gst_caps_intersect (filter_caps, GST_CAPS (l->data));
            skip = gst_caps_is_empty (icaps);
            gst_caps_unref (icaps);
        }

        /* this is the size of our window (stays fixed) */
        out_caps = gst_caps_copy (GST_CAPS (l->data));
        gst_structure_set (gst_caps_get_structure (out_caps, 0), "width",
                           G_TYPE_INT, OUT_WIDTH, "height", G_TYPE_INT, OUT_HEIGHT, NULL);

        g_object_set (filter2, "caps", out_caps, NULL);

        /* filter1 gets these too to prevent videotestsrc from renegotiating */
        g_object_set (filter1, "caps", out_caps, NULL);
        gst_caps_unref (out_caps);

        caps = gst_caps_copy (GST_CAPS (l->data));
        GST_INFO ("testing format: %" GST_PTR_FORMAT, caps);

        s = gst_caps_to_string (caps);

        if (skip) {
            g_print ("Skipping format: %s\n", s);
            g_free (s);
            continue;
        }

        g_print ("Format: %s\n", s);

        caps = gst_caps_make_writable (caps);

        /* FIXME: check return values */
        ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
        if (ret != GST_STATE_CHANGE_FAILURE) {
            ret = gst_element_get_state (pipeline, NULL, NULL, -1);

            if (ret != GST_STATE_CHANGE_FAILURE) {
                test_with_caps (src, crop, caps);
            } else {
                g_print ("Format: %s not supported (failed to go to PLAYING)\n", s);
            }
        } else {
            g_print ("Format: %s not supported\n", s);
        }

        gst_element_set_state (pipeline, GST_STATE_NULL);

        gst_caps_unref (caps);
        g_free (s);
    }

    g_list_foreach (caps_list, (GFunc) gst_caps_unref, NULL);
    g_list_free (caps_list);

    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);

    return 0;
}
示例#9
0
QGlib::RefCountedObject *wrapCaps(void *caps)
{
    return QGlib::constructWrapper(GST_CAPS(caps)->type, caps);
}