provegard / airpnp

AirPlay to UPnP bridge written in Python
http://airpnp.finkod.se
BSD 3-Clause "New" or "Revised" License
42 stars 4 forks source link

steep learning curve #7

Closed jer1956 closed 6 years ago

jer1956 commented 6 years ago

I came across this because it does what i want. But i know nothing about python. I installed python 2.7.14 on windows 10. I used pip to install twisted. Now i'm stuck. How do i get twisted to use the code?

provegard commented 6 years ago

This project is really old. I don't recall if I have tested it on Windows.

Twisted is a dependency. It's hard to say anything unless you post some log output or error messages.

On 7 Oct 2017 2:53 PM, "jer1956" notifications@github.com wrote:

I came across this because it does what i want. But i know nothing about python. I installed python 2.7.14 on windows 10. I used pip to install twisted. Now i'm stuck. How do i get twisted to use the code?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/provegard/airpnp/issues/7, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwhgjch6Lgcc7hawFhm7ytU1JgoiAUkks5sp3RQgaJpZM4PxVx8 .

jer1956 commented 6 years ago

Hi, Thanks for replying so quickly. Both python and twisted run from the command prompt. All i then did was unzip the app, cd to top folder, and run the twistd command. It says airpnp is an unknown command. Do i need to import the app into python? Do i need a .tac file?

provegard commented 6 years ago

Sorry, now I see what you mean. I'm not sure. I suppose Twisted may have changed since I wrote the readme. I can try on my Windows machine later on.

jer1956 commented 6 years ago

That would be a great help. I did find a guide which said i needed to add the parent folder to sys path for the plugin folder to be found. I did that...didn't help.

jer1956 commented 6 years ago

It has been pointed out to me that ahari won't work on windows. Do you use that to find upnp devices?

jer1956 commented 6 years ago

So do i need to run a virtual linux? It would need to offer up virtual airplay devices detected by tuneblade running on the host windows at the same time.

jer1956 commented 6 years ago

I have installed a mini linux build via virtualbox. I then used sudo to install everthing in your readme. Some was already there. I downloaded and unzipped the app. I then used linux File Manager to open a command prompt in it's folder. I ran the twistd command and got the same error. Do we need an older version of it?

provegard commented 6 years ago

I haven't had time to test yet, sorry. I guess Linux is a more viable path than Windows given the dependencies.

jer1956 commented 6 years ago

I looked at the listed commands. It says web loads a web app from the folder. So should it be twistd web..called from app folder parent?

jer1956 commented 6 years ago

Doing that gets no error. If i try it a second time it says a server is already running.

jer1956 commented 6 years ago

I now have a twistd log and pid file in the folder airpnp-master

jer1956 commented 6 years ago

This command is meant to run plugin

$ twistd -n web --class=twistdPlugin.resource

jer1956 commented 6 years ago

As i posted first. Steep learning curve. Two files are missing. Manifest.in and setup.py.

I have followed aguide and templates to create them. Running sudo python setup.py install

...has added the two plugins as twistd commands.

provegard commented 6 years ago

I tested on my server where I have twistd 13.2.0. Just running twistd airpnp starts the server in the background, as you noted. As described in the README, you may use twistd -n airpnp to start in the foreground instead. You can kill the existing process by its PID found in the pid file.

The server successfully found my WDTVLIVE UPnP device. However, I couldn't connect from my iPad. I suppose the published Avahi configuration is too old. I got an email from someone a long time ago with updated configuration. The diff against airpnp/AirPlayService.py follows:

@@ -243,8 +265,9 @@ class AirPlayService(MultiService):

         # 0x77 instead of 0x07 in order to support AirPlay from ordinary apps;
         # also means that the body for play will be a binary plist.
-        self.features = 0x77
-        self.model = "AppleTV2,1"
+        #self.features = 0x77
+        self.features = 0x386b# 0x39f7 +8 (VideoVolumeControl) - 16 (HTTP Live Streaming) - 2^7 (Mirroring) - 2^8 (ScreenRotate)
+        self.model = "AppleTV3,2"

         # create TCP server
         TCPServer(port, self.create_site(), 100, interface=host).setServiceParent(self)
@@ -252,8 +275,8 @@ class AirPlayService(MultiService):
         # create avahi service
         if (name is None):
             name = "Airplay Service on " + platform.node()
-        zconf = ZeroconfService(name, port=port, stype="_airplay._tcp",
-                                text=["deviceid=" + self.deviceid, "features=" + hex(self.features), "model=" + self.model],
+        zconf = ZeroconfService(self.deviceid.replace(":","")+"@"+name, port=port, stype="_raop._tcp",
+                                text=["ch=2", "cn=0,1", "ek=1", "et=0,1", "pw=false", "sm=false", "sr=44100", "ss=16", "sv=false", "tp=UDP" , "txtvers=1", "vn=3" ],
                                 index=index)
         zconf.setServiceParent(self)

With these changes, my iPad (not the newest, but with iOS 11) detected the UPnP correctly. However, when I tried to connect, I got an error message. I haven't tested anything beyond that. If you get it to work, feel free to open a PR!

I'm not sure what you mean by steep learning curve. I followed the README in a fresh clone of the repo with success, so as far as I can tell they are correct. Perhaps you have some differences in your machine setup compared to mine?

jer1956 commented 6 years ago

I could not get it to run until i installed the plugins by adding the two missing files. I have had to learn how to do that myself. I then had to get virtual box into bridge mode so it was a device on my lan. So it runs, finds dmr's and start airplay services. Bonjour does not find them. I can manually add them to Tuneblade. It trys to connect, but fails. The log output on the linux window shows tuneblade did try to connect.

jer1956 commented 6 years ago

P.S. I then tried to install the plugins into windows python the same way. It failed due to the missing function getifaddrs, a linux only function.

jer1956 commented 6 years ago

twistd.log

jer1956 commented 6 years ago

Full level 4 log twistd.log

provegard commented 6 years ago

As far as I can see from the log, airpnp is up and running, is detecting UPnP devices and is accepting AirPlay commands.

Please note that there is no RTSP support in airpnp.

jer1956 commented 6 years ago

From what i've read Airplay uses rtsp for "in use" interrogations. Hence why tuneblade starts with rtsp. Tuneblade works with my actual airplay devices. http://nto.github.io/AirPlay.html#audio-rtsprequests

So in essence this is for video only via http?

provegard commented 6 years ago

Yes, that's the use case I developed it for. Basically controlling my WDTVLIVE from an iPad/iPhone. I actually have a UPnP audio device so I thought about RTSP support, but I never got around to implement it - partly because said audio device has a buggy UPnP implementation.

jer1956 commented 6 years ago

Don't get me wrong. This is a very clever idea that has room for improvement. You have issues yourself with detection. Is that because it has no bonjour code? I had the same problem with my Yamaha amp. My IPAD cannot find it. But with tuneblade i can manually put in a device using it's IP and controller port. So ironically i can only use it's Apple feature via a PC!

jer1956 commented 6 years ago

Trying to get this working forced me to use Linux in a Virtualbox. I have found another linux tool. Pulseaudio-dlna. I will focus on trying that. Thankyou for your time

provegard commented 6 years ago

No problem! I hope you'll find something that works. :)