diff src/ushare.c @ 133:0db6ccf0fe31

modify DLNA display name & UUID
author Naoya OYAMA <naoya.oyama@gmail.com>
date Thu, 14 Oct 2010 00:07:05 +0900
parents 20442921bff5
children 2a9ac5ce2c7e
line wrap: on
line diff
--- a/src/ushare.c	Wed Oct 13 01:39:24 2010 +0900
+++ b/src/ushare.c	Thu Oct 14 00:07:05 2010 +0900
@@ -82,15 +82,21 @@
 static struct ushare_t *
 ushare_new (void)
 {
+  extern thread_data *gp_tdata;
+  thread_data *tdata = gp_tdata;
   struct ushare_t *ut = (struct ushare_t *) malloc (sizeof (struct ushare_t));
+  char model_name[32];
+  model_name[0] = '\0';
   if (!ut)
     return NULL;
+  snprintf(model_name, sizeof(model_name), "%s:dev%d", PACKAGE_NAME, tdata->device_id);
+  model_name[sizeof(model_name)-1] = '\0';
 
 //  ut->name = strdup (DEFAULT_USHARE_NAME);
-  ut->name = strdup (PACKAGE_NAME);
+  ut->name = strdup (model_name);
   ut->interface = strdup (DEFAULT_USHARE_IFACE);
 //  ut->model_name = strdup (DEFAULT_USHARE_NAME);
-  ut->model_name = strdup (PACKAGE_NAME);
+  ut->model_name = strdup (model_name);
   ut->contentlist = NULL;
   ut->rb = rbinit (rb_compare, NULL);
   ut->root_entry = NULL;
@@ -504,10 +510,11 @@
 static char *
 create_udn (char *interface)
 {
+  extern thread_data *gp_tdata;
+  thread_data *tdata = gp_tdata;
   int sock = -1;
   char *buf;
   unsigned char *ptr;
-  pid_t PID = (getpid() & 0xFFFF);
 
 #if (defined(BSD) || defined(__FreeBSD__) || defined(__APPLE__))
   int mib[6];
@@ -574,7 +581,7 @@
   ptr = (unsigned char *) ifr.ifr_hwaddr.sa_data;
 #endif /* (defined(BSD) || defined(__FreeBSD__)) */
 
-  snprintf (buf, 64, "%s-%04x-%02x%02x%02x%02x%02x%02x", DEFAULT_UUID, PID,
+  snprintf (buf, 64, "%s-%04x-%02x%02x%02x%02x%02x%02x", DEFAULT_UUID, tdata->device_id,
             (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
             (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377));