FDH2 / UxPlay

AirPlay Unix mirroring server
GNU General Public License v3.0
1.53k stars 78 forks source link

xvimagesink not working on R Pi cm4 with 4" 800x480 touchscreen monitor (was:phone connects then immediately disconnects) #277

Closed Boaztheostrich closed 6 months ago

Boaztheostrich commented 6 months ago

I'm running Raspbian OS Bookworm on a cm4 with this carrier board My phone, iphone 13 mini, is seeing the airplay target but when I connect it shows this error.

I am using no command line arguments just

uxplay

(uxplay:2570): CRITICAL : 01:27:50.927: gst_v4l2_buffer_pool_orphan: assertion 'bpool' failed X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 131 (XInputExtension) Minor opcode of failed request: 46 () Value in failed request: 0xd Serial number of failed request: 62 Current serial number in output stream: 66

fduncanh commented 6 months ago

The gstreamer bufferpool message is harmless.

This is your (X11) error, maybe to do with touchscreen?

X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 131 (XInputExtension)
Minor opcode of failed request: 46 ()
Value in failed request: 0xd
Serial number of failed request: 62
Current serial number in output stream: 66

You need to find what opcode 46 in XInputExtension means.

Boaztheostrich commented 6 months ago

Sounds good, I will try to do some research on what opcode 46 means. Do you have any ideas on what the right direction to start looking would be for something like this?

fduncanh commented 6 months ago

Somewhere buried in X11 at X.org https://www.x.org/wiki/ but its not obvious how to find opcodes.

as a workaround, try uxplay -vs glimagesink

https://www.x.org/releases/X11R7.7/doc/inputproto/XI2proto.txt https://www.x.org/releases/X11R7.7/doc/index.html

https://www.x.org/wiki/guide/extensions/#index2h2

https://codebrowser.dev/gtk/include/X11/extensions/XInput2.h.html

Try to see when the X11 error occurs (maybe when gstreamer creates the video window?

try uxplay -d to see how far uxplay gets before the error

then run uxplay after

export GST_DEBUG=2

(or 4, but try 2 first) to see how far gstreamer gets.

fduncanh commented 6 months ago

https://tronche.com/gui/x/xlib/event-handling/protocol-errors/default-handlers.html

Boaztheostrich commented 6 months ago
boazburnett@raspberrypi:~ $ uxplay -d
UxPlay 1.62: An Open-Source AirPlay mirroring and audio-streaming server.
Audio format 1: AAC-ELD 44100/2
GStreamer audio pipeline 1: "appsrc name=audio_source ! queue ! avdec_aac ! audioconvert ! audioresample ! volume name=volume ! level ! autoaudiosink sync=false"
Audio format 2: ALAC 44100/16/2
GStreamer audio pipeline 2: "appsrc name=audio_source ! queue ! avdec_alac ! audioconvert ! audioresample ! volume name=volume ! level ! autoaudiosink sync=false"
GStreamer video pipeline will be:
"appsrc name=video_source ! queue ! h264parse ! decodebin ! videoconvert ! autovideosink name=video_sink sync=false"
Initialized GStreamer video renderer
using system MAC address e4:5f:01:fa:db:68
Initialized server socket(s)
Accepted IPv4 client on socket 31
Local: 192.168.0.33
Remote: 192.168.0.7
httpd receiving on socket 31
conn_request

GET /info RTSP/1.0
X-Apple-ProtocolVersion: 1
Content-Length: 70
Content-Type: application/x-apple-binary-plist
CSeq: 0
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>qualifier</key>
    <array>
        <string>txtAirPlay</string>
    </array>
</dict>
</plist>

Handling request GET with URL /info

RTSP/1.0 200 OK 
CSeq: 0 
Server: AirTunes/220.68 
Content-Type: application/x-apple-binary-plist 
Content-Length: 1071 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>txtAirPlay</key>
    <data>
    GmRldmljZWlkPWU0OjVmOjAxOmZhOmRiOjY4F2ZlYXR1cmVzPTB4NUE3RkZFRTYsMHgw
    CWZsYWdzPTB4NBBtb2RlbD1BcHBsZVRWMywyQ3BrPWIwNzcyN2Q2ZjZjZDZlMDhiNThl
    ZGU1MjVlYzNjZGVhYTI1MmFkOWY2ODNmZWIyMTJlZjhhMjA1MjQ2NTU0ZTcncGk9MmUz
    ODgwMDYtMTNiYS00MDQxLTlhNjctMjVkZDRhNDNkNTM2DnNyY3ZlcnM9MjIwLjY4BHZ2
    PTI=
    </data>
    <key>features</key>
    <integer>1518337766</integer>
    <key>name</key>
    <string>UxPlay@raspberrypi</string>
    <key>audioFormats</key>
    <array>
        <dict>
            <key>type</key>
            <integer>100</integer>
            <key>audioInputFormats</key>
            <integer>67108860</integer>
            <key>audioOutputFormats</key>
            <integer>67108860</integer>
        </dict>
        <dict>
            <key>type</key>
            <integer>101</integer>
            <key>audioInputFormats</key>
            <integer>67108860</integer>
            <key>audioOutputFormats</key>
            <integer>67108860</integer>
        </dict>
    </array>
    <key>pi</key>
    <string>2e388006-13ba-4041-9a67-25dd4a43d536</string>
    <key>vv</key>
    <integer>2</integer>
    <key>statusFlags</key>
    <integer>68</integer>
    <key>keepAliveLowPower</key>
    <integer>1</integer>
    <key>sourceVersion</key>
    <string>220.68</string>
    <key>pk</key>
    <data>
    sHcn1vbNbgi1jt5SXsPN6qJSrZ9oP+shLviiBSRlVOc=
    </data>
    <key>keepAliveSendStatsAsBody</key>
    <integer>1</integer>
    <key>deviceID</key>
    <string>e4:5f:01:fa:db:68</string>
    <key>audioLatencies</key>
    <array>
        <dict>
            <key>outputLatencyMicros</key>
            <false/>
            <key>type</key>
            <integer>100</integer>
            <key>audioType</key>
            <string>default</string>
            <key>inputLatencyMicros</key>
            <false/>
        </dict>
        <dict>
            <key>outputLatencyMicros</key>
            <false/>
            <key>type</key>
            <integer>101</integer>
            <key>audioType</key>
            <string>default</string>
            <key>inputLatencyMicros</key>
            <false/>
        </dict>
    </array>
    <key>model</key>
    <string>AppleTV3,2</string>
    <key>macAddress</key>
    <string>e4:5f:01:fa:db:68</string>
    <key>displays</key>
    <array>
        <dict>
            <key>uuid</key>
            <string>e0ff8a27-6738-3d56-8a16-cc53aacee925</string>
            <key>widthPhysical</key>
            <false/>
            <key>heightPhysical</key>
            <false/>
            <key>width</key>
            <integer>1920</integer>
            <key>height</key>
            <integer>1080</integer>
            <key>widthPixels</key>
            <integer>1920</integer>
            <key>heightPixels</key>
            <integer>1080</integer>
            <key>rotation</key>
            <false/>
            <key>refreshRate</key>
            <integer>60</integer>
            <key>maxFPS</key>
            <integer>30</integer>
            <key>overscanned</key>
            <false/>
            <key>features</key>
            <integer>14</integer>
        </dict>
    </array>
</dict>
</plist>

httpd receiving on socket 31
conn_request

POST /pair-setup RTSP/1.0
Content-Length: 32
Content-Type: application/octet-stream
CSeq: 1
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

2e 10 ec 41 f1 5f ea b1 53 65 67 47 ef 00 e1 67 
88 c9 1c 6e fc 17 56 ef b0 75 5d 44 10 40 73 de 

Handling request POST with URL /pair-setup

RTSP/1.0 200 OK 
CSeq: 1 
Server: AirTunes/220.68 
Content-Type: application/octet-stream 
Content-Length: 32 

8c de d8 51 78 15 62 6b 94 ac cb 13 47 63 f8 8c 
26 71 02 40 3b 72 0c e1 fe 30 fa c3 85 1b e0 e2 

httpd receiving on socket 31
conn_request

POST /pair-verify RTSP/1.0
X-Apple-PD: 1
X-Apple-AbsoluteTime: 733018376
Content-Length: 68
Content-Type: application/octet-stream
CSeq: 2
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

01 00 00 00 51 9f 8b 38 1f 83 87 54 2b e6 86 af 
6c 14 d8 ea 0e 46 07 ac 05 a4 4b f7 e2 1b 1a 32 
57 40 bb 4b 2e 10 ec 41 f1 5f ea b1 53 65 67 47 
ef 00 e1 67 88 c9 1c 6e fc 17 56 ef b0 75 5d 44 
10 40 73 de 

Handling request POST with URL /pair-verify

RTSP/1.0 200 OK 
CSeq: 2 
Server: AirTunes/220.68 
Content-Type: application/octet-stream 
Content-Length: 96 

b9 52 42 46 dd c0 11 1e e3 e9 5c 6f d7 63 7e 5e 
a1 18 3a 0e 84 21 2a 88 de 2a 3f 5d d9 75 db 49 
34 96 71 1e 85 2c 64 df fe f8 a0 1c 68 70 64 f0 
7c ed b3 54 6d f7 7e bf 15 47 cb f4 40 49 41 56 
f8 82 77 a5 4a 62 29 a9 4d 72 ee 09 4a b7 e9 d7 
f0 02 c7 4f 13 99 72 b2 e8 07 9f e3 41 30 c3 03 

httpd receiving on socket 31
conn_request

POST /pair-verify RTSP/1.0
X-Apple-PD: 1
X-Apple-AbsoluteTime: 733018376
Content-Length: 68
Content-Type: application/octet-stream
CSeq: 3
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

00 00 00 00 82 9b 03 64 0f 05 b2 e6 66 ec 67 bf 
9c a5 6f 0a 87 e3 64 66 27 9a 02 29 7b 23 17 46 
5c ce b5 c6 cf 4a 77 bf 3d d8 81 8a f3 20 b2 76 
76 c5 49 ab 01 7c 14 fc 3b 52 f9 c3 f0 f6 0d f1 
2c fe 4a 3d 

Handling request POST with URL /pair-verify
2nd pair-verify step: checking signature
pair-verify: signature is verified

RTSP/1.0 200 OK 
CSeq: 3 
Server: AirTunes/220.68 
Content-Type: application/octet-stream 

httpd receiving on socket 31
conn_request

POST /fp-setup RTSP/1.0
X-Apple-ET: 32
Content-Length: 16
Content-Type: application/octet-stream
CSeq: 4
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

46 50 4c 59 03 01 01 00 00 00 00 04 02 00 00 bb 

Handling request POST with URL /fp-setup

RTSP/1.0 200 OK 
CSeq: 4 
Server: AirTunes/220.68 
Content-Type: application/octet-stream 
Content-Length: 142 

46 50 4c 59 03 01 02 00 00 00 00 82 02 00 0f 9f 
3f 9e 0a 25 21 db df 31 2a b2 bf b2 9e 8d 23 2b 
63 76 a8 c8 18 70 1d 22 ae 93 d8 27 37 fe af 9d 
b4 fd f4 1c 2d ba 9d 1f 49 ca aa bf 65 91 ac 1f 
7b c6 f7 e0 66 3d 21 af e0 15 65 95 3e ab 81 f4 
18 ce ed 09 5a db 7c 3d 0e 25 49 09 a7 98 31 d4 
9c 39 82 97 34 34 fa cb 42 c6 3a 1c d9 11 a6 fe 
94 1a 8a 6d 4a 74 3b 46 c3 a7 64 9e 44 c7 89 55 
e4 9d 81 55 00 95 49 c4 e2 f7 a3 f6 d5 ba 

httpd receiving on socket 31
conn_request

POST /fp-setup RTSP/1.0
X-Apple-ET: 32
Content-Length: 164
Content-Type: application/octet-stream
CSeq: 5
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

46 50 4c 59 03 01 03 00 00 00 00 98 00 8f 1a 9c 
89 71 8a c4 e2 84 d7 a1 9a a3 b4 9b 75 0b 79 4b 
05 52 81 3e e7 7a 27 e1 7b 20 d1 bd d6 8a e6 51 
ba 4d 7c 1e b3 be 8d d6 e7 30 1d d6 4c 93 3c 45 
db 08 81 bc 5e 7d 5f f4 22 b0 81 92 01 39 93 c9 
3a 69 11 d8 b7 37 78 5f a4 a5 d2 d6 7a b6 49 5a 
8c a4 f3 08 4d 18 cb 8a a7 d3 04 12 4c 68 99 6b 
7f 28 9b 06 0a 58 36 13 44 9d 68 d5 1d 63 2f 5b 
64 bb 3a 37 21 c5 39 2d a6 e0 a4 b3 8c 07 e2 0e 
8c 60 2f 8f e9 85 aa dd ee 4f 3c 13 60 3b 5e 78 
eb 36 e8 92 

Handling request POST with URL /fp-setup

RTSP/1.0 200 OK 
CSeq: 5 
Server: AirTunes/220.68 
Content-Type: application/octet-stream 
Content-Length: 32 

46 50 4c 59 03 01 04 00 00 00 00 14 8c 60 2f 8f 
e9 85 aa dd ee 4f 3c 13 60 3b 5e 78 eb 36 e8 92 

httpd receiving on socket 31
conn_request

SETUP rtsp://192.168.0.33/15446461116898954721 RTSP/1.0
Content-Length: 695
Content-Type: application/x-apple-binary-plist
CSeq: 6
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>et</key>
    <integer>32</integer>
    <key>statsCollectionEnabled</key>
    <false/>
    <key>eiv</key>
    <data>
    ar2DssQajgZZFHz5+4kXgg==
    </data>
    <key>sessionUUID</key>
    <string>D65CDA8C-05A5-4DE1-A9D9-BDB53FC5144B</string>
    <key>timingProtocol</key>
    <string>NTP</string>
    <key>diagnosticsAndUsage</key>
    <true/>
    <key>osName</key>
    <string>iPhone OS</string>
    <key>osBuildVersion</key>
    <string>21E219</string>
    <key>sourceVersion</key>
    <string>760.20.1</string>
    <key>timingPort</key>
    <integer>52212</integer>
    <key>isScreenMirroringSession</key>
    <true/>
    <key>osVersion</key>
    <string>17.4</string>
    <key>ekey</key>
    <data>
    RlBMWQECAQAAAAA8AAAAAOVbg8Iro49Q4aFBukXaRA8AAAAQ/LRmiMvtwlqFVVhK2VHV
    PL8UxF5OPxyhhu2OlOzfxKIUUOjb
    </data>
    <key>sessionCorrelationUUID</key>
    <string>BBF6F45A-7107-49F1-A5E3-697A11FEBB8A</string>
    <key>internalBuild</key>
    <false/>
    <key>deviceID</key>
    <string>08:87:C7:2E:44:99</string>
    <key>model</key>
    <string>iPhone14,4</string>
    <key>name</key>
    <string>Boaz’ Eyephone</string>
    <key>macAddress</key>
    <string>9E:D6:75:BF:C1:22</string>
</dict>
</plist>

Handling request SETUP with URL rtsp://192.168.0.33/15446461116898954721
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
Transport: null
SETUP 1
eiv_len = 16
16 byte aesiv (needed for AES-CBC audio decryption iv):
6a bd 83 b2 c4 1a 8e 06 59 14 7c f9 fb 89 17 82 

ekey_len = 72
ekey:
46 50 4c 59 01 02 01 00 00 00 00 3c 00 00 00 00 
e5 5b 83 c2 2b a3 8f 50 e1 a1 41 ba 45 da 44 0f 
00 00 00 10 fc b4 66 88 cb ed c2 5a 85 55 58 4a 
d9 51 d5 3c bf 14 c4 5e 4e 3f 1c a1 86 ed 8e 94 
ec df c4 a2 14 50 e8 db 

fairplay_decrypt ret = 0
16 byte aeskey (fairplay-decrypted from ekey):
48 0f 6b c8 90 88 84 ce 4c 6b fd c0 9f 1b 19 0b 

32 byte shared ecdh_secret:
fd 64 4a 5b d0 de 4f 6c 6d 6c 66 9b bd 3f bc 2f 
72 77 6d d7 32 c9 d2 64 33 8e d4 0b c6 8f 28 41 

Client identified as User-Agent: AirPlay/760.20.1
16 byte aeskey after sha-256 hash with ecdh_secret:
83 d3 7d 66 76 a0 90 e1 b7 3a 36 71 35 b6 ca ac 

timing_rport = 52212
raop_ntp parse remote ip = 192.168.0.7
raop_ntp starting time
raop_ntp local timing port socket 32 port UDP 39596
raop_rtp parse remote ip = 192.168.0.7
raop_rtp_mirror parse remote ip = 192.168.0.7

raop_ntp send_len = 32, now = 1711325577503736
eport = 37439, tport = 39596

RTSP/1.0 200 OK 
CSeq: 6 
Server: AirTunes/220.68 
Content-Type: application/x-apple-binary-plist 
Content-Length: 77 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>timingPort</key>
    <integer>39596</integer>
    <key>eventPort</key>
    <integer>37439</integer>
</dict>
</plist>

raop_ntp receive time type_t=83 packetlen = 32
80 d3 00 07 00 00 00 00 e9 ab 40 09 80 f4 d7 ad 
83 b1 d5 f2 79 be 69 80 83 b1 d5 f2 79 c6 93 a9 

raop_ntp sync correction = -1710844439030228
Accepted IPv4 client on socket 33
Local: 192.168.0.33
Remote: 192.168.0.7
httpd receiving on socket 31
conn_request

GET /info RTSP/1.0
X-Apple-ProtocolVersion: 1
CSeq: 7
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

Handling request GET with URL /info

RTSP/1.0 200 OK 
CSeq: 7 
Server: AirTunes/220.68 
Content-Type: application/x-apple-binary-plist 
Content-Length: 1071 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>txtAirPlay</key>
    <data>
    GmRldmljZWlkPWU0OjVmOjAxOmZhOmRiOjY4F2ZlYXR1cmVzPTB4NUE3RkZFRTYsMHgw
    CWZsYWdzPTB4NBBtb2RlbD1BcHBsZVRWMywyQ3BrPWIwNzcyN2Q2ZjZjZDZlMDhiNThl
    ZGU1MjVlYzNjZGVhYTI1MmFkOWY2ODNmZWIyMTJlZjhhMjA1MjQ2NTU0ZTcncGk9MmUz
    ODgwMDYtMTNiYS00MDQxLTlhNjctMjVkZDRhNDNkNTM2DnNyY3ZlcnM9MjIwLjY4BHZ2
    PTI=
    </data>
    <key>features</key>
    <integer>1518337766</integer>
    <key>name</key>
    <string>UxPlay@raspberrypi</string>
    <key>audioFormats</key>
    <array>
        <dict>
            <key>type</key>
            <integer>100</integer>
            <key>audioInputFormats</key>
            <integer>67108860</integer>
            <key>audioOutputFormats</key>
            <integer>67108860</integer>
        </dict>
        <dict>
            <key>type</key>
            <integer>101</integer>
            <key>audioInputFormats</key>
            <integer>67108860</integer>
            <key>audioOutputFormats</key>
            <integer>67108860</integer>
        </dict>
    </array>
    <key>pi</key>
    <string>2e388006-13ba-4041-9a67-25dd4a43d536</string>
    <key>vv</key>
    <integer>2</integer>
    <key>statusFlags</key>
    <integer>68</integer>
    <key>keepAliveLowPower</key>
    <integer>1</integer>
    <key>sourceVersion</key>
    <string>220.68</string>
    <key>pk</key>
    <data>
    sHcn1vbNbgi1jt5SXsPN6qJSrZ9oP+shLviiBSRlVOc=
    </data>
    <key>keepAliveSendStatsAsBody</key>
    <integer>1</integer>
    <key>deviceID</key>
    <string>e4:5f:01:fa:db:68</string>
    <key>audioLatencies</key>
    <array>
        <dict>
            <key>outputLatencyMicros</key>
            <false/>
            <key>type</key>
            <integer>100</integer>
            <key>audioType</key>
            <string>default</string>
            <key>inputLatencyMicros</key>
            <false/>
        </dict>
        <dict>
            <key>outputLatencyMicros</key>
            <false/>
            <key>type</key>
            <integer>101</integer>
            <key>audioType</key>
            <string>default</string>
            <key>inputLatencyMicros</key>
            <false/>
        </dict>
    </array>
    <key>model</key>
    <string>AppleTV3,2</string>
    <key>macAddress</key>
    <string>e4:5f:01:fa:db:68</string>
    <key>displays</key>
    <array>
        <dict>
            <key>uuid</key>
            <string>e0ff8a27-6738-3d56-8a16-cc53aacee925</string>
            <key>widthPhysical</key>
            <false/>
            <key>heightPhysical</key>
            <false/>
            <key>width</key>
            <integer>1920</integer>
            <key>height</key>
            <integer>1080</integer>
            <key>widthPixels</key>
            <integer>1920</integer>
            <key>heightPixels</key>
            <integer>1080</integer>
            <key>rotation</key>
            <false/>
            <key>refreshRate</key>
            <integer>60</integer>
            <key>maxFPS</key>
            <integer>30</integer>
            <key>overscanned</key>
            <false/>
            <key>features</key>
            <integer>14</integer>
        </dict>
    </array>
</dict>
</plist>

httpd receiving on socket 31
conn_request

GET_PARAMETER rtsp://192.168.0.33/15446461116898954721 RTSP/1.0
Content-Length: 8
Content-Type: text/parameters
CSeq: 8
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

volume 

Handling request GET_PARAMETER with URL rtsp://192.168.0.33/15446461116898954721

RTSP/1.0 200 OK 
CSeq: 8 
Server: AirTunes/220.68 
Content-Type: text/parameters 
Content-Length: 13 

volume: 0.0 

httpd receiving on socket 31
conn_request

RECORD rtsp://192.168.0.33/15446461116898954721 RTSP/1.0
CSeq: 9
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

Handling request RECORD with URL rtsp://192.168.0.33/15446461116898954721
raop_handler_record

RTSP/1.0 200 OK 
CSeq: 9 
Server: AirTunes/220.68 
Audio-Latency: 11025 
Audio-Jack-Status: connected; type=analog 

httpd receiving on socket 31
conn_request

SETUP rtsp://192.168.0.33/15446461116898954721 RTSP/1.0
Content-Length: 204
Content-Type: application/x-apple-binary-plist
CSeq: 10
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
User-Agent: AirPlay/760.20.1

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>streams</key>
    <array>
        <dict>
            <key>timestampInfo</key>
            <array>
                <dict>
                    <key>name</key>
                    <string>SubSu</string>
                </dict>
                <dict>
                    <key>name</key>
                    <string>BePxT</string>
                </dict>
                <dict>
                    <key>name</key>
                    <string>AfPxT</string>
                </dict>
                <dict>
                    <key>name</key>
                    <string>BefEn</string>
                </dict>
                <dict>
                    <key>name</key>
                    <string>EmEnc</string>
                </dict>
            </array>
            <key>latencyMs</key>
            <integer>100</integer>
            <key>type</key>
            <integer>110</integer>
            <key>streamConnectionID</key>
            <integer>3093951541214924279</integer>
        </dict>
    </array>
</dict>
</plist>

Handling request SETUP with URL rtsp://192.168.0.33/15446461116898954721
DACP-ID: B7BC5DB6DF02C5E6
Active-Remote: 2936494571
Transport: null
type = 110
streamConnectionID (needed for AES-CTR video decryption key and iv): 3093951541214924279
raop_rtp_mirror starting mirroring
raop_rtp_mirror local data port socket 34 port TCP 44777
Mirroring initialized successfully

RTSP/1.0 200 OK 
CSeq: 10 
Server: AirTunes/220.68 
Content-Type: application/x-apple-binary-plist 
Content-Length: 85 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>streams</key>
    <array>
        <dict>
            <key>dataPort</key>
            <integer>44777</integer>
            <key>type</key>
            <integer>110</integer>
        </dict>
    </array>
</dict>
</plist>

raop_rtp_mirror accepting client
raop_rtp_mirror: unidentified extra header data  710.000000, 0.000000
begin video stream wxh = 500x1080; source 500x1080
raop_rtp_mirror width_source = 500.000000 height_source = 1080.000000 width = 500.000000 height = 1080.000000
raop_rtp_mirror: sps/pps header size = 6
raop_rtp_mirror h264 sps/pps header:
01 64 00 1f ff e1 

raop_rtp_mirror sps size = 18
raop_rtp_mirror h264 Sequence Parameter Set:
27 64 00 1f ac 13 14 50 20 02 27 9e 59 b8 08 08 
08 10 

raop_rtp_mirror pps size = 4
raop_rtp_mirror h264 Picture Parameter Set:
28 ee 3c b0 

remainder size = 4
remainder of sps+pps packet:
02 00 00 00 

raop_rtp video: now = 1711325577.656576, ntp = 1711325577.717586, latency = -0.061010
nalu_type = 5, nalu_size = 8002,  processed bytes 8006, payloadsize = 8006 nalus_count = 1
Begin streaming to GStreamer video pipeline
Looking for X11 UxPlay Window, attempt 1

** (uxplay:4176): CRITICAL **: 19:12:57.660: gst_v4l2_buffer_pool_orphan: assertion 'bpool' failed
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  131 (XInputExtension)
  Minor opcode of failed request:  46 ()
  Value in failed request:  0xd
  Serial number of failed request:  46
  Current serial number in output stream:  50

Here's the response I got from running uxplay -d

Boaztheostrich commented 6 months ago
uxplay -vs glimagesink

Returned

boazburnett@raspberrypi:~ $ uxplay -vs glimagesink
UxPlay 1.62: An Open-Source AirPlay mirroring and audio-streaming server.

** (uxplay:10672): ERROR **: 19:18:02.881: get_parse_launch error (video) :
 no element "glimagesink"

Trace/breakpoint trap
Boaztheostrich commented 6 months ago

I think code 46 is referring to #X_CloseFont and 50 is referencing #define X_ListFontsWithInfo.

This is from this site: https://cgit.freedesktop.org/xorg/proto/xproto/tree/Xproto.h

thiccaxe commented 6 months ago

related? https://stackoverflow.com/questions/68029291/gstreamer-v4l2src-failed-to-allocate-buffer-when-run-on-a-jetson-nano

Boaztheostrich commented 6 months ago

I think code 46 is referring to #X_CloseFont and 50 is referencing #define X_ListFontsWithInfo.

This is from this site: https://cgit.freedesktop.org/xorg/proto/xproto/tree/Xproto.h

Sorry ignore this, I didn't understand that the minor opcodes corresponded to the major opcode. I was able to find the minor opcode of 46

R046 XInputExtension:SelectEvents

Hope that helps! If there's anything else I can do please let me know.

I also got that GST Debug 2 return

boazburnett@raspberrypi:~ $ uxplay
UxPlay 1.62: An Open-Source AirPlay mirroring and audio-streaming server.
0:00:01.464549354 40972   0x5594d86690 WARN                 kmssink gstkmssink.c:1160:gst_kms_sink_start:<video_sink-actual-sink-kms> error: Could not open DRM module (NULL)
0:00:01.464614428 40972   0x5594d86690 WARN                 kmssink gstkmssink.c:1160:gst_kms_sink_start:<video_sink-actual-sink-kms> error: reason: No such file or directory (2)
0:00:01.464689964 40972   0x5594d86690 WARN                basesink gstbasesink.c:5878:gst_base_sink_change_state:<video_sink-actual-sink-kms> error: Failed to start
using system MAC address e4:5f:01:fa:db:68
Initialized server socket(s)
0:00:01.503669451 40972   0x5594cd7c00 WARN                    v4l2 gstv4l2object.c:3228:gst_v4l2_object_reset_compose_region:<v4l2h264dec0:sink> Failed to get default compose rectangle with VIDIOC_G_SELECTION: Invalid argument
Accepted IPv4 client on socket 31
Local: 192.168.0.33
Remote: 192.168.0.7
Client identified as User-Agent: AirPlay/760.20.1
Accepted IPv4 client on socket 33
Local: 192.168.0.33
Remote: 192.168.0.7
raop_rtp_mirror starting mirroring
Begin streaming to GStreamer video pipeline

** (uxplay:40972): CRITICAL **: 19:44:15.926: gst_v4l2_buffer_pool_orphan: assertion 'bpool' failed
0:00:15.078938122 40972   0x5594cd7c00 WARN                    v4l2 gstv4l2object.c:3228:gst_v4l2_object_reset_compose_region:<v4l2h264dec0:sink> Failed to get default compose rectangle with VIDIOC_G_SELECTION: Invalid argument
0:00:15.080169259 40972   0x5594cd7c00 WARN                    v4l2 gstv4l2object.c:2255:gst_v4l2_object_get_streamparm:<v4l2h264dec0:src> VIDIOC_G_PARM failed
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  131 (XInputExtension)
  Minor opcode of failed request:  46 ()
  Value in failed request:  0xd
  Serial number of failed request:  46
  Current serial number in output stream:  50
Boaztheostrich commented 6 months ago

related? https://stackoverflow.com/questions/68029291/gstreamer-v4l2src-failed-to-allocate-buffer-when-run-on-a-jetson-nano

@fduncanh was saying the bpool error is harmless

Boaztheostrich commented 6 months ago

I also wanted to mention the changes I have made to the config.txt file, I'm not sure if this would effect the display but I thought I would mention it:

# Enable DRM VC4 V3D driver
#dtoverlay=vc4-kms-v3d
#max_framebuffers=2

# stuff for the screen
dtoverlay=ctp40,touchscreen-swapped-x-y,touchscreen-inverted-y
enable_dpi_lcd=1
dpi_group=2
dpi_mode=87
dpi_output_format=0x7f216
dpi_timings=480 0 10 16 59 800 0 15 113 15 0 0 0 60 0 32000000 6

display_lcd_rotate=1

The screen I am using has had some weird behavior I haven't seen on previous touch screens that I have used. Such as the refresh rate being displayed as 0hz in the screen configuration tool and all the rotate options being grayed out.

fduncanh commented 6 months ago

@Boaztheostrich

if your system doesn't find glimagesink, you need to install it:

sudo apt install gstreamer1.0-gl

then try "uxplay -vs glimagesink"

If your touchscreen monitor is somehow breaking xvimagesink, glimagesink may get around the issue.

another possibility is "uxplay -vs gtksink". (install gstreamer1.0-gtk3 for that one)

see the README

fduncanh commented 6 months ago

Re the "bufferpool" message : I get it it too. Its some noise that gstreamer is making with no significance (error message spam)

fduncanh commented 6 months ago

@Boaztheostrich

I can exactly reproduce your X11 error (same opcodes etc) (on a Pi model 4B with bookworm) when I use

uxplay -vs ximagesink

(this is an older X11 videosink without the "xv" extensions) No touchscreen involved. Looks like Raspberry PI does not support this videosink.

but

uxplay -vs xvimagesink

which is the better X11 videosink, works fine.

Maybe you don't have the xvimagesink installed, (and autovideosink is choosing ximagesink)?

To see what you have installed, use

gst-inspect-1.0 | grep imagesink

(this needs gstreamer1.0-tools to be installed) On my system, this shows glimagesink, ximagesink and xvimagesink are available.

(install gstreamer1.0-x if it is not already installed) This provides libgstpango.so, libgstximagesink.so, and libgstxvimagesink.so, so I dont see how you could be missing xvimagesink if you have ximagesink. Try "uxplay -vs xvimagesink" to see what happens.

See the README

Boaztheostrich commented 6 months ago
boazburnett@raspberrypi:~ $ gst-inspect-1.0 | grep imagesink
ximagesink:  ximagesink: Video sink
xvimagesink:  xvimagesink: Video sink

This is what I got for gst-inspect

but when I tried to run the xvimagesink it failed with this error

boazburnett@raspberrypi:~ $ uxplay -vs xvimagesink
UxPlay 1.62: An Open-Source AirPlay mirroring and audio-streaming server.
Failed to initialize GStreamer video renderer
using system MAC address e4:5f:01:fa:db:68
Initialized server socket(s)
GStreamer error: Could not initialise Xv output
Failed to initialize GStreamer video renderer
Initialized server socket(s)
GStreamer error: Could not initialise Xv output
Failed to initialize GStreamer video renderer
Initialized server socket(s)
GStreamer error: Could not initialise Xv output
Failed to initialize GStreamer video renderer
Initialized server socket(s)
GStreamer error: Could not initialise Xv output
^C

xvinfo returns this:

boazburnett@raspberrypi:~ $ xvinfo
X-Video Extension version 2.2
screen #0
 no adaptors present
fduncanh commented 6 months ago

For whatever reason your system (presumably the monitor) does not support the X11 "xv" video extension, and ximagesink (no v) seems broken on R Pi. Install glimagesink its a very good videosink, or gtksink.

Boaztheostrich commented 6 months ago

glimagesink did work but I wasn't able to get it to run full screen and it was very laggy on my CM4. I wasn't able to get gtksink working.

Any ideas on what I could do to make the monitor accept the xv video extension?

fduncanh commented 6 months ago

also try "uxplay -vs waylandsink"

R Pi 5 likes Wayland https://projects-raspberry.com/raspberry-pi-os-update-bookworm-comes-with-new-display-engine/

fduncanh commented 6 months ago

glimagesink doesnt do fullscreen

waylandsink does.

You might need to use raspi-config to activate wayland (??)

fduncanh commented 6 months ago

It's surprising that the monitor doesnt like xv, maybe you can find a fix. can you test a different monitor to confirm the monitor is the problem?

https://www.x.org/releases/current/doc/videoproto/xv-protocol-v2.txt https://www.x.org/releases/X11R7.7/doc/man/man3/Xv.3.xhtml

Boaztheostrich commented 6 months ago

On my pi4 and 5 it hasn't been an issue at all, the cm4 carrier board I am using doesn't have an hdmi out I may be able to try a different carrier board tmw.

I do think you're right about it being the screen though. I tried to get the waylandsink working, switched from x11 to wayland in raspiconfig, and it refuses to boot to the desktop. There is just a blinking cursor top left corner.

But X11 works fine.

fduncanh commented 6 months ago

@Boaztheostrich since the failure of ximagesink (no v) occurs when uxplay starts streaming video, and I see it too, so its not a issue of your monitor (unlike the xvimagesink failure, which is) I can probably track it down.

UxPlay does some X11 manipulations (in renderers/x_display.h) at that time, and the ximagesink code is available in gstreamer. Quite possibly the code in x_display.h is triggering the X issue in ximagesink

Boaztheostrich commented 6 months ago

Good stuff! But xvimagesink is an issue of the display? I’m talking to the manufacturer about that issue, but haven’t heard too much back yet.

On Mon, Mar 25, 2024 at 8:03 AM fduncanh @.***> wrote:

@Boaztheostrich https://github.com/Boaztheostrich since the failure of ximagesink (no v) occurs when uxplay starts streaming video, and I see it too, so its not a issue of your monitor (unlike the xvimagesink failure, which is) I can probably track it down.

UxPlay does some X11 manipulations (in renderers/x_display.h) at that time, and the ximagesink code is available in gstreamer.

— Reply to this email directly, view it on GitHub https://github.com/FDH2/UxPlay/issues/277#issuecomment-2017960792, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATKHZWCJLM3HSJ23QUQCZ33Y2AOBFAVCNFSM6AAAAABFA24QASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJXHE3DANZZGI . You are receiving this because you were mentioned.Message ID: @.***>

fduncanh commented 6 months ago

As a diagnostic for the ximagesink failure, Try building uxplay with the cmake option -DNO_X11_DEPS=ON

This option just omits the code in renderers/x_display_fix.h

You will probably lose fullscreen mode of ximagesink, but it will show if the code in x_display_fix is the issue. Then use uxplay -vs ximagesink

(I will check this out myself later but not immediately.)

EDIT: unfortunately, compiling with -DNO_X11_DEPS=ON doesnt fix the bug with ximagesink (no v). That means its not anything that UxPlay is doing, its something making ximagesink incompatible with R Pi. I'll try building and tweaking the gstreamer libgstximagesink code from gstreamer1.0-x

fduncanh commented 6 months ago

the basic tests:

 gst-launch-1.0 -v videotestsrc ! ximagesink  fails  with " X Error of failed request: Badvalue ..."

 gst-launch-1.0 -v videotestsrc ! xvimagesink      works for me
fduncanh commented 6 months ago

For what its worth, I booted the RPI 4B into an older ubuntu 22.04.LTS with gstreamer-1.20.1 and ximagesink works fine.

I tried again with ubuntu 23.04 with gstreamer 1.22.1 and ximagesink failed with the X error : Badvalue

so maybe gstreamer-1.22.x has the bug (on R Pi, not X86_64) but 1.20.x doesnt.

fduncanh commented 6 months ago

I checked uxplay -vs ximagesink on ubuntu 23.10 which has gstreamer 1.22.6 get X badvalue error

manjaro RPi4 current with gstreamer-1.22.10 : ximagesink WORKS!

I dont yet know if a bug got fixed, or whether Arch/manjaro does a better build of gstreamer.

As expected, Raspberry Pi OS (Legacy, Bullseye) with gstreamer-1.18.4 has a working ximagesink

Boaztheostrich commented 6 months ago

I installed raspbian os bullseye to see if I would have better luck with that.

But when I tried to install uxplat with

sudo apt install uxplay

It was unable to locate the package

fduncanh commented 6 months ago

You need to build uxplay from github source for Bullseye: its very easy. Debian first included uxplay in Bookworm

https://github.com/FDH2/UxPlay#getting-uxplay

Boaztheostrich commented 6 months ago

Good stuff! I was able to build from source and got it running on bullseye. Would it be possible to just downgrade gstreamer on bookworm to get it working?

I was also wondering if this

Enable DRM VC4 V3D driver #dtoverlay=vc4-kms-v3d #max_framebuffers=2

Would be impacting the latency at all?

I feel like it’s definitely more laggy on this device with this touchscreen than it has been in the past.

The previous devices may have been using the xv image sink though I’m not 100% sure.

On Thu, Mar 28, 2024 at 12:29 AM fduncanh @.***> wrote:

You need to build uxplay from github source for Bullseye: its very easy. Debian first included uxplay in Bookworm

  • yes, ximagesink works on bullseye. (but I'm not sure if RPi 5 works on bullseye?, RPi 4B will work)

https://github.com/FDH2/UxPlay#getting-uxplay

-

I replaced the GStreamer 1.22.0 in R Pi OS bookworm with latest 1.22.10 build from source: same ximagesink error.

1.22.0 has some reworking of ximagesink which might be the source of the problem. I'm waiting for ubuntu 24.04 to be released soon to see if gstreamer 1.24.0 also has the ximagesink bug.

— Reply to this email directly, view it on GitHub https://github.com/FDH2/UxPlay/issues/277#issuecomment-2024437660, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATKHZWALTXZGYKC6HLYJGYDY2OTEZAVCNFSM6AAAAABFA24QASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRUGQZTONRWGA . You are receiving this because you were mentioned.Message ID: @.***>