Need advise on my approach with UnPn

Sep 5, 2011 at 6:19 PM

Dear all,

I need to build a Windows touch application which is capable of receiving pictures from a device like a Camera(compatible DLNA/Unpn) or Iphone using the ImediaShare server App.
The idea is from a connected device though Wifi, beeing able to receive selected pictures from a server into the application.

As I am not an expert in UnPn and DLNA, I am looking for a simple lib which could turn my touch application as a listner for such device.

Does this ManagedUpnP can help me reach that goal ?

Is it smple to integrate in my app ?

Is tehre clear sample on how device gets recognised and could communicate wth my app and exchange data?

Thanks for help and advise

Sep 5, 2011 at 6:33 PM

I have download the code and run the sample but do not understand how to use it to integrate it in my own application.

Could you explain a bit please ?




Sep 7, 2011 at 5:54 AM
Edited Sep 7, 2011 at 6:27 AM


This library allows you to perform the discovery and communication with devices at the UPnP level, so yes it will help you connect to the device via the UPnP protocol, query the device and then you will need to write the code connect using the DLNA protocol to get the pictures. However, the library does assume that you have a basic knowledge about how the UPnP protocol works, ie, what a Service is, what a Device is, and how they are identified. For information on this check out the UPnP website:


Specifically these documents:


Reading these documents will give you a better undestanding of the underlying technologies anyway, so its a good idea, but all you really need to know is what a device and service is and how they are identified.

It is extremely easy to integrate, and with no more than 3 lines of code you can be ready to call Actions or query State Variables of a service.

The device your connecting to will follow a certain UPnP standard for that service or device type, to discover a service simply use this code replacing the service type ID for the type ID which your device type uses, this can be determined by using the example program included in the framework to see what its service type is.


using ManagedUPnP;
using ManagedUPnP.Descriptions;

            Services lsServices = Discovery.FindServices("urn:schemas-upnp-org:service:WANPPPConnection:1"); // Replace string with the service type id used by your class of devices service.

            foreach (Service lsService in lsServices)
                ServiceDescription lsdDesc = lsService.Description();

		// You can now call lsService.InvokeAction or lsSErvice.QueryStateVariable, or
		// create your own descendant of the service class by writing it yourself or you can
		// use the code generation feature in the sample to generate your own class based on the
		// available actions and / or state variables.

I dont know a lot about the DLNA protocol, but I would assume the UPnP service will provide URLs which your program to use to connect via DLNA and get the pictures.



Sep 7, 2011 at 8:38 AM

Thanks ofr your reply.

In fact here ii here what I am trying to do :

I have an touch application which communicate with a Wifi Camera using the UnPn protocole. The Classes for the UnPn communication I took it from an open source project ready to use. But touble i hav notice is that this open source seems
to not work really well because my camera is not detected all the time, and when it does I am lucky. My application can be used also Iphone with ImediaShare but same stuff.

By trying your sample application, and connecting either my Iphone or Wifi Camera to Wifi network, both devices was detected imediatly by your code. Due to that I though may be it is better integrated or identify and would like to give a try on my app.

The only thing I need now from your side in order to save time for my test, because I have a customer project iterresting in my app, is simply to explain me  :

 - Which method should I call to detect the device and Identify it.
 - Which method should I call to receive data from device

That is true that I have no knowledge on UnPn today, but as a developpement as long as I could use ready made code and use it as a black box will not re invent the real

Thnaks for your help


Sep 7, 2011 at 9:01 AM
Edited Sep 7, 2011 at 9:06 AM

UPnP does not have a set function to "receive data from a device", UPnP devices have services, and each service supports Actions and State Variables, so it would depend on what actions you need to call to get the information to stread the data. What im saying is, that this framework only coverrs the UPnP side of things, ir does not cover the DLNA side of things which is where the streaming comes in.

If your current code can stream data, then this is a direct function of UPnP, its most likely that a particular UPnP action will return a URL which you then stream from, but it is NOT part of UPnP itself, it is part of DLNA, UPnP only encapsulates the discovery, calling actions, invoking state variables, or receiving events when state variables change.

Look at the devices Actions and State Variables to determine what you need to call.

The code I posted above is all you need, simply put in the service ID of the service you wish to use on the UPnP device and thats it.

When you call an action simply use the InvokeAction method of the "Service" class returned by that code above, to give you any more information, i would need to know the exact specifications for the device class you want to connect to and what actions or state variables you need to call or enquire on. Im not sure what extra information you need?

This line will discover the services for any device (use the sample program to get the service type ID):


string sServiceTypeID = "your type id here";
Services lsServices = Discovery.FindServices(sServiceTypeID);


Then the services returns an IEnumerable<Service> class which you can enumerate through or just use the first one, simply call InvokeAction on the service class for the action you want.

If you need more help i will need the logs from my program which is displayed when you select the device in question, If you want to plug in a third party UPnP framework you will need to know the basics of UPnP so that you know how to plug it in.

Sep 7, 2011 at 9:54 AM

Will you be interrested to see the set of UnPn class I used ? may be it will give you an Idea ? Cause for me its chinees :-)



Sep 8, 2011 at 12:25 AM

I dont really have time to be looking through code and learning how DLNA works, but if you paste in here the logs for the primary Device of the UPnP camera taken from the test program included with this framework, that should give us enough for me to help you get started.



Sep 26, 2011 at 8:18 AM


I come back to my case and here is the set of libary we have used for our application :
Do you use those as well or it is own made ?



Sep 26, 2011 at 10:01 PM


No it does not use those dev tools, it Uses the Microsoft COM objects from UPNP.DLL, which is part of windows. However from what you were saying previously, those dev tools provide DLNA code as well, where as this framework does not, it only provides UPNP, so, if you wish to use my framework to access DLNA device functionality, you will have to write a layer on top of this framework to get it do that.