After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 785730 - New elements: libSRT src/sink
New elements: libSRT src/sink
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other All
: Normal enhancement
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-08-02 12:48 UTC by Justin Kim
Modified: 2017-11-07 19:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[1/2] srtsrc (21.42 KB, patch)
2017-08-02 12:50 UTC, Justin Kim
none Details | Review
[2/2] srtsink (22.51 KB, patch)
2017-08-02 12:50 UTC, Justin Kim
none Details | Review
[1/2] srtclientsrc (22.41 KB, patch)
2017-08-03 02:57 UTC, Justin Kim
none Details | Review
[2/2] srtserversink (25.17 KB, patch)
2017-08-03 02:58 UTC, Justin Kim
none Details | Review
[2/2] srtserversink (25.18 KB, patch)
2017-08-03 07:11 UTC, Justin Kim
none Details | Review
[2/2] srtserversink (26.73 KB, patch)
2017-08-03 09:09 UTC, Justin Kim
none Details | Review
[2/2] srtserversink (26.33 KB, patch)
2017-08-04 01:14 UTC, Justin Kim
none Details | Review
[1/2] srtclientsrc (22.49 KB, patch)
2017-08-08 14:11 UTC, Justin Kim
none Details | Review
[2/2] srtserversink (26.39 KB, patch)
2017-08-08 14:11 UTC, Justin Kim
none Details | Review
RFC: srt elements (87.19 KB, patch)
2017-08-11 21:30 UTC, Justin Kim
none Details | Review
RFC: srt elements (87.09 KB, patch)
2017-08-29 00:59 UTC, Justin Kim
none Details | Review
srt elements (93.33 KB, patch)
2017-10-01 07:08 UTC, Justin Kim
none Details | Review
srt elements (93.85 KB, patch)
2017-10-02 09:43 UTC, Justin Kim
none Details | Review
Updated patch with a bunch of things I learned while doing interop testing. In particular, added a latency property to all elements. Also added the rendez-vous mode to the *client* elements. Factored out some of the common code between the client elements (97.63 KB, patch)
2017-11-03 15:34 UTC, Olivier Crête
none Details | Review
Same as previous patch, but I had forgotten to merge in the mutex protecting the client list. I also took the liberty to replace it with the object lock instead of introducing anotehr mutex. (97.53 KB, patch)
2017-11-03 15:41 UTC, Olivier Crête
committed Details | Review

Description Justin Kim 2017-08-02 12:48:51 UTC
SRT is another type of UDP-based protocol that optimizes streaming across unpredictable networks. The SRT library is developing in github(https://github.com/Haivision/srt).

I created an initial version of srtsrc and srtsink. Although the protocol is based on UDP, the APIs look like connection oriented protocol so in my initial version, srtsrc is a client, srtsink is a server.

I tested streaming by the below pipeline.

For srtsink, I couldn't find a proper TS file so I just transcoded sintel trailer.

 gst-launch-1.0 -v \
    filesrc location=~/trailer.mp4 \
    ! decodebin name=d d. ! vaapih264enc ! queue ! mpegtsmux name=mux ! rtpmp2tpay ! srtsink \
    d. ! avenc_ac3 ! mux.


 gst-launch-1.0 -v \
    srtsrc uri="srt://127.0.0.1:7001" \
    caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP2T" \
    ! rtpmp2tdepay ! decodebin name=d d. ! autovideosink sync=false d. ! autoaudiosink sync=false
Comment 1 Justin Kim 2017-08-02 12:50:23 UTC
Created attachment 356778 [details] [review]
[1/2] srtsrc
Comment 2 Justin Kim 2017-08-02 12:50:44 UTC
Created attachment 356779 [details] [review]
[2/2] srtsink
Comment 3 Tim-Philipp Müller 2017-08-02 13:15:29 UTC
Should it be srtclientsrc and srtserversink then?
Comment 4 Justin Kim 2017-08-03 02:57:38 UTC
Created attachment 356814 [details] [review]
[1/2] srtclientsrc
Comment 5 Justin Kim 2017-08-03 02:58:27 UTC
Created attachment 356815 [details] [review]
[2/2] srtserversink
Comment 6 Justin Kim 2017-08-03 07:11:29 UTC
Created attachment 356818 [details] [review]
[2/2] srtserversink
Comment 7 Justin Kim 2017-08-03 09:09:31 UTC
Created attachment 356831 [details] [review]
[2/2] srtserversink

changed to use 'struct' instead of just socket descriptor in a signal.
Comment 8 Tim-Philipp Müller 2017-08-03 09:26:30 UTC
> changed to use 'struct' instead of just socket descriptor in a signal.

How will this work in an application? G_TYPE_POINTER is not usable in bindings, and the client struct will not be exposed in any header files for the application.
Comment 9 Justin Kim 2017-08-03 10:01:17 UTC
(In reply to Tim-Philipp Müller from comment #8)
> > changed to use 'struct' instead of just socket descriptor in a signal.
> 
> How will this work in an application? G_TYPE_POINTER is not usable in
> bindings, and the client struct will not be exposed in any header files for
> the application.

I rush to implement so I missed some points. I'll submit the patch again.
Thanks for advice.
Comment 10 Justin Kim 2017-08-04 01:14:00 UTC
Created attachment 356906 [details] [review]
[2/2] srtserversink
Comment 11 Olivier Crête 2017-08-08 02:46:40 UTC
Also, in SRT the client/server is not linked to sender/receiver. So I think we could have a client-sender to a server-receiver too.
Comment 12 Justin Kim 2017-08-08 14:11:30 UTC
Created attachment 357196 [details] [review]
[1/2] srtclientsrc

correct copyright
Comment 13 Justin Kim 2017-08-08 14:11:57 UTC
Created attachment 357197 [details] [review]
[2/2] srtserversink

correct copyright
Comment 14 Justin Kim 2017-08-11 21:30:24 UTC
Created attachment 357448 [details] [review]
RFC: srt elements

I assumed no one started reviewing the proposed patches. So I squashed and re-organized codes. In addition, as Olivier's suggestion, srtserversrc and srtclientsink are introduced too.
Comment 15 Justin Kim 2017-08-29 00:59:36 UTC
Created attachment 358647 [details] [review]
RFC: srt elements

Added more enhancements. Thanks, Olivier!
Comment 16 George Kiagiadakis 2017-09-29 10:23:11 UTC
Wouldn't it be easier if the server/client selection was done via the URI instead of creating new elements? libsrt has a tool called stransmit, which works like that. And it seems there is also the simultaneous open mode, which is not covered by these elements.

stransmit behaves like this:

# client mode - assuming that 192.168.1.1 is a remote IP
srt://192.168.1.1:7000
srt://192.168.1.1:7000?mode=client
srt://192.168.1.1:7000?mode=caller

# server mode - assuming that 192.168.1.1 is a local interface IP
srt://192.168.1.1:7000?mode=server
srt://192.168.1.1:7000?mode=listener
srt://:7000?adapter=192.168.1.1
srt://:7000    (binds to 0.0.0.0)

# SO mode - assuming that 192.168.1.1 is a local interface IP and 192.168.1.2 is a remote one
srt://192.168.1.2:7000?mode=rendezvous  (connect to 192.168.1.2 and bind to 0.0.0.0)
srt://192.168.1.2:7000?mode=rendezvous&adapter=192.168.1.1  (connect to 192.168.1.2 and bind to 192.168.1.1)
Comment 17 Brendan Lockhart 2017-09-29 22:49:40 UTC
Would it be possible to set the rank of srtserversrc to secondary? As is, playbin will sometimes select srtserversrc instead of srtclientsrc.

Also, from my testing it appears that srtserversink will accept and handle multiple client connections. Is this intended behaviour? I don't believe the stransmit app works in this way, but supporting multiple clients would be a fantastic feature :)
Comment 18 rland 2017-09-30 05:49:43 UTC
Great work! -)
Btw,it seems that SRT did not provide compilation of Android platform instructions, no way to quickly test demo on Android.
Comment 19 Justin Kim 2017-10-01 06:46:13 UTC
(In reply to George Kiagiadakis from comment #16)
> Wouldn't it be easier if the server/client selection was done via the URI
> instead of creating new elements?

I thought socket type per element would be easier than URI parameters.
From the beginning, I considered a feature to switching socket type by setting property (or parsing URL) in an element, but I felt I needed to use more if-else to set socket options.

How about introducing a kind of wrapper bin to deploy a proper socket type element by parsing URI parameters?

> it seems there is also the simultaneous open mode,
> which is not covered by these elements.

Yes, I wasn't sure that mode and suffered from lack of testing for server and client connections.

(In reply to Brendan Lockhart from comment #17)
> Would it be possible to set the rank of srtserversrc to secondary?

I think it could be. This idea could be related to the above (introducing a wrapper bin). My simple idea is lowering the ranks of source elements to secondary or marginal, then the wrapper bin has primary rank. What do you guys think about this idea?

> Also, from my testing it appears that srtserversink will accept and handle
> multiple client connections. Is this intended behaviour? I don't believe the
> stransmit app works in this way, but supporting multiple clients would be a
> fantastic feature :)

Yes, it's an intended implementation because I thought we can get a live stream via srt so any client can be connected, even though stransmit doesn't provide/support multiple clients.

(In reply to luckychou from comment #18)
> Btw,it seems that SRT did not provide compilation of Android platform
> instructions, no way to quickly test demo on Android.

Are there any tutorial or instruction of using 'libsrt' on Android? I can't find that kind of information while quick searching. It would be a starting point anyway.
Comment 20 Justin Kim 2017-10-01 07:08:51 UTC
Created attachment 360715 [details] [review]
srt elements

Added little more tunning of socket options.
Comment 21 Brendan Lockhart 2017-10-02 07:45:25 UTC
Is it possible that the line:
"static GParamSpec *properties[PROP_LAST + 1];" in gstsrtclientsrc.c has an extra "+ 1"? I think that line may have been missed in your last patch. That script may also need the param spec for PROP_LATENCY.

If the srtserversink supports multiple clients, should we add a mutex surrounding changes to the clients GList?
Comment 22 Justin Kim 2017-10-02 07:58:20 UTC
(In reply to Brendan Lockhart from comment #21)
> Is it possible that the line:
> "static GParamSpec *properties[PROP_LAST + 1];" in gstsrtclientsrc.c has an
> extra "+ 1"? I think that line may have been missed in your last patch. That
> script may also need the param spec for PROP_LATENCY.

Oh, I missed some patches in my local while squashing.
 I should verify it. Thanks for reviewing.

> If the srtserversink supports multiple clients, should we add a mutex
> surrounding changes to the clients GList?

Yes. Maybe.
Comment 23 Justin Kim 2017-10-02 09:43:34 UTC
Created attachment 360750 [details] [review]
srt elements

Add mutex locks to serversink to protect clients list
Comment 24 Olivier Crête 2017-11-03 15:34:06 UTC
Created attachment 362912 [details] [review]
Updated patch with a bunch of things I learned while doing interop testing. In particular, added a latency property to all elements. Also added the rendez-vous mode to the *client* elements. Factored out some of the common code between the client elements
Comment 25 Olivier Crête 2017-11-03 15:41:49 UTC
Created attachment 362914 [details] [review]
Same as previous patch, but I had forgotten to merge in the mutex protecting the client list. I also took the liberty to replace it with the object lock instead of introducing anotehr mutex.
Comment 26 Olivier Crête 2017-11-07 19:35:24 UTC
Merged

Author: Justin Kim <justin.kim@collabora.com>
Date:   Mon Jul 31 14:38:34 2017 +0900

    srt: Introduce SRT source and sink
    
    SRT[0] is an open source transport technology[1] that optimizes
    streaming performance across unpredictable networks.
    
    Although SRT is based on UDP, it works like connection-oriented
    protocol. However, it doesn't mean that the SRT server or client
    is necessarily to link to a receiver or a sender so, here, the
    pairs of source and sink elements are introduced.
    
     - srtserversink: SRT server to feed SRT stream
     - srtclientsrc:  SRT client to get SRT stream from srtserversink
    
     - srtclientsink: SRT client to send SRT stream
     - srtserversrc:  SRT server to listen from srtclientsink
    
    [0] https://github.com/Haivision/srt
    [1] http://www.srtalliance.org/
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785730