initialize rtp to NULL

There was at least 1 case where the variable was used without being
initialized.
add static qualifier to functions
remove some unused parameters
enable more compiler warnings