UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
messaging.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2013-2023 CESNET, z. s. p. o.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, is permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * 3. Neither the name of CESNET nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
26 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
28 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#ifndef _MESSAGING_H
39#define _MESSAGING_H
40
41#ifdef __cplusplus
42#include <cstring>
43#else
44#include <stdalign.h>
45#endif
46
47#include "types.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53struct messaging;
54struct module;
55struct response;
56
57#define RESPONSE_OK 200
58#define RESPONSE_ACCEPTED 202
59#define RESPONSE_NO_CONTENT 204
60#define RESPONSE_BAD_REQUEST 400
61#define RESPONSE_NOT_FOUND 404
62#define RESPONSE_REQ_TIMEOUT 408
63#define RESPONSE_INT_SERV_ERR 500
64#define RESPONSE_NOT_IMPL 501
65
66#define RESPONSE_SUCCESSFUL(code) ((code) >= 200 && (code) < 300)
67
68struct message;
69
70struct message {
75 alignas(8) void (*data_deleter)(struct message *);
76
77 // following members are used internally and should not be touched anyhow
78 // except from messaging.cpp
79 void (*send_response)(void *priv_data, struct response *);
80 void *priv_data;
81};
82
94
95struct msg_sender {
96 struct message m;
98 union {
99 struct {
102 };
103 char receiver[128];
104 char fec_cfg[1024];
105 };
106};
107
119 struct message m;
121 union {
122 uint16_t new_rx_port;
123 struct video_desc new_desc;
124 char postprocess_cfg[1024];
125 };
126};
127
132
138
139struct msg_stats {
140 struct message m;
141 char what[128];
142 int value;
143};
144
150#ifdef __cplusplus
151 msg_universal(const char *contents) {
152 memset(&m, 0, sizeof m);
153 strncpy(text, contents, sizeof text - 1);
154 }
155#endif
156 struct message m;
157 char text[8192];
158};
159
160#define MSG_UNIVERSAL_TAG_TX "TX_msg "
161
162struct response *new_response(int status, const char *optional_message);
163void free_response(struct response *r);
164int response_get_status(struct response *r);
165const char *response_get_text(struct response *r);
166
168void module_store_message(struct module *node, struct message *m);
169
170struct response *send_message(struct module *, const char *path, struct message *msg) __attribute__ ((warn_unused_result));
171#define SEND_MESSAGE_FLAG_QUIET (1<<0)
172#define SEND_MESSAGE_FLAG_NO_STORE (1<<1)
173struct response *send_message_sync(struct module *, const char *path, struct message *msg, int timeout_ms, int flags) __attribute__ ((warn_unused_result));
174struct response *send_message_to_receiver(struct module *, struct message *msg) __attribute__ ((warn_unused_result));
175struct message *new_message(size_t length) __attribute__ ((warn_unused_result));
176void free_message(struct message *m, struct response *r);
177const char *response_status_to_text(int status);
178
179struct message *check_message(struct module *);
180
181void free_message_for_child(void *m, struct response *r);
182
183#ifdef __cplusplus
184}
185#endif
186
187#endif// _MESSAGING_H
188
const char unsigned int flags
void free_message(struct message *m, struct response *r)
msg_sender_type
Definition messaging.h:83
@ SENDER_MSG_MUTE_TOGGLE
Definition messaging.h:89
@ SENDER_MSG_RESET_SSRC
Definition messaging.h:92
@ SENDER_MSG_QUERY_VIDEO_MODE
Definition messaging.h:91
@ SENDER_MSG_GET_STATUS
Definition messaging.h:86
@ SENDER_MSG_MUTE
Definition messaging.h:87
@ SENDER_MSG_CHANGE_FEC
Definition messaging.h:90
@ SENDER_MSG_CHANGE_RECEIVER
Definition messaging.h:84
@ SENDER_MSG_UNMUTE
Definition messaging.h:88
@ SENDER_MSG_CHANGE_PORT
Definition messaging.h:85
struct message * new_message(size_t length) __attribute__((warn_unused_result))
void module_store_message(struct module *node, struct message *m)
void module_check_undelivered_messages(struct module *)
Sends message with waiting for response.
void free_message_for_child(void *m, struct response *r)
Definition messaging.cpp:99
compress_change_type
Definition messaging.h:128
@ CHANGE_COMPRESS
Definition messaging.h:129
@ CHANGE_PARAMS
Definition messaging.h:130
struct response * new_response(int status, const char *optional_message)
struct response * send_message_to_receiver(struct module *, struct message *msg) __attribute__((warn_unused_result))
int response_get_status(struct response *r)
msg_receiver_type
Definition messaging.h:108
@ RECEIVER_MSG_MUTE_TOGGLE
Definition messaging.h:116
@ RECEIVER_MSG_DECREASE_VOLUME
Definition messaging.h:113
@ RECEIVER_MSG_UNMUTE
Definition messaging.h:115
@ RECEIVER_MSG_CHANGE_RX_PORT
Definition messaging.h:109
@ RECEIVER_MSG_INCREASE_VOLUME
Definition messaging.h:112
@ RECEIVER_MSG_MUTE
Definition messaging.h:114
@ RECEIVER_MSG_GET_AUDIO_STATUS
Definition messaging.h:111
@ RECEIVER_MSG_VIDEO_PROP_CHANGED
Definition messaging.h:110
struct response * send_message_sync(struct module *, const char *path, struct message *msg, int timeout_ms, int flags) __attribute__((warn_unused_result))
Sends message without waiting for response.
struct message * check_message(struct module *)
struct response * send_message(struct module *, const char *path, struct message *msg) __attribute__((warn_unused_result))
Sends message without waiting for response.
void free_response(struct response *r)
const char * response_status_to_text(int status)
const char * response_get_text(struct response *r)
struct __attribute__((packed))
Definition rtp.h:88
void * priv_data
Definition messaging.h:80
void(* send_response)(void *priv_data, struct response *)
Definition messaging.h:79
void(* data_deleter)(struct message *)
Definition messaging.h:75
enum compress_change_type what
Definition messaging.h:135
uint16_t new_rx_port
Definition messaging.h:122
struct message m
Definition messaging.h:119
enum msg_receiver_type type
Definition messaging.h:120
struct message m
Definition messaging.h:96
enum msg_sender_type type
Definition messaging.h:97
struct message m
Definition messaging.h:140
char what[128]
Definition messaging.h:141
msg_universal(const char *contents)
Definition messaging.h:151
struct message m
Definition messaging.h:156
char text[8192]
Definition messaging.h:157
This file contains some common data types.