xerpi / vita-udcd-uvc

PSVita UDCD USB Video Class plugin
468 stars 23 forks source link

Is it possible to connect Vita to the host PC as a Composite Device? #10

Open vladkorotnev opened 5 years ago

vladkorotnev commented 5 years ago

What I mean is, I'd like to try writing audio streaming support (no idea how yet — I'm thinking of emulating a USB Audio Class device with either as many channels as there are open ports, or a fixed number of channels since not many games would use 8+ ports anyway).

However that means the plugin will need to emulate 2 devices — USB Video and USB Audio. From what I know any generic webcam solves that by presenting a "Composite Device" to the host with 2 descendant devices: one for video, and one for audio.

Is there any way to make the Vita run multiple USB drivers concurrently in a similar way?

xerpi commented 5 years ago

Yes that would be possible but it's not easy to implement. You have to change the USB descriptors to simulate a composite device and then implement the code that sends the audio data through the endpoints. Also, this will reduce the available bandwidth for the image streaming so either the resolution or the FPS would have to go down.

That's why it's easier to stream audio via bluetooth or the jack cable.

vladkorotnev commented 5 years ago

Is the image bandwidth already maxing out the USB channel?

The cables are indeed the easiest way, but that means either it's necessary to split the cable or to bear with lags introduced by bluetooth which is not good for playing rhythm games.

Or am I missing something out and there is already a plugin which allows to connect a 3.5 cable and use the built in speakers at the same time? (I just got the vita yesterday so didn't really yet do any proper reading on what it can do)

xerpi commented 5 years ago

Basically 864x488 is about the highest resolution that can go at 60FPS: https://www.reddit.com/r/vitahacks/comments/aci8cf/ucdc_resolution/edad2oe/

What do you mean with split the cable? And I don't think the Bluetooth lag would be noticeable.

vladkorotnev commented 5 years ago

Split the cable, as in, make it so that one end goes to the Vita, the other to the capture card, and the third one to the headphones.

Bluetooth lag is already noticeable on headphones, yet bearable (I have to press the controls about 20-40ms in advance but that's it). It's already at the edge of playablity when using Adrenaline. However in case the signal will go first to the PC and only then to the headphones... I suspect at least a 100-200ms delay.

Or does the Vita support playback to multiple Bluetooth devices at once?

That's unfortunate with the bandwidth, probably adding some kind of compression could free up some, but that would just kill the whole point of all the hardware acceleration implemented.

xerpi commented 5 years ago

At first I tried to compress the framebuffer to MJPEG via hardware and it was too slow (it took 100ms to compress the frame), that's why I use NV12, it takes 2-3ms to "compress" via hardware.

More info here: https://www.reddit.com/r/vitahacks/comments/7c1uge/poc_v2_psvita_as_a_uvc_usb_video_class_device/

I'm not sure about the Bluetooth playback tbh.