]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
HTSP: Add possibility to subscribe to a channelName
authorAndreas Öman <andreas@lonelycoder.com>
Tue, 30 Oct 2012 09:37:04 +0000 (10:37 +0100)
committerAndreas Öman <andreas@lonelycoder.com>
Tue, 30 Oct 2012 09:37:04 +0000 (10:37 +0100)
src/htsp_server.c

index 450ff19338595ac15960f7ae3d4f783319b7e4bb..d1f65f602a8ba6a2adb9d76a529193f1298ed694 100644 (file)
@@ -1112,16 +1112,21 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in)
   uint32_t chid, sid, weight, req90khz, normts;
   channel_t *ch;
   htsp_subscription_t *hs;
-
-  if(htsmsg_get_u32(in, "channelId", &chid))
-    return htsp_error("Missing argument 'channelId'");
-
+  const char *str;
   if(htsmsg_get_u32(in, "subscriptionId", &sid))
     return htsp_error("Missing argument 'subscriptionId'");
 
-  if((ch = channel_find_by_identifier(chid)) == NULL)
-    return htsp_error("Requested channel does not exist");
+  if(!htsmsg_get_u32(in, "channelId", &chid)) {
 
+    if((ch = channel_find_by_identifier(chid)) == NULL)
+      return htsp_error("Requested channel does not exist");
+  } else if((str = htsmsg_get_str(in, "channelName")) != NULL) {
+    if((ch = channel_find_by_name(str, 0, 0)) == NULL)
+      return htsp_error("Requested channel does not exist");
+
+  } else {
+    return htsp_error("Missing argument 'channelId' or 'channelName'");
+  }
   weight = htsmsg_get_u32_or_default(in, "weight", 150);
   req90khz = htsmsg_get_u32_or_default(in, "90khz", 0);
   normts = htsmsg_get_u32_or_default(in, "normts", 0);