Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Streaming to Sony NAS-SV20i fails #7

Closed
parkerlreed opened this issue Feb 7, 2024 · 65 comments · Fixed by #11
Closed

Streaming to Sony NAS-SV20i fails #7

parkerlreed opened this issue Feb 7, 2024 · 65 comments · Fixed by #11
Assignees
Labels
bug Something isn't working

Comments

@parkerlreed
Copy link

parkerlreed commented Feb 7, 2024

The Sony receiver takes about 10 seconds to start a stream. blast errors out almost instantaneously (the display on the Sony shows that it tries to start loading it)

(1)(deck@steamdeck Downloads)$ ./blast -headers
----------
DLNA receivers
0: NAS-SV20i
----------
Select the DLNA device:
[0]
----------
Audio sources
0: filter-chain-source
1: filter-chain-sink.monitor
2: input.virtual-sink.monitor
3: output.virtual-source
4: alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_1__sink.monitor
5: alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__sink.monitor
6: alsa_input.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__source
7: alsa_output.pci-0000_04_00.1.hdmi-stereo-extra2.monitor
8: blast.monitor
----------
Select the audio source:
[7]
----------
Your LAN ip addresses
0: 192.168.100.87
1: fe80::b68c:9dff:fe7f:39f7
----------
Select the lan IP address for the stream:
[0]
----------
2024/02/07 15:49:49 starting the stream on port 9000 (configure your firewall if necessary)
2024/02/07 15:49:49 stream URI: http://192.168.100.87:9000/stream.mp3
2024/02/07 15:49:49 setting av1transport URI and playing
(string) (len=4) "HEAD"
(http.Header) (len=1) {
 (string) (len=27) "Getcontentfeatures.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=1) "1"
 }
}
transport: play: SOAP fault. Code: s:Client | Explanation: UPnPError | Detail: <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>501</errorCode><errorDescription>Action Play failed
</errorDescription></UPnPError>
@parkerlreed
Copy link
Author

Debug output

(1)(deck@steamdeck Downloads)$ ./blast -debug
----------
DLNA receivers
0: NAS-SV20i
----------
Select the DLNA device:
[0]
(*goupnp.MaybeRootDevice)(0xc00007e460)({
 USN: (string) (len=84) "uuid:200000000000-1010-8000-78843c671ffd::urn:schemas-upnp-org:service:AVTransport:1",
 Root: (*goupnp.RootDevice)(0xc000017800)({
  XMLName: (xml.Name) {
   Space: (string) (len=31) "urn:schemas-upnp-org:device-1-0",
   Local: (string) (len=4) "root"
  },
  SpecVersion: (goupnp.SpecVersion) {
   Major: (int32) 1,
   Minor: (int32) 0
  },
  URLBase: (url.URL) http://192.168.100.134:54380/MediaRenderer_NAS-SV20i.xml,
  URLBaseStr: (string) (len=56) "http://192.168.100.134:54380/MediaRenderer_NAS-SV20i.xml",
  Device: (goupnp.Device) Device ID uuid:200000000000-1010-8000-78843c671ffd : urn:schemas-upnp-org:device:MediaRenderer:1 (NAS-SV20i)
 }),
 Location: (*url.URL)(0xc00016c480)(http://192.168.100.134:54380/MediaRenderer_NAS-SV20i.xml),
 LocalAddr: (net.IP) (len=16 cap=16) 192.168.100.87,
 Err: (error) <nil>
})
([]*av1.AVTransport1) (len=1 cap=1) {
 (*av1.AVTransport1)(0xc00021f5c0)({
  ServiceClient: (goupnp.ServiceClient) {
   SOAPClient: (*soap.SOAPClient)(0xc0000000c0)({
    EndpointURL: (url.URL) http://192.168.100.134:54380/upnp/control/AVTransport,
    HTTPClient: (http.Client) {
     Transport: (http.RoundTripper) <nil>,
     CheckRedirect: (func(*http.Request, []*http.Request) error) <nil>,
     Jar: (http.CookieJar) <nil>,
     Timeout: (time.Duration) 0s
    }
   }),
   RootDevice: (*goupnp.RootDevice)(0xc000218400)({
    XMLName: (xml.Name) {
     Space: (string) (len=31) "urn:schemas-upnp-org:device-1-0",
     Local: (string) (len=4) "root"
    },
    SpecVersion: (goupnp.SpecVersion) {
     Major: (int32) 1,
     Minor: (int32) 0
    },
    URLBase: (url.URL) http://192.168.100.134:54380/MediaRenderer_NAS-SV20i.xml,
    URLBaseStr: (string) (len=56) "http://192.168.100.134:54380/MediaRenderer_NAS-SV20i.xml",
    Device: (goupnp.Device) Device ID uuid:200000000000-1010-8000-78843c671ffd : urn:schemas-upnp-org:device:MediaRenderer:1 (NAS-SV20i)
   }),
   Location: (*url.URL)(0xc00016c480)(http://192.168.100.134:54380/MediaRenderer_NAS-SV20i.xml),
   Service: (*goupnp.Service)(0xc000211730)(Service ID urn:upnp-org:serviceId:AVTransport : urn:schemas-upnp-org:service:AVTransport:1),
   localAddr: (net.IP) <nil>
  }
 })
}
(interface {}) <nil>
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
  <specVersion>
    <major>1</major>
    <minor>0</minor>
  </specVersion>
  <device>
    <deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
    <friendlyName>NAS-SV20i</friendlyName>
    <manufacturer>Sony Corporation</manufacturer>
    <manufacturerURL>http://www.sony.net/</manufacturerURL>
    <modelDescription>Network Controlled Player</modelDescription>
    <modelName>NAS-SV20i</modelName>
    <UDN>uuid:200000000000-1010-8000-78843c671ffd</UDN>
    <dlna:X_DLNADOC xmlns:dlna="urn:schemas-dlna-org:device-1-0">DMR-1.50</dlna:X_DLNADOC>
    <dlna:X_DLNACAP xmlns:dlna="urn:schemas-dlna-org:device-1-0">playcontainer-1-0</dlna:X_DLNACAP>
    <iconList>
      <icon>
        <mimetype>image/png</mimetype>
        <width>48</width>
        <height>48</height>
        <depth>24</depth>
        <url>/icon/NAS-SV20_48_48_24.png</url>
      </icon>
      <icon>
        <mimetype>image/png</mimetype>
        <width>120</width>
        <height>120</height>
        <depth>24</depth>
        <url>/icon/NAS-SV20_120_120_24.png</url>
      </icon>
      <icon>
        <mimetype>image/jpeg</mimetype>
        <width>48</width>
        <height>48</height>
        <depth>24</depth>
        <url>/icon/NAS-SV20_48_48_24.jpg</url>
      </icon>
      <icon>
        <mimetype>image/jpeg</mimetype>
        <width>120</width>
        <height>120</height>
        <depth>24</depth>
        <url>/icon/NAS-SV20_120_120_24.jpg</url>
      </icon>
    </iconList>
    <serviceList>
      <service>
        <serviceType>urn:schemas-upnp-org:service:RenderingControl:1</serviceType>
        <serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
        <SCPDURL>/RenderingControlSCPD.xml</SCPDURL>
        <controlURL>/upnp/control/RenderingControl</controlURL>
        <eventSubURL>/upnp/event/RenderingControl</eventSubURL>
      </service>
      <service>
        <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1</serviceType>
        <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
        <SCPDURL>/ConnectionManagerSCPD.xml</SCPDURL>
        <controlURL>/upnp/control/ConnectionManager</controlURL>
        <eventSubURL>/upnp/event/ConnectionManager</eventSubURL>
      </service>
      <service>
        <serviceType>urn:schemas-upnp-org:service:AVTransport:1</serviceType>
        <serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
        <SCPDURL>/AVTransportSCPD.xml</SCPDURL>
        <controlURL>/upnp/control/AVTransport</controlURL>
        <eventSubURL>/upnp/event/AVTransport</eventSubURL>
      </service>
      <service>
        <serviceType>urn:schemas-sony-com:service:IRCC:1</serviceType>
        <serviceId>urn:schemas-sony-com:serviceId:IRCC</serviceId>
        <SCPDURL>/IRCCSCPD.xml</SCPDURL>
        <controlURL>/upnp/control/IRCC</controlURL>
        <eventSubURL></eventSubURL>
      </service>
      <service>
        <serviceType>urn:schemas-sony-com:service:Party:1</serviceType>
        <serviceId>urn:schemas-sony-com:serviceId:Party</serviceId>
        <SCPDURL>/PartySCPD.xml</SCPDURL>
        <controlURL>/upnp/control/Party</controlURL>
        <eventSubURL>/upnp/event/Party</eventSubURL>
      </service>
    </serviceList>
  </device>
</root>

@ugjka ugjka self-assigned this Feb 8, 2024
@ugjka
Copy link
Owner

ugjka commented Feb 8, 2024

Try building from https://github.com/ugjka/blast/tree/7-streaming-to-sony-nas-sv20i-fails branch

Or try this build
blast.zip

@ugjka
Copy link
Owner

ugjka commented Feb 8, 2024

The problem seems it doesn't like this part in the code

// handle devices like Samsung TVs
	if r.Header.Get("GetContentFeatures.DLNA.ORG") == "1" {
		f := dlnaContentFeatures{
			profileName:     "MP3",
			supportTimeSeek: false,
			supportRange:    false,
			flags:           DLNA_ORG_FLAG_STREAMING_TRANSFER_MODE | DLNA_ORG_FLAG_DLNA_V15,

		}
		w.Header().Set("ContentFeatures.DLNA.ORG", f.String())
	}

In the test build I zeroed out the flags, if that doesn't work then I'll try disabling the content features header completely, or maybe i need to send MPEG instead of MP3

@ugjka ugjka added the bug Something isn't working label Feb 8, 2024
@parkerlreed
Copy link
Author

Seemingly same issue

(1)(deck@steamdeck Downloads)$ ./blast -headers
----------
DLNA receivers
0: NAS-SV20i
----------
Select the DLNA device:
[0]
----------
Audio sources
0: filter-chain-source
1: filter-chain-sink.monitor
2: input.virtual-sink.monitor
3: output.virtual-source
4: alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_1__sink.monitor
5: alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__sink.monitor
6: alsa_input.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__source
7: alsa_output.pci-0000_04_00.1.hdmi-stereo-extra2.monitor
8: blast.monitor
----------
Select the audio source:
[7]
----------
Your LAN ip addresses
0: 192.168.100.87
1: fe80::b68c:9dff:fe7f:39f7
----------
Select the lan IP address for the stream:
[0]
----------
2024/02/08 12:22:03 starting the stream on port 9000 (configure your firewall if necessary)
2024/02/08 12:22:03 stream URI: http://192.168.100.87:9000/stream.mp3
2024/02/08 12:22:03 setting av1transport URI and playing
(string) (len=4) "HEAD"
(http.Header) (len=1) {
 (string) (len=27) "Getcontentfeatures.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=1) "1"
 }
}
transport: play: SOAP fault. Code: s:Client | Explanation: UPnPError | Detail: <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>501</errorCode><errorDescription>Action Play failed
</errorDescription></UPnPError>

@ugjka
Copy link
Owner

ugjka commented Feb 8, 2024

I updated the branch with content features disabled

Build:
blast.zip

@parkerlreed
Copy link
Author

Extracted to a new folder to make sure I wasnt reusing an old copy. Same messages.

(deck@steamdeck Mac)$ ./blast -headers
----------
DLNA receivers
0: NAS-SV20i
----------
Select the DLNA device:
[0]
----------
Audio sources
0: filter-chain-source
1: filter-chain-sink.monitor
2: input.virtual-sink.monitor
3: output.virtual-source
4: alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_1__sink.monitor
5: alsa_output.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__sink.monitor
6: alsa_input.pci-0000_04_00.5-platform-acp5x_mach.0.HiFi__hw_acp5x_0__source
7: alsa_output.pci-0000_04_00.1.hdmi-stereo-extra2.monitor
8: blast.monitor
----------
Select the audio source:
[7]
----------
Your LAN ip addresses
0: 192.168.100.87
1: fe80::b68c:9dff:fe7f:39f7
----------
Select the lan IP address for the stream:
[0]
----------
2024/02/08 12:30:23 starting the stream on port 9000 (configure your firewall if necessary)
2024/02/08 12:30:23 stream URI: http://192.168.100.87:9000/stream.mp3
2024/02/08 12:30:23 setting av1transport URI and playing
(string) (len=4) "HEAD"
(http.Header) (len=1) {
 (string) (len=27) "Getcontentfeatures.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=1) "1"
 }
}
transport: play: SOAP fault. Code: s:Client | Explanation: UPnPError | Detail: <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>501</errorCode><errorDescription>Action Play failed
</errorDescription></UPnPError>

@ugjka
Copy link
Owner

ugjka commented Feb 8, 2024

Ok, lets not exit blast when play error is thrown, perhaps it can still play afterwards

Build:
blast.zip

@parkerlreed
Copy link
Author

Looks like the idea of the player being slow to load doesn't hold up. Never starts playing anything.

I know this definitely supports MP3 as I can browse from the speakers to another UPnP server and load files fine. As well as sending to the speakers from BubbleUPnP.

BubbleUPnP's audio cast on Android sends PCM and does work with the same Sony set, if that's of any use info wise.

@ugjka
Copy link
Owner

ugjka commented Feb 8, 2024

It reads the http headers by making a head request and then bails out, it doesn't like what it gets, so here is a build that only sends content-type header

blast.zip

@ugjka
Copy link
Owner

ugjka commented Feb 8, 2024

I have high hopes that it doesn't like content-length header bigger than 32 bit value, but will see

@parkerlreed
Copy link
Author

No luck there either. I attempted a wireshark capture but I'm not seeing the data I expect (For one the Sony doesnt even have any packets talking to the computer)

@ugjka
Copy link
Owner

ugjka commented Feb 8, 2024

Well, where is this HEAD request coming from?

(string) (len=4) "HEAD"
(http.Header) (len=1) {
 (string) (len=27) "Getcontentfeatures.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=1) "1"
 }
}

@parkerlreed
Copy link
Author

I meant the Sony IS talking to the computer, just that my wireshark capture is faulty and I can't figure out why.

@ugjka
Copy link
Owner

ugjka commented Feb 8, 2024

Ok, lets switch it up and send wav audio instead

Build:
blast.zip

@parkerlreed
Copy link
Author

parkerlreed commented Feb 8, 2024

Receiver is still choking on something. I get the little blinking icons on the display indicating that it tried to start loading but lord knows what's failing.

----------
2024/02/08 13:18:58 starting the stream on port 9000 (configure your firewall if necessary)
2024/02/08 13:18:58 stream URI: http://192.168.100.87:9000/stream.wav
2024/02/08 13:18:58 setting av1transport URI and playing
(string) (len=4) "HEAD"
(http.Header) (len=1) {
 (string) (len=27) "Getcontentfeatures.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=1) "1"
 }
}
play: SOAP fault. Code: s:Client | Explanation: UPnPError | Detail: <UPnPError xmlns="urn:schemas-upnp-org:control-1-0"><errorCode>501</errorCode><errorDescription>Action Play failed
</errorDescription></UPnPError>

@ugjka
Copy link
Owner

ugjka commented Feb 8, 2024

I'm going to sleep and think about it tomorrow or some other day, but it looks like it expects some header particularly something about Getcontentfeatures.dlna.org. I have some dlna spec docs and need to check out some other implementations. Perhaps i'll get bubbleupnp app and try to sniff it to see what is it doing

@parkerlreed
Copy link
Author

sony.txt

Here's a pcapng of the Sony MAC

@parkerlreed
Copy link
Author

Thanks a ton for the help! Get some rest.

@parkerlreed
Copy link
Author

Forgot to get the other half of the conversation (Sony as dst)

other.txt

@ugjka
Copy link
Owner

ugjka commented Feb 10, 2024

I think i found a clue https://stackoverflow.com/questions/46856189/upnp-control-point-cannot-playing-audio

wee need to set some metadata, gonna work on it

@ugjka
Copy link
Owner

ugjka commented Feb 11, 2024

you can try https://github.com/ugjka/blast/releases and see if it fixes the problem

@parkerlreed
Copy link
Author

Promising! The unit makes a few attempts to play it and throws an error code, so it may be down to MP3 formatting.

Your LAN ip addresses
0: 192.168.100.141
1: fe80::b68c:9dff:fe7f:39f7
----------
Select the lan IP address for the stream:
[0]
----------
2024/02/12 13:18:23 starting the stream on port 9000 (configure your firewall if necessary)
2024/02/12 13:18:24 stream URI: http://192.168.100.141:9000/stream.mp3
2024/02/12 13:18:24 setting av1transport URI and playing
(string) (len=21) "192.168.100.143:54804"
(*url.URL)(0xc00017c120)(/stream.mp3)
(string) (len=4) "HEAD"
(http.Header) (len=1) {
 (string) (len=27) "Getcontentfeatures.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=1) "1"
 }
}
(string) (len=21) "192.168.100.143:54805"
(*url.URL)(0xc0000c81b0)(/stream.mp3)
(string) (len=3) "GET"
(http.Header) (len=1) {
 (string) (len=21) "Transfermode.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=9) "Streaming"
 }
}
(string) (len=21) "192.168.100.143:54806"
(*url.URL)(0xc000299b00)(/stream.mp3)
(string) (len=3) "GET"
(http.Header) (len=1) {
 (string) (len=21) "Transfermode.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=9) "Streaming"
 }
}

@parkerlreed
Copy link
Author

20240212_132143
20240212_132145

@ugjka
Copy link
Owner

ugjka commented Feb 13, 2024

I've prepared a build with multiple test cases: blast.zip

There are 5 test cases, starting with 1

You can run them like this ./blast -test 1

Test 1: do not send "Content-Length" header
Test 2: "ContentFeatures.DLNA.ORG" header that is similar to bubbleupnp
Test 3: do not send "Connection", "Keep-Alive"
Test 4: use Http chunked tranfer encoding
Test 5: use Http chunked transer encoding with old content features header

@ugjka
Copy link
Owner

ugjka commented Feb 13, 2024

Also try the latest version i pushed which handles CTE https://github.com/ugjka/blast/releases/tag/v0.5.0

@parkerlreed
Copy link
Author

parkerlreed commented Feb 13, 2024

All the tests are coming back the same. The streaming is "working" now with the same 81004 error. I believe it doesn't like the formatting of the MP3 stream. Maybe a build with the new fixes and WAV/PCM?

0.5.0

Same 81004

Select the lan IP address for the stream:
[0]
----------
2024/02/13 10:22:10 starting the stream on port 9000 (configure your firewall if necessary)
2024/02/13 10:22:10 stream URI: http://192.168.100.141:9000/stream.mp3
2024/02/13 10:22:10 setting av1transport URI and playing
(string) (len=8) "HTTP/1.1"
(string) (len=21) "192.168.100.143:35971"
(*url.URL)(0xc00024b8c0)(/stream.mp3)
(string) (len=4) "HEAD"
(http.Header) (len=1) {
 (string) (len=27) "Getcontentfeatures.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=1) "1"
 }
}
(string) (len=8) "HTTP/1.1"
(string) (len=21) "192.168.100.143:35972"
(*url.URL)(0xc00024ba70)(/stream.mp3)
(string) (len=3) "GET"
(http.Header) (len=1) {
 (string) (len=21) "Transfermode.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=9) "Streaming"
 }
}
(string) (len=8) "HTTP/1.1"
(string) (len=21) "192.168.100.143:35973"
(*url.URL)(0xc000299c20)(/stream.mp3)
(string) (len=3) "GET"
(http.Header) (len=1) {
 (string) (len=21) "Transfermode.dlna.org": ([]string) (len=1 cap=1) {
  (string) (len=9) "Streaming"
 }
}

@ugjka
Copy link
Owner

ugjka commented Feb 13, 2024

can you try sending some internet mp3 radio streams to your device with this: dlna-send.zip

like:

./dlna-send https://dublab.out.airtime.pro/dublab_a
./dlna-send http://www.lmp.d2g.com:8050/stream

I'll try maing wav version when i have time

@ugjka
Copy link
Owner

ugjka commented Feb 13, 2024

sanity check

when running blast can you open the stream url in your browser or some other player or even cast to other dlna device like bubbleupnp

when running blast is there blast-rec device active in linux audio settings

@parkerlreed
Copy link
Author

Heres the full pcap for Bubble
PCAPdroid_16_Feb_09_22_56.txt

@parkerlreed
Copy link
Author

parkerlreed commented Feb 16, 2024

Oh I dont think this is the radio. Playing the stream back on the phone is just as garbled. Is this possibly feeding MP3 data into a WAV container erroneously?

Input #0, s16be, from 'http://192.168.100.141:9000/stream.lpcm':0   
  Duration: N/A, bitrate: 1411 kb/s
  Stream #0:0: Audio: pcm_s16be, 44100 Hz, 2 channels, s16, 1411 kb/s

@parkerlreed
Copy link
Author

parkerlreed commented Feb 16, 2024

Oh your lpcm is advertising at s16be but it's actually s32le. Manually specificying the format to ffplay loads correctly and sounds correct

I tried -bits 32 and that creates an invalid format for both ffplay and the radio

http://192.168.100.141:9000/stream.lpcm: Invalid data found when processing input
    nan    :  0.000 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0 ```

@parkerlreed
Copy link
Author

parkerlreed commented Feb 16, 2024

So another rabbit hole I just went down was grabbing the line input via the network as this supports it. ffplay was giving me a weird 406 but curl directly worked.

Which leads me to an interesting discovery. This unit sends out S32BE. So that may be the preferred format overall.

(deck@steamdeck ~)$ curl -v "http://192.168.100.143:60151/a/proc/audioin/input_1?LPCM"
*   Trying 192.168.100.143:60151...
* Connected to 192.168.100.143 (192.168.100.143) port 60151 (#0)
> GET /a/proc/audioin/input_1?LPCM HTTP/1.1
> Host: 192.168.100.143:60151
> User-Agent: curl/8.1.2
> Accept: */*
> 
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Pragma: no-cache
< CACHE-CONTROL: no-cache
< Content-Type: audio/L16;rate=44100;channels=2
< transferMode.dlna.org: Streaming
< Connection: Keep-Alive
< Date: Thu, 01 Jan 2009 00:20:17 GMT
< Server: Linux/2.6 UPnP/1.0 NAS-SV20i/1.02.301
< X-AV-Server-Info: av=5.0; hn=""; cn="Sony Corporation"; mn="NAS-SV20i"; mv="1.02.301";
< X-AV-Physical-Unit-Info: pa="NAS-SV20i";
< 
Warning: Binary output can mess up your terminal. Use "--output -" to tell 
Warning: curl to output it to your terminal anyway, or consider "--output 
Warning: <FILE>" to save to a file.
* Failure writing output to destination
* Failed reading the chunked-encoded stream
* Closing connection 0

@ugjka
Copy link
Owner

ugjka commented Feb 16, 2024

Very unlikely it is S32BE, pcm is a raw format and doesn't have any metadata so all those probing tools just spew out nonsense

according to this i didn't specify this -c:a pcm_s16le in ffmpeg command

here is a new build blast.zip

you cant try also setting -rate 48000 since that is what bubble sends

@parkerlreed
Copy link
Author

Same mismatch... Just garbled audio

@parkerlreed
Copy link
Author

parkerlreed commented Feb 16, 2024

My point was piping that curl into ffplay I HAD to use -f s32be to not get corrupted audio. So it appears to actually be that format. s16le results in garbled.

(deck@steamdeck Downloads)$ curl -v "http://192.168.100.143:60151/a/proc/ipod/ip%3a/000A27001AD6EF9C/7L744ZA7YXX/1/2/86/1/1%3fLPCM" | ffplay - -f s32be
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 192.168.100.143:60151...
* Connected to 192.168.100.143 (192.168.100.143) port 60151 (#0)
> GET /a/proc/ipod/ip%3a/000A27001AD6EF9C/7L744ZA7YXX/1/2/86/1/1%3fLPCM HTTP/1.1
> Host: 192.168.100.143:60151
> User-Agent: curl/8.1.2
> Accept: */*
> 
...
...
< HTTP/1.1 200 OK00 fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0   
< Transfer-Encoding: chunked
< Pragma: no-cache
< CACHE-CONTROL: no-cache
< Content-Type: audio/L16;rate=44100;channels=2
< transferMode.dlna.org: Streaming
< Connection: Keep-Alive
< Date: Thu, 01 Jan 2009 03:49:04 GMT
< Server: Linux/2.6 UPnP/1.0 NAS-SV20i/1.02.301
< X-AV-Server-Info: av=5.0; hn=""; cn="Sony Corporation"; mn="NAS-SV20i"; mv="1.02.301";
< X-AV-Physical-Unit-Info: pa="NAS-SV20i";
< 
{ [1448 bytes data]
Input #0, s32be, from 'fd:':aq=    0KB vq=    0KB sq=    0B f=0/0   
  Duration: N/A, bitrate: 1411 kb/s
  Stream #0:0: Audio: pcm_s32be, 44100 Hz, 1 channels, s32, 1411 kb/s
  10.46 M-A:  0.000 fd=   0 aq=  176KB vq=    0KB sq=    0B f=0/0   
100 2016k    0 2016k    0     0   163k      0 --:--:--  0:00:12 --:--:--  163k

@ugjka
Copy link
Owner

ugjka commented Feb 17, 2024

What happens if you actually specify the sample rate and channels, like this :

ffplay -f s16le -ar 44100 -ac 2 -i I find it unlikely you are getting 32 bit mono output. It is actually possible to play back stereo pcm at mono if you double the bit depth

can you also post ffmpeg -version and ffmpeg -formats and also some general information about your linux device

edit: also parec --version and parec -h

@ugjka
Copy link
Owner

ugjka commented Feb 17, 2024

perhaps i need to add --raw to parec command

parecCMD := exec.Command(
		"parec",
		"--device="+s.sink,
		"--client-name=blast-rec",
		"--rate="+fmt.Sprint(s.samplerate),
		"--channels="+fmt.Sprint(s.channels),
		"--format="+fmt.Sprintf("s%dle", s.bitdepth),
		"--raw",
	)

or for some reason the --format= directive gets ignored

new build: [edit: check the last post]

also what is your linux system's endianess lscpu | grep "Byte Order"

@ugjka
Copy link
Owner

ugjka commented Feb 17, 2024

Can you check your mic audio with this, which is basically what blast does

parec --client-name=blast-rec --rate=44100 --channels=2 --format=s16le --raw | ffmpeg -f s16le -ac 2 -ar 44100 -i - -f s16le -c:a pcm_s16le - | ffplay -f s16le -ac 2 -ar 44100 -i -

you should be able to hear your own voice if the mic is working

@ugjka
Copy link
Owner

ugjka commented Feb 17, 2024

new build: blast.zip

has -log option which will log ffmpeg

@parkerlreed
Copy link
Author

What happens if you actually specify the sample rate and channels, like this :

ffplay -f s16le -ar 44100 -ac 2 -i I find it unlikely you are getting 32 bit mono output. It is actually possible to play back stereo pcm at mono if you double the bit depth

can you also post ffmpeg -version and ffmpeg -formats and also some general information about your linux device

edit: also parec --version and parec -h

Testing from the phone which has been the same results as from the Steam Deck

Screen_Recording_20240217_111905_Termux.mp4

It'll be a second before I can test with the computer again.

@parkerlreed
Copy link
Author

parec --client-name=blast-rec --rate=44100 --channels=2 --format=s16le --raw | ffmpeg -f s16le -ac 2 -ar 44100 -i - -f s16le -c:a pcm_s16le - | ffplay -f s16le -ac 2 -ar 44100 -i -

Yeah this works fine. The weirdness I was seeing was streams from the Sony device (not related to this issue was just trying to see what formats the device liked). About to try the log version

@parkerlreed
Copy link
Author

FFMpeg seems to be in order. The Sony device is NOT playing (or serving for that matter) s16le properly (which is what got me checking the streaming FROM rabbit hole)

The Sony speakers themselves are a 2010 embedded Linux device. There's a good chance they themselves are big endian native.

So in short, blast is working perfectly for the UPnP communication. The current issue is the speaker does NOT like s16le at all.

Formats from the Steam Deck https://gist.github.com/parkerlreed/ce628a05741cac76b5b82a682a93558a

Parec https://gist.github.com/parkerlreed/21d9c01bf4ac7005a64d312caa88fa99

Select the audio source:
[7]
----------
Your LAN ip addresses
0: 192.168.86.241
1: fda8:1649:2d5b:67d2:b68c:9dff:fe7f:39f7
2: fe80::b68c:9dff:fe7f:39f7
----------
Select the lan IP address for the stream:
[0]
----------
2024/02/17 11:31:14 starting the stream on port 9000 (configure your firewall if necessary)
2024/02/17 11:31:14 stream URI: http://192.168.86.241:9000/stream.lpcm
2024/02/17 11:31:14 setting av1transport URI and playing
parec --device=alsa_output.pci-0000_04_00.1.hdmi-stereo-extra2.monitor --client-name=blast-rec --rate=44100 --channels=2 --format=s16le --raw
ffmpeg -f s16le -ac 2 -ar 44100 -i - -f s16le -c:a pcm_s16le -
ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 13.1.1 (GCC) 20230429
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-version3 --enable-vulkan
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, s16le, from 'fd:':
  Duration: N/A, bitrate: 1411 kb/s
  Stream #0:0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Output #0, s16le, to 'pipe:':
  Metadata:
    encoder         : Lavf60.3.100
  Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc60.3.100 pcm_s16le
Size=    2236kB time=00:00:13.02 bitrate=1406.2kbits/s speed= 1.1x  

@ugjka
Copy link
Owner

ugjka commented Feb 17, 2024

I will write a flag that let's you swap endianess

@parkerlreed
Copy link
Author

Trying decoding with s16BE doesn't work for some reason.

Screen_Recording_20240217_114746_Termux.mp4

@parkerlreed
Copy link
Author

Would you like a raw dump of the stream to mess with? That might be easier (To see what format it is ACTUALLY compatible with)

@ugjka
Copy link
Owner

ugjka commented Feb 17, 2024

new build: blast.zip

try ./blast -uselpcm -bige -log

@parkerlreed
Copy link
Author

Okay, interesting discovery. If you dump it to a file first, FFmpeg is happy. So it does appear to actually be S16BE.

I went to test the dump I made straight to a file and it played correctly.

@ugjka
Copy link
Owner

ugjka commented Feb 17, 2024

yeah i guess your device is big endian and bubbleupnp somehow can detect it

@parkerlreed
Copy link
Author

Success!

https://youtu.be/b6BnQRNiInE

I can't express how thankful I am. You are awesome.

@ugjka
Copy link
Owner

ugjka commented Feb 17, 2024

Thank you for patience 😹 this was a wild ride and i learned a lot!

I'll merge the changes and push a new release and later when i have time I'll work on a way to detect endianess of remote devices automatically, perhaps i need to pay closer look to pcaps you sent

@parkerlreed
Copy link
Author

Okay, interesting discovery. If you dump it to a file first, FFmpeg is happy. So it does appear to actually be S16BE.

I went to test the dump I made straight to a file and it played correctly.

Oh you love to see it. ffmpeg stopped passing in the extra arguments after mine type because it fixed HLS streams. Not considering that things actually use that for like rate and channels. https://trac.ffmpeg.org/ticket/10869

That's why it was broken for streaming, but playing for the local file.

@ugjka
Copy link
Owner

ugjka commented Feb 18, 2024

Apparently you can use this method to pass byte order as well endianness=little-endian

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants