Re: How to receive mp3 stream in UPNP media renderer using libsoup?


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

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
for using libsoup for an embedded UPNP device.

How do I receive HTTP headers only and then disconnect using
And how to do it in non-blocking way and integrate with range
and chunked responses?

The long story:

I have partly implemented a UPNP proxy (using Gupnp) which will
MP3 stream from one device, process it in specific ways, format it
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
reasonably limited size RAM cache

    - source might not report Content-Length at all and not accept
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
chunks of mp3 file on a timer at pace required by audio playback

    - source might send data as Transfer-Encoding: chunked in which
I'll have to download separate chunks without missing any (it might
live stream)

In all these cases I have to receive the HTTP headers alone first
inspect them to find out how to set up internal data structures and
to continue streaming and whether it is possible to continue at all
not, I'll have to send corresponding UPNP state and position events
UPNP control points).

Also, while receiving HTTP headers (and later also mp3 stream) my 
program should not block - it should continue streaming out the
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
soup_session_send_async instead and how to abort connection right
receiving HTTP headers and then how to proceed receiving mp3 data in 

I have been reading libsoup documentation and while it has some
code pieces, it doesn't give answers about use cases - which
should be used when, and how to achieve non-blocking but grained
over the process without using explicit multithreading (which seems
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
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
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
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.


Avast antivīrusa programmatūra pārbaudīja, vai šajā e-pasta ziņojumā
nav vīrusu.

libsoup-list mailing list
libsoup-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]