Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/subscriptions.c b/src/subscriptions.c
- index 276cade..26a2a96 100644
- --- a/src/subscriptions.c
- +++ b/src/subscriptions.c
- @@ -1225,3 +1225,32 @@ void subscription_log(th_subscription_t *s, int on)
- }
- }
- +int subscription_get_user_count_on_other_muxes(char *username, tvh_uuid_t mux_uuid)
- +{
- + th_subscription_t *s;
- + int count;
- +
- + tvhinfo("dbg", "listing subscriptions for %s on other muxes", username);
- +
- + count = 0;
- +
- + LIST_FOREACH(s, &subscriptions, ths_global_link) {
- + tvhinfo("dbg", "=>chan=0x%x, srv=0x%x", s->ths_channel?1:0, s->ths_service?1:0);
- + if (s->ths_service)
- + {
- + source_info_t si;
- + s->ths_service->s_setsourceinfo(s->ths_service, &si);
- + tvhinfo("dbg", "subscription from %s on %s", s->ths_username?:"no-user", s->ths_channel->ch_name);
- + if (s->ths_username && username && !strcmp(username, s->ths_username) && uuid_cmp(&si.si_mux_uuid, &mux_uuid))
- + {
- + tvhinfo("dbg", "OTHER MUX");
- + count++;
- + }
- + }
- + }
- +
- + tvhinfo("dbg", "%s has %d subscriptions on other muxes", username, count);
- +
- + return count;
- +}
- +
- diff --git a/src/subscriptions.h b/src/subscriptions.h
- index 5fb5ecf..a6a610a 100644
- --- a/src/subscriptions.h
- +++ b/src/subscriptions.h
- @@ -231,4 +231,6 @@ static inline int subscriptions_active(void)
- struct htsmsg;
- struct htsmsg *subscription_create_msg(th_subscription_t *s, const char *lang);
- +int subscription_get_user_count_on_other_muxes(char *username, tvh_uuid_t mux_uuid);
- +
- #endif /* SUBSCRIPTIONS_H */
- diff --git a/src/webui/webui.c b/src/webui/webui.c
- index bca4d92..9ccac87 100644
- --- a/src/webui/webui.c
- +++ b/src/webui/webui.c
- @@ -1211,6 +1211,8 @@ http_stream_channel(http_connection_t *hc, channel_t *ch, int weight)
- const char *name;
- void *tcp_id;
- int res = HTTP_STATUS_SERVICE;
- + idnode_list_mapping_t* ilm;
- + service_t* ch_first_service;
- if (http_access_verify_channel(hc, ACCESS_STREAMING, ch))
- return HTTP_STATUS_UNAUTHORIZED;
- @@ -1232,6 +1234,24 @@ http_stream_channel(http_connection_t *hc, channel_t *ch, int weight)
- else
- qsize = 1500000;
- + ilm = LIST_FIRST(&ch->ch_services);
- + if (ilm)
- + {
- + ch_first_service = (service_t* )ilm->ilm_in1;
- + if (ch_first_service)
- + {
- + source_info_t si;
- + int count;
- + ch_first_service->s_setsourceinfo(ch_first_service, &si);
- + count = subscription_get_user_count_on_other_muxes(hc->hc_username?:(hc->hc_access?hc->hc_access->aa_username:NULL), si.si_mux_uuid);
- + if (count > 0)
- + {
- + tvherror("webui", "User is already using %d muxes while the max is %d", count, 1);
- + return HTTP_STATUS_NOT_ALLOWED;
- + }
- + }
- + }
- +
- profile_chain_init(&prch, pro, ch);
- if (!profile_chain_open(&prch, NULL, 0, qsize)) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement