- if (audio && queue_audio && video && queue_video && videodemux && switch_audio)
- {
- g_object_set (G_OBJECT (queue_audio), "max-size-bytes", 256*1024, NULL);
- g_object_set (G_OBJECT (queue_audio), "max-size-buffers", 0, NULL);
- g_object_set (G_OBJECT (queue_audio), "max-size-time", (guint64)0, NULL);
- g_object_set (G_OBJECT (queue_video), "max-size-buffers", 0, NULL);
- g_object_set (G_OBJECT (queue_video), "max-size-bytes", 2*1024*1024, NULL);
- g_object_set (G_OBJECT (queue_video), "max-size-time", (guint64)0, NULL);
- g_object_set (G_OBJECT (switch_audio), "select-all", TRUE, NULL);
- all_ok = 1;
- }
- } else /* is audio */
- {
- std::string demux_type;
- switch ( sourceinfo.containertype )
- {
- case ctMP4:
- demux_type = "qtdemux";
- break;
- default:
- break;
- }
- if ( demux_type.length() )
- {
- audiodemux = gst_element_factory_make(demux_type.c_str(), "audiodemux");
- if (!audiodemux)
- m_error_message = "GStreamer plugin " + demux_type + " not available!\n";
- }
- switch ( sourceinfo.audiotype )
- {
- case atMP3:
- {
- id3demux = gst_element_factory_make("id3demux", "id3demux");
- if ( !id3demux )
- {
- m_error_message += "failed to create Gstreamer element id3demux\n";
- break;
- }
- parser = gst_element_factory_make("mp3parse", "audiosink");
- if ( !parser )
- {
- m_error_message += "failed to create Gstreamer element mp3parse\n";
- break;
- }
- sink = gst_element_factory_make("dvbaudiosink", "audiosink2");
- if ( !sink )
- m_error_message += "failed to create Gstreamer element dvbaudiosink\n";
- else
- all_ok = 1;
- break;
- }
- case atAAC:
- {
- if ( !audiodemux )
- {
- m_error_message += "cannot parse raw AAC audio\n";
- break;
- }
- sink = gst_element_factory_make("dvbaudiosink", "audiosink");
- if (!sink)
- m_error_message += "failed to create Gstreamer element dvbaudiosink\n";
- else
- all_ok = 1;
- break;
- }
- case atAC3:
- {
- if ( !audiodemux )
- {
- m_error_message += "cannot parse raw AC3 audio\n";
- break;
- }
- sink = gst_element_factory_make("dvbaudiosink", "audiosink");
- if ( !sink )
- m_error_message += "failed to create Gstreamer element dvbaudiosink\n";
- else
- all_ok = 1;
- break;
- }
- default:
- { /* filesrc -> decodebin -> audioconvert -> capsfilter -> alsasink */
- decoder = gst_element_factory_make ("decodebin", "decoder");
- if (!decoder)
- m_error_message += "failed to create Gstreamer element decodebin\n";
-
- conv = gst_element_factory_make ("audioconvert", "converter");
- if (!conv)
- m_error_message += "failed to create Gstreamer element audioconvert\n";
-
- flt = gst_element_factory_make ("capsfilter", "flt");
- if (!flt)
- m_error_message += "failed to create Gstreamer element capsfilter\n";
-
- /* for some reasons, we need to set the sample format to depth/width=16, because auto negotiation doesn't work. */
- /* endianness, however, is not required to be set anymore. */
- if (flt)
- {
- GstCaps *caps = gst_caps_new_simple("audio/x-raw-int", /* "endianness", G_TYPE_INT, 4321, */ "depth", G_TYPE_INT, 16, "width", G_TYPE_INT, 16, /*"channels", G_TYPE_INT, 2, */NULL);
- g_object_set (G_OBJECT (flt), "caps", caps, NULL);
- gst_caps_unref(caps);
- }
-
- sink = gst_element_factory_make ("alsasink", "alsa-output");
- if (!sink)
- m_error_message += "failed to create Gstreamer element alsasink\n";
-
- if (source && decoder && conv && sink)
- all_ok = 1;
- break;
- }
- }