code refactor of rtmedia media file