summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/meson.build4
-rw-r--r--include/plugin.h333
-rw-r--r--include/transmitter_api.h283
-rw-r--r--include/waltham-renderer.h43
4 files changed, 663 insertions, 0 deletions
diff --git a/include/meson.build b/include/meson.build
new file mode 100644
index 0000000..a8c2855
--- /dev/null
+++ b/include/meson.build
@@ -0,0 +1,4 @@
+install_headers(
+ 'transmitter_api.h',
+ subdir: dir_include_waltham_transmiter_install
+)
diff --git a/include/plugin.h b/include/plugin.h
new file mode 100644
index 0000000..daa0fea
--- /dev/null
+++ b/include/plugin.h
@@ -0,0 +1,333 @@
+/*
+ * Copyright (C) 2017 Advanced Driver Information Technology Joint Venture GmbH
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef WESTON_TRANSMITTER_PLUGIN_H
+#define WESTON_TRANSMITTER_PLUGIN_H
+
+/* XXX: all functions and variables with a name, and things marked with a
+ * comment, containing the word "fake" are mockups that need to be
+ * removed from the final implementation.
+ */
+
+#include <stdint.h>
+#include <wayland-client.h>
+
+#include <libweston/libweston.h>
+#include <ivi-layout-export.h>
+
+#include "transmitter_api.h"
+
+#include <waltham-client.h>
+
+
+struct waltham_display;
+
+enum wthp_seat_capability {
+ /**
+ * the seat has pointer devices
+ */
+ WTHP_SEAT_CAPABILITY_POINTER = 1,
+ /**
+ * the seat has one or more keyboards
+ */
+ WTHP_SEAT_CAPABILITY_KEYBOARD = 2,
+ /**
+ * the seat has touch devices
+ */
+ WTHP_SEAT_CAPABILITY_TOUCH = 4,
+};
+
+/* epoll structure */
+struct watch {
+ struct waltham_display *display;
+ int fd;
+ void (*cb)(struct watch *w, uint32_t events);
+};
+
+struct waltham_display {
+ struct wth_connection *connection;
+ struct watch conn_watch;
+ struct wth_display *display;
+
+ bool running;
+
+ struct wthp_registry *registry;
+
+ struct wthp_callback *bling;
+
+ struct wthp_compositor *compositor;
+ struct wthp_blob_factory *blob_factory;
+ struct wthp_seat *seat;
+ struct wthp_pointer *pointer;
+ struct wthp_keyboard *keyboard;
+ struct wthp_touch *touch;
+ struct wthp_ivi_application *application;
+ struct wthp_ivi_app_id *application_id;
+ struct wtimer *fiddle_timer;
+
+ struct weston_transmitter_remote *remote;
+ char *addr;
+ char *port;
+};
+
+/* a timerfd based timer */
+struct wtimer {
+ struct watch watch;
+ void (*func)(struct wtimer *, void *);
+ void *data;
+};
+
+struct weston_transmitter {
+ struct weston_compositor *compositor;
+ struct wl_listener compositor_destroy_listener;
+
+ struct wl_list remote_list; /* transmitter_remote::link */
+
+ struct wl_listener stream_listener;
+ struct wl_signal connected_signal;
+ struct wl_event_loop *loop;
+
+ struct waltham_renderer_interface *waltham_renderer;
+};
+
+struct weston_transmitter_remote {
+ struct weston_transmitter *transmitter;
+ struct wl_list link;
+ char *model;
+ char *addr;
+ char *port;
+ int32_t width;
+ int32_t height;
+
+ enum weston_transmitter_connection_status status;
+ struct wl_signal connection_status_signal;
+ struct wl_signal conn_establish_signal;
+
+ struct wl_list output_list; /* weston_transmitter_output::link */
+ struct wl_list surface_list; /* weston_transmitter_surface::link */
+ struct wl_list seat_list; /* weston_transmitter_seat::link */
+
+ struct wl_listener establish_listener;
+
+ struct wl_event_source *establish_timer; /* for establish connection */
+ struct wl_event_source *retry_timer; /* for retry connection */
+
+ struct waltham_display *display; /* waltham */
+ struct wl_event_source *source;
+};
+
+
+struct weston_transmitter_surface {
+ struct weston_transmitter_remote *remote;
+ struct wl_list link; /* weston_transmitter_remote::surface_list */
+ struct wl_signal destroy_signal; /* data: weston_transmitter_surface */
+
+ enum weston_transmitter_stream_status status;
+ struct wl_signal stream_status_signal;
+
+ struct weston_surface *surface;
+ struct wl_listener surface_destroy_listener;
+ const struct ivi_layout_interface *lyt; /* not needed anymore, please remove */
+
+ weston_transmitter_ivi_resize_handler_t resize_handler;
+ void *resize_handler_data;
+
+ struct weston_output *sync_output;
+ struct wl_listener sync_output_destroy_listener;
+
+ int32_t attach_dx; /**< wl_surface.attach(buffer, dx, dy) */
+ int32_t attach_dy; /**< wl_surface.attach(buffer, dx, dy) */
+ struct wl_list frame_callback_list; /* weston_frame_callback::link */
+ struct wl_list feedback_list; /* weston_presentation_feedback::link */
+
+ /* waltham */
+ struct wthp_surface *wthp_surf;
+ struct wthp_blob_factory *wthp_blob;
+ struct wthp_buffer *wthp_buf;
+ struct wthp_ivi_surface *wthp_ivi_surface;
+ struct wthp_ivi_application *wthp_ivi_application;
+};
+
+struct weston_transmitter_output_info {
+ uint32_t subpixel; /* enum wl_output_subpixel */
+ uint32_t transform; /* enum wl_output_transform */
+ int32_t scale;
+ int32_t x;
+ int32_t y;
+ int32_t width_mm;
+ int32_t height_mm;
+ /* char *make; is WESTON_TRANSMITTER_OUTPUT_MAKE */
+ char *model;
+
+ struct weston_mode mode;
+};
+
+struct weston_transmitter_output {
+ struct weston_output base;
+
+ struct {
+ bool draw_initial_frame;
+ struct wl_surface *surface;
+ struct wl_output *output;
+ struct wl_display *display;
+ int configure_width, configure_height;
+ bool wait_for_configure;
+ } parent;
+
+ const char *name;
+ struct weston_transmitter_remote *remote;
+ struct wl_list link; /* weston_transmitter_remote::output_list */
+
+ struct frame *frame;
+ struct wl_event_source *finish_frame_timer;
+ struct wl_callback *frame_cb;
+ struct renderer *renderer;
+};
+
+struct weston_transmitter_seat {
+ struct weston_seat *base;
+ struct wl_list link;
+
+ /* pointer */
+ wl_fixed_t pointer_surface_x;
+ wl_fixed_t pointer_surface_y;
+
+ struct wl_listener get_pointer_listener;
+ struct weston_transmitter_surface *pointer_focus;
+ struct wl_listener pointer_focus_destroy_listener;
+
+ struct wl_event_source *pointer_timer; /* fake */
+
+ double pointer_phase; /* fake */
+
+ /* keyboard */
+ struct weston_transmitter_surface *keyboard_focus;
+
+ /* touch */
+ struct weston_transmitter_surface *touch_focus;
+};
+
+struct ivi_layout_surface {
+ struct wl_list link; /* ivi_layout::surface_list */
+ struct wl_signal property_changed;
+ int32_t update_count;
+ uint32_t id_surface;
+
+ struct ivi_layout *layout;
+ struct weston_surface *surface;
+
+ struct ivi_layout_surface_properties prop;
+
+ struct {
+ struct ivi_layout_surface_properties prop;
+ } pending;
+
+ struct wl_list view_list; /* ivi_layout_view::surf_link */
+};
+
+void
+transmitter_surface_ivi_resize(struct weston_transmitter_surface *txs,
+ int32_t width, int32_t height);
+
+int
+transmitter_remote_create_output(struct weston_transmitter_remote *remote,
+ const struct weston_transmitter_output_info *info);
+int
+transmitter_remote_create_output_with_name(struct weston_transmitter_remote *remote, char *name);
+
+void
+transmitter_output_destroy(struct weston_transmitter_output *output);
+
+int
+transmitter_remote_create_seat(struct weston_transmitter_remote *remote);
+
+void
+transmitter_seat_destroy(struct weston_transmitter_seat *seat);
+
+/* The below are the functions to be called from the network protocol
+ * input event handlers.
+ */
+
+void
+transmitter_seat_pointer_enter(struct weston_transmitter_seat *seat,
+ uint32_t serial,
+ struct weston_transmitter_surface *txs,
+ wl_fixed_t surface_x,
+ wl_fixed_t surface_y);
+
+void
+transmitter_seat_pointer_leave(struct weston_transmitter_seat *seat,
+ uint32_t serial,
+ struct weston_transmitter_surface *txs);
+
+void
+transmitter_seat_pointer_motion(struct weston_transmitter_seat *seat,
+ uint32_t time,
+ wl_fixed_t surface_x,
+ wl_fixed_t surface_y);
+
+void
+transmitter_seat_pointer_button(struct weston_transmitter_seat *seat,
+ uint32_t serial,
+ uint32_t time,
+ uint32_t button,
+ uint32_t state);
+
+void
+transmitter_seat_pointer_axis(struct weston_transmitter_seat *seat,
+ uint32_t time,
+ uint32_t axis,
+ wl_fixed_t value);
+
+void
+transmitter_seat_pointer_frame(struct weston_transmitter_seat *seat);
+
+void
+transmitter_seat_pointer_axis_source(struct weston_transmitter_seat *seat,
+ uint32_t axis_source);
+
+void
+transmitter_seat_pointer_axis_stop(struct weston_transmitter_seat *seat,
+ uint32_t time,
+ uint32_t axis);
+
+void
+transmitter_seat_pointer_axis_discrete(struct weston_transmitter_seat *seat,
+ uint32_t axis,
+ int32_t discrete);
+
+/* Fake functions for mockup testing: */
+
+int
+transmitter_seat_fake_pointer_input(struct weston_transmitter_seat *seat,
+ struct weston_transmitter_surface *txs);
+
+void
+seat_capabilities(struct wthp_seat *wthp_seat,
+ enum wthp_seat_capability caps);
+
+
+
+#endif /* WESTON_TRANSMITTER_PLUGIN_H */
diff --git a/include/transmitter_api.h b/include/transmitter_api.h
new file mode 100644
index 0000000..39b616a
--- /dev/null
+++ b/include/transmitter_api.h
@@ -0,0 +1,283 @@
+/*
+ * Copyright (C) 2017 Advanced Driver Information Technology Joint Venture GmbH
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef WESTON_TRANSMITTER_API_H
+#define WESTON_TRANSMITTER_API_H
+
+#include <libweston/plugin-registry.h>
+
+#include <stdint.h>
+
+/** \file
+ *
+ * This is the Transmitter API published via weston_plugin_api_register().
+ */
+
+struct weston_transmitter;
+struct weston_transmitter_remote;
+struct weston_transmitter_surface;
+struct weston_transmitter_output;
+
+#define WESTON_TRANSMITTER_API_NAME "transmitter_v1"
+
+/** See weston_transmitter_api::remote_get_status */
+enum weston_transmitter_connection_status {
+ /** The connection hand-shake is not yet complete */
+ WESTON_TRANSMITTER_CONNECTION_INITIALIZING,
+
+ /** The connection is live and ready to be used. */
+ WESTON_TRANSMITTER_CONNECTION_READY,
+
+ /** The connection is dead. */
+ WESTON_TRANSMITTER_CONNECTION_DISCONNECTED,
+};
+
+/** See weston_transmitter_api::surface_get_stream_status */
+enum weston_transmitter_stream_status {
+ /** The stream hand-shake is not yet complete. */
+ WESTON_TRANSMITTER_STREAM_INITIALIZING,
+
+ /** The stream is carrying surface content updates as needed. */
+ WESTON_TRANSMITTER_STREAM_LIVE,
+
+ /** The stream has failed and disconnected permanently. */
+ WESTON_TRANSMITTER_STREAM_FAILED,
+};
+
+/** The Transmitter Base API
+ *
+ * Transmitter is a Weston plugin that provides remoting of weston_surfaces
+ * over the network. Shells use this API to create remote connections and
+ * push surfaces over the network. Shells are also responsible for relaying
+ * basic window state changes to Transmitter.
+ *
+ * In addition to the Transmitter Base API, shells also need to use a
+ * shell protocol specific Transmitter API to relay specific window state
+ * changes.
+ */
+struct weston_transmitter_api {
+ /** Fetch the Transmitter plugin context
+ *
+ * \param compositor The compositor instance.
+ * \return The weston_transmitter context, which is always the same
+ * for the given compositor instance.
+ */
+ struct weston_transmitter *
+ (*transmitter_get)(struct weston_compositor *compositor);
+
+ /**
+ * Connect to a remote server via Transmitter.
+ *
+ * \param txr The Transmitter context.
+ * \param status Listener to inform of connection status changes.
+ * \return A handle to the remote connection, or NULL on failure.
+ *
+ * This call attempts to open a connection asynchronously. The
+ * connection is not usable until the listener signals it is ready.
+ * The listener may also signal that the connection failed instead.
+ *
+ * The listener callback argument is the weston_transmitter_remote
+ * returned by this function. Use remote_get_status() to fetch the
+ * current status.
+ *
+ */
+ struct weston_transmitter_remote *
+ (*connect_to_remote)(struct weston_transmitter *txr);
+
+ /**
+ * Retrieve the connection status.
+ *
+ * If the status is WESTON_TRANSMITTER_CONNECTION_DISCONNECTED,
+ * you have to shut the remote down completely. There is no automatic
+ * reconnect.
+ */
+ enum weston_transmitter_connection_status
+ (*remote_get_status)(struct weston_transmitter_remote *remote);
+
+ /**
+ * Destroy/disconnect a remote connection.
+ *
+ * Disconnects if connected, and destroys the connection.
+ * The connection status handler is not called.
+ *
+ * The caller is responsible for destroying all
+ * weston_transmitter_surfaces before calling this.
+ */
+ void
+ (*remote_destroy)(struct weston_transmitter_remote *remote);
+
+ /** Push a weston_surface to be transmitted to a remote.
+ *
+ * \param ws The surface to push.
+ * \param remote The remote connection to use.
+ * \param stream_status Listener for stream status changes.
+ * \return The Transmitter surface handle.
+ *
+ * The surface cannot be visible on the remote until the stream
+ * status listener signals WESTON_TRANSMITTER_STREAM_LIVE. After that,
+ * surface updates made by the application will be automatically
+ * streamed to the remote, and input events from the remote will be
+ * delivered to the application.
+ *
+ * The listener callback argument is the weston_transmitter_surface
+ * returned by this function. Use surface_get_stream_status() to
+ * fetch the current status.
+ */
+ struct weston_transmitter_surface *
+ (*surface_push_to_remote)(struct weston_surface *ws, const char *app_id,
+ struct weston_transmitter_remote *remote,
+ struct wl_listener *stream_status);
+
+ /**
+ * Retrieve the surface content stream status.
+ *
+ * If the status is WESTON_TRANSMITTER_STREAM_FAILED, remoting the
+ * surface has stopped. There is no automatic retry.
+ */
+ enum weston_transmitter_stream_status
+ (*surface_get_stream_status)(struct weston_transmitter_surface *txs);
+
+ /** Stop remoting a weston_surface
+ *
+ * \param txs Transmitter surface handle to be stopped and freed.
+ *
+ * The surface stream status handler is not called.
+ */
+ void
+ (*surface_destroy)(struct weston_transmitter_surface *txs);
+
+ /** Notify of weston_surface being configured
+ *
+ * \param txs The Transmitter surface handle.
+ * \param dx The x delta given in wl_surface.attach request.
+ * \param dy The y delta given in wl_surface.attach request.
+ *
+ * Notifies Transmitter of new surface confguration. Transmitter will
+ * forward the arguments, window state, and reference the buffer for
+ * image transmission.
+ *
+ * Shells are meant to call this function for remoted surfaces in
+ * the weston_surface::configure handler.
+ *
+ * XXX: Is this necessary if we have weston_surface::apply_state_signal?
+ *
+ * Essentially this is just an elaborate way to forward dx,dy.
+ */
+ void
+ (*surface_configure)(struct weston_transmitter_surface *txs,
+ int32_t dx, int32_t dy);
+
+ void
+ (*surface_gather_state)(struct weston_transmitter_surface *txs);
+
+ /** Notify that surface is connected to receiver
+ *
+ * \param txr The Transmitter context.
+ * \param connected_listener Listener for connected_signal.
+ */
+ void
+ (*register_connection_status)(struct weston_transmitter *txr,
+ struct wl_listener *connected_listener);
+
+ /** get weston_surface from weston_transmitter_surface
+ *
+ * \param txs The Transmitter surface.
+ */
+ struct weston_surface *
+ (*get_weston_surface)(struct weston_transmitter_surface *txs);
+
+ struct weston_transmitter_remote *
+ (*get_transmitter_remote)(const char *output_name, struct weston_transmitter *transmitter);
+};
+
+static inline const struct weston_transmitter_api *
+weston_get_transmitter_api(struct weston_compositor *compositor)
+{
+ return weston_plugin_api_get(compositor, WESTON_TRANSMITTER_API_NAME,
+ sizeof(struct weston_transmitter_api));
+}
+
+#define WESTON_TRANSMITTER_IVI_API_NAME "transmitter_ivi_v1"
+
+/** For relaying configure events from Transmitter to shell. */
+typedef void (*weston_transmitter_ivi_resize_handler_t)(void *data,
+ int32_t width,
+ int32_t height);
+
+/** The Transmitter IVI-shell API
+ *
+ * Contains the IVI-shell specifics required to remote an ivi-surface.
+ */
+struct weston_transmitter_ivi_api {
+ /** Set IVI-id for a transmitter surface
+ *
+ * \param txs The transmitted surface.
+ * \param ivi_id The IVI-surface id as specified by the
+ * ivi_application.surface_create request.
+ */
+ void
+ (*set_ivi_id)(struct weston_transmitter_surface *txs, uint32_t ivi_id);
+
+ /** Set callback to relay configure events.
+ *
+ * \param txs The transmitted surface.
+ * \param cb The callback function pointer.
+ * \param data User data to be passed to the callback.
+ *
+ * The arguments to the callback function are user data, and width and
+ * height from the configure event from the remote compositor. The
+ * shell must relay this event to the application.
+ */
+ void
+ (*set_resize_callback)(struct weston_transmitter_surface *txs,
+ weston_transmitter_ivi_resize_handler_t cb,
+ void *data);
+};
+
+static inline const struct weston_transmitter_ivi_api *
+weston_get_transmitter_ivi_api(struct weston_compositor *compositor)
+{
+ return weston_plugin_api_get(compositor,
+ WESTON_TRANSMITTER_IVI_API_NAME,
+ sizeof(struct weston_transmitter_ivi_api));
+}
+
+/** Identifies outputs created by the Transmitter by make */
+#define WESTON_TRANSMITTER_OUTPUT_MAKE "Weston-Transmitter"
+
+/* Remote compositor/output are identified by model */
+
+
+struct renderer {
+ void (*repaint_output)(struct weston_transmitter_output *output);
+ struct GstAppContext *ctx;
+ int32_t dmafd; /* dmafd received from compositor-drm */
+ int buf_stride;
+ int surface_width;
+ int surface_height;
+ bool recorder_enabled;
+};
+
+#endif /* WESTON_TRANSMITTER_API_H */
diff --git a/include/waltham-renderer.h b/include/waltham-renderer.h
new file mode 100644
index 0000000..268a002
--- /dev/null
+++ b/include/waltham-renderer.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2017 Advanced Driver Information Technology GmbH, Advanced Driver Information Technology Corporation, Robert Bosch GmbH, Robert Bosch Car Multimedia GmbH, DENSO Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef TRANSMITTER_WALTHAM_RENDERER_H_
+#define TRANSMITTER_WALTHAM_RENDERER_H_
+
+struct weston_transmitter_output;
+
+struct waltham_renderer_interface {
+ int (*display_create)(struct weston_transmitter_output *output);
+};
+
+struct gst_settings {
+ int width;
+ int height;
+ int bitrate;
+ char *ip;
+ int port;
+};
+
+#endif /* TRANSMITTER_WALTHAM_RENDERER_H_ */