Mercurial > pt1.oyama
comparison src/ushare.c @ 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 | 726fe10d9e4a |
children | 6c710e5a28b8 |
comparison
equal
deleted
inserted
replaced
169:cb54f9777734 | 170:4f3640bf350d |
---|---|
71 #include "gettext.h" | 71 #include "gettext.h" |
72 #include "trace.h" | 72 #include "trace.h" |
73 #include "buffer.h" | 73 #include "buffer.h" |
74 #include "ctrl_telnet.h" | 74 #include "ctrl_telnet.h" |
75 #include "recpt1.h" | 75 #include "recpt1.h" |
76 #include "pt1_common.h" | |
76 | 77 |
77 struct ushare_t *ut = NULL; | 78 struct ushare_t *ut = NULL; |
78 | 79 |
79 static struct ushare_t * ushare_new (void) | 80 static struct ushare_t * ushare_new (void) |
80 __attribute__ ((malloc)); | 81 __attribute__ ((malloc)); |
85 extern thread_data *gp_tdata; | 86 extern thread_data *gp_tdata; |
86 extern struct channel_info_list *channel_list; | 87 extern struct channel_info_list *channel_list; |
87 thread_data *tdata = gp_tdata; | 88 thread_data *tdata = gp_tdata; |
88 struct ushare_t *ut = (struct ushare_t *) malloc (sizeof (struct ushare_t)); | 89 struct ushare_t *ut = (struct ushare_t *) malloc (sizeof (struct ushare_t)); |
89 char model_name[32]; | 90 char model_name[32]; |
91 char host_name[HOST_NAME_MAX+1]; | |
90 model_name[0] = '\0'; | 92 model_name[0] = '\0'; |
93 gethostname(host_name, sizeof(host_name)); | |
91 if (!ut) | 94 if (!ut) |
92 return NULL; | 95 return NULL; |
93 snprintf(model_name, sizeof(model_name), "%s:dev%d", PACKAGE_NAME, tdata->device_id); | 96 snprintf(model_name, sizeof(model_name), "%s: %s", host_name, tdata->device_name); |
94 model_name[sizeof(model_name)-1] = '\0'; | 97 model_name[sizeof(model_name)-1] = '\0'; |
95 | 98 |
96 // ut->name = strdup (DEFAULT_USHARE_NAME); | 99 // ut->name = strdup (DEFAULT_USHARE_NAME); |
97 ut->name = strdup (model_name); | 100 ut->name = strdup (model_name); |
98 ut->interface = strdup (DEFAULT_USHARE_IFACE); | 101 ut->interface = strdup (DEFAULT_USHARE_IFACE); |
287 { | 290 { |
288 char *description = NULL; | 291 char *description = NULL; |
289 int res; | 292 int res; |
290 size_t len; | 293 size_t len; |
291 | 294 |
295 char *friendly_name = ut->name; | |
296 char manufacturer[] = "GeeXboX Team"; | |
297 char manufacturer_url[] = "http://ushare.geexbox.org/"; | |
298 char model_description[] = "uShare : DLNA Media Server"; | |
299 char *model_name = ut->model_name; | |
300 char model_number[] = "001"; | |
301 char model_url[] = "http://ushare.geexbox.org/"; | |
302 char serial_number[] = "USHARE-01"; | |
303 char *uuid = ut->udn; | |
304 char presentation_url[] = "/web/ushare.html"; | |
305 char cms_scpd_url[] = "/web/cms.xml"; | |
306 char cms_control_url[] = "/web/cms_control"; | |
307 char cms_event_url[] = "/web/cms_event"; | |
308 char cds_scpd_url[] = "/web/cds.xml"; | |
309 char cds_control_url[] = "/web/cds_control"; | |
310 char cds_event_url[] = "/web/cds_event"; | |
311 | |
292 if (!ut || !ut->name || !ut->udn || !ut->ip) | 312 if (!ut || !ut->name || !ut->udn || !ut->ip) |
293 return -1; | 313 return -1; |
294 | 314 |
295 #ifdef HAVE_DLNA | 315 len = strlen (UPNP_DMS_DESCRIPTION) + strlen (friendly_name) |
296 if (ut->dlna_enabled) | 316 + strlen (manufacturer) + strlen (manufacturer_url) |
297 { | 317 + strlen (model_description) + strlen (model_name) |
298 len = 0; | 318 + strlen (model_number) + strlen (model_url) + strlen (serial_number) |
299 description = | 319 + strlen (uuid) + strlen (presentation_url) + strlen (cms_scpd_url) |
300 dlna_dms_description_get (ut->name, | 320 + strlen (cms_control_url) + strlen (cms_event_url) |
301 "GeeXboX Team", | 321 + strlen (cds_scpd_url) + strlen (cds_control_url) |
302 "http://ushare.geexbox.org/", | 322 + strlen (cds_event_url) + 1; |
303 "uShare : DLNA Media Server", | |
304 ut->model_name, | |
305 "001", | |
306 "http://ushare.geexbox.org/", | |
307 "USHARE-01", | |
308 ut->udn, | |
309 "/web/ushare.html", | |
310 "/web/cms.xml", | |
311 "/web/cms_control", | |
312 "/web/cms_event", | |
313 "/web/cds.xml", | |
314 "/web/cds_control", | |
315 "/web/cds_event"); | |
316 if (!description) | |
317 return -1; | |
318 } | |
319 else | |
320 { | |
321 #endif /* HAVE_DLNA */ | |
322 len = strlen (UPNP_DESCRIPTION) + strlen (ut->name) | |
323 + strlen (ut->model_name) + strlen (ut->udn) + 1; | |
324 description = (char *) malloc (len * sizeof (char)); | 323 description = (char *) malloc (len * sizeof (char)); |
325 memset (description, 0, len); | 324 memset (description, 0, len); |
326 sprintf (description, UPNP_DESCRIPTION, ut->name, ut->model_name, ut->udn); | 325 sprintf (description, UPNP_DMS_DESCRIPTION, friendly_name, |
327 #ifdef HAVE_DLNA | 326 manufacturer, manufacturer_url, model_description, |
328 } | 327 model_name, model_number, model_url, serial_number, uuid, |
329 #endif /* HAVE_DLNA */ | 328 presentation_url, cms_scpd_url, cms_control_url, cms_event_url, |
329 cds_scpd_url, cds_control_url, cds_event_url); | |
330 | 330 |
331 log_info (_("Initializing UPnP subsystem ...\n")); | 331 log_info (_("Initializing UPnP subsystem ...\n")); |
332 res = UpnpInit (ut->ip, ut->port); | 332 res = UpnpInit (ut->ip, ut->port); |
333 if (res != UPNP_E_SUCCESS) | 333 if (res != UPNP_E_SUCCESS) |
334 { | 334 { |
581 buf = (char *) malloc (64 * sizeof (char)); | 581 buf = (char *) malloc (64 * sizeof (char)); |
582 memset (buf, 0, 64); | 582 memset (buf, 0, 64); |
583 ptr = (unsigned char *) ifr.ifr_hwaddr.sa_data; | 583 ptr = (unsigned char *) ifr.ifr_hwaddr.sa_data; |
584 #endif /* (defined(BSD) || defined(__FreeBSD__)) */ | 584 #endif /* (defined(BSD) || defined(__FreeBSD__)) */ |
585 | 585 |
586 snprintf (buf, 64, "%s-%04x-%02x%02x%02x%02x%02x%02x", DEFAULT_UUID, tdata->device_id, | 586 snprintf (buf, 64, "%s-%04x-%02x%02x%02x%02x%02x%02x", DEFAULT_UUID, get_device_id_by_name(tdata->device_name), |
587 (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377), | 587 (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377), |
588 (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)); | 588 (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)); |
589 | 589 |
590 if (sock) | 590 if (sock) |
591 close (sock); | 591 close (sock); |