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=83f7c286fb71580e65f7871ac31d2be0b1d784ab;hpb=19ed4e26ab884460a93765e2412cda76ac795794;p=apps%2Fcamera-gstreamer.git diff --git a/app/main.cpp b/app/main.cpp index 83f7c28..64a435b 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -14,9 +14,9 @@ #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 @@ -28,6 +28,10 @@ #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 @@ -57,8 +61,6 @@ struct display { } output_data; struct xdg_wm_base *wm_base; - struct agl_shell_desktop *agl_shell_desktop; - int has_xrgb; }; @@ -215,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; } @@ -366,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, @@ -411,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)); @@ -602,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) { @@ -682,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) { @@ -706,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); @@ -764,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); @@ -795,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; @@ -819,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