From de8358d7df88d7642f4bc23c761935e27828ddb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sun, 25 Nov 2007 19:21:40 +0000 Subject: [PATCH] HTSP media stream muxer --- htsp_muxer.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++ htsp_muxer.h | 28 +++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 htsp_muxer.c create mode 100644 htsp_muxer.h diff --git a/htsp_muxer.c b/htsp_muxer.c new file mode 100644 index 00000000..34882910 --- /dev/null +++ b/htsp_muxer.c @@ -0,0 +1,116 @@ +/* + * tvheadend, HTSP streaming + * Copyright (C) 2007 Andreas Öman + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tvhead.h" +#include "channels.h" +#include "subscriptions.h" +#include "dispatch.h" +#include "epg.h" +#include "pvr.h" +#include "htsp_muxer.h" + + + +/* + * Called when a subscription gets/loses access to a transport + */ +static void +client_subscription_callback(struct th_subscription *s, + subscription_event_t event, void *opaque) +{ + htsp_connection_t *hc = opaque; + + switch(event) { + case TRANSPORT_AVAILABLE: + break; + + case TRANSPORT_UNAVAILABLE: + break; + } +} + +/* + * + */ +void +htsp_muxer_subscribe(htsp_connection_t *hc, th_channel_t *ch, int weight) +{ + th_subscription_t *s; + th_muxer_t *m; + + LIST_FOREACH(s, &hc->hc_subscriptions, ths_subscriber_link) { + if(s->ths_channel == ch) { + subscription_set_weight(s, weight); + return; + } + } + + m = calloc(1, sizeof(th_muxer_t)); + + LIST_INSERT_HEAD(&hc->hc_subscriptions, s, ths_subscriber_link); +} + +/* + * + */ +void +htsp_muxer_unsubscribe(htsp_connection_t *hc, th_channel_t *ch) +{ + th_subscription_t *s; + htsp_muxerer_t *htsp; + + LIST_FOREACH(s, &hc->hc_subscriptions, ths_subscriber_link) { + if(s->ths_channel == ch) + break; + } + + if(s != NULL) { + LIST_REMOVE(s, ths_subscriber_link); + free(s->hs_opaque); + subscription_unsubscribe(s); + } +} + +/* + * + */ +void +htsp_muxer_cleanup(htsp_connection_t *hc) +{ + th_subscription_t *s; + + while((s = LIST_FIRST(&hc->hc_subscriptions)) != NULL) { + LIST_REMOVE(s, ths_subscriber_link); + subscription_unsubscribe(s); + } +} + diff --git a/htsp_muxer.h b/htsp_muxer.h new file mode 100644 index 00000000..8367d8f6 --- /dev/null +++ b/htsp_muxer.h @@ -0,0 +1,28 @@ +/* + * tvheadend, HTSP streaming + * Copyright (C) 2007 Andreas Öman + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef HTSP_MUXER_H_ +#define HTSP_MUXER_H_ + +void htsp_muxer_subscribe(htsp_t *htsp, th_channel_t *ch, int weight); + +void htsp_muxer_unsubscribe(htsp_t *htsp, th_channel_t *ch); + +void htsp_muxer_cleanup(htsp_t *htsp); + +#endif /* HTSP_MUXER_H_ */