Skip to content

Add new --no-decode (-N) option (see #10) #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/whep-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static GMainLoop *loop = NULL;
static GstElement *pipeline = NULL, *pc = NULL;
static const char *audio_caps = NULL, *video_caps = NULL;
static gboolean no_trickle = FALSE, gathering_done = FALSE,
follow_link = FALSE, force_turn = FALSE;
follow_link = FALSE, force_turn = FALSE, no_decode = FALSE;
static const char *stun_server = NULL, **turn_server = NULL;
static char *auto_stun_server = NULL, **auto_turn_server = NULL;
static int latency = -1;
Expand Down Expand Up @@ -133,6 +133,7 @@ static GOptionEntry opt_entries[] = {
{ "log-timestamps", 'L', 0, G_OPTION_ARG_NONE, &whep_log_timestamps, "Enable logging timestamps (default: disabled)", NULL },
{ "eos-sink-name", 'e', 0, G_OPTION_ARG_STRING, &eos_sink_name, "GStreamer sink name for EOS signal", NULL },
{ "jitter-buffer", 'b', 0, G_OPTION_ARG_INT, &latency, "Jitter buffer (latency) to use in RTP, in milliseconds (default: -1, use webrtcbin's default)", NULL },
{ "no-decode", 'N', 0, G_OPTION_ARG_NONE, &no_decode, "Don't decode and play received RTP streams (ignores incoming traffic)"},
{ NULL },
};

Expand Down Expand Up @@ -211,9 +212,12 @@ int main(int argc, char *argv[]) {
}
}
WHEP_LOG(LOG_INFO, "Audio caps: %s\n", audio_caps ? audio_caps : "(none)");
WHEP_LOG(LOG_INFO, "Video caps: %s\n\n", video_caps ? video_caps : "(none)");
WHEP_LOG(LOG_INFO, "Video caps: %s\n", video_caps ? video_caps : "(none)");
if(no_decode)
WHEP_LOG(LOG_WARN, "Ignoring incoming traffic (won't decode/play RTP streams)\n");
if(latency > 1000)
WHEP_LOG(LOG_WARN, "Very high jitter-buffer latency configured (%u)\n", latency);
WHEP_LOG(LOG_INFO, "\n");

/* Initialize gstreamer */
gst_init(NULL, NULL);
Expand Down Expand Up @@ -1262,9 +1266,10 @@ static void whep_incoming_decodebin_stream(GstElement *decodebin, GstPad *pad, g
}
}
static void whep_incoming_stream(GstElement *webrtc, GstPad *pad, gpointer user_data) {
/* Create an element to decode the stream */
WHEP_LOG(LOG_INFO, "Creating decodebin element\n");
GstElement *decodebin = gst_element_factory_make("decodebin", NULL);
/* Create an element to decode (or ignore) the stream */
const char *element = (no_decode ? "fakesink" : "decodebin");
WHEP_LOG(LOG_INFO, "Creating '%s' element\n", element);
GstElement *decodebin = gst_element_factory_make(element, NULL);
g_signal_connect(decodebin, "pad-added", G_CALLBACK(whep_incoming_decodebin_stream), pc);
gst_bin_add(GST_BIN(pipeline), decodebin);
gst_element_sync_state_with_parent(decodebin);
Expand Down