diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-24 17:56:02 (GMT) |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2014-07-24 20:55:42 (GMT) |
commit | e0d453a3a2c120264b13c44f004025b0330547a8 (patch) | |
tree | 4517a7e8f3100f1f75b4cecd68486b42d4f7f0df /src/lib.h | |
parent | fae0aa58c19a1918e7b7750b4862e2abcbc55788 (diff) | |
download | soup-transcoding-proxy-e0d453a3a2c120264b13c44f004025b0330547a8.zip soup-transcoding-proxy-e0d453a3a2c120264b13c44f004025b0330547a8.tar.gz |
Implement concurrent RTP-UDP streams, and a REST API for status and auth
When the --token-server=ADDR/MASK argument is passed to the server, the token
verification framework is enabled, and the specified subnet is allowed to access
the REST API to add/revoke/list tokens that allow clients to connect, and to
list/abort streams running on the server.
Details about the REST API are documented in the file "REST-API".
There were also some organisational and name changes in the code.
Diffstat (limited to 'src/lib.h')
-rw-r--r-- | src/lib.h | 75 |
1 files changed, 48 insertions, 27 deletions
@@ -27,39 +27,50 @@ #include <gst/gst.h> #include <libsoup/soup.h> -typedef struct _TranscodeServerCtx TranscodeServerCtx; -typedef struct _TranscodeClientCtx TranscodeClientCtx; - -enum stp_stream_status { - STP_STATUS_NONE, - STP_STATUS_STREAMING, - STP_STATUS_FLUSHING, - STP_STATUS_FINISHED, -}; +typedef struct _STPServerCtx STPServerCtx; +typedef struct _STPClientCtx STPClientCtx; +typedef struct _STPStreamToken STPStreamToken; + +#define STP_STREAM_TYPE_INVALID (1 << 0) +#define STP_STREAM_TYPE_HTTP (1 << 1) +#define STP_STREAM_TYPE_RTP_UDP (1 << 2) +#define STP_STREAM_TYPE_RTP_TCP (1 << 3) /* Not supported yet */ +#define STP_STREAM_TYPE_ALL STP_STREAM_TYPE_HTTP | STP_STREAM_TYPE_RTP_UDP -struct _TranscodeServerCtx { +#define STP_STATUS_NONE g_intern_static_string ("none") +#define STP_STATUS_STREAMING g_intern_static_string ("streaming") +#define STP_STATUS_FLUSHING g_intern_static_string ("flushing") +#define STP_STATUS_FINISHED g_intern_static_string ("finished") + +struct _STPServerCtx { SoupMessage *msg; GstElement *pipeline; GstElement *appsrc; - /* If the encoding is not chunked, we'll get multiple requests - * with separate Content-Length headers on the same path */ - SoupEncoding encoding; - /* Set to TRUE when the incoming stream ends; let's us know if + /* Also used as the key in the parent hash table */ + char *sessionid; + /* Comman-separated list of host:port pairs */ + char *udp_clients; + /* RTP or HTTP or both */ + guint stream_type; + /* Keeps track of the stream running status, let's us know if * we need to set the PUT response on EOS/ERROR on the pipeline, * and whether to reject further data when using a persistent * Content-Length + Content-Range PUT stream. */ - enum stp_stream_status status; + const char *status; + + /* If the encoding is not chunked, we'll get multiple requests + * with separate Content-Length headers on the same path */ + SoupEncoding encoding; + guint timeout_handler_id; guint seconds_since_read; /* List of client contexts */ GList *clients; /* Reference to the parent context hash table */ GHashTable *parent_ctx_table; - /* Reference to the key in the parent hash table */ - char *path; }; -struct _TranscodeClientCtx { +struct _STPClientCtx { /* We don't hold refs to any of these */ SoupMessage *msg; GstElement *appsink; @@ -70,7 +81,13 @@ struct _TranscodeClientCtx { gulong finished_handler_id; guint seconds_since_write; /* The transcode server context; we don't hold a ref to this */ - TranscodeServerCtx *server_ctx; + STPServerCtx *server_ctx; +}; + +struct _STPStreamToken { + guint stream_type; + /* Comma-separated host:port list */ + char *udp_clients; }; #ifdef ENCODE_DEBUG @@ -79,18 +96,22 @@ struct _TranscodeClientCtx { #define stp_print_status(...) do {} while (0) #endif -gboolean invoke_g_hash_table_remove (TranscodeServerCtx *ctx); -gboolean invoke_g_free_client_context (TranscodeClientCtx *ctx); +gboolean invoke_g_hash_table_remove (STPServerCtx *ctx); +gboolean invoke_g_free_client_context (STPClientCtx *ctx); + +const char* stp_get_stream_type_string (guint stream_type); +guint stp_get_stream_type_from_string (const char *type); + +gboolean stp_validate_token_server (GInetAddressMask *mask, + SoupClientContext *client); -void stp_cleanup_transcode_server_ctx (TranscodeServerCtx *ctx); -void stp_cleanup_transcode_client_ctx (TranscodeClientCtx *ctx); +void stp_server_ctx_cleanup (STPServerCtx *ctx); +void stp_client_ctx_cleanup (STPClientCtx *ctx); +void stp_stream_token_free (STPStreamToken *token); gboolean stp_on_gst_bus_message (GstBus *bus, GstMessage *msg, - TranscodeServerCtx *ctx); -gboolean stp_unref_gst_buffer (GstBuffer **buffer, - guint idx, - gpointer user_data); + STPServerCtx *ctx); GstBuffer* stp_get_streamheader_from_caps (GstCaps *caps); GstBuffer* stp_get_gst_buffer (SoupBuffer *chunk); |