[转] Inside DuetDisplay and Unattributed Open-Source

转自 http://ich.deanmcnamee.com/re/2014/12/18/DuetDisplay.html

I read about Duet a few days before its release. There were some interesting claims being suggested — “ex-Apple engineer” is able to run a display over the lightning connector, with zero latency. The marketing made it sound like this Apple-insiderness allowed them to do something new, perhaps a hardware level / accelerated connection with the iOS device to run it as a “real” display at 60 FPS. So how does it work?

Overview

The Duet driver creates an additional display, a memory backed framebuffer. The pixel contents of this framebuffer display are captured and compressed (with the help of CocoaSplit) and sent to the iOS device through the iTunes TCP over USB transport mechanism implemented by PeerTalk. So in the end this is quite like a VNC over TCP over UDP, so I find the claims of “zero lag” and 60 FPS to be a bit dishonest. This is not something like a DisplayLink connection.

Open-Source Libraries

Before Duet was released for iOS, the Desktop Duet.app was available to download. Taking a look at the binary revealed code from a few open-source libraries:

Credits?

Credits? I am not a lawyer and generally not a psychopath about software licensing. However, having spent much of my life on open-source software, I feel that when someone gives you something to use, commercially, free of charge, with attribution as the only obligation, that’s a pretty good deal. You really have a responsibility to do the right (and legal) thing. As far as I’ve seen, none of the above libraries are attributed anywhere in Duet. Additionally it seems CocoaSplit is licensed under the GPL. Uh oh.

PeerTalk

PeerTalk uses the iTunes usbmux system to relay TCP connections across the iOS USB connection. I am surprised that Apple has approved this in the AppStore, as it uses a reversed engineered interface to the usbmuxd socket. The good news is that if Apple has approved Duet, it means if all is fair anyone else should be able to use usbmux also.

scheduleReadPacketWithCallback

Disassembly of “DuetUSBChannel” as compared with PTUSBChannel scheduleReadPacketWithCallback. It seems the main difference between PeerTalk and the version in Duet, is the prefix has been renamed from PT to Duet. Why?

CocoaSplit

CocoaSplit is designed for capturing and streaming a display.

420v.fgsh

420v fragement shader included in Duet.app, as compared to the shader in CocoaSplit. Now, this is quite similar to one of the examples from Apple, however notice that the variables are renamed and it matches the whitespace and naming from CocoaSplit identically.

PreviewView

Duet’s PreviewView, as compared with the same from CocoaSplit.

GPUImage

GPUImage is a general purpose library of image processing via OpenGL.

GPUImage

GPUImageFramebuffer as seen in Duet.app.

Driver

I haven’t looked very deeply at the driver, but it is implementing a virtual screen framebuffer, similar to what is done by EWProxyFramebuffer. I’m not suggesting that any of the code from EWProxyFramebuffer was used. However, if you were to try to implement something similar that would be a good starting point.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,436评论 0 10
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,535评论 5 6
  • 在中南半岛北部的密林深处,坐落着一座神圣的巨石庙宇。千余年前,古老高棉民族在热带雨林深处,用智慧建筑了世界上最...
    初见拾月阅读 781评论 0 0
  • HunmanIK简称HIK,它是一个全身反向运动学的解算器和重定位器。MotionBuilder中的HIK工具提供...
    CG动捕阅读 2,523评论 2 4
  • 求木之长者,必固其根本; 欲流之远者,必浚其泉源。 (一)身世 我的爷爷名讳薛世山,祖籍山东省青洲府诸城县逄戈庄方...
    薛顺堂阅读 1,105评论 2 6