refactors from UltraGridRTPSink branch