001-group-videos-by-directory-for-panasonic-tvs.patch (3842B)
1 From c8245740c3a8699cfe7d7e5aa0d427b931018ad5 Mon Sep 17 00:00:00 2001 2 From: Yusuke Yanbe <y.yanbe@gmail.com> 3 Date: Mon, 4 Jul 2016 08:20:46 +0900 4 Subject: [PATCH] Add support for grouping videos by directory for Panasonic 5 TVs 6 7 --- 8 upnpsoap.c | 24 +++++++++++++++++++----- 9 upnpsoap.h | 5 ++++- 10 2 files changed, 23 insertions(+), 6 deletions(-) 11 12 --- a/upnpsoap.c 13 +++ b/upnpsoap.c 14 @@ -1052,6 +1052,15 @@ callback(void *args, int argc, char **ar 15 add_res(size, duration, bitrate, sampleFrequency, nrAudioChannels, 16 resolution, dlna_buf, mime, detailID, ext, passed_args); 17 } 18 + 19 + DPRINTF(E_DEBUG, L_HTTP, "Title: %s - %d Returned / %d childCount\n", 20 + title, passed_args->returned, passed_args->childCount); 21 + 22 + ret = strcatf(str, "<pxn:groupTopFlag>%d</pxn:groupTopFlag>" 23 + "<pxn:groupID>%s</pxn:groupID>" 24 + "<pxn:groupTitle>%s</pxn:groupTitle>" 25 + "<pxn:groupMemberNum>%d</pxn:groupMemberNum>", 26 + passed_args->returned == passed_args->childCount, parent, passed_args->parentTitle, passed_args->childCount); 27 break; 28 case ESamsungSeriesCDE: 29 case ELGDevice: 30 @@ -1314,8 +1323,11 @@ BrowseContentDirectory(struct upnphttp * 31 if (!where[0]) 32 sqlite3_snprintf(sizeof(where), where, "PARENT_ID = '%q'", ObjectID); 33 34 - if (!totalMatches) 35 + if (!totalMatches) { 36 totalMatches = get_child_count(ObjectID, magic); 37 + args.childCount = totalMatches; 38 + args.parentTitle = sql_get_text_field(db, "SELECT d.TITLE FROM OBJECTS o LEFT JOIN DETAILS d ON (d.ID = o.DETAIL_ID) WHERE OBJECT_ID='%q'", ObjectID); 39 + } 40 ret = 0; 41 if (SortCriteria && !orderBy) 42 { 43 @@ -1354,14 +1366,16 @@ BrowseContentDirectory(struct upnphttp * 44 SoapError(h, 709, "Unsupported or invalid sort criteria"); 45 goto browse_error; 46 } 47 - 48 sql = sqlite3_mprintf("SELECT %s, %s, %s, " COLUMNS 49 "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)" 50 - " where %s %s limit %d, %d;", 51 + " where %s order by d.date limit %d, %d;", 52 objectid_sql, parentid_sql, refid_sql, 53 - where, THISORNUL(orderBy), StartingIndex, RequestedCount); 54 + where, StartingIndex, RequestedCount); 55 DPRINTF(E_DEBUG, L_HTTP, "Browse SQL: %s\n", sql); 56 ret = sqlite3_exec(db, sql, callback, (void *) &args, &zErrMsg); 57 + if (args.parentTitle) { 58 + sqlite3_free(args.parentTitle); 59 + } 60 } 61 if( (ret != SQLITE_OK) && (zErrMsg != NULL) ) 62 { 63 @@ -1795,7 +1809,7 @@ SearchContentDirectory(struct upnphttp * 64 (*ContainerID == '*') ? NULL : 65 sqlite3_mprintf("UNION ALL " SELECT_COLUMNS 66 "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)" 67 - " where OBJECT_ID = '%q' and (%s) ", ContainerID, where), 68 + " where OBJECT_ID = '%q' and (%s) ORDER BY d.date", ContainerID, where), 69 orderBy, StartingIndex, RequestedCount); 70 DPRINTF(E_DEBUG, L_HTTP, "Search SQL: %s\n", sql); 71 ret = sqlite3_exec(db, sql, callback, (void *) &args, &zErrMsg); 72 --- a/upnpsoap.h 73 +++ b/upnpsoap.h 74 @@ -27,7 +27,8 @@ 75 #define CONTENT_DIRECTORY_SCHEMAS \ 76 " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"" \ 77 " xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\"" \ 78 - " xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"" 79 + " xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"" \ 80 + " xmlns:pxn=\"urn:schemas-panasonic-com:pxn\"" 81 #define DLNA_NAMESPACE \ 82 " xmlns:dlna=\"urn:schemas-dlna-org:metadata-1-0/\"" 83 #define PV_NAMESPACE \ 84 @@ -39,6 +40,8 @@ struct Response 85 int start; 86 int returned; 87 int requested; 88 + int childCount; 89 + char *parentTitle; 90 int iface; 91 uint32_t filter; 92 uint32_t flags;