简体   繁体   中英

UPnP AV Remote Control in Java or C#

I need to create some kind of remote control that can interact with a UPnP media server.

I've read that there are kind of like three applications for the UPnP AV stack: media server, media renderer, control point. At first, I thought that a control point is what I want to program, however, after skimming through the docs of a few libraries, it appears to me that a control point still wants to play the media files the server provides on the very device, the control point runs on, using external software (unlike the media renderer, that plays the files itself).

Have I understood this correctly or am I totally wrong?

Furthermore, I couldn't find any library, that seemed easy enough to use. This is probably due to my poor skills but I also have the feeling that the documentation of many libraries is rather bad and incomplete.

I don't remember all the libraries I came across, but they included often mentioned names such as Cling, Fraunhofer FOKUS and CyberLink. I read most of the stuff on their websites including some docs and couldn't really find out how I could use them the way I want to.

I'd simply need something that lets me connect to a server, index the media listings so I can jump to whatever track and the only give me the possibility to play, stop, pause, next, prev and control the volume . The files however should be played back serverside .

Do you know of any such great thing for Java or C#? Thanks a lot in advance. :)

At first, I thought that a control point is what I want to program, however, after skimming through the docs of a few libraries, it appears to me that a control point still wants to play the media files the server provides on the very device, the control point runs on, using external software (unlike the media renderer, that plays the files itself).

To be compatible with UPnP AV, software applications or hardware devices have to include at least one UPnP AV device (MediaServer, ControlPoint or MediaRenderer) and its mandatory services. There are applications providing several devices, thus, the logical separation may not be found in practice. Often, video players only implement the ControlPoint services for browsing a server and downloading its content (the content could be located even on another server).

I'd simply need something that lets me connect to a server, index the media listings so I can jump to whatever track and the only give me the possibility to play, stop, pause, next, prev and control the volume. The files however should be played back serverside.

UPnP defines several Services that have to be implemented by a device (eg, a MediaServer has to provide a DirectoryService). Every service has mandatory and optional actions (eg, a DirectoryService can be browsed via the Browse method). To achieve what you want, your server has to implement a UPnP MediaServer (needed for browsing its content) and a UPnP MediaRenderer (needed to control the playback). A UPnP ControlPoint acts as a kind of remote control. It is used to browse the server and select the server for playing back files.

A browse request looks like this (ObjectID 0 always denotes the root of the tree):

<Browse xmlns:u =" urn:schemas-upnp-org:service:ContentDirectory:1 ">
<ObjectID>0</ObjectID>
<Filter></Filter>
<RequestedCount>0</RequestedCount>
<StartingIndex >0</StartingIndex>
<SortCriteria ></ SortCriteria>
<BrowseFlag> BrowseDirectChildren </BrowseFlag >
</u:Browse>

The server answers with a response that could look like this:

<DIDL-Lite>
<item id="1" parentID ="0" restricted ="1">
<upnp:class>object.item.videoItem </upnp:class>
<dc:title>Video file</dc:title>
<upnp:artist>John Doe</upnp:artist>
<upnp:genre>Action</ upnp:genre>
<upnp:director>John Doe Jr.</upnp:director>
<res protocolInfo="http-get:*:video/mpeg:*" resolution ="352x288">
http://10.20.30.40:12345/ExportContent?id=1
</res>
</item>
</DIDL-Lite >

In this case, the server only has one video item (usually, the server will have several folders containing many items). The res element contains information about the resource itself (where it is located, which transport protocol has to be used, the mime type,...). In your case, the server could even answer with "localhost" as address, preventing downloading the file. The MediaRenderer part of your server should be able to access it anyway.

I don't remember all the libraries I came across, but they included often mentioned names such as Cling, Fraunhofer FOKUS and CyberLink.

Personally, I would recommend CyberLink for Java . I used it to implement a MediaServer, however it offers enough to implement a ControlPoint or MediaRenderer too. Additionally, you should get a UPnP developer tool such as Developer tools for UPnP (originally Intel UPnP tools) or the GUPnP tools for Linux . GUPnP also provides a UPnP library for C. These developer tools allow you to invoke and debug UPnP commands and come very handy during development. Another useful resource are the UPnP device descriptions from the UPnP consortium.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM