X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=app%2Fmain.cpp;h=64a435b319b79b83769986e5e1df6a08d85b55cb;hb=refs%2Ftags%2Fricefish_17.90.0;hp=2d286ba5b4a348873908581207cc0cd12c897de9;hpb=4f2e6690a893ed41be6eb3c74d6cab82a5e12f39;p=apps%2Fcamera-gstreamer.git diff --git a/app/main.cpp b/app/main.cpp index 2d286ba..64a435b 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -14,15 +14,24 @@ #include #include -#include "xdg-shell-client-protocol.h" -#include "agl-shell-desktop-client-protocol.h" #include "utils.h" +#include "xdg-shell-client-protocol.h" +#include "AglShellGrpcClient.h" #include #include #include +#if !GST_CHECK_VERSION(1, 22, 0) +#define gst_is_wl_display_handle_need_context_message gst_is_wayland_display_handle_need_context_message +#define gst_wl_display_handle_context_new gst_wayland_display_handle_context_new +#endif + +#ifndef APP_DATA_PATH +#define APP_DATA_PATH /usr/share/applications/data +#endif + // these only applies if the window is a dialog/pop-up one // by default the compositor make the window maximized #define WINDOW_WIDTH_SIZE 640 @@ -52,8 +61,6 @@ struct display { } output_data; struct xdg_wm_base *wm_base; - struct agl_shell_desktop *agl_shell_desktop; - int has_xrgb; }; @@ -92,7 +99,6 @@ struct receiver_data { struct window *window; GstElement *pipeline; - GstWaylandVideo *wl_video; GstVideoOverlay *overlay; }; @@ -211,6 +217,7 @@ create_shm_buffer(struct display *display, struct buffer *buffer, buffer->height = height; fprintf(stdout, "Created shm buffer with width %d, height %d\n", width, height); + return 0; } @@ -362,32 +369,6 @@ static const struct wl_output_listener output_listener = { display_handle_scale }; -static void -application_id(void *data, struct agl_shell_desktop *agl_shell_desktop, - const char *app_id) -{ - (void) data; - (void) agl_shell_desktop; - (void) app_id; -} - -static void -application_id_state(void *data, struct agl_shell_desktop *agl_shell_desktop, - const char *app_id, const char *app_data, - uint32_t app_state, uint32_t app_role) -{ - (void) data; - (void) app_data; - (void) agl_shell_desktop; - (void) app_id; - (void) app_state; - (void) app_role; -} - -static const struct agl_shell_desktop_listener agl_shell_desktop_listener = { - application_id, - application_id_state, -}; static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, @@ -407,12 +388,6 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, d->shm = static_cast(wl_registry_bind(registry, id, &wl_shm_interface, 1)); wl_shm_add_listener(d->shm, &shm_listener, d); - } else if (strcmp(interface, "agl_shell_desktop") == 0) { - d->agl_shell_desktop = static_cast(wl_registry_bind(registry, id, - &agl_shell_desktop_interface, 1)); - /* as an example, show how to register for events from the compositor */ - agl_shell_desktop_add_listener(d->agl_shell_desktop, - &agl_shell_desktop_listener, d); } else if (strcmp(interface, "wl_output") == 0) { d->wl_output = static_cast(wl_registry_bind(registry, id, &wl_output_interface, 1)); @@ -462,12 +437,11 @@ bus_sync_handler(GstBus *bus, GstMessage *message, gpointer user_data) struct receiver_data *d = static_cast(user_data); - if (gst_is_wayland_display_handle_need_context_message(message)) { + if (gst_is_wl_display_handle_need_context_message(message)) { GstContext *context; struct wl_display *display_handle = d->window->display->wl_display; - context = gst_wayland_display_handle_context_new(display_handle); - d->wl_video = GST_WAYLAND_VIDEO(GST_MESSAGE_SRC(message)); + context = gst_wl_display_handle_context_new(display_handle); gst_element_set_context(GST_ELEMENT(GST_MESSAGE_SRC(message)), context); goto drop; @@ -599,6 +573,8 @@ create_window(struct display *display, int width, int height, const char *app_id window->display = display; window->width = width; window->height = height; + window->init_width = width; + window->init_height = height; window->surface = wl_compositor_create_surface(display->wl_compositor); if (display->wm_base) { @@ -679,11 +655,6 @@ create_display(int argc, char *argv[]) return NULL; } - if (display->agl_shell_desktop == NULL) { - fprintf(stderr, "No agl_shell extension present\n"); - return NULL; - } - wl_display_roundtrip(display->wl_display); if (!display->has_xrgb) { @@ -703,9 +674,6 @@ destroy_display(struct display *display) if (display->wm_base) xdg_wm_base_destroy(display->wm_base); - if (display->agl_shell_desktop) - agl_shell_desktop_destroy(display->agl_shell_desktop); - if (display->wl_compositor) wl_compositor_destroy(display->wl_compositor); @@ -761,13 +729,12 @@ GstElement* create_pipeline(int* argc, char** argv[]) snprintf(pipeline_str, sizeof(pipeline_str), "v4l2src device=%s ! video/x-raw,width=%d,height=%d ! waylandsink", camera_device, width, height); else if (gst_pipeline_failed == TRUE) { - snprintf(pipeline_str, sizeof(pipeline_str), "filesrc location=%s/still-image.jpg ! decodebin ! videoconvert ! imagefreeze ! waylandsink fullscreen=true", - xstr(APP_DATA_PATH), width, height); + snprintf(pipeline_str, sizeof(pipeline_str), "filesrc location=%s/still-image.jpg ! decodebin ! videoconvert ! imagefreeze ! waylandsink", + xstr(APP_DATA_PATH)); fallback_gst_pipeline_tried = TRUE; } else { - snprintf(pipeline_str, sizeof(pipeline_str), "pipewiresrc ! video/x-raw,width=%d,height=%d ! waylandsink", width, - height); + snprintf(pipeline_str, sizeof(pipeline_str), "pipewiresrc ! waylandsink"); } fprintf(stdout, "Using pipeline: %s\n", pipeline_str); @@ -792,6 +759,13 @@ int main(int argc, char* argv[]) struct window* window; const char* app_id = "camera-gstreamer"; + // for starting the application from the beginning, with a diffrent + // role we need to handle that creating the main window + if (argc >= 2 && strcmp(argv[1], "float") == 0) { + GrpcClient *client = new GrpcClient(); + client->SetAppFloat(std::string(app_id), 30, 400); + } + sa.sa_sigaction = signal_int; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESETHAND | SA_SIGINFO; @@ -816,13 +790,6 @@ int main(int argc, char* argv[]) if (!display) return -1; - // if you'd want to place the video in a pop-up/dialog type of window: - // agl_shell_desktop_set_app_property(display->agl_shell_desktop, app_id, - // AGL_SHELL_DESKTOP_APP_ROLE_POPUP, - // WINDOW_WIDTH_POS_X, WINDOW_WIDTH_POS_Y, - // 0, 0, WINDOW_WIDTH_SIZE, WINDOW_HEIGHT_SIZE, - // display->wl_output); - // we use the role to set a correspondence between the top level // surface and our application, with the previous call letting the // compositor know that we're one and the same