You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.7 KiB

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