-
-
Notifications
You must be signed in to change notification settings - Fork 401
aravissrc gst element switch test
#918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: aravis-0-8
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,100 @@ | ||||||||||||||||||||||||||||||
| /* Simple script which will start an aravis pipeline, then restart ONLY the camera. */ | ||||||||||||||||||||||||||||||
| #include <gst/gst.h> | ||||||||||||||||||||||||||||||
| #include <stdio.h> | ||||||||||||||||||||||||||||||
| #include <unistd.h> | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| int | ||||||||||||||||||||||||||||||
| main (int argc, char *argv[]) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| GstElement *pipeline; | ||||||||||||||||||||||||||||||
| GstElement *source; | ||||||||||||||||||||||||||||||
| GstElement *sink; | ||||||||||||||||||||||||||||||
| GstElement *new_source; | ||||||||||||||||||||||||||||||
| GstState current_state, pending_state; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| gst_init (&argc, &argv); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| pipeline = gst_pipeline_new ("aravis_pipeline"); | ||||||||||||||||||||||||||||||
| source = gst_element_factory_make ("aravissrc", "source"); | ||||||||||||||||||||||||||||||
| if (!source) { | ||||||||||||||||||||||||||||||
| printf ("Failed to create the source element\n"); | ||||||||||||||||||||||||||||||
| return EXIT_FAILURE; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| g_object_set(G_OBJECT(source), | ||||||||||||||||||||||||||||||
| "camera-name", "Aravis-Fake-GV01", | ||||||||||||||||||||||||||||||
| "num-arv-buffers", 5, | ||||||||||||||||||||||||||||||
| "packet-resend", FALSE, | ||||||||||||||||||||||||||||||
| "packet-size", 9000, | ||||||||||||||||||||||||||||||
| "auto-packet-size", FALSE, | ||||||||||||||||||||||||||||||
| NULL); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| sink = gst_element_factory_make ("fakesink", "fake_sink"); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (!pipeline || !source || !sink) { | ||||||||||||||||||||||||||||||
| printf ("Not all elements could be created.\n"); | ||||||||||||||||||||||||||||||
| return EXIT_FAILURE; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if (!gst_element_link (source, sink)) { | ||||||||||||||||||||||||||||||
| printf ("Elements could not be linked.\n"); | ||||||||||||||||||||||||||||||
| gst_object_unref (pipeline); | ||||||||||||||||||||||||||||||
| return EXIT_FAILURE; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| printf ("Start the pipeline\n"); | ||||||||||||||||||||||||||||||
| g_assert_cmpint (gst_element_set_state(pipeline, GST_STATE_PLAYING), ==, GST_STATE_CHANGE_ASYNC); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+47
to
+49
|
||||||||||||||||||||||||||||||
| printf ("Wait for a few frames\n"); | ||||||||||||||||||||||||||||||
| sleep (1); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| printf ("Stop the source\n"); | ||||||||||||||||||||||||||||||
| g_assert_cmpint (gst_element_set_state(source, GST_STATE_NULL), ==, GST_STATE_CHANGE_SUCCESS); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+53
to
+55
|
||||||||||||||||||||||||||||||
| gst_element_get_state (source, ¤t_state, &pending_state, 0); | ||||||||||||||||||||||||||||||
| printf ("source current state:%d - pending state:%d\n", current_state, pending_state); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| sleep (1); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| gst_element_unlink(source, sink); | ||||||||||||||||||||||||||||||
| g_assert (gst_bin_remove(GST_BIN(pipeline), source)); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+56
to
+63
|
||||||||||||||||||||||||||||||
| printf ("Create a new source\n"); | ||||||||||||||||||||||||||||||
| new_source = gst_element_factory_make ("aravissrc", "new_source"); | ||||||||||||||||||||||||||||||
| if (!new_source) { | ||||||||||||||||||||||||||||||
| printf ("Failed to create the source element\n"); | ||||||||||||||||||||||||||||||
| return EXIT_FAILURE; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| g_object_set(G_OBJECT(new_source), | ||||||||||||||||||||||||||||||
| "camera-name", "Aravis-Fake-GV01", | ||||||||||||||||||||||||||||||
| "num-arv-buffers", 5, | ||||||||||||||||||||||||||||||
| "packet-resend", FALSE, | ||||||||||||||||||||||||||||||
| "packet-size", 9000, | ||||||||||||||||||||||||||||||
| "auto-packet-size", FALSE, | ||||||||||||||||||||||||||||||
| NULL); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| g_assert (gst_bin_add(GST_BIN(pipeline), new_source)); | ||||||||||||||||||||||||||||||
| g_assert (gst_element_link(new_source, sink)); | ||||||||||||||||||||||||||||||
| g_assert (gst_element_sync_state_with_parent(new_source)); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| gst_element_get_state (source, ¤t_state, &pending_state, 0); | ||||||||||||||||||||||||||||||
| printf ("new source current state:%d - pending state:%d\n", current_state, pending_state); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| printf ("Start the new source\n"); | ||||||||||||||||||||||||||||||
| g_assert_cmpint (gst_element_set_state(source, GST_STATE_PLAYING), ==, GST_STATE_CHANGE_SUCCESS); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| gst_element_get_state (source, ¤t_state, &pending_state, 0); | ||||||||||||||||||||||||||||||
|
Comment on lines
+82
to
+88
|
||||||||||||||||||||||||||||||
| gst_element_get_state (source, ¤t_state, &pending_state, 0); | |
| printf ("new source current state:%d - pending state:%d\n", current_state, pending_state); | |
| printf ("Start the new source\n"); | |
| g_assert_cmpint (gst_element_set_state(source, GST_STATE_PLAYING), ==, GST_STATE_CHANGE_SUCCESS); | |
| gst_element_get_state (source, ¤t_state, &pending_state, 0); | |
| gst_element_get_state (new_source, ¤t_state, &pending_state, 0); | |
| printf ("new source current state:%d - pending state:%d\n", current_state, pending_state); | |
| printf ("Start the new source\n"); | |
| g_assert_cmpint (gst_element_set_state(new_source, GST_STATE_PLAYING), ==, GST_STATE_CHANGE_SUCCESS); | |
| gst_element_get_state (new_source, ¤t_state, &pending_state, 0); |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new_source is created with gst_element_factory_make() and added to the pipeline, but the local reference is never released. Even though unreffing the pipeline will drop the bin’s reference, your original reference will remain and leak unless you unref new_source (or g_clear_object(&new_source)) before exiting.
| printf ("Free the pipeline\n"); | |
| printf ("Free the pipeline\n"); | |
| gst_object_unref (new_source); | |
| gst_object_unref (sink); | |
| gst_object_unref (source); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -103,4 +103,12 @@ if get_option('tests') | |||||
| include_directories: [library_inc]) | ||||||
| endforeach | ||||||
|
|
||||||
| if gst_enabled | ||||||
| executable ('arv-gst-test', 'arvgsttest.c', | ||||||
| link_with: aravis_library, | ||||||
| dependencies: aravis_dependencies + gst_deps, | ||||||
|
||||||
| dependencies: aravis_dependencies + gst_deps, | |
| dependencies: gst_deps, |
Copilot
AI
Feb 8, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation in this new if gst_enabled block uses spaces and doesn't match the surrounding Meson file which otherwise uses tab-indented blocks. This makes the file harder to scan and can trip style/whitespace tooling; align the indentation with the existing foreach/if blocks above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file uses
g_object_set(G_OBJECT(...), ...)without the spacing convention used elsewhere intests/(e.g.g_object_set (stream, ...)in tests/arvdevicetest.c:190). Consider aligning the formatting here (spaces after function name and insideG_OBJECT (...)) to match the surrounding codebase style.