annotate src/ushare.h @ 149:a9f60d56d673

Fix DLNA problem
author Naoya OYAMA <naoya.oyama@gmail.com>
date Sat, 25 Aug 2012 11:10:24 +0900
parents 066f33b2213a
children 30e91361506a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
125
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
1 /*
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
2 * ushare.h : GeeXboX uShare UPnP Media Server header.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
3 * Originally developped for the GeeXboX project.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
4 * Parts of the code are originated from GMediaServer from Oskar Liljeblad.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
5 * Copyright (C) 2005-2007 Benjamin Zores <ben@geexbox.org>
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
6 *
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
10 * (at your option) any later version.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
11 *
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
15 * GNU Library General Public License for more details.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
16 *
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License along
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
18 * with this program; if not, write to the Free Software Foundation,
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
20 */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
21
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
22 #ifndef _USHARE_H_
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
23 #define _USHARE_H_
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
24
136
2a9ac5ce2c7e Remove internal libdlna and libupnp.(using OS package by default)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 131
diff changeset
25 #include <upnp.h>
2a9ac5ce2c7e Remove internal libdlna and libupnp.(using OS package by default)
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 131
diff changeset
26 #include <upnptools.h>
125
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
27 #include <stdbool.h>
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
28 #include <pthread.h>
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
29
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
30 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
31 #include <dlna.h>
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
32 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
33
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
34 #include "content.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
35 #include "buffer.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
36 #include "redblack.h"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
37
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
38 #define VIRTUAL_DIR "/web"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
39 #define XBOX_MODEL_NAME "Windows Media Connect Compatible"
131
20442921bff5 change display name. modify PES buf size.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 126
diff changeset
40 //#define DEFAULT_UUID "898f9738-d930-4db4-a3cf"
20442921bff5 change display name. modify PES buf size.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 126
diff changeset
41 #define DEFAULT_UUID "898f9738-d930-4db4"
125
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
42
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
43 #define STREAM_FILE_NAME "stream.ts"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
44 #define STREAM_LOCATION VIRTUAL_DIR "/" STREAM_FILE_NAME
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
45
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
46 #define UPNP_MAX_CONTENT_LENGTH 4096
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
47
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
48 #define STARTING_ENTRY_ID_DEFAULT 0
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
49 #define STARTING_ENTRY_ID_XBOX360 100000
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
50
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
51 #define UPNP_DESCRIPTION \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
52 "<?xml version=\"1.0\" encoding=\"utf-8\"?>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
53 "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
54 " <specVersion>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
55 " <major>1</major>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
56 " <minor>0</minor>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
57 " </specVersion>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
58 " <device>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
59 " <deviceType>urn:schemas-upnp-org:device:MediaServer:1</deviceType>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
60 " <friendlyName>%s: 1</friendlyName>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
61 " <manufacturer>GeeXboX Team</manufacturer>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
62 " <manufacturerURL>http://ushare.geexbox.org/</manufacturerURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
63 " <modelDescription>GeeXboX uShare : UPnP Media Server</modelDescription>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
64 " <modelName>%s</modelName>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
65 " <modelNumber>001</modelNumber>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
66 " <modelURL>http://ushare.geexbox.org/</modelURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
67 " <serialNumber>GEEXBOX-USHARE-01</serialNumber>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
68 " <UDN>uuid:%s</UDN>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
69 " <serviceList>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
70 " <service>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
71 " <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
72 " <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
73 " <SCPDURL>/web/cms.xml</SCPDURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
74 " <controlURL>/web/cms_control</controlURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
75 " <eventSubURL>/web/cms_event</eventSubURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
76 " </service>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
77 " <service>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
78 " <serviceType>urn:schemas-upnp-org:service:ContentDirectory:1</serviceType>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
79 " <serviceId>urn:upnp-org:serviceId:ContentDirectory</serviceId>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
80 " <SCPDURL>/web/cds.xml</SCPDURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
81 " <controlURL>/web/cds_control</controlURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
82 " <eventSubURL>/web/cds_event</eventSubURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
83 " </service>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
84 " <service>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
85 " <serviceType>urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1</serviceType>\n" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
86 " <serviceId>urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar</serviceId>\n" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
87 " <SCPDURL>/web/msr.xml</SCPDURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
88 " <controlURL>/web/msr_control</controlURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
89 " <eventSubURL>/web/msr_event</eventSubURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
90 " </service>\n" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
91 " </serviceList>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
92 " <presentationURL>/web/ushare.html</presentationURL>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
93 " </device>" \
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
94 "</root>"
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
95
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
96 struct ushare_t {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
97 char *name;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
98 char *interface;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
99 char *model_name;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
100 content_list *contentlist;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
101 struct rbtree *rb;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
102 struct upnp_entry_t *root_entry;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
103 int nr_entries;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
104 int starting_id;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
105 int init;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
106 UpnpDevice_Handle dev;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
107 char *udn;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
108 char *ip;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
109 unsigned short port;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
110 unsigned short telnet_port;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
111 struct buffer_t *presentation;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
112 bool use_presentation;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
113 bool use_telnet;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
114 #ifdef HAVE_DLNA
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
115 bool dlna_enabled;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
116 dlna_t *dlna;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
117 dlna_org_flags_t dlna_flags;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
118 #endif /* HAVE_DLNA */
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
119 bool xbox360;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
120 bool verbose;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
121 bool daemon;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
122 bool override_iconv_err;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
123 char *cfg_file;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
124 pthread_mutex_t termination_mutex;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
125 pthread_cond_t termination_cond;
146
066f33b2213a EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 136
diff changeset
126 char **channel_name;
066f33b2213a EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 136
diff changeset
127 char **location_name;
066f33b2213a EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 136
diff changeset
128 char request_channel[64];
066f33b2213a EXPERIMENTAL: Select a particular program from multi-channel.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 136
diff changeset
129 int nr_channel;
125
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
130 };
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
131
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
132 struct action_event_t {
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
133 struct Upnp_Action_Request *request;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
134 bool status;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
135 struct service_t *service;
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
136 };
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
137
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
138 inline void display_headers (void);
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
139 void * dlna_startup(void *p);
126
5dcaf3785ebe fix process terminate problem.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 125
diff changeset
140 void UPnPBreak (int s __attribute__ ((unused)));
5dcaf3785ebe fix process terminate problem.
Naoya OYAMA <naoya.oyama@gmail.com>
parents: 125
diff changeset
141
125
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
142
e413158cae13 Add ushare project files.
naoyan@johnstown.minaminoshima.org
parents:
diff changeset
143 #endif /* _USHARE_H_ */