I am using Gstreamer through C++. I am trying to play raw pcm buffer using rawaudioparse. Although I can play it, I Cannot Adjust Volume of Pipeline while playing, Cannot Seek to time, Cannot Query Duration.
THis is the code I tried.
pipeline = gst_parse_launch("appsrc name=src ! rawaudioparse format=pcm num-channels=1 sample-rate=44100 pcm-format=GST_AUDIO_FORMAT_S32LE ! volume name=vol ! audioconvert ! audioresample ! autoaudiosink --gst-debug=2", NULL);
GstElement* appsrc = gst_bin_get_by_name(GST_BIN(pipeline), "src");
GstStreamVolume* volume = (GstStreamVolume*)gst_bin_get_by_name(GST_BIN(pipeline), "vol");
(buf = ..., bufsize = ...)
GstBuffer* buffer = gst_buffer_new_allocate(NULL, bufsize, NULL);
gst_buffer_fill(buffer, 0, buf, bufsize);
gst_app_src_push_buffer(GST_APP_SRC(appsrc), buffer);
gst_app_src_end_of_stream(GST_APP_SRC(appsrc));
gst_element_set_state(pipeline, GST_STATE_PLAYING);
When I try to seek
gst_element_seek_simple(pipeline, GST_FORMAT_TIME, GstSeekFlags(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), 10 * GST_MSECOND);
IT FAILS, NO SEEKING IS PERFORMED
When I try to set volume
gst_stream_volume_set_volume((GstStreamVolume*)pipeline, GST_STREAM_VOLUME_FORMAT_CUBIC, volumelevel);
The volume doesn't change.
When I try to query the duration, the duration yields -1
gint64 duration;
gst_element_query_duration(pipeline, GST_FORMAT_TIME, &duration);
std::cout << "Duration: " << duration << std::endl;
the source appsrc is set to live by default. Change source property using stream-type=GST_APP_STREAM_TYPE_SEEKABLE to perform the seek operation. Also implement seek in application