2010年8月27日 星期五

How to use libupnp sample code

First, download the libupnp source code

http://sourceforge.net/projects/pupnp/files/

version is libupnp-1.6.6

now we extract and compiler it


mad@mad-desktop:~$ tar -jxvf libupnp-1.6.6.tar.bz2
mad@mad-desktop:~$ cd libupnp-1.6.6/
mad@mad-desktop:~/libupnp-1.6.6$ ./configure
mad@mad-desktop:~/libupnp-1.6.6$ make


now we compiler sample code


mad@mad-desktop:~/libupnp-1.6.6$ cd upnp/
mad@mad-desktop:~/libupnp-1.6.6/upnp$ cd sample/
mad@mad-desktop:~/libupnp-1.6.6/upnp/sample$ make check


now you can see the execute file.upnp_tv_ctrlpt and upnp_tv_device
upnp_tv_ctrlpt is UPnP control point and
upnp_tv_device is upnp virtual device
we execute it


mad@mad-desktop:~/libupnp-1.6.6/upnp/sample$ ./upnp_tv_device


you can see upnp virtual device information


mad@mad-desktop:~/LAB/libupnp/libupnp-1.6.6/upnp/sample$ ./upnp_tv_device
Initializing UPnP Sdk with
ipaddress = (null) port = 0
UPnP Initialized
ipaddress= 192.168.0.123 port = 49154
Specifying the webserver root directory -- ./web
Registering the RootDevice
with desc_doc_url: http://192.168.0.123:49154/tvdevicedesc.xml
RootDevice Registered
Initializing State Table
Found service: urn:schemas-upnp-org:service:tvcontrol:1
serviceId: urn:upnp-org:serviceId:tvcontrol1
Found service: urn:schemas-upnp-org:service:tvpicture:1
serviceId: urn:upnp-org:serviceId:tvpicture1
State Table Initialized
Advertisements Sent

>>


you can see the device's service at the url
http://192.168.0.123:49154/tvdevicedesc.xml



and then you execute control point

mad@mad-desktop:~/LAB/libupnp/libupnp-1.6.6/upnp/sample$ ./upnp_tv_ctrlpt


mad@mad-desktop:~/LAB/libupnp/libupnp-1.6.6/upnp/sample$ ./upnp_tv_ctrlpt
Initializing UPnP Sdk with
ipaddress = (null) port = 0

UPnP Initialized
ipaddress= 192.168.0.123 port = 49153

Registering Control Point
Control Point Registered




then you can see virtual device's discovery



======================================================================

----------------------------------------------------------------------

UPNP_DISCOVERY_SEARCH_RESULT

ErrCode = 0

Expires = 100

DeviceId = uuid:Upnp-TVEmulator-1_0-1234567890001

DeviceType = urn:schemas-upnp-org:device:tvdevice:1

ServiceType =

ServiceVer =

Location = http://192.168.0.123:49155/tvdevicedesc.xml

OS = Linux/2.6.28-18-generic, UPnP/1.0, Portable SDK for UPnP devices/1.6.6

Ext =

----------------------------------------------------------------------

======================================================================



to be continued

沒有留言:

張貼留言