]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
create a subscription to a channel and output the content-type
authorsb1066 <sb1066@gmail.com>
Wed, 7 Jul 2010 20:20:31 +0000 (20:20 +0000)
committersb1066 <sb1066@gmail.com>
Wed, 7 Jul 2010 20:20:31 +0000 (20:20 +0000)
src/http.c

index ab856e0b5023c3da313541b029cf2428094f432f..6f317a12f162335c313914acd107a75130beed9b 100644 (file)
@@ -35,6 +35,8 @@
 #include "rtsp.h"
 #include "access.h"
 #include "channels.h"
+#include "subscriptions.h"
+#include "streaming.h"
 
 static void *http_server;
 
@@ -784,6 +786,13 @@ http_serve(int fd, void *opaque, struct sockaddr_in *peer,
   close(fd);
 }
 
+static void
+http_stream_run(http_connection_t *hc, streaming_queue_t *sq)
+{
+        http_output_content(hc, "audio/mp2t");
+}
+
+
 static void
 http_stream_playlist(http_connection_t *hc)
 {
@@ -808,6 +817,35 @@ http_stream_playlist(http_connection_t *hc)
 static int
 http_stream_channel(http_connection_t *hc, int chid)
 {
+  channel_t *ch;
+  streaming_queue_t sq;
+  th_subscription_t *s;
+  int priority = 150; //Default value, Compute this somehow
+
+  pthread_mutex_lock(&global_lock);
+
+  if((ch = channel_find_by_identifier(chid)) == NULL) {
+    pthread_mutex_unlock(&global_lock);
+    http_error(hc, HTTP_STATUS_BAD_REQUEST);
+    return HTTP_STATUS_BAD_REQUEST;
+  }
+
+  streaming_queue_init(&sq, ~SMT_TO_MASK(SUBSCRIPTION_RAW_MPEGTS));
+
+  s = subscription_create_from_channel(ch, priority, 
+                                       "HTTP", &sq.sq_st,
+                                       SUBSCRIPTION_RAW_MPEGTS);
+
+
+  pthread_mutex_unlock(&global_lock);
+
+  http_stream_run(hc, &sq);
+
+  pthread_mutex_lock(&global_lock);
+  subscription_unsubscribe(s);
+  pthread_mutex_unlock(&global_lock);
+  streaming_queue_deinit(&sq);
+
   return 0;
 }