"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "avahi.c" between
minidlna-1.2.0.tar.gz and minidlna-1.2.1.tar.gz

About: ReadyMedia (formerly known as MiniDLNA) is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients.

avahi.c  (minidlna-1.2.0):avahi.c  (minidlna-1.2.1)
skipping to change at line 52 skipping to change at line 52
static struct context { static struct context {
AvahiThreadedPoll *threaded_poll; AvahiThreadedPoll *threaded_poll;
AvahiClient *client; AvahiClient *client;
AvahiEntryGroup *group; AvahiEntryGroup *group;
} ctx; } ctx;
/***************************************************************** /*****************************************************************
* Private functions * Private functions
*****************************************************************/ *****************************************************************/
/* Called when publishing of service data completes */
static void publish_reply(AvahiEntryGroup *g, static void publish_reply(AvahiEntryGroup *g,
AvahiEntryGroupState state, AvahiEntryGroupState state,
void *userdata); AVAHI_GCC_UNUSED void *userdata)
{
assert(ctx.group == NULL || g == ctx.group);
switch (state) {
case AVAHI_ENTRY_GROUP_ESTABLISHED:
/* The entry group has been established successfully */
DPRINTF(E_MAXDEBUG, L_SSDP, "publish_reply: AVAHI_ENTRY_GROUP_EST
ABLISHED\n");
break;
case AVAHI_ENTRY_GROUP_COLLISION:
/* With multiple names there's no way to know which one collided
*/
DPRINTF(E_ERROR, L_SSDP, "publish_reply: AVAHI_ENTRY_GROUP_COLLIS
ION: %s\n",
avahi_strerror(avahi_client_errno(ctx.client)));
avahi_threaded_poll_quit(ctx.threaded_poll);
break;
case AVAHI_ENTRY_GROUP_FAILURE:
DPRINTF(E_ERROR, L_SSDP, "Failed to register service: %s\n",
avahi_strerror(avahi_client_errno(ctx.client)));
avahi_threaded_poll_quit(ctx.threaded_poll);
break;
case AVAHI_ENTRY_GROUP_UNCOMMITED:
case AVAHI_ENTRY_GROUP_REGISTERING:
default:
break;
}
}
static int static int
_add_svc(const char *cat, const char *srv, const char *id, const char *platform) _add_svc(const char *cat, const char *srv, const char *id, const char *platform)
{ {
char name[128+1]; char name[128+1];
char path[64]; char path[64];
int ret; int ret;
snprintf(name, sizeof(name), "%s on %s", cat, friendly_name); snprintf(name, sizeof(name), "%s on %s", cat, friendly_name);
snprintf(path, sizeof(path), snprintf(path, sizeof(path),
"path=/TiVoConnect?Command=QueryContainer&Container=%s", id); "path=/TiVoConnect?Command=QueryContainer&Container=%s", id);
DPRINTF(E_INFO, L_SSDP, "Registering '%s'\n", name); DPRINTF(E_INFO, L_SSDP, "Registering '%s'\n", name);
ret = avahi_entry_group_add_service(ctx.group, AVAHI_IF_UNSPEC, AVAHI_PRO TO_UNSPEC, ret = avahi_entry_group_add_service(ctx.group, AVAHI_IF_UNSPEC, AVAHI_PRO TO_INET,
0, name, srv, NULL, NULL, runtime_var s.port, 0, name, srv, NULL, NULL, runtime_var s.port,
"protocol=http", path, platform, NULL ); "protocol=http", path, platform, NULL );
if (ret < 0) if (ret < 0)
DPRINTF(E_ERROR, L_SSDP, "Failed to add %s: %s\n", DPRINTF(E_ERROR, L_SSDP, "Failed to add %s: %s\n",
srv, avahi_strerror(avahi_client_errno(ctx.client))); srv, avahi_strerror(avahi_client_errno(ctx.client)));
return ret; return ret;
} }
/* Try to register the TiVo DNS SRV service type. */ /* Try to register the TiVo DNS SRV service type. */
static void static void
register_stuff(void) register_stuff(void)
{ {
assert(ctx.client); assert(ctx.client);
if (!ctx.group) if (!ctx.group)
skipping to change at line 100 skipping to change at line 127
return; return;
} }
} }
if (avahi_entry_group_is_empty(ctx.group)) if (avahi_entry_group_is_empty(ctx.group))
{ {
if (_add_svc("Music", "_tivo-music._tcp", "1", NULL) < 0) if (_add_svc("Music", "_tivo-music._tcp", "1", NULL) < 0)
return; return;
if (_add_svc("Photos", "_tivo-photos._tcp", "3", NULL) < 0) if (_add_svc("Photos", "_tivo-photos._tcp", "3", NULL) < 0)
return; return;
if (_add_svc("Videos", "_tivo-videos._tcp", "2", "platform=pc/rea dydlna") < 0) if (_add_svc("Videos", "_tivo-videostream._tcp", "2", "platform=p c/"SERVER_NAME) < 0)
return; return;
if (avahi_entry_group_commit(ctx.group) < 0) if (avahi_entry_group_commit(ctx.group) < 0)
{ {
DPRINTF(E_ERROR, L_SSDP, "Failed to commit entry group: % s\n", DPRINTF(E_ERROR, L_SSDP, "Failed to commit entry group: % s\n",
avahi_strerror(avahi_client_errno(ctx.client))); avahi_strerror(avahi_client_errno(ctx.client)));
return; return;
} }
} }
} }
/* Called when publishing of service data completes */
static void publish_reply(AvahiEntryGroup *g,
AvahiEntryGroupState state,
AVAHI_GCC_UNUSED void *userdata)
{
assert(ctx.group == NULL || g == ctx.group);
switch (state) {
case AVAHI_ENTRY_GROUP_ESTABLISHED:
/* The entry group has been established successfully */
DPRINTF(E_MAXDEBUG, L_SSDP, "publish_reply: AVAHI_ENTRY_GROUP_EST
ABLISHED\n");
break;
case AVAHI_ENTRY_GROUP_COLLISION:
/* With multiple names there's no way to know which one collided
*/
DPRINTF(E_ERROR, L_SSDP, "publish_reply: AVAHI_ENTRY_GROUP_COLLIS
ION: %s\n",
avahi_strerror(avahi_client_errno(ctx.client)));
avahi_threaded_poll_quit(ctx.threaded_poll);
break;
case AVAHI_ENTRY_GROUP_FAILURE:
DPRINTF(E_ERROR, L_SSDP, "Failed to register service: %s\n",
avahi_strerror(avahi_client_errno(ctx.client)));
avahi_threaded_poll_quit(ctx.threaded_poll);
break;
case AVAHI_ENTRY_GROUP_UNCOMMITED:
case AVAHI_ENTRY_GROUP_REGISTERING:
default:
break;
}
}
static void client_callback(AvahiClient *client, static void client_callback(AvahiClient *client,
AvahiClientState state, AvahiClientState state,
void *userdata) void *userdata)
{ {
ctx.client = client; ctx.client = client;
switch (state) { switch (state) {
case AVAHI_CLIENT_S_RUNNING: case AVAHI_CLIENT_S_RUNNING:
/* The server has started up successfully and registered its host /* The server has started up successfully and registered its host
* name on the network, so it's time to create our services */ * name on the network, so it's time to create our services */
register_stuff(); register_stuff();
break; break;
case AVAHI_CLIENT_S_COLLISION: case AVAHI_CLIENT_S_COLLISION:
skipping to change at line 205 skipping to change at line 202
************************************************************************/ ************************************************************************/
/* /*
* Tries to shutdown this loop impl. * Tries to shutdown this loop impl.
* Call this function from inside this thread. * Call this function from inside this thread.
*/ */
void tivo_bonjour_unregister(void) void tivo_bonjour_unregister(void)
{ {
DPRINTF(E_DEBUG, L_SSDP, "tivo_bonjour_unregister\n"); DPRINTF(E_DEBUG, L_SSDP, "tivo_bonjour_unregister\n");
if (ctx.group)
{
avahi_entry_group_reset(ctx.group);
avahi_entry_group_free(ctx.group);
}
if (ctx.threaded_poll) if (ctx.threaded_poll)
avahi_threaded_poll_stop(ctx.threaded_poll); avahi_threaded_poll_stop(ctx.threaded_poll);
if (ctx.client) if (ctx.client)
avahi_client_free(ctx.client); avahi_client_free(ctx.client);
if (ctx.threaded_poll) if (ctx.threaded_poll)
avahi_threaded_poll_free(ctx.threaded_poll); avahi_threaded_poll_free(ctx.threaded_poll);
} }
/* /*
* Tries to setup the Zeroconf thread and any * Tries to setup the Zeroconf thread and any
 End of changes. 9 change blocks. 
40 lines changed or deleted 42 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)