Merge pull request #4892 from fededim/master
[feed/packages.git] / multimedia / minidlna / patches / 001-group-videos-by-directory-for-panasonic-tvs.patch
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 @@ -1095,6 +1095,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, "&lt;pxn:groupTopFlag&gt;%d&lt;/pxn:groupTopFlag&gt;"
23 + "&lt;pxn:groupID&gt;%s&lt;/pxn:groupID&gt;"
24 + "&lt;pxn:groupTitle&gt;%s&lt;/pxn:groupTitle&gt;"
25 + "&lt;pxn:groupMemberNum&gt;%d&lt;/pxn:groupMemberNum&gt;",
26 + passed_args->returned == passed_args->childCount, parent, passed_args->parentTitle, passed_args->childCount);
27 break;
28 case ESamsungSeriesCDE:
29 case ELGDevice:
30 @@ -1357,8 +1366,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 @@ -1397,14 +1409,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 @@ -1838,7 +1852,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;