gstreamer: extract common code