I encode my Sony BRAVIA KDL-40EX505 and had the same problem.
192.168.0.102 - my computer and server for music files. 192.168.0.10 - Sony TV.
When I do setAVTransportURI, the following happens:
The next POST is sent to the TV
POST /upnp/control/AVTransport HTTP/1.1 Host: 192.168.0.10:52323 Connection: keep-alive Content-Length: 442 Cache-Control: no-cache Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop Content-Type: text/xml;charset="UTF-8" Soapaction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36 Postman-Token: a8169b28-fb09-7029-60a9-b7e2641dc1d6 Accept: */* Accept-Encoding: gzip, deflate Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4 <?xml version="1.0" encoding="utf-8" standalone="yes"?> <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"> <InstanceID>0</InstanceID> <CurrentURI>http://192.168.0.102:80/music.php?f=geradeaus</CurrentURI> <CurrentURIMetaData></CurrentURIMetaData> </u:SetAVTransportURI> </s:Body> </s:Envelope>
The TV transmits a HEAD request to the URL specified in CurrentURI from the POST above:
HEAD /music.php?f=geradeaus HTTP/1.1 getcontentFeatures.dlna.org: 1 X-AV-Physical-Unit-Info: pa="BRAVIA KDL-40EX505"; X-AV-Client-Info: av="5.0"; cn="Sony Corporation"; mn="BRAVIA KDL-40EX505"; mv="1.7"; Host: 192.168.0.102:80
Response to a HEAD request:
HTTP/1.1 200 OK Date: Sat, 05 Mar 2016 20:58:58 GMT Server: Apache/2.4.9 (Win64) PHP/5.5.12 X-Powered-By: PHP/5.5.12 Content-Length: 9622288 transferMode.dlna.org: Streaming Accept-Ranges: bytes Cache-Control: no-cache contentFeatures.dlna.org: DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000 Content-Type: audio/mpeg
If everything worked, the TV answers the first POST request with 200 OK, otherwise you will get 500 Internal Server Error.
Result
So, for Sony BRAVIA KDL-40EX505 it is important to enable
transferMode.dlna.org: Streaming
and
contentFeatures.dlna.org: DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000
in the response of the HEADER request to the audio or video file. I did this with the php file:
<?php $file = $_GET['f'].'.mp3'; header('Content-Length: '.filesize($file)); header('Content-Type: audio/mpeg'); header('transferMode.dlna.org: Streaming'); header('Accept-Ranges: bytes'); header('Cache-Control: no-cache'); header('contentFeatures.dlna.org: DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000'); fpassthru(fopen($file, 'rb')); exit; ?>
This is called through 192.168.0.102:80/music.php?f=geradeaus and returns geradeaus.mp3
Learn the line contentFeatures.dlna.org
I used BubbleUPnP for Android (you need to find a UPnP player that works for you) to play the music file. After that, I opened the Cling Workbench ( http://4thline.org/projects/cling/workbench/ ), selecting my TV, select AVTransport in the tree structure and the "Use Service" button. The URI of the file being played through BubbleUPnP is displayed in the Current URI section. Then I made a HEAD call against this URI using the HEADER I found through WireShark (the important ones are getcontentFeatures.dlna.org, X-AV-Physical-Unit-Info and X-AV-Client-Info, you can also send http GET to your TV: 52323 / upnp / control / AVTransport instead of using WireShark, which returns X-AV-Physical-Unit-Info and X-AV-Client-Info in the response header).
HEAD call for BubbleUPnP on Android:
HEAD /external/audio/media/8588.mp3 HTTP/1.1 Host: 192.168.0.12:57645 Connection: keep-alive Cache-Control: no-cache X-AV-Physical-Unit-Info: pa="BRAVIA KDL-40EX505"; X-AV-Client-Info: av="5.0"; cn="Sony Corporation"; mn="BRAVIA KDL-40EX505"; mv="1.7"; User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36 getcontentFeatures.dlna.org: 1 Postman-Token: 39fabd1c-7464-6631-2645-c62cdca6f83d Accept: */* Accept-Encoding: gzip, deflate, sdch Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
BubbleUPnP responds with the correct line contentFeatures.dlna.org
HTTP/1.1 200 OK Date: Sat, 05 Mar 2016 21:31:37 GMT Server: Android, UPnP/1.0 DLNADOC/1.50, BubbleUPnP/2.6.0.2-amz Cache-Control: no-cache transferMode.dlna.org: Streaming contentFeatures.dlna.org: DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000 Content-Type: audio/mpeg Last-Modified: Sat, 05 Mar 2016 18:21:43 GMT Content-Length: 8523162 Accept-Ranges: bytes