GoogleChrome / samples

A repo containing samples tied to new functionality in each release of Google Chrome.
https://www.chromestatus.com/samples
Apache License 2.0
5.77k stars 2.38k forks source link

WebTransport server does not support live-streaming #756

Open guest271314 opened 2 years ago

guest271314 commented 2 years ago

WebTransport server does not support live-streaming (media streams; data streams).

Steps to reproduce: Modify webtransport_server.py to stream content using, for example

for c in iter(lambda: ''.join(choice(digits) for i in range(512)).encode('ascii'), b''):  # replace '' with b'' for Python 3
                    if c is not None:
                        self._http._quic.send_stream_data(
                            event.stream_id, c, end_stream=False)  

and

                cmd = 'parec', '-d', 'alsa_output.pci-0000_00_1.analog-stereo.monitor'
                process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
                os.set_blocking(process.stdout.fileno(), False)
                for c in iter(lambda: process.stdout.read(512), b''):  
                    if c is not None:                     
                        self._http._quic.send_stream_data(
                            event.stream_id, c, end_stream=False)

Expected result: Data to be streamed to WebTransport client. Actual result: No data is streamed to client. Related: https://github.com/aiortc/aioquic/issues/226.

yutakahirano commented 2 years ago

Again, please create a repository that includes your change. Also we need the file to reproduce the problem.

guest271314 commented 2 years ago

Again, please create a repository that includes your change.

I forked GoogleChrome/samples. https://github.com/guest271314/samples-1. Th current test sends N datagrams, and only because the servr stops sending the infinite stream without another write() I write every N data grams received, not ideal. We do not even get the far with streams.

Also we need the file to reproduce the problem.

There really is no file for the live-streaming case.

Chromium does not support capture of system audio (monitor) output on Linux.

To get the monitor device on a Linux OS with PulseAudio

$ pactl list | grep -A2 'Source #' | grep 'Name: .*\.monitor$' | cut -d" " -f2

then supply result as -d option to parec

cmd = 'parec', '-d', 'alsa_output.pci-0000_00_1.analog-stereo.monitor'
                process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
                os.set_blocking(process.stdout.fileno(), False)
                for c in iter(lambda: process.stdout.read(512), b''):  
                    if c is not None:                     
                        self._http._quic.send_stream_data(
                            event.stream_id, c, end_stream=False)

play music, speech synthesis, etc. either using unidirectional or bidirectional stream or datagrams. None work as expected for streaming indefinite content to the browser. The code in these two (2) repositories https://github.com/guest271314/quictransport and https://github.com/guest271314/webtransport used to work for streaming speech synthesis PCM before QuicTransport/quic-transport was deprecated. Many changes have occurred to WebTransport specification and implementation since then. If I recall live-streaming never worked. I was able to achieve live streaming with a Python host https://github.com/guest271314/captureSystemAudio/blob/master/native_messaging/capture_system_audio/capture_system_audio.py using Native Messasing and Transferable Streams (https://github.com/guest271314/captureSystemAudio#web-accessible-resources-php-passthru-parec-fetch-transferable-streams-media-capture-transform-breakout-box), which does work, right now.

As a substitute for Linux OS and PulseAudio, you can use

for c in iter(lambda: ''.join(choice(digits) for i in range(512)).encode('ascii'), b''):  # replace '' with b'' for Python 3
                    if c is not None:
                        self._http._quic.send_stream_data(
                            event.stream_id, c, end_stream=False)  

which is effectively an infinite stream of numbers, close enough to raw PCM data.

I am trying to test WebTransport version, without success.

The above should provide comprehensive details of what the use cases are, and the code that used to work for short streams, and code that works withour using WebTransport, and what I am currently testing.

In short, create some form of indetermine, indefinite stream of data and try to stream that data to the browser - could be 5 minutes of data, could be 2 hours, or 2 days of streaming, or more.

If you have any questions, I will answer them, in any venue you decide.