test-onvif example: Add support for AAC backchannel
Detect upstream backchannel codec and support AAC in MPEG4-GENERIC encapsulation Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8378>
This commit is contained in:
parent
d2dcfea052
commit
9adc7bd9f0
@ -35,10 +35,60 @@ setup_backchannel_shoveler (GstElement * rtspsrc, GstCaps * caps)
|
||||
{
|
||||
GstElement *appsink;
|
||||
|
||||
backpipe = gst_parse_launch ("audiotestsrc is-live=true wave=red-noise ! "
|
||||
"mulawenc ! rtppcmupay ! appsink name=out", NULL);
|
||||
if (!backpipe)
|
||||
gst_println ("Have audio backchannel caps %" GST_PTR_FORMAT "\n", caps);
|
||||
|
||||
const GstStructure *s = gst_caps_get_structure (caps, 0);
|
||||
|
||||
const gchar *encoding = gst_structure_get_string (s, "encoding-name");
|
||||
if (encoding == NULL) {
|
||||
g_error
|
||||
("Could not setup backchannel pipeline: Missing encoding-name field");
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
GError *error = NULL;
|
||||
|
||||
if (g_str_equal (encoding, "PCMU")) {
|
||||
backpipe =
|
||||
gst_parse_launch
|
||||
("audiotestsrc is-live=true wave=red-noise ! capsfilter name=ratefilter ! "
|
||||
"rtppcmupay ! appsink name=out", &error);
|
||||
} else if (g_str_equal (encoding, "MPEG4-GENERIC")) {
|
||||
backpipe =
|
||||
gst_parse_launch
|
||||
("audiotestsrc is-live=true wave=red-noise ! capsfilter name=ratefilter ! "
|
||||
"voaacenc ! aacparse ! rtpmp4gpay ! appsink name=out", &error);
|
||||
} else {
|
||||
g_error ("Could not setup backchannel pipeline: Unsupported encoding %s",
|
||||
encoding);
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
if (!backpipe) {
|
||||
g_error ("Could not setup backchannel pipeline");
|
||||
if (error != NULL) {
|
||||
g_error ("Error: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
gint rate = 32000;
|
||||
if (!gst_structure_get_int (s, "clock-rate", &rate)) {
|
||||
g_error ("Could not setup backchannel pipeline: Missing clock-rate field");
|
||||
g_main_loop_quit (loop);
|
||||
}
|
||||
|
||||
GstElement *rate_filter =
|
||||
gst_bin_get_by_name (GST_BIN (backpipe), "ratefilter");
|
||||
g_assert (rate_filter != NULL);
|
||||
|
||||
GstCaps *rate_caps =
|
||||
gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, rate, NULL);
|
||||
g_object_set (G_OBJECT (rate_filter), "caps", rate_caps, NULL);
|
||||
gst_caps_unref (rate_caps);
|
||||
|
||||
gst_object_unref (GST_OBJECT (rate_filter));
|
||||
|
||||
appsink = gst_bin_get_by_name (GST_BIN (backpipe), "out");
|
||||
g_object_set (G_OBJECT (appsink), "caps", caps, "emit-signals", TRUE, NULL);
|
||||
|
Loading…
x
Reference in New Issue
Block a user