Skip to content

Commit

Permalink
Added support for static Opus files to Streaming plugin (#2040)
Browse files Browse the repository at this point in the history
  • Loading branch information
lminiero authored Apr 6, 2020
1 parent 042aa05 commit d9aa1ce
Show file tree
Hide file tree
Showing 5 changed files with 402 additions and 66 deletions.
6 changes: 3 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,9 @@ endif
if ENABLE_PLUGIN_STREAMING
plugin_LTLIBRARIES += plugins/libjanus_streaming.la
plugins_libjanus_streaming_la_SOURCES = plugins/janus_streaming.c
plugins_libjanus_streaming_la_CFLAGS = $(plugins_cflags) $(LIBCURL_CFLAGS)
plugins_libjanus_streaming_la_LDFLAGS = $(plugins_ldflags) $(LIBCURL_LDFLAGS) $(LIBCURL_LIBS)
plugins_libjanus_streaming_la_LIBADD = $(plugins_libadd) $(LIBCURL_LIBADD)
plugins_libjanus_streaming_la_CFLAGS = $(plugins_cflags) $(LIBCURL_CFLAGS) $(OGG_CFLAGS)
plugins_libjanus_streaming_la_LDFLAGS = $(plugins_ldflags) $(LIBCURL_LDFLAGS) $(LIBCURL_LIBS) $(OGG_LDFLAGS) $(OGG_LIBS)
plugins_libjanus_streaming_la_LIBADD = $(plugins_libadd) $(LIBCURL_LIBADD) $(OGG_LIBADD)
conf_DATA += conf/janus.plugin.streaming.jcfg.sample
stream_DATA += \
plugins/streams/music.mulaw \
Expand Down
35 changes: 30 additions & 5 deletions conf/janus.plugin.streaming.jcfg.sample.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,19 @@ general: {
#string_ids = true
}

gstreamer-sample: {
#
# This is an example of an RTP source stream, which is what you'll need
# in the vast majority of cases: here, the Streaming plugin will bind to
# some ports, and expect media to be sent by an external source (e.g.,
# FFmpeg or Gstreamer). This sample listens on 5002 for audio (Opus) and
# 5004 for video (VP8), which is what the sample gstreamer script in the
# plugins/streams folder sends to. Whatever is sent to those ports will
# be the source of a WebRTC broadcast users can subscribe to.
#
rtp-sample: {
type = "rtp"
id = 1
description = "Opus/VP8 live stream coming from gstreamer"
description = "Opus/VP8 live stream coming from external source"
audio = true
video = true
audioport = 5002
Expand All @@ -109,6 +118,13 @@ gstreamer-sample: {
secret = "adminpwd"
}

#
# This is a sample of the file-based streaming support. Specifically,
# this simulates a radio broadcast by streaming (in a loop) raw a-Law
# (that is, G.711) frames. Since type is "live", anyone subscribing to
# this mountpoint will listen to the same broadcast as if it were live.
# Notice that file-based streaming supports Opus files too, but no video.
#
file-live-sample: {
type = "live"
id = 2
Expand All @@ -119,6 +135,14 @@ file-live-sample: {
secret = "adminpwd"
}

#
# This is another sample of the file-based streaming support, but using
# the "ondemand" type instead. In this case, the file we're streaming
# contains raw mu-Law (still G.711) frames. Since this is "ondemand",
# anyone subscribing to this mountpoint will listen to their own version
# of the stream, meaning that it will start from the beginning and then
# loop when it's over. On-demand streaming supports Opus files as well.
#
file-ondemand-sample: {
type = "ondemand"
id = 3
Expand Down Expand Up @@ -171,10 +195,11 @@ file-ondemand-sample: {
#}

#
# This is a sample configuration for Opus/VP8 multicast streams. You
# This is a variation of the rtp-sample configuration for Opus/VP8 shown
# before, where multicast support is used to receive the streams. You
# need an external script to feed data on those ports, of course.
#
#gstreamer-multicast: {
#rtp-multicast: {
#type = "rtp"
#id = 20
#description = "Opus/VP8 live multicast stream sample"
Expand All @@ -197,7 +222,7 @@ file-ondemand-sample: {
# authentication will only work if you installed libcurl >= 7.45.0)
# NOTE WELL: the plugin does NOT transcode, so the RTSP stream MUST be
# in a format the browser can digest (e.g., VP8 or H.264 baseline for video)
# Again, you can override payload type, rtpmap and/or fmtp, if needed
# Again, you can override payload type, rtpmap and/or fmtp, if needed.
#
#rtsp-test: {
#type = "rtsp"
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ AC_SUBST([OPUS_LIBS])
PKG_CHECK_MODULES([OGG],
[ogg],
[
AC_DEFINE(HAVE_LIBOGG)
AS_IF([test "x$enable_plugin_voicemail" = "xmaybe"],
[enable_plugin_voicemail=yes])
],
Expand Down
16 changes: 16 additions & 0 deletions html/streamingtest.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,19 @@ $(document).ready(function() {
if(jsep !== undefined && jsep !== null) {
Janus.debug("Handling SDP as well...");
Janus.debug(jsep);
var stereo = (jsep.sdp.indexOf("stereo=1") !== -1);
// Offer from the plugin, let's answer
streaming.createAnswer(
{
jsep: jsep,
// We want recvonly audio/video and, if negotiated, datachannels
media: { audioSend: false, videoSend: false, data: true },
customizeSdp: function(jsep) {
if(stereo && jsep.sdp.indexOf("stereo=1") == -1) {
// Make sure that our offer contains stereo too
jsep.sdp = jsep.sdp.replace("useinbandfec=1", "useinbandfec=1;stereo=1");
}
},
success: function(jsep) {
Janus.debug("Got SDP!");
Janus.debug(jsep);
Expand Down Expand Up @@ -298,6 +305,15 @@ function updateStreamsList() {
$('#watch').attr('disabled', true).unbind('click');
var list = result["list"];
Janus.log("Got a list of available streams");
if(list && Array.isArray(list)) {
list.sort(function(a, b) {
if(!a || a.id < (b ? b.id : 0))
return -1;
if(!b || b.id < (a ? a.id : 0))
return 1;
return 0;
});
}
Janus.debug(list);
for(var mp in list) {
Janus.debug(" >> [" + list[mp]["id"] + "] " + list[mp]["description"] + " (" + list[mp]["type"] + ")");
Expand Down
Loading

0 comments on commit d9aa1ce

Please sign in to comment.