From: Jaroslav Kysela Date: Thu, 24 Nov 2016 14:02:30 +0000 (+0100) Subject: htsp/http streaming: fix the de_playcount updates X-Git-Tag: v4.2.1~206 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb5ed85435394164027df6a2d9b09d49e93b706b;p=thirdparty%2Ftvheadend.git htsp/http streaming: fix the de_playcount updates --- diff --git a/src/htsp_server.c b/src/htsp_server.c index 530cb87f9..baa543b27 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -707,7 +707,7 @@ htsp_channel_tag_find_by_identifier(htsp_connection_t *htsp, uint32_t id) * */ static htsmsg_t * -htsp_file_open(htsp_connection_t *htsp, const char *path, int fd) +htsp_file_open(htsp_connection_t *htsp, const char *path, int fd, dvr_entry_t *de) { struct stat st; @@ -718,6 +718,11 @@ htsp_file_open(htsp_connection_t *htsp, const char *path, int fd) return htsp_error(htsp, N_("Unable to open file")); } + if (de) { + de->de_playcount++; + dvr_entry_changed_notify(de); + } + htsp_file_t *hf = calloc(1, sizeof(htsp_file_t)); hf->hf_fd = fd; hf->hf_id = ++htsp->htsp_file_id; @@ -2689,13 +2694,13 @@ htsp_method_file_open(htsp_connection_t *htsp, htsmsg_t *in) if (filename == NULL) return htsp_error(htsp, N_("DVR schedule does not have a file yet")); - return htsp_file_open(htsp, filename, 0); + return htsp_file_open(htsp, filename, 0, de); } else if ((s2 = tvh_strbegins(str, "imagecache/")) != NULL) { int fd = imagecache_open(atoi(s2)); if (fd < 0) return htsp_error(htsp, N_("Failed to open image")); - return htsp_file_open(htsp, str, fd); + return htsp_file_open(htsp, str, fd, NULL); } else { return htsp_error(htsp, N_("Unknown file")); diff --git a/src/webui/webui.c b/src/webui/webui.c index ba6e87ceb..8c22ca144 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -1510,7 +1510,6 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque) return HTTP_STATUS_UNAUTHORIZED; pthread_mutex_lock(&global_lock); - de = dvr_entry_find_by_uuid(remain); if (de == NULL) de = dvr_entry_find_by_id(atoi(remain)); @@ -1523,12 +1522,6 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque) return HTTP_STATUS_UNAUTHORIZED; } - /* Play count + 1 when write access */ - if (!dvr_entry_verify(de, hc->hc_access, 0)) { - de->de_playcount = de->de_playcount + 1; - dvr_entry_changed_notify(de); - } - fname = tvh_strdupa(filename); content = muxer_container_filename2mime(fname, 1); charset = de->de_config ? de->de_config->dvr_charset_id : NULL; @@ -1622,6 +1615,17 @@ page_dvrfile(http_connection_t *hc, const char *remain, void *opaque) free(str); } } + /* Play count + 1 when write access */ + if (!hc->hc_no_output && file_start <= 0 && + !dvr_entry_verify(de, hc->hc_access, 0)) { + de = dvr_entry_find_by_uuid(remain); + if (de == NULL) + de = dvr_entry_find_by_id(atoi(remain)); + if (de) { + de->de_playcount = de->de_playcount + 1; + dvr_entry_changed_notify(de); + } + } pthread_mutex_unlock(&global_lock); if (tcp_id == NULL) { close(fd);