From bb119bc879d22b49d31a451b5c30736df23fd156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20T=C3=B6rnblom?= Date: Tue, 21 Aug 2012 21:20:23 +0100 Subject: [PATCH] reconfigure muxes when stream source changes (usually on pmt update). --- src/dvr/dvr_rec.c | 2 ++ src/muxer.c | 13 +++++++++++++ src/muxer.h | 3 +++ src/muxer_pass.c | 15 +++++++++++++-- src/muxer_tvh.c | 16 ++++++++++++++++ src/webui/webui.c | 10 +++++++--- 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index c030d0cf..cf8319e0 100755 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -468,6 +468,8 @@ dvr_thread(void *aux) "dvr", "Recording completed: \"%s\"", de->de_filename ?: lang_str_get(de->de_title, NULL)); + } else if(sm->sm_code == SM_CODE_SOURCE_RECONFIGURED) { + muxer_reconfigure(de->de_mux, sm->sm_data); } else { if(de->de_last_error != sm->sm_code) { diff --git a/src/muxer.c b/src/muxer.c index ac69fe92..cd3071fe 100644 --- a/src/muxer.c +++ b/src/muxer.c @@ -225,6 +225,19 @@ muxer_init(muxer_t *m, const struct streaming_start *ss, const char *name) } +/** + * sanity wrapper arround m_reconfigure() + */ +int +muxer_reconfigure(muxer_t *m, const struct streaming_start *ss) +{ + if(!m || !ss) + return -1; + + return m->m_reconfigure(m, ss); +} + + /** * sanity wrapper arround m_open_file() */ diff --git a/src/muxer.h b/src/muxer.h index 1f167192..6fdeb918 100644 --- a/src/muxer.h +++ b/src/muxer.h @@ -42,6 +42,8 @@ typedef struct muxer { int (*m_init) (struct muxer *, // Init The muxer with streams const struct streaming_start *, const char *); + int (*m_reconfigure)(struct muxer *, // Reconfigure the muxer on + const struct streaming_start *); // stream changes int (*m_close) (struct muxer *); // Close the muxer void (*m_destroy) (struct muxer *); // Free the memory int (*m_write_meta) (struct muxer *, struct epg_broadcast *); // Append epg data @@ -65,6 +67,7 @@ muxer_t *muxer_create(struct service *s, muxer_container_type_t mc); int muxer_open_file (muxer_t *m, const char *filename); int muxer_open_stream (muxer_t *m, int fd); int muxer_init (muxer_t *m, const struct streaming_start *ss, const char *name); +int muxer_reconfigure (muxer_t *m, const struct streaming_start *ss); int muxer_close (muxer_t *m); int muxer_destroy (muxer_t *m); int muxer_write_meta (muxer_t *m, struct epg_broadcast *eb); diff --git a/src/muxer_pass.c b/src/muxer_pass.c index af73cc30..b61aa400 100644 --- a/src/muxer_pass.c +++ b/src/muxer_pass.c @@ -90,10 +90,10 @@ pass_muxer_mime(muxer_t* m, const struct streaming_start *ss) /** - * Init the passthrough muxer with streams + * Generate the pmt and pat from a streaming start message */ static int -pass_muxer_init(muxer_t* m, const struct streaming_start *ss, const char *name) +pass_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss) { pass_muxer_t *pm = (pass_muxer_t*)m; @@ -128,6 +128,16 @@ pass_muxer_init(muxer_t* m, const struct streaming_start *ss, const char *name) } +/** + * Init the passthrough muxer with streams + */ +static int +pass_muxer_init(muxer_t* m, const struct streaming_start *ss, const char *name) +{ + return pass_muxer_reconfigure(m, ss); +} + + /** * Open the muxer as a stream muxer (using a non-seekable socket) */ @@ -303,6 +313,7 @@ pass_muxer_create(service_t *s, muxer_container_type_t mc) pm->m_open_stream = pass_muxer_open_stream; pm->m_open_file = pass_muxer_open_file; pm->m_init = pass_muxer_init; + pm->m_reconfigure = pass_muxer_reconfigure; pm->m_mime = pass_muxer_mime; pm->m_write_meta = pass_muxer_write_meta; pm->m_write_pkt = pass_muxer_write_pkt; diff --git a/src/muxer_tvh.c b/src/muxer_tvh.c index 7708b206..6d5a0de1 100644 --- a/src/muxer_tvh.c +++ b/src/muxer_tvh.c @@ -79,6 +79,21 @@ tvh_muxer_init(muxer_t* m, const struct streaming_start *ss, const char *name) } +/** + * Multisegment matroska files do exist but I am not sure if they are supported + * by many media players. For now, we'll treat it as an error. + */ +static int +tvh_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss) +{ + tvh_muxer_t *tm = (tvh_muxer_t*)m; + + tm->m_errors++; + + return -1; +} + + /** * Open the muxer as a stream muxer (using a non-seekable socket) */ @@ -196,6 +211,7 @@ tvh_muxer_create(muxer_container_type_t mc) tm->m_open_file = tvh_muxer_open_file; tm->m_mime = tvh_muxer_mime; tm->m_init = tvh_muxer_init; + tm->m_reconfigure = tvh_muxer_reconfigure; tm->m_write_meta = tvh_muxer_write_meta; tm->m_write_pkt = tvh_muxer_write_pkt; tm->m_close = tvh_muxer_close; diff --git a/src/webui/webui.c b/src/webui/webui.c index 14766b74..fb22dbd0 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -213,9 +213,13 @@ http_stream_run(http_connection_t *hc, streaming_queue_t *sq, break; case SMT_STOP: - tvhlog(LOG_WARNING, "webui", "Stop streaming %s, %s", hc->hc_url_orig, - streaming_code2txt(sm->sm_code)); - run = 0; + if(sm->sm_code == SM_CODE_SOURCE_RECONFIGURED) { + muxer_reconfigure(mux, sm->sm_data); + } else { + tvhlog(LOG_WARNING, "webui", "Stop streaming %s, %s", hc->hc_url_orig, + streaming_code2txt(sm->sm_code)); + run = 0; + } break; case SMT_SERVICE_STATUS: