summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis de Arquer <ldearquer@gmail.com>2015-02-21 12:33:17 +0000
committerLuis de Arquer <ldearquer@gmail.com>2015-02-21 12:33:17 +0000
commit9da0c1427371cb2f7498c986577041b07c3f7ed7 (patch)
tree5d88533b865d423b755ca93f02c1357779276d01
parentaaaea24c216f36e7a9d9601c88174dca63ec59f4 (diff)
network/http-launch: Add support for MJPEG streams using multipartmux
-rw-r--r--network/http-launch/http-launch.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/network/http-launch/http-launch.c b/network/http-launch/http-launch.c
index 7071b1e..23519f1 100644
--- a/network/http-launch/http-launch.c
+++ b/network/http-launch/http-launch.c
@@ -41,6 +41,7 @@ static GList *clients = NULL;
static GstElement *pipeline = NULL;
static GstElement *multisocketsink = NULL;
static gboolean started = FALSE;
+static gchar content_type[256];
static void
remove_client (Client * client)
@@ -107,7 +108,7 @@ client_message (Client * client, const gchar * data, guint len)
http_version = "HTTP/1.0";
if (parts[1] && strcmp (parts[1], "/") == 0) {
- response = g_strdup_printf ("%s 200 OK\r\n" "\r\n", http_version);
+ response = g_strdup_printf ("%s 200 OK\r\n%s\r\n", http_version, content_type);
} else {
response = g_strdup_printf ("%s 404 Not Found\r\n\r\n", http_version);
}
@@ -126,7 +127,7 @@ client_message (Client * client, const gchar * data, guint len)
http_version = "HTTP/1.0";
if (parts[1] && strcmp (parts[1], "/") == 0) {
- response = g_strdup_printf ("%s 200 OK\r\n" "\r\n", http_version);
+ response = g_strdup_printf ("%s 200 OK\r\n%s\r\n", http_version, content_type);
ok = TRUE;
} else {
response = g_strdup_printf ("%s 404 Not Found\r\n\r\n", http_version);
@@ -378,6 +379,17 @@ main (gint argc, gchar ** argv)
gst_object_unref (bin);
return -3;
}
+
+ /*
+ * Make the HTTP header 'Content-type' if we are trying to create a
+ * MJPEG (or any other multipart) stream.
+ */
+ if ( strcmp ("GstMultipartMux", g_type_name(G_OBJECT_TYPE(stream)) ) == 0 ) {
+ strcpy (content_type, "Content-Type: "
+ "multipart/x-mixed-replace;boundary=--ThisRandomString\r\n");
+ } else {
+ strcpy (content_type, "");
+ }
srcpad = gst_element_get_static_pad (stream, "src");
if (!srcpad) {