Mercurial > pt1.oyama
changeset 170:4f3640bf350d
Change display name of DLNA.
- old_display name: (recpt1:devN)
- new_display name: (hostname: /dev/ptXdevY)
- change UUID format.
author | Naoya OYAMA <naoya.oyama@gmail.com> |
---|---|
date | Wed, 17 Oct 2012 23:47:16 +0900 |
parents | cb54f9777734 |
children | 6c710e5a28b8 |
files | src/pt1_common.c src/pt1_common.h src/recpt1.c src/recpt1.h src/tssplitter_lite.c src/ushare.c src/ushare.h |
diffstat | 7 files changed, 83 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pt1_common.c Sun Oct 07 00:37:34 2012 +0900 +++ b/src/pt1_common.c Wed Oct 17 23:47:16 2012 +0900 @@ -454,6 +454,7 @@ fprintf(stderr, "Cannot open tuner device: %s\n", device); return 1; } + tdata->device_name = device; /* power on LNB */ if(tdata->table->type == CHTYPE_SATELLITE) { @@ -515,6 +516,7 @@ } fprintf(stderr, "device = %s\n", tuner[lp]); + tdata->device_name = tuner[lp]; break; /* found suitable tuner */ } } @@ -550,3 +552,27 @@ return rv; } + +uint16_t +get_device_id_by_name(char *device_name) +{ + char *p = NULL; + uint8_t id = -1; + uint8_t pt = -1; + uint16_t device_id = -1; + + p = strstr(device_name, "/dev/pt"); + if(!p) + return -1; + p += strlen("/dev/pt"); + pt = atoi(p++); + + p = strstr(p, "video"); + if(!p) + return -1; + p += strlen("video"); + id = atoi(p); + + device_id = (pt & 0xff) <<8 | (id & 0xff); + return device_id; +}
--- a/src/pt1_common.h Sun Oct 07 00:37:34 2012 +0900 +++ b/src/pt1_common.h Wed Oct 17 23:47:16 2012 +0900 @@ -40,5 +40,6 @@ void calc_cn(int fd, int type, boolean use_bell); int tune(char *channel, thread_data *tdata, char *device); int close_tuner(thread_data *tdata); +uint16_t get_device_id_by_name(char *device_name); #endif
--- a/src/recpt1.c Sun Oct 07 00:37:34 2012 +0900 +++ b/src/recpt1.c Wed Oct 17 23:47:16 2012 +0900 @@ -47,9 +47,6 @@ extern struct ushare_t *ut; thread_data *gp_tdata; -/* prototypes */ -static int get_device_id_by_name ( const char *name ); - static struct channel_info_list *open_list_file( char *type, struct channel_info_list *info_list) @@ -168,7 +165,8 @@ sscanf(rbuf.mtext, "ch=%s t=%d e=%d i=%s", channel, &recsec, &time_to_add, sid_list); - if ((strcmp(channel, "")) && strcmp(tdata->ch, channel)) { + if ((strcmp(channel, "")) && strcmp(tdata->ch, channel) || + (strcmp(sid_list, "")) && strcmp(tdata->sid_list, sid_list)) { #if 0 /* re-initialize decoder */ if(tdata->decoder) { @@ -1457,16 +1455,3 @@ 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 Sun Oct 07 00:37:34 2012 +0900 +++ b/src/recpt1.h Wed Oct 17 23:47:16 2012 +0900 @@ -89,7 +89,7 @@ int lnb; /* LNB voltage */ int tfd; /* tuner fd */ int wfd; /* output file fd */ - int device_id; /* /dev/pt1video[N] */ + char *device_name; /* "/dev/ptXvideoY" */ ISDB_T_FREQ_CONV_TABLE *table; sock_data *sock_data; pthread_t signal_thread;
--- a/src/tssplitter_lite.c Sun Oct 07 00:37:34 2012 +0900 +++ b/src/tssplitter_lite.c Wed Oct 17 23:47:16 2012 +0900 @@ -608,7 +608,7 @@ /* prescan SID/PMT */ for(i = 13, j = 0; i < (size + 8) - 4; i = i + 4) { pid = GetPid(&buf[i+2]); - if(pid == 0x0010) + if(pid == NIT) continue; avail_sids[j] = (buf[i] << 8) + buf[i+2]; sp->avail_pmts[j] = pid; @@ -621,7 +621,7 @@ /* 最終 4 バイトはCRCなので飛ばす */ for(i = 13; i < (size + 8) - 4; i = i + 4) { pid = GetPid(&buf[i+2]); - if(pid==0x0010) + if(pid == NIT) continue; service_id = (buf[i] << 8) + buf[i+1];
--- a/src/ushare.c Sun Oct 07 00:37:34 2012 +0900 +++ b/src/ushare.c Wed Oct 17 23:47:16 2012 +0900 @@ -73,6 +73,7 @@ #include "buffer.h" #include "ctrl_telnet.h" #include "recpt1.h" +#include "pt1_common.h" struct ushare_t *ut = NULL; @@ -87,10 +88,12 @@ thread_data *tdata = gp_tdata; struct ushare_t *ut = (struct ushare_t *) malloc (sizeof (struct ushare_t)); char model_name[32]; + char host_name[HOST_NAME_MAX+1]; model_name[0] = '\0'; + gethostname(host_name, sizeof(host_name)); if (!ut) return NULL; - snprintf(model_name, sizeof(model_name), "%s:dev%d", PACKAGE_NAME, tdata->device_id); + snprintf(model_name, sizeof(model_name), "%s: %s", host_name, tdata->device_name); model_name[sizeof(model_name)-1] = '\0'; // ut->name = strdup (DEFAULT_USHARE_NAME); @@ -289,44 +292,41 @@ int res; size_t len; + char *friendly_name = ut->name; + char manufacturer[] = "GeeXboX Team"; + char manufacturer_url[] = "http://ushare.geexbox.org/"; + char model_description[] = "uShare : DLNA Media Server"; + char *model_name = ut->model_name; + char model_number[] = "001"; + char model_url[] = "http://ushare.geexbox.org/"; + char serial_number[] = "USHARE-01"; + char *uuid = ut->udn; + char presentation_url[] = "/web/ushare.html"; + char cms_scpd_url[] = "/web/cms.xml"; + char cms_control_url[] = "/web/cms_control"; + char cms_event_url[] = "/web/cms_event"; + char cds_scpd_url[] = "/web/cds.xml"; + char cds_control_url[] = "/web/cds_control"; + char cds_event_url[] = "/web/cds_event"; + if (!ut || !ut->name || !ut->udn || !ut->ip) return -1; -#ifdef HAVE_DLNA - if (ut->dlna_enabled) - { - len = 0; - description = - dlna_dms_description_get (ut->name, - "GeeXboX Team", - "http://ushare.geexbox.org/", - "uShare : DLNA Media Server", - ut->model_name, - "001", - "http://ushare.geexbox.org/", - "USHARE-01", - ut->udn, - "/web/ushare.html", - "/web/cms.xml", - "/web/cms_control", - "/web/cms_event", - "/web/cds.xml", - "/web/cds_control", - "/web/cds_event"); - if (!description) - return -1; - } - else - { -#endif /* HAVE_DLNA */ - len = strlen (UPNP_DESCRIPTION) + strlen (ut->name) - + strlen (ut->model_name) + strlen (ut->udn) + 1; + len = strlen (UPNP_DMS_DESCRIPTION) + strlen (friendly_name) + + strlen (manufacturer) + strlen (manufacturer_url) + + strlen (model_description) + strlen (model_name) + + strlen (model_number) + strlen (model_url) + strlen (serial_number) + + strlen (uuid) + strlen (presentation_url) + strlen (cms_scpd_url) + + strlen (cms_control_url) + strlen (cms_event_url) + + strlen (cds_scpd_url) + strlen (cds_control_url) + + strlen (cds_event_url) + 1; description = (char *) malloc (len * sizeof (char)); memset (description, 0, len); - sprintf (description, UPNP_DESCRIPTION, ut->name, ut->model_name, ut->udn); -#ifdef HAVE_DLNA - } -#endif /* HAVE_DLNA */ + sprintf (description, UPNP_DMS_DESCRIPTION, friendly_name, + manufacturer, manufacturer_url, model_description, + model_name, model_number, model_url, serial_number, uuid, + presentation_url, cms_scpd_url, cms_control_url, cms_event_url, + cds_scpd_url, cds_control_url, cds_event_url); log_info (_("Initializing UPnP subsystem ...\n")); res = UpnpInit (ut->ip, ut->port); @@ -583,7 +583,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, tdata->device_id, + snprintf (buf, 64, "%s-%04x-%02x%02x%02x%02x%02x%02x", DEFAULT_UUID, get_device_id_by_name(tdata->device_name), (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377), (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377));
--- a/src/ushare.h Sun Oct 07 00:37:34 2012 +0900 +++ b/src/ushare.h Wed Oct 17 23:47:16 2012 +0900 @@ -48,7 +48,7 @@ #define STARTING_ENTRY_ID_DEFAULT 0 #define STARTING_ENTRY_ID_XBOX360 100000 -#define UPNP_DESCRIPTION \ +#define UPNP_DMS_DESCRIPTION \ "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \ "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">" \ " <specVersion>" \ @@ -57,39 +57,33 @@ " </specVersion>" \ " <device>" \ " <deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>" \ -" <friendlyName>%s: 1</friendlyName>" \ -" <manufacturer>GeeXboX Team</manufacturer>" \ -" <manufacturerURL>http://ushare.geexbox.org/</manufacturerURL>" \ -" <modelDescription>GeeXboX uShare : UPnP Media Server</modelDescription>" \ +" <friendlyName>%s</friendlyName>" \ +" <manufacturer>%s</manufacturer>" \ +" <manufacturerURL>%s</manufacturerURL>" \ +" <modelDescription>%s</modelDescription>" \ " <modelName>%s</modelName>" \ -" <modelNumber>001</modelNumber>" \ -" <modelURL>http://ushare.geexbox.org/</modelURL>" \ -" <serialNumber>GEEXBOX-USHARE-01</serialNumber>" \ +" <modelNumber>%s</modelNumber>" \ +" <modelURL>%s</modelURL>" \ +" <serialNumber>%s</serialNumber>" \ " <UDN>uuid:%s</UDN>" \ +" <presentationURL>%s</presentationURL>" \ +" <dlna:X_DLNADOC>DMS-1.00</dlna:X_DLNADOC>" \ " <serviceList>" \ " <service>" \ " <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>" \ " <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>" \ -" <SCPDURL>/web/cms.xml</SCPDURL>" \ -" <controlURL>/web/cms_control</controlURL>" \ -" <eventSubURL>/web/cms_event</eventSubURL>" \ +" <SCPDURL>%s</SCPDURL>" \ +" <controlURL>%s</controlURL>" \ +" <eventSubURL>%s</eventSubURL>" \ " </service>" \ " <service>" \ " <serviceType>urn:schemas-upnp-org:service:ContentDirectory:1</serviceType>" \ " <serviceId>urn:upnp-org:serviceId:ContentDirectory</serviceId>" \ -" <SCPDURL>/web/cds.xml</SCPDURL>" \ -" <controlURL>/web/cds_control</controlURL>" \ -" <eventSubURL>/web/cds_event</eventSubURL>" \ +" <SCPDURL>%s</SCPDURL>" \ +" <controlURL>%s</controlURL>" \ +" <eventSubURL>%s</eventSubURL>" \ " </service>" \ -" <service>" \ -" <serviceType>urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1</serviceType>\n" \ -" <serviceId>urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar</serviceId>\n" \ -" <SCPDURL>/web/msr.xml</SCPDURL>" \ -" <controlURL>/web/msr_control</controlURL>" \ -" <eventSubURL>/web/msr_event</eventSubURL>" \ -" </service>\n" \ " </serviceList>" \ -" <presentationURL>/web/ushare.html</presentationURL>" \ " </device>" \ "</root>"