是否有人对Apple的iOS远程应用程序使用的协议进行反向工程,以通过IP控制Apple TV? [英] Has anyone reversed engineered the protocol used by Apple's iOS Remote app for controlling an Apple TV over IP?

查看:172
本文介绍了是否有人对Apple的iOS远程应用程序使用的协议进行反向工程,以通过IP控制Apple TV?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇我是否可以编写可以控制Apple TV的程序,特别是运行tvOS 9.1.1的Apple TV 4代,例如Apple的iOS远程应用程序.我想向其发送用于在四个基本方向上导航,在屏幕上选择一个项目,在导航堆栈中向上移动的命令-本质上是Apple的Remote应用程序可以执行的操作.

I'm curious if it's possible for me to write programs that can control an Apple TV, specifically an Apple TV 4th gen running tvOS 9.1.1, like Apple's Remote app for iOS can. I'd like to send it commands for navigating in the four cardinal directions, selecting an item on the screen, going up the navigation stack -- essentially what Apple's Remote app can do.

有人进行过逆向工程所用协议的工作吗?到目前为止,"Cursory Googling"仅产生了关于早期Apple TV和DAAP协议的过时结果,看起来与我想要的东西有所不同.

Has anyone done any work reverse engineering the protocol it uses? Cursory Googling only has so far yielded out of date results about earlier generation Apple TVs and the DAAP protocol which looks like something different than what I want.

推荐答案

我确实设法通过python脚本控制了Apple TV(当前正在运行tvOS 9.2).事实证明,您不需要使用家庭共享"来让远程应用程序控制Apple TV.我不知道如果启用了家庭共享"功能,以下方法是否会起作用,但是在Apple TV上禁用了家庭共享"功能后,iOS远程应用程序可以选择手动添加设备. (这可能需要删除已经与之配对的所有设备,因为不幸的是,这对于我来说必须使它显示添加设备"按钮.)在将iPhone与Apple TV配对后,我记录了一些内容.它的请求,复制配对GUID,然后构造一些我自己的请求.

I did manage to control my Apple TV (currently running tvOS 9.2) from a python script. It turns out that you don't need to use Home Sharing to have a remote app control the Apple TV. I don't know if the following method will work if Home Sharing is enabled, but with it disabled on the Apple TV, the iOS Remote app has the option to manually add a device. (This may require removing all of the devices it is already paired with, since that was unfortunately necessary for me to get it to display the 'Add a device' button.) Once I had paired my iPhone to the Apple TV, I recorded some of its requests, copied the pairing GUID, and then constructed some of my own requests.

仅需执行三个请求:

/login?pairing-guid=< your pairing guid here >&hasFP=1

登录到Apple TV.响应的最后四个字节是会话ID,编码为大端4字节整数.

Logs into the Apple TV. The last four bytes of the response's is a session id, encoded as a big-endian four byte integer.

/logout?session-id=< your session id here >

注销.并非完全必要,因为我发现登录只是为您提供了一个新的会话ID,但按照预期的方式做事可能不是一个坏主意.

Logs out. Not strictly necessary, as I found that logging in simply gets you a new session id, but probably not a bad idea to do things the way it expects.

/ctrl-int/1/controlpromptentry?prompt-id=114&session-id=< your session id here >

将用户输入发送到Apple TV.数据是输入命令或可能的移动触摸的多个缓冲区之一.为了在基本方向上运动,有必要发送几个这样的请求来模拟运动触感.

Send user input to the Apple TV. The data is one of several buffers that input a command, or possible a moving touch. For movement in the cardinal directions, sending several of these requests to simulate a moving touch is necessary.

我有一个python脚本,在这里演示如何执行此操作: http://pastebin.com/mDHc353A

I have a python script demonstrating how to do this here: http://pastebin.com/mDHc353A

使用请求库: http://docs.python-requests.org/en/大师/

还要特别感谢Adam Miskiewicz/github用户skevy,因为我在他的atlas-后端存储库中使用了此文件,该文件方便地具有正确的缓冲区以供移动:

Also special thanks to Adam Miskiewicz / github user skevy, since I made use of this file in his atlas-backend repo that conveniently had the right buffers to send for movement: https://github.com/skevy/atlas-backend/blob/master/atlas/services/appletv.coffee

这篇关于是否有人对Apple的iOS远程应用程序使用的协议进行反向工程,以通过IP控制Apple TV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆