Commit 98489099 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf
Browse files

libndi: Allow setting initial tally state

parent c4b32a1a
......@@ -445,28 +445,6 @@ ndi_ctx *libndi_init(void)
return NULL;
}
/* Create and scramble request messages */
char *tx_msgs[4] = {
"<ndi_version text=\"3\" video=\"4\" audio=\"3\" sdk=\"3.5.1\" platform=\"LINUX\"/>",
"<ndi_video quality=\"high\"/>",
"<ndi_enabled_streams video=\"true\" audio=\"true\" text=\"true\"/>",
"<ndi_tally on_program=\"true\" on_preview=\"false\"/>"
};
for(size_t i = 0; i < sizeof(tx_msgs) / sizeof(*tx_msgs); i++) {
size_t payload_len = strlen(tx_msgs[i]) + 1;
ndi_message *ndi_request = &ndi_ctx->ndi_request[i];
ndi_request->buf = calloc(1, payload_len + 20);
if(!ndi_request->buf)
goto end;
int dst_len = 0;
create_text_message(ndi_request->buf, &dst_len, tx_msgs[i], payload_len);
ndi_scramble_type1(ndi_request->buf+12, 8+payload_len, 8+payload_len);
ndi_request->len = dst_len;
}
ndi_ctx->pending_requests = 4;
ndi_ctx->fifo = av_fifo_alloc(10000);
if(!ndi_ctx->fifo)
goto end;
......@@ -508,6 +486,41 @@ int libndi_setup(ndi_ctx *ndi_ctx, ndi_opts *ndi_opts)
return -1;
}
/* Create and scramble request messages */
char *tx_msgs[4] = {
"<ndi_version text=\"3\" video=\"4\" audio=\"3\" sdk=\"3.5.1\" platform=\"LINUX\"/>",
"<ndi_video quality=\"high\"/>",
"<ndi_enabled_streams video=\"true\" audio=\"true\" text=\"true\"/>",
};
char tally_msg[64];
int ret = snprintf(tally_msg, sizeof(tally_msg),
"<ndi_tally on_program=\"%s\" on_preview=\"%s\"/>",
(ndi_opts->initial_tally_state == NDI_TALLY_LIVE) ? "true" : "false",
(ndi_opts->initial_tally_state == NDI_TALLY_PREVIEW) ? "true" : "false");
if (ret < 0 || ret >= (int)sizeof(tally_msg))
return -1;
tx_msgs[3] = tally_msg;
for(size_t i = 0; i < sizeof(tx_msgs) / sizeof(*tx_msgs); i++) {
size_t payload_len = strlen(tx_msgs[i]) + 1;
ndi_message *ndi_request = &ndi_ctx->ndi_request[i];
ndi_request->buf = calloc(1, payload_len + 20);
if(!ndi_request->buf) {
fprintf(stderr, "Malloc failed \n");
return -1;
}
int dst_len = 0;
create_text_message(ndi_request->buf, &dst_len, tx_msgs[i], payload_len);
ndi_scramble_type1(ndi_request->buf+12, 8+payload_len, 8+payload_len);
ndi_request->len = dst_len;
}
ndi_ctx->pending_requests = 4;
return 0;
}
......
......@@ -33,6 +33,13 @@ enum ndi_data_type
NDI_DATA_TEXT
};
typedef enum ndi_tally_state
{
NDI_TALLY_NONE = 0,
NDI_TALLY_PREVIEW,
NDI_TALLY_LIVE
} ndi_tally_state_t;
#define NDI_NUM_DATA_POINTERS 16
typedef struct
......@@ -89,6 +96,7 @@ typedef struct
{
char *ip;
char *port;
ndi_tally_state_t initial_tally_state;
} ndi_opts;
int libndi_setup(ndi_ctx *ndi_ctx, ndi_opts *ndi_opts);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment