URL fix for Airplay
#1
I noticed that a lot of streams on my iPad cannot be played with Airplay on XBMC. Looking at the loggings I noticed that some data is appended to the url, removing this fixes quite some streams.

For example: http://www.radio1.nl/ Click on the webcam link on your[/code] iPad. The ipad plays this nicely, but the stream cannot be transferred to xbmc. The server replies with a 404.

Apply this patch to fix it.

Code:
--- a/xbmc/network/AirPlayServer.cpp
+++ b/xbmc/network/AirPlayServer.cpp
@@ -801,9 +801,9 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,

     if (status != AIRPLAY_STATUS_NEED_AUTH)
     {
-      CStdString userAgent="AppleCoreMedia/1.0.0.8F455 (AppleTV; U; CPU OS 4_3 like Mac OS X; de_de)";
-      CURL::Encode(userAgent);
-      location += "|User-Agent=" + userAgent;
+      //CStdString userAgent="AppleCoreMedia/1.0.0.8F455 (AppleTV; U; CPU OS 4_3 like Mac OS X; de_de)";
+      //CURL::Encode(userAgent);
+      //location += "|User-Agent=" + userAgent;

       CFileItem fileToPlay(location, false);
       fileToPlay.SetProperty("StartPercent", position*100.0f);
Reply
#2
We need the useragent for other streams like apple trailers. I won't apply that. More over we seem to have an issue to strip that options off from the url (which might have sneaked in through the development phase). The righ patch is to get the useragent parsed and removed from the url at the right spot.
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#3
(2012-11-24, 19:20)Memphiz Wrote: We need the useragent for other streams like apple trailers. I won't apply that. More over we seem to have an issue to strip that options off from the url (which might have sneaked in through the development phase). The righ patch is to get the useragent parsed and removed from the url at the right spot.

Ok, you are correct. I didn't check apple trailers and my patch did break them. The apple trailers however are not a regular HLS request, an m4v file instead of an m3u8[/code] is requested. So I created this interim solution: the useragent is appended to the url, except if the string ".m3u8" is found somewhere in the url.
Code:
--- a/xbmc/network/AirPlayServer.cpp
+++ b/xbmc/network/AirPlayServer.cpp
@@ -800,10 +800,19 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
     }

     if (status != AIRPLAY_STATUS_NEED_AUTH)
-    {
-      CStdString userAgent="AppleCoreMedia/1.0.0.8F455 (AppleTV; U; CPU OS 4_3 like Mac OS X; de_de)";
-      CURL::Encode(userAgent);
-      location += "|User-Agent=" + userAgent;
+    {
+      /*
+       Special case, do not attach userAgent to .m3u8 requests, some servers
+       reject a request with the userAgent appended to the request
+      */
+    
+      int m3u8_found = location.Find(".m3u8");
+      if (m3u8_found == -1)
+      {        
+        CStdString userAgent="AppleCoreMedia/1.0.0.8F455 (AppleTV; U; CPU OS 4_3 like Mac OS X; de_de)";
+        CURL::Encode(userAgent);
+        location += "|User-Agent=" + userAgent;
+      }

       CFileItem fileToPlay(location, false);
       fileToPlay.SetProperty("StartPercent", position*100.0f);
Reply
#4
Well as said we need to fix it somewhere deeper in our player code. The airplay stuff is the wrong place to any workarounds. Will try to have a look at it.
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#5
The right approach would be to set s->user_agent in lib/ffmpeg/libavformat/http.c, right? If I set user_agent (line 350) manually to '"AppleCoreMedia/1.0.0.10A523 (iPad; U; CPU OS 6_0_1 like Mac OS X; nl_nl)", things start to work.
Reply
#6
Keep track of this PR which will fix it ... https://github.com/xbmc/xbmc/pull/1844
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#7
Thnx, great!
Reply
#8
(2012-11-25, 20:04)erikoo Wrote: Thnx, great!

I'm trying to compile xbmc in order to have this improvement since 3 days, however I'm not succeded.

Is it possible for some help to compile and upload it ?

Thanks!

Reply
#9
http://wiki.xbmc.org/index.php?title=HOW..._candidate

The fix is in the latest release candidate, it has been in the master for about a month.
Image
Reply
#10
(2013-01-07, 11:51)crash123 Wrote: http://wiki.xbmc.org/index.php?title=HOW..._candidate

The fix is in the latest release candidate, it has been in the master for about a month.

We are looking for a fix / update in windows/linux versions
Reply
#11
eh ? http://xbmc.org/download/ and rc3 is chopped liver ?
Reply
#12
...does this fix only work for airtunes? When I try to watch Video via airplay from e. g. this app (https://itunes.apple.com/de/app/unser-sa...35119?mt=8) there's only audio but no video (app might be available only in Germany, Switzerland, Austria). Might be bad coding of the app though...
Reply
#13
That happens with multiple apps and has nothing to do with the fix mentioned here. Its some sort of drm stuff where the videostream just isn't allowed iirc.
AppleTV4/iPhone/iPod/iPad: HowTo find debug logs and everything else which the devs like so much: click here
HowTo setup NFS for Kodi: NFS (wiki)
HowTo configure avahi (zeroconf): Avahi_Zeroconf (wiki)
READ THE IOS FAQ!: iOS FAQ (wiki)
Reply
#14
(2013-01-07, 22:32)davilla Wrote: eh ? http://xbmc.org/download/ and rc3 is chopped liver ?

Just tested live version of rc3.

And it's working like a charm!!

Thanks to everybody who contributed on this fix !!!
Reply
#15
Hi Everyone, i endup reading this topic as i noticed that to all my HLS stream being sent via Airplay, something was appended to the URL.

|User-Agent=AppleCoreMedia%2f1.0.0.8F455%20(AppleTV%3b%20U%3b%20CPU%20OS%204_3%20like%20Mac%20OS%20X%3b%20de_de)

I was like what the hell is this harcoded user agent that make all my streams to fail.

So well i guess you had very good reasons to do it, but i just wanted to highlight the fact that many tokenised streams (as akamai) are using this user agent to create their token, once the token is generated, they will check if the encoded token match with the original user agent it has been originally encoded by, and since this is hardcoded here, the stream has no chance of success, so they of course always fail, creating a nice 403 Forbidden!

Code:
22:04:57 T:1968979968   ERROR: CCurlFile::Stat - Failed: HTTP response code said error(22) for https://xxxxxxxxxxx.akamaihd.net/i/aStreamName@aStreamID/index_500_av-b.m3u8?sd=10&rebase=on&id=nopenopenope|User-Agent=AppleCoreMedia%2f1.0.0.8F455%20(AppleTV%3b%20U%3b%20CPU%20OS%204_3%20like%20Mac%20OS%20X%3b%20de_de)
22:04:57 T:1968979968  NOTICE: DVDPlayer: Opening: https://xxxxxxxxxxx.akamaihd.net/i/aStreamName@aStreamID/index_500_av-b.m3u8?sd=10&rebase=on&id=nopenopenope|User-Agent=AppleCoreMedia%2f1.0.0.8F455%20(AppleTV%3b%20U%3b%20CPU%20OS%204_3%20like%20Mac%20OS%20X%3b%20de_de)
22:04:57 T:1968979968 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
22:04:57 T:1694495808  NOTICE: Thread DVDPlayer start, auto delete: false
22:04:57 T:1694495808  NOTICE: Creating InputStream
22:04:57 T:1881142336   ERROR: CecLogMessage - could not start CEC communications
22:04:57 T:1881142336   ERROR: OpenConnection - could not opening a connection to the CEC adapter
22:04:58 T:1694495808   ERROR: CCurlFile::FillBuffer - Failed: HTTP returned error 403

My temporary fix is to put charles proxy behind Kodi on my raspberry pi and apply some rewriting rules that will automatically erase this hardcoded user agent in the request to the akamai server

Could it be an option somewhere in Kodi (using 14.2) where we could select hardcoding the user agent or not ?

Thanks a lot for your help and all this wonderful code that made xbmc/kodi so awesome

Kinds Regards

Steve
Reply

Logout Mark Read Team Forum Stats Members Help
URL fix for Airplay0