简体   繁体   English

Java或C#中的UPnP AV远程控制

[英]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. 我需要创建一种可以与UPnP媒体服务器交互的远程控制。

I've read that there are kind of like three applications for the UPnP AV stack: media server, media renderer, control point. 我已经读过UPnP AV堆栈有三种应用程序:媒体服务器,媒体渲染器,控制点。 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. 我不记得我遇到的所有图书馆,但它们包括经常提到的名字,如Cling,Fraunhofer FOKUS和Cyber​​Link。 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#? 你知道Java或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. 为了与UPnP AV兼容,软件应用程序或硬件设备必须包括至少一个UPnP AV设备(MediaServer,ControlPoint或MediaRenderer)及其强制服务。 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). 通常,视频播放器仅实现用于浏览服务器和下载其内容的ControlPoint服务(内容甚至可以位于另一服务器上)。

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). UPnP定义了必须由设备实现的若干服务(例如,MediaServer必须提供DirectoryService)。 Every service has mandatory and optional actions (eg, a DirectoryService can be browsed via the Browse method). 每个服务都有强制和可选的操作(例如,可以通过Browse方法浏览DirectoryService)。 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). 为了实现您的目标,您的服务器必须实现UPnP MediaServer(浏览其内容所需)和UPnP MediaRenderer(需要控制播放)。 A UPnP ControlPoint acts as a kind of remote control. UPnP ControlPoint充当一种远程控制。 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): 浏览请求如下所示(ObjectID 0始终表示树的根):

<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,...). res元素包含有关资源本身的信息(它所在的位置,必须使用的传输协议,mime类型,......)。 In your case, the server could even answer with "localhost" as address, preventing downloading the file. 在您的情况下,服务器甚至可以使用“localhost”作为地址回答,从而阻止下载文件。 The MediaRenderer part of your server should be able to access it anyway. 无论如何,服务器的MediaRenderer部分应该能够访问它。

I don't remember all the libraries I came across, but they included often mentioned names such as Cling, Fraunhofer FOKUS and CyberLink. 我不记得我遇到的所有图书馆,但它们包括经常提到的名字,如Cling,Fraunhofer FOKUS和Cyber​​Link。

Personally, I would recommend CyberLink for Java . 就个人而言,我会推荐Cyber​​Link for Java I used it to implement a MediaServer, however it offers enough to implement a ControlPoint or MediaRenderer too. 我用它来实现MediaServer,但它提供了足够的实现ControlPoint或MediaRenderer。 Additionally, you should get a UPnP developer tool such as Developer tools for UPnP (originally Intel UPnP tools) or the GUPnP tools for Linux . 此外,您应该获得UPnP开发人员工具,例如用于UPnP的开发人员工具(最初是英特尔UPnP工具)用于LinuxGUPnP工具 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. GUPnP还为C提供了一个UPnP库。这些开发人员工具允许您调用和调试UPnP命令,并在开发过程中非常方便。 Another useful resource are the UPnP device descriptions from the UPnP consortium. 另一个有用的资源是来自UPnP联盟的UPnP设备描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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