xrdp-ng: refactor stream utils