2006/11/14

數位家庭產品初探 -- ushare *.h

先列清單再摘重點說明,後續對研究源碼會有很大幫助

buffer.h cms.h http.h minmax.h services.h util_iconv.h
cds.h content.h metadata.h msr.h trace.h
cfgparser.h gettext.h mime.h presentation.h ushare.h

  • buffer.h: String buffer manipulation tools
定義 struct buffer_t {
char *buf;
size_t len;
size_t capacity; <-- 這較特別
};
及 buffer_new(), buffer_free(), buffer_append(), buffer_appendf() <-- format

  • cds.h: Content Directory Service
定義 CDS_DESCRIPTION, CDS_DESCRIPTION_LEN, CDS_LOCATION(/web/cds.xml), CDS_SERVICE_ID(urn:upnp-org:serviceId:ContentDirectory), CDS_SERVICE_TYPE(urn:schemas-upnp-org:service:ContentDirectory:1)

  • cfgparser.h: config file parser

  • cms.h: Connection Management Service
CMS_DESCRIPTION, CMS_DESCRIPTION_LEN, CMS_LOCATION(/web/cms.xml), CMS_SERVICE_ID(urn:upnp-org:serviceId:ConnectionManager), CMS_SERVICE_TYPE(urn:schemas-upnp-org:service:ConnectionManager:1)

  • content.h: content list
typedef struct content_list {
char **content;
int count;
} content_list; <-- 這寫法是個陣列
add_content(), del_content(指明 idx), free_content() <-- 整個 list,非單一

  • gettext.h: conditional use of GNU
簡單舉例 #define _(string) gettext (string)

  • http.h: Web Server handler

  • metadata.h: CDS Metadata DB
struct upnp_entry_t {
int id;
char *fullpath;
struct upnp_entry_t *parent;
int child_count;
struct upnp_entry_t **childs;
char *class;
char *protocol;
char *title;
char *url;
int size;
int fd;
};
typedef struct xml_convert_s {
char charac;
char *xml;
} xml_convert_t;
free_metadata_list(), build_metadata_list(), upnp_get_entry(), upnp_entry_free()

  • mime.h: media file MIME-type association
struct mime_type_t {
char *extension;
char *class;
char *protocol;
};

  • msr.h: Microsoft Registrar Service Routine
MSR_DESCRIPTION, MSR_DESCRIPTION_LEN, MSR_LOCATION "/web/msr.xml", MSR_SERVICE_ID "urn:microsoft.com:serviceId:X_MS_MediaReceiverRegistrar", MSR_SERVICE_TYPE "urn:microsoft.com:service:X_MS_MediaReceiverRegistrar:1"

  • presentation.h: UPnP Presentation Page
USHARE_PRESENTATION_PAGE "/web/ushare.html", PRESENTATION_PAGE_CONTENT_TYPE "text/html", USHARE_CGI "/web/ushare.cgi", process_cgi(), build_presentation_page()

  • services.h: UPnP services handler
struct service_action_t {
char *name;
bool (*function) (struct action_event_t *);
};
struct service_t {
char *id;
char *type;
struct service_action_t *actions;
};
#define SERVICE_CONTENT_TYPE "text/xml"
find_service_action(), upnp_add_response(), upnp_get_string(), upnp_get_ui4()

  • trace.h: log facility

  • ushare.h: UPnP Media Server
#define VIRTUAL_DIR "/web"
UPNP_DESCRIPTION,
struct ushare_t {
char *name;
char *interface;
content_list *contentlist;
struct upnp_entry_t *root_entry;
int nr_entries;
int init;
UpnpDevice_Handle dev;
char *udn;
char *ip;
unsigned short port;
struct buffer_t *presentation;
bool use_presentation;
bool verbose;
bool daemon;
};
struct action_event_t {
struct Upnp_Action_Request *request;
bool status;
struct service_t *service;
};

  • util_iconv.h: iconv string encoding utilities

0 意見: