2009-08-27 08:32:35 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<!-- $Revision: $ -->
|
|
|
|
|
|
|
|
<chapter xml:id="gupnp.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
2009-09-09 09:42:34 +00:00
|
|
|
This example shows how to obtain information about all devices and services.
|
2009-09-09 09:52:06 +00:00
|
|
|
It starts infinite loop (use CLI) and while any of available devices or services
|
2009-09-09 09:42:34 +00:00
|
|
|
is found proper callback function will be invoked.
|
2009-08-27 08:32:35 +00:00
|
|
|
</para>
|
|
|
|
<example>
|
2009-09-09 09:42:34 +00:00
|
|
|
<title>Search for all UPnP devices and services.</title>
|
2009-08-27 08:32:35 +00:00
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
|
2009-09-09 09:42:34 +00:00
|
|
|
/* Callback for available device */
|
|
|
|
function device_proxy_available_cb($proxy, $arg)
|
|
|
|
{
|
|
|
|
$info = gupnp_device_info_get($proxy);
|
|
|
|
|
|
|
|
$type = $info['device_type'];
|
|
|
|
$location = $info['location'];
|
|
|
|
|
|
|
|
printf("Device available:\n");
|
|
|
|
printf("\ttype: %s\n", $type);
|
|
|
|
printf("\tlocation: %s\n", $location);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Callback for available service */
|
|
|
|
function service_proxy_available_cb($proxy, $arg)
|
|
|
|
{
|
|
|
|
$info = gupnp_service_info_get($proxy);
|
|
|
|
|
|
|
|
$type = $info['service_type'];
|
|
|
|
$location = $info['location'];
|
|
|
|
|
|
|
|
printf("Service available:\n");
|
|
|
|
printf("\ttype: %s\n", $type);
|
|
|
|
printf("\tlocation: %s\n", $location);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create the UPnP context */
|
|
|
|
$context = gupnp_context_new();
|
|
|
|
if (!$context) {
|
|
|
|
printf("Error creating the GUPnP context\n");
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We're interested in everything */
|
|
|
|
$cp = gupnp_control_point_new($context, "ssdp:all");
|
|
|
|
|
|
|
|
/* Set callbacks */
|
|
|
|
gupnp_control_point_callback_set($cp,
|
|
|
|
GUPNP_SIGNAL_DEVICE_PROXY_AVAILABLE, 'device_proxy_available_cb');
|
|
|
|
gupnp_control_point_callback_set($cp,
|
|
|
|
GUPNP_SIGNAL_SERVICE_PROXY_AVAILABLE, 'service_proxy_available_cb');
|
|
|
|
|
|
|
|
/* Start for browsing (infinite loop, hit Ctrl-C to interrupt) */
|
|
|
|
gupnp_control_point_browse_start($cp);
|
2009-08-27 08:32:35 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</chapter>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|
|
|
|
|