From 751ad9ad65fc193f66e1156856919c8ad7b45182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Tue, 7 Jul 2009 18:17:54 +0000 Subject: [PATCH] Add '-j ' option that performs a static subscription for a transport. Useful when debugging. --- src/main.c | 9 ++++++++- src/subscriptions.c | 32 ++++++++++++++++++++++++++++++++ src/subscriptions.h | 2 ++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index c5124b25..19911411 100644 --- a/src/main.c +++ b/src/main.c @@ -230,8 +230,9 @@ main(int argc, char **argv) const char *contentpath = TVHEADEND_CONTENT_PATH; const char *homedir = NULL; const char *rawts_input = NULL; + const char *join_transport = NULL; - while((c = getopt(argc, argv, "fu:g:c:Chdr:")) != -1) { + while((c = getopt(argc, argv, "fu:g:c:Chdr:j:")) != -1) { switch(c) { case 'f': forkaway = 1; @@ -254,6 +255,9 @@ main(int argc, char **argv) case 'r': rawts_input = optarg; break; + case 'j': + join_transport = optarg; + break; default: usage(argv[0]); } @@ -347,6 +351,9 @@ main(int argc, char **argv) if(rawts_input != NULL) rawts_init(rawts_input); + if(join_transport != NULL) + subscription_dummy_join(join_transport); + pthread_mutex_unlock(&global_lock); diff --git a/src/subscriptions.c b/src/subscriptions.c index 32988217..635c6ec0 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -255,3 +255,35 @@ subscription_create_from_transport(th_transport_t *t, const char *name, subscription_link_transport(s, t); return s; } + + +/** + * + */ +static void +dummy_callback(void *opauqe, streaming_message_t *sm) +{ + streaming_msg_free(sm); +} + + +/** + * + */ +void +subscription_dummy_join(const char *id) +{ + th_transport_t *t = transport_find_by_identifier(id); + streaming_target_t *st; + + if(t == NULL) { + tvhlog(LOG_ERR, "subscription", + "Unable to dummy join %s, transport not found", id); + return; + } + + st = calloc(1, sizeof(streaming_target_t)); + streaming_target_init(st, dummy_callback, NULL); + subscription_create_from_transport(t, "dummy", st); + +} diff --git a/src/subscriptions.h b/src/subscriptions.h index b0ed51e2..e3f418c5 100644 --- a/src/subscriptions.h +++ b/src/subscriptions.h @@ -66,4 +66,6 @@ void subscription_stop(th_subscription_t *s); void subscription_unlink_transport(th_subscription_t *s); +void subscription_dummy_join(const char *id); + #endif /* SUBSCRIPTIONS_H */