Use airplay to send images

Source: Internet
Author: User

Original article: http://livevision.us/wordpress/2011/02/16/airplay-without-private-api/

Without the efforts of Erica Sadun and the emergence of similar tools such as airplayer, airflick, airpdf, and airsay, I may not have the idea of trying it out. In this article, I will demonstrate creating an iOS app (camthis) to send images to Apple TV, neither using any private API nor jailbreak. I did not submit it to the Apple store, but I will always offer it if there are any new messages.

Update: camthis is currently accepted by Apple.

Required tools:

  • Airplayer (written by Erica Sadun)

The airplayer download link in this link has been deleted, the reader can download: http://download.cnet.com/AirPlayer/3001-13632_4-75330532.html? SPI = cc4808989275f217e583547fa2bef669

  • Bonjour Browser
  • Packet peeper
  • Asihttprequest framework
  • IOS test app

Run airplayer:

  • In this article, we will adopt a trick similar to spoofing to sniff Apple TV's network communication... download and run airplayer.

Note: airplayer is unavailable. Use other similar software.

  • Airplayer uses broadcast _ ariplay. _ TCP messages and bonjour discovers them to disguise them as Apple TV. Therefore, your Mac can be regarded as an Apple TV.
  • When airplayer is running, iOS devices in the same network can push images to airplayer.

Run bonjour Browser:(Download)

  • Bonjour browser is an outstanding Mac application that discovers all bonjour devices on the network.
  • We only use bonjour browser to find the IP address of Apple TV (airplayer), so I won't tell you how to write an iOS bonjour application.

Once the IP address is obtained, write down the address + port (in the middle, the IP address and port of AppleTV I simulated on Mac Are 192.168.1.102: 7000 ).

Bonjourbrowser

Use packet peeper to sniff the network package sent by the IOS airplay device:

  • Packet peeper is an open-source tool for sniffing network packets sent/received on Mac
  • It supports tcpdump filters. We will use it to filter network packets so that we can focus on Apple TV's network packets.
  • When you start a session, you can set a filter similar to "TCP port 7000 ".

Select an airplayer image:

  • If everything goes well, you will see an airplay flag in the upper right corner of the photo app.

Press airplay. We can see that a large number of network packages are monitored in packet peeper.

  • Once the Network Package is monitored, you can select all network packages in the session and select "View menu-> View TCP stream". The result is similar.

Packetpeeper results

  • Do you see the session on the left? It was the first request sent from the device to AppleTV to exchange Client/Server relationships. This is what we know about reversehttp -- that's right. In fact, it has already been included in the draft RFC.
  • In order to enable my iPhone app to initialize and process reversehttp, I had a headache for several hours-but you don't have to worry about it. You just need to care about something like/Server-Info and/photo.

Sample Code:

  • OK. Now that you have all the requirements, you can send an image to AppleTV.
  • Assume that the asihttprequest framework is used. If you are not familiar with it, refer to here.
  • This is code (simple, isn't it ?)

-(Void) senduiimage {

Uiimage * IMG = [uiimageimagenamed: @ "test.png"];

Nsdata * Data = uiimagejpegrepresentation (IMG, 1.0 );

Nsmutabledata * mdata = [[nsmutabledata alloc] initwithdata: Data] autorelease];

 

Nslog (@ "put photo ...");

Nsurl * url = [nsurlurlwithstring: @ "http: // 192.168.2.32: 7000/photo"];

Request = [asihttprequest requestwithurl: url];

[Request setrequestmethod: @ "put"];

[Requestaddrequestheader: @ "User-Agent" value: @ "mediacontrol/1.0"];

[Request setpostbody: mdata];

[Requestsetshouldattemptpersistentconnection: Yes];

[Request startsynchronous];

Nserror * error = [Request Error];

If (! Error ){

Nslog (@ "success ");

} Else {

Nslog (@ "% @", [errorlocalizeddescription]);

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.