Re: How to receive mp3 stream in UPNP media renderer using libsoup?
- From: Jens Georg <mail jensge org>
- To: libsoup-list gnome org
- Subject: Re: How to receive mp3 stream in UPNP media renderer using libsoup?
- Date: Mon, 08 Aug 2016 14:29:20 +0200
Hi,
the canonical way to do that is to do a HEAD request with all required
request headers first. Then set up the GET request according to the
returned headers. IIRC this is also described in the UPnP (or DLNA)
guidelines. GStreamer's souphttpsrc does not correctly implement this.
There is a proxy DLNA source element but it's not very recommended to
use.
Regarding connection re-use, that really depends on the clients you
talk to. Rule of thumb is that if your peer talks HTTP1.1, you should
re-use the connection.
Hi all.
I'm somewhat new to Gnome libraries and I have some specific
questions
for using libsoup for an embedded UPNP device.
How do I receive HTTP headers only and then disconnect using
Libsoup?
And how to do it in non-blocking way and integrate with range
requests
and chunked responses?
The long story:
I have partly implemented a UPNP proxy (using Gupnp) which will
receive
MP3 stream from one device, process it in specific ways, format it
and
send to another UPNP device.
Now I want to receive http-get audio/mpeg stream from UPNP source
server, but there are some tricky scenarios to deal with:
- source server might not accept range requests but report
Content-Length - in this case I'll have to download entire mp3 file
into
reasonably limited size RAM cache
- source might not report Content-Length at all and not accept
range
requests - in this case I'll download mp3 file in background up to
reasonably sane limit
- source might accept range requests - in this case I'll
download
chunks of mp3 file on a timer at pace required by audio playback
endpoint
- source might send data as Transfer-Encoding: chunked in which
case
I'll have to download separate chunks without missing any (it might
be
live stream)
In all these cases I have to receive the HTTP headers alone first
and
inspect them to find out how to set up internal data structures and
how
to continue streaming and whether it is possible to continue at all
(if
not, I'll have to send corresponding UPNP state and position events
to
UPNP control points).
Also, while receiving HTTP headers (and later also mp3 stream) my
program should not block - it should continue streaming out the
audio
data it already had received and also respond to UPNP requests.
I have already implemented simple HTTP Soup client using
soup_session_queue_message but I'm confused in which cases I should
use
soup_session_send_async instead and how to abort connection right
after
receiving HTTP headers and then how to proceed receiving mp3 data in
background.
I have been reading libsoup documentation and while it has some
useful
code pieces, it doesn't give answers about use cases - which
approach
should be used when, and how to achieve non-blocking but grained
control
over the process without using explicit multithreading (which seems
to
be discouraged in the libsoup documentation and I also would like to
avoid it, if possible).
I know that it might be possible to use gstreamer for the streaming
stuff, but I don't want to add dependency of it and also I'll need
to
have access to raw audio samples and do some conditional dispatching
(the target UPNP device is picky and in some cases I can feed it
initial
mp3 data, but in some other cases I'll have to re-encode it using
lame-mp3). Also I've heard that gstreamer is not meant to be used as
a
plug-in in my code but vice versa.
If you have any suggestions or maybe know any tutorials or simple
projects which have already implemented similar use cases
(range/chunked/entire file mp3 stream receiving for UPNP media
renderer), I'd be grateful for some links.
Regards,
Martin
---
Avast antivīrusa programmatūra pārbaudīja, vai šajā e-pasta ziņojumā
nav vīrusu.
https://www.avast.com/antivirus
_______________________________________________
libsoup-list mailing list
libsoup-list gnome org
https://mail.gnome.org/mailman/listinfo/libsoup-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]