C# - RTP 屏幕流

C# - RTP screen streaming

我正在尝试制作一个远程桌面应用程序,用户可以在其中从网络应用程序(如在 logmein 中)控制他的电脑。 我通过桌面部分的 C# 和 web 应用程序的 NodeJS 实现了这一点,使用 Socket.IO.

进行了通信

我的第一次尝试是捕获屏幕截图(仅 5 fps),然后将其与之前的屏幕截图进行比较并仅发送 8 位图像颜色的差异,这导致 - 800 * 600 分辨率虚拟桌面 - 在第一张图片 100kb,然后根据屏幕上的变化从 5kb 到 60Kb。

用我的本地机器控制一个 virtualbox,一切都很完美,但是当我在线托管 webapp 时,结果是灾难性的,出现了不可能的延迟。

研究了几次发现这种app用我的方法是做不出来的,必须要用实时协议,在客户端屏幕上直播。

我的问题是:

Is there any free / open-source RTP libraries that is ready-to-use ?

How would-I transfer a live streaming from the desk app to the webapp since it's coming from the client side which has no open port ? I was thinking of another desktop app that will run on the server (hosting the webapp) and then it will stream the same content again, and then the webapp can simply display the content by acceding to the local ip with the RTP port, but this doesn't solve the mystery of transferring a live streaming from the client to the server ?

这会很棘手。上面的所有库都遵循严格的 RTSP/RTP 规范,该规范要求在您的主机端打开一个侦听端口,这无疑将位于 nat'd 地址之后。我会坚持每一端都是客户端并到达 'up' 到您的网络服务。您还需要保证帧的交付(因为您交付增量增量),因此 RTP(传统上基于 UDP)将具有挑战性。

一些想法

归根结底,RTP 只是一个标准化的 12 字节 header 和压缩媒体的打包规则。它不会帮助延迟。真正的好处是允许您以符合标准的方式连接到端点,例如 VLC 客户端。

您可以调整您的套接字,这会有所帮助,但老实说,我会关注的是压缩和屏幕捕获效率。你使用什么图像压缩? VNC 传统上使用 zlib 和其他一些有损格式,例如 jpeg。这些框架越小越好。

还有另一个可能有用的想法 - Microsoft 有一个 API 用于获取 'dirty screen areas'。它被称为 Desktop Duplication API 并且它的执行速度非常快。但是它是 Win8 及更高版本。

祝你一切顺利!