From 91c6003d8097161998706c674c51c1da7051646e Mon Sep 17 00:00:00 2001 From: sb1066 Date: Wed, 7 Jul 2010 20:20:31 +0000 Subject: [PATCH] create a subscription to a channel and output the content-type --- src/http.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/http.c b/src/http.c index ab856e0b..6f317a12 100644 --- a/src/http.c +++ b/src/http.c @@ -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; }