M7350/oe-core/meta-msm/recipes/minidlna/files/0001-search-criteria.patch
2024-09-09 08:57:42 +00:00

107 lines
4.0 KiB
Diff

From 50e2af73ca40e48ebd1bdc1ae4d7c6a59e0c0025 Mon Sep 17 00:00:00 2001
From: Tyler Wear <twear@codeaurora.org>
Date: Wed, 1 Apr 2015 17:42:33 -0700
Subject: [PATCH 1/1] search-criteria
---
metadata.c | 10 ++++++++++++------
upnpsoap.c | 40 +++++++++++++++++++++++++++++-----------
1 file changed, 29 insertions(+), 11 deletions(-)
diff --git a/metadata.c b/metadata.c
index 0b6ec56..229f80f 100644
--- a/metadata.c
+++ b/metadata.c
@@ -814,7 +814,10 @@
min = (int)(duration / 60 % 60);
sec = (int)(duration % 60);
ms = (int)(ctx->duration / (AV_TIME_BASE/1000) % 1000);
- xasprintf(&m.duration, "%d:%02d:%02d.%03d", hours, min, sec, ms);
+ if (sec ==0 && ms ==0)
+ xasprintf(&m.duration, "%d:%02d:%02d", hours, min, sec);
+ else
+ xasprintf(&m.duration, "%d:%02d:%02d.%03d", hours, min, sec, ms);
}
/* NOTE: The DLNA spec only provides for ASF (WMV), TS, PS, and MP4 containers.
diff --git a/upnpsoap.c b/upnpsoap.c
index 0b6ec56..229f80f 100644
--- a/upnpsoap.c
+++ b/upnpsoap.c
@@ -165,11 +165,21 @@ RegisterDevice(struct upnphttp * h, cons
char body[512];
int bodylen;
-
- bodylen = snprintf(body, sizeof(body), resp,
- action, "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1",
- uuidvalue, action);
- BuildSendAndCloseSoapResp(h, body, bodylen);
+struct NameValueParserData data;
+ const char * id;
+ ParseNameValue(h->req_buf + h->req_contentoff, h->req_contentlen, &data, XML_STORE_EMPTY_FL);
+ id = GetValueFromNameValueList(&data, "DeviceID");
+ if(id)
+ {
+ int bodylen;
+ bodylen = snprintf(body, sizeof(body), resp,
+ action, "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1",
+ uuidvalue, action);
+ BuildSendAndCloseSoapResp(h, body, bodylen);
+ }
+ else
+ SoapError(h, 402, "Invalid Args");
+ ClearNameValueList(&data);
}
static void
@@ -1712,17 +1712,35 @@ SearchContentDirectory(struct upnphttp * h, const char * action)
goto search_error;
}
- sql = sqlite3_mprintf( SELECT_COLUMNS
- "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
- " where OBJECT_ID glob '%q%s' and (%s) %s "
- "%z %s"
- " limit %d, %d",
- ContainerID, sep, where, groupBy,
- (*ContainerID == '*') ? NULL :
- sqlite3_mprintf("UNION ALL " SELECT_COLUMNS
- "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
- " where OBJECT_ID = '%q' and (%s) ", ContainerID, where),
- orderBy, StartingIndex, RequestedCount);
+ if( strncmp(where, "OBJECT_ID is not NULL", 21) != 0)
+ {
+ sql = sqlite3_mprintf( SELECT_COLUMNS
+ "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
+ " where OBJECT_ID glob '%q%s' and (%s) %s "
+ "%z %s"
+ " limit %d, %d",
+ ContainerID, sep, where, groupBy,
+ (*ContainerID == '*') ? NULL :
+ sqlite3_mprintf("UNION ALL " SELECT_COLUMNS
+ "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
+ " where OBJECT_ID = '%q' and (%s) ", ContainerID, where),
+ orderBy, StartingIndex, RequestedCount);
+ }
+ else
+ {
+ sql = sqlite3_mprintf( SELECT_COLUMNS
+ "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
+ " where OBJECT_ID glob '%q%s' and (%s) %s "
+ "%z"
+ " limit %d, %d",
+ ContainerID, sep, where,
+ (*ContainerID == '*') ? NULL :
+ sqlite3_mprintf("UNION ALL " SELECT_COLUMNS
+ "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)"
+ " where OBJECT_ID = '%q' and (%s) ", ContainerID, where),
+ orderBy, StartingIndex, RequestedCount);
+ }
+
DPRINTF(E_DEBUG, L_HTTP, "Search SQL: %s\n", sql);
ret = sqlite3_exec(db, sql, callback, (void *) &args, &zErrMsg);
if( (ret != SQLITE_OK) && (zErrMsg != NULL) )
--
1.8.2.1