changeset 133:0db6ccf0fe31

modify DLNA display name & UUID
author Naoya OYAMA <naoya.oyama@gmail.com>
date Thu, 14 Oct 2010 00:07:05 +0900
parents 7b663556757f
children c4e0a5777363
files src/http.c src/pt1_dev.h src/recpt1.c src/recpt1.h src/ushare.c
diffstat 5 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/http.c	Wed Oct 13 01:39:24 2010 +0900
+++ b/src/http.c	Thu Oct 14 00:07:05 2010 +0900
@@ -29,7 +29,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include <stdint.h>
 
 #include <upnp/upnp.h>
 #include <upnp/upnptools.h>
--- a/src/pt1_dev.h	Wed Oct 13 01:39:24 2010 +0900
+++ b/src/pt1_dev.h	Thu Oct 14 00:07:05 2010 +0900
@@ -2,6 +2,8 @@
 #ifndef _PT1_DEV_H_
 #define _PT1_DEV_H_
 
+#define DEVICE_NAME_BASE "/dev/pt1video"
+
 char *bsdev[NUM_BSDEV] = {
     "/dev/pt1video1",
     "/dev/pt1video0",
--- a/src/recpt1.c	Wed Oct 13 01:39:24 2010 +0900
+++ b/src/recpt1.c	Thu Oct 14 00:07:05 2010 +0900
@@ -54,7 +54,7 @@
 /* prototypes */
 int tune(char *channel, thread_data *tdata, char *device);
 int close_tuner(thread_data *tdata);
-
+static int get_device_id_by_name ( const char *name );
 
 /* ipc message receive */
 void *
@@ -972,6 +972,7 @@
     /* case 1: specified tuner device */
     if(device) {
         tdata->tfd = open(device, O_RDONLY);
+        tdata->device_id = get_device_id_by_name(device);
         if(tdata->tfd < 0) {
             fprintf(stderr, "Cannot open tuner device: %s\n", device);
             return 1;
@@ -1022,6 +1023,7 @@
                     continue;
                 }
 
+                tdata->device_id = get_device_id_by_name(tuner[lp]);
                 break; /* found suitable tuner */
             }
         }
@@ -1506,3 +1508,15 @@
     return 0;
 }
 
+static int
+get_device_id_by_name
+( const char *name )
+{
+    int i = -1;
+    if ( name != NULL ) {
+        if( ! strncmp(name, DEVICE_NAME_BASE, strlen(DEVICE_NAME_BASE) ) ) {
+            i = atoi(name+strlen(DEVICE_NAME_BASE));
+        }
+    }
+    return i;
+}
--- a/src/recpt1.h	Wed Oct 13 01:39:24 2010 +0900
+++ b/src/recpt1.h	Thu Oct 14 00:07:05 2010 +0900
@@ -88,6 +88,7 @@
     int lnb;    /* LNB voltage */
     int tfd;    /* tuner fd */
     int wfd;    /* output file fd */
+    int device_id; /* /dev/pt1video[N] */
     ISDB_T_FREQ_CONV_TABLE *table;
     sock_data *sock_data;
     pthread_t signal_thread;
--- 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));