summaryrefslogtreecommitdiffstats
path: root/waltham-transmitter
diff options
context:
space:
mode:
authorfukubayashi.akio <fukubayashi.akio@genetec.co.jp>2019-05-31 15:56:15 +0900
committerfukubayashi.akio <fukubayashi.akio@genetec.co.jp>2019-05-31 15:56:15 +0900
commitd91dd6cd072a96c544ecf82fa8dd86765b215aec (patch)
tree58329cc3d3b6871ac5716d7bb4a1c12a8f28d0e2 /waltham-transmitter
parentcd33a17ea5ac787786e5289ec914a96adeaf6346 (diff)
Add multi transfer
Signed-off-by: fukubayashi.akio <fukubayashi.akio@genetec.co.jp>
Diffstat (limited to 'waltham-transmitter')
-rw-r--r--waltham-transmitter/transmitter-plugin/CMakeLists.txt4
-rw-r--r--waltham-transmitter/transmitter-plugin/output.c4
-rw-r--r--waltham-transmitter/transmitter-plugin/plugin.c175
-rw-r--r--waltham-transmitter/transmitter-plugin/transmitter_api.h1
-rw-r--r--waltham-transmitter/waltham-renderer/waltham-renderer.c9
5 files changed, 154 insertions, 39 deletions
diff --git a/waltham-transmitter/transmitter-plugin/CMakeLists.txt b/waltham-transmitter/transmitter-plugin/CMakeLists.txt
index d751870..299357a 100644
--- a/waltham-transmitter/transmitter-plugin/CMakeLists.txt
+++ b/waltham-transmitter/transmitter-plugin/CMakeLists.txt
@@ -5,6 +5,7 @@ pkg_check_modules(WAYLAND_SERVER wayland-server>=1.13.0 REQUIRED)
pkg_check_modules(WESTON weston>=2.0.0 REQUIRED)
pkg_check_modules(PIXMAN pixman-1 REQUIRED)
pkg_check_modules(WALTHAM waltham REQUIRED)
+pkg_check_modules(JSON-C json-c REQUIRED)
include_directories(
include
@@ -15,6 +16,7 @@ include_directories(
${WESTON_INCLUDE_DIRS}
${PIXMAN_INCLUDE_DIRS}
${WALTHAM_INCLUDE_DIRS}
+ ${JSON-C_INCLUDE_DIR}
)
link_directories(
@@ -22,6 +24,7 @@ link_directories(
${WESTON_LIBRARY_DIRS}
${PIXMAN_LIBRARY_DIRS}
${WALTHAM_LIBRARY_DIRS}
+ ${JSON-C_LIBRARY_DIRS}
)
add_library(${PROJECT_NAME} MODULE
@@ -40,6 +43,7 @@ set(LIBS
${WESTON_LIBRARIES}
${PIXMAN_LIBRARIES}
${WALTHAM_LIBRARIES}
+ ${JSON-C_LIBRARIES}
)
SET(SRC_FILES
diff --git a/waltham-transmitter/transmitter-plugin/output.c b/waltham-transmitter/transmitter-plugin/output.c
index 6768eee..f5b1c21 100644
--- a/waltham-transmitter/transmitter-plugin/output.c
+++ b/waltham-transmitter/transmitter-plugin/output.c
@@ -192,8 +192,8 @@ transmitter_output_repaint(struct weston_output *base,
(view->surface, remote, NULL);
output->renderer->dmafd =
- api->get_dma_fd_from_view(&output->base, view, &output->renderer->buf_stride);
- if(output->renderer->dmafd < 0) {
+ api->get_dma_fd_from_view(&output->base, view);
+ if(!output->renderer->dmafd) {
weston_log("Failed to get dmafd\n");
goto out;
}
diff --git a/waltham-transmitter/transmitter-plugin/plugin.c b/waltham-transmitter/transmitter-plugin/plugin.c
index 92510c2..9cd26f9 100644
--- a/waltham-transmitter/transmitter-plugin/plugin.c
+++ b/waltham-transmitter/transmitter-plugin/plugin.c
@@ -27,6 +27,7 @@
#include <assert.h>
#include <string.h>
#include <linux/input.h>
+#include <json-c/json.h>
#include "compositor.h"
@@ -47,6 +48,7 @@
#define MAX_EPOLL_WATCHES 2
#define ESTABLISH_CONNECTION_PERIOD 2000
#define RETRY_CONNECTION_PERIOD 5000
+#define WTH_CONNECTION_PATH "/etc/hmi-config/connection.json"
/* XXX: all functions and variables with a name, and things marked with a
* comment, containing the word "fake" are mockups that need to be
@@ -151,8 +153,6 @@ transmitter_surface_gather_state(struct weston_transmitter_surface *txs)
wthp_surface_commit(txs->wthp_surf);
wth_connection_flush(remote->display->connection);
- free(data);
- data=NULL;
txs->attach_dx = 0;
txs->attach_dy = 0;
}
@@ -574,6 +574,8 @@ waltham_client_init(struct waltham_display *dpy)
dpy->running = true;
+ weston_log("Connection IP:%s Port:%s\n", dpy->remote->addr, dpy->remote->port);
+
return 0;
}
@@ -835,6 +837,85 @@ transmitter_create_remote(struct weston_transmitter *txr,
return 0;
}
+int inputJsonFilie(const char *file, json_object **obj)
+{
+ const int input_size = 128;
+ int ret = -1;
+ FILE *fp;
+ struct json_tokener *tokener;
+ enum json_tokener_error json_error;
+ char buffer[input_size];
+ int block_cnt = 1;
+ size_t len;
+
+ weston_log("Input file: %s\n", file);
+
+ // Open json file
+ fp = fopen(file, "rb");
+ if (NULL == fp)
+ {
+ weston_log("Could not open file\n");
+ return ret;
+ }
+
+ // Parse file data
+ tokener = json_tokener_new();
+ while (1)
+ {
+ len = fread(buffer, sizeof(char), input_size, fp);
+ *obj = json_tokener_parse_ex(tokener, buffer, len);
+ if (NULL != *obj)
+ {
+ weston_log("File input is success\n");
+ ret = 0;
+ break;
+ }
+
+ json_error = json_tokener_get_error(tokener);
+ if ((json_tokener_continue != json_error) || (input_size > len))
+ {
+ weston_log("Failed to parse file (byte:%d err:%s)\n",
+ (input_size * block_cnt), json_tokener_error_desc(json_error));
+ weston_log("\n%s\n", buffer);
+ *obj = NULL;
+ break;
+ }
+ block_cnt++;
+ }
+
+ // Close json file
+ fclose(fp);
+
+ // Free json_tokener
+ json_tokener_free(tokener);
+
+ return ret;
+}
+
+const char* getStringFromJson(json_object* obj, const char* key)
+{
+ json_object* tmp;
+ if (!json_object_object_get_ex(obj, key, &tmp))
+ {
+ weston_log("Not found key \"%s\"\n", key);
+ return NULL;
+ }
+
+ return json_object_get_string(tmp);
+}
+
+int getIntFromJson(json_object *obj, const char *key)
+{
+ json_object *tmp;
+ if (!json_object_object_get_ex(obj, key, &tmp))
+ {
+ weston_log("Not found key \"%s\"\n", key);
+ return 0;
+ }
+
+ return json_object_get_int(tmp);
+}
+
struct wet_compositor {
struct weston_config *config;
struct wet_output_config *parsed_options;
@@ -845,48 +926,72 @@ struct wet_compositor {
static void
transmitter_get_server_config(struct weston_transmitter *txr)
{
- struct wet_compositor *compositor =
- (struct wet_compositor *)weston_compositor_get_user_data(txr->compositor);
- struct weston_config *config = wet_get_config(txr->compositor);
- struct weston_config_section *section;
const char *name = NULL;
- char *model = NULL;
- char *addr = NULL;
- char *port = NULL;
- char *width = '0';
- char *height = '0';
+ char model[256] = "";
+ const char *addr = NULL;
+ const char *port = NULL;
+ const char *area = NULL;
+ const char *screen_name = NULL;
+ char width[5] = "0";
+ char height[5] = "0";
int ret;
+ json_object *json_obj, *json_cfg_conn, *json_conn, *json_cfg_area,*json_area;
+ char *conn_path = WTH_CONNECTION_PATH;
+ int conn_len, area_len, i, j;
- section = weston_config_get_section(config, "remote", NULL, NULL);
+ ret = inputJsonFilie(conn_path, &json_obj);
- while (weston_config_next_section(config, &section, &name)) {
- if (0 == strcmp(name, "remote-output")) {
- if (0 != weston_config_section_get_string(section, "output-name",
- &model, 0))
- continue;
+ if (0 > ret)
+ {
+ weston_log("Error Could not open %s\n",conn_path);
+ return;
+ }
- if (0 != weston_config_section_get_string(section, "server-address",
- &addr, 0))
- continue;
+ weston_log("json_obj dump %s\n", json_object_get_string(json_obj));
- if (0 != weston_config_section_get_string(section, "port",
- &port, 0))
- continue;
+ if (!json_object_object_get_ex(json_obj, "connections", &json_cfg_conn))
+ {
+ weston_log("connection.json Parse Error!! Not Found connections\n");
+ return ;
+ }
- if (0 != weston_config_section_get_string(section, "width",
- &width, 0))
- continue;
+ conn_len = json_object_array_length(json_cfg_conn);
- if (0 != weston_config_section_get_string(section, "height",
- &height, 0))
- continue;
- ret = transmitter_create_remote(txr, model, addr,
- port, width, height);
- if (ret < 0) {
+ for (i = 0; i < conn_len; i++)
+ {
+ json_conn = json_object_array_get_idx(json_cfg_conn, i);
+
+ addr = getStringFromJson(json_conn, "ip");
+ screen_name = getStringFromJson(json_conn, "screen_name");
+
+ if (!json_object_object_get_ex(json_conn, "areas", &json_cfg_area))
+ {
+ weston_log("connection.json Parse Error!! Not Found area\n");
+ return;
+ }
+
+ area_len = json_object_array_length(json_cfg_area);
+
+ for (j = 0; j < area_len; j++)
+ {
+ json_area = json_object_array_get_idx(json_cfg_area, j);
+
+ area = getStringFromJson(json_area, "area_name");
+ port = getStringFromJson(json_area, "transmitter_port");
+ sprintf(width, "%d", getIntFromJson(json_area, "width"));
+ sprintf(height, "%d", getIntFromJson(json_area, "height"));
+ sprintf(model, "%s_%s:%s", "transmitter", screen_name, area);
+
+ weston_log("model:%s addr:%s port:%s area:%s width:%s height:%s\n", model, addr, port, area, width, height);
+ ret = transmitter_create_remote(txr, model, addr,
+ port, width, height);
+
+ if (ret < 0)
+ {
weston_log("Fatal: Transmitter create_remote failed.\n");
- }
- }
- }
+ }
+ }
+ }
}
WL_EXPORT int
diff --git a/waltham-transmitter/transmitter-plugin/transmitter_api.h b/waltham-transmitter/transmitter-plugin/transmitter_api.h
index 9f382bf..9b3e5fe 100644
--- a/waltham-transmitter/transmitter-plugin/transmitter_api.h
+++ b/waltham-transmitter/transmitter-plugin/transmitter_api.h
@@ -270,7 +270,6 @@ struct renderer {
void (*repaint_output)(struct weston_output *base);
struct GstAppContext *ctx;
int32_t dmafd; /* dmafd received from compositor-drm */
- int buf_stride;
int surface_width;
int surface_height;
bool recorder_enabled;
diff --git a/waltham-transmitter/waltham-renderer/waltham-renderer.c b/waltham-transmitter/waltham-renderer/waltham-renderer.c
index 76e045c..a475735 100644
--- a/waltham-transmitter/waltham-renderer/waltham-renderer.c
+++ b/waltham-transmitter/waltham-renderer/waltham-renderer.c
@@ -169,6 +169,13 @@ gst_pipe_init(struct weston_transmitter_output *output, struct gst_settings *set
NULL);
gst_caps_unref(caps);
+ GstElement *sink = gst_bin_get_by_name(GST_BIN(gstctx->pipeline), "sink");
+ gchar *g_host = (gchar *)output->remote->addr;
+ gint g_port = (gint)atoi(output->remote->port);
+ g_object_set(G_OBJECT(sink), "host", g_host, "port", g_port, NULL);
+
+ weston_log("Parsing GST pipeline:%s",pipe);
+
gst_element_set_state((GstElement*)((void*)gstctx->pipeline), GST_STATE_PLAYING);
output->renderer->ctx = gstctx;
@@ -223,7 +230,7 @@ static void waltham_renderer_repaint_output(struct weston_transmitter_output *ou
GstBuffer *gstbuffer;
GstMemory *mem;
GstAllocator *allocator;
- int stride = output->renderer->buf_stride;
+ int stride = output->renderer->surface_width * 4;
gsize offset = 0;
if(!output->renderer->recorder_enabled)