You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I managed to get working solution using localhost and now I want to separate ffplay to different machine. How can I set the RTPSession to send data to my new IP (lets say "172.23.55.150"). Currently it was sending to IPAddress.Loopback.
I tried to set the IP in rtpSession.SetDestination but it didn't work.
How can I modify this example to make it work?
private static RTPSession CreateRtpSessionLive(List<SDPAudioVideoMediaFormat> audioFormats, List<SDPAudioVideoMediaFormat> videoFormats)
{
var rtpSession = new RTPSession(false, false, false, IPAddress.Loopback);
bool hasAudio = false;
bool hasVideo = false;
if (audioFormats != null && audioFormats.Count > 0)
{
MediaStreamTrack audioTrack = new MediaStreamTrack(SDPMediaTypesEnum.audio, false, audioFormats, MediaStreamStatusEnum.SendRecv);
rtpSession.addTrack(audioTrack);
hasAudio = true;
}
if (videoFormats != null && videoFormats.Count > 0)
{
MediaStreamTrack videoTrack = new MediaStreamTrack(SDPMediaTypesEnum.video, false, videoFormats, MediaStreamStatusEnum.SendRecv);
rtpSession.addTrack(videoTrack);
hasVideo = true;
}
var sdpOffer = rtpSession.CreateOffer(null);
// Because the SDP being written to the file is the input to ffplay the connection ports need to be changed
// to the ones ffplay will be listening on.
if (hasAudio)
{
sdpOffer.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).Port = FFPLAY_DEFAULT_AUDIO_PORT;
}
if (hasVideo)
{
sdpOffer.Media.Single(x => x.Media == SDPMediaTypesEnum.video).Port = FFPLAY_DEFAULT_VIDEO_PORT;
}
Console.WriteLine(sdpOffer);
using (StreamWriter sw = new StreamWriter(FFLIVE_DEFAULT_SDP_PATH))
{
sw.Write(sdpOffer);
}
rtpSession.Start();
rtpSession.SetDestination(SDPMediaTypesEnum.audio, new IPEndPoint(IPAddress.Loopback, FFPLAY_DEFAULT_AUDIO_PORT), new IPEndPoint(IPAddress.Loopback, FFPLAY_DEFAULT_AUDIO_PORT + 1));
rtpSession.SetDestination(SDPMediaTypesEnum.video, new IPEndPoint(IPAddress.Loopback, FFPLAY_DEFAULT_VIDEO_PORT), new IPEndPoint(IPAddress.Loopback, FFPLAY_DEFAULT_VIDEO_PORT + 1));
//StartFFplay();
return rtpSession;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi I managed to get working solution using localhost and now I want to separate ffplay to different machine. How can I set the RTPSession to send data to my new IP (lets say "172.23.55.150"). Currently it was sending to IPAddress.Loopback.
I tried to set the IP in rtpSession.SetDestination but it didn't work.
How can I modify this example to make it work?
Beta Was this translation helpful? Give feedback.
All reactions