diff options
author | Luis de Arquer <ldearquer@gmail.com> | 2015-02-21 12:33:17 +0000 |
---|---|---|
committer | Luis de Arquer <ldearquer@gmail.com> | 2015-02-21 12:33:17 +0000 |
commit | ae5102cc4583fe0da11b4d9dc89d5eda60e14842 (patch) | |
tree | ecedd776cbd0363ca3ee4f70915c1dbe2a88c64e | |
parent | fe19ac0b13d16e8dbcf53bcebd0ec7e2981fadba (diff) |
Add support for MJPEG streams using multipartmux
-rw-r--r-- | http-launch/src/http-launch.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/http-launch/src/http-launch.c b/http-launch/src/http-launch.c index 7071b1e..23519f1 100644 --- a/http-launch/src/http-launch.c +++ b/http-launch/src/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) { |