It might be possible to create some heuristics to detect RTP H.264/H.265 payload format, but there’s currently no functionality in GStreamer for typefinding packetised input like that.
It would be best to have some kind of out-of-band channel to transmit the type of stream carried.
This could be for example:
use RTSP to set up the RTP streaming (the RTSP protocol will provide the info in form of an SDP)
if you use multicast, you can advertise your streams with some broadcast protocol (and include the SDP)
shared knowledge between sender and receiver, e.g. you know what’s what based on the port number
use an SDP file (local, transmitted via some other channel, or downloaded via http) to set up the streaming, e.g. using sdpsrc or such