diff options
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); |