diff --git a/src/rtsp/BasicRTSPOnlyServer.cpp b/src/rtsp/BasicRTSPOnlyServer.cpp index 1e2134ce9..ff111670b 100644 --- a/src/rtsp/BasicRTSPOnlyServer.cpp +++ b/src/rtsp/BasicRTSPOnlyServer.cpp @@ -42,6 +42,7 @@ * */ +#include // for "weHaveAnIPv*Address()" #include "rtsp/BasicRTSPOnlyServer.hh" #include "rtsp/BasicRTSPOnlySubsession.hh" @@ -137,9 +138,17 @@ int BasicRTSPOnlyServer::init_server() { rtspServer->addServerMediaSession(sms); - char* url = rtspServer->rtspURL(sms); - *env << "\n[RTSP Server] Play this stream using the URL \"" << url << "\"\n"; - delete[] url; + *env << "\n"; + if (weHaveAnIPv4Address(*env)) { + char* url = rtspServer->ipv4rtspURL(sms); + *env << "[RTSP Server] Play this stream using the URL \"" << url << "\"\n"; + delete[] url; + } + if (weHaveAnIPv6Address(*env)) { + char* url = rtspServer->ipv6rtspURL(sms); + *env << "[RTSP Server] Play this stream using the URL \"" << url << "\"\n"; + delete[] url; + } return 0; } diff --git a/src/rtsp/BasicRTSPOnlySubsession.cpp b/src/rtsp/BasicRTSPOnlySubsession.cpp index 59c40682d..16dbe38f9 100644 --- a/src/rtsp/BasicRTSPOnlySubsession.cpp +++ b/src/rtsp/BasicRTSPOnlySubsession.cpp @@ -93,40 +93,41 @@ BasicRTSPOnlySubsession::~BasicRTSPOnlySubsession() { } char const* BasicRTSPOnlySubsession::sdpLines(int addressFamily) { - (void) addressFamily; if (fSDPLines == NULL) { - setSDPLines(); + setSDPLines(addressFamily); } return fSDPLines; } -void BasicRTSPOnlySubsession::setSDPLines() { +void BasicRTSPOnlySubsession::setSDPLines(int addressFamily) { //TODO: should be more dynamic + const char *ip_ver_list_addr = + addressFamily == AF_INET ? "4 0.0.0.0" : "6 ::"; + //VStream if (avType == video || avType == av) { unsigned estBitrate = 5000; char const* mediaType = "video"; uint8_t rtpPayloadType = 96; - AddressString ipAddressStr(0); char* rtpmapLine = strdup("a=rtpmap:96 H264/90000\n"); //char const* auxSDPLine = ""; char const* const sdpFmt = "m=%s %u RTP/AVP %u\r\n" - "c=IN IP4 %s\r\n" + "c=IN IP%s\r\n" "b=AS:%u\r\n" "a=rtcp:%d\r\n" "%s" "a=control:%s\r\n"; unsigned sdpFmtSize = strlen(sdpFmt) + strlen(mediaType) + 5 /* max short len */ + 3 /* max char len */ - + strlen(ipAddressStr.val()) + 20 /* max int len */ + + strlen(ip_ver_list_addr) + 20 /* max int len */ + strlen(rtpmapLine) + strlen(trackId()); char* sdpLines = new char[sdpFmtSize]; snprintf(sdpLines, sdpFmtSize, sdpFmt, mediaType, // m= rtp_port,//fPortNumForSDP, // m= rtpPayloadType, // m= - ipAddressStr.val(), // c= address + ip_ver_list_addr, // c= address estBitrate, // b=AS: rtp_port + 1, rtpmapLine, // a=rtpmap:... (if present) @@ -139,7 +140,6 @@ void BasicRTSPOnlySubsession::setSDPLines() { if (avType == audio || avType == av) { unsigned estBitrate = 384; char const* mediaType = "audio"; - AddressString ipAddressStr(0); char rtpmapLine[STR_LEN]; //char const* auxSDPLine = ""; @@ -147,14 +147,14 @@ void BasicRTSPOnlySubsession::setSDPLines() { audio_codec, audio_sample_rate, audio_channels, rtpmapLine); char const* const sdpFmt = "m=%s %u RTP/AVP %u\r\n" - "c=IN IP4 %s\r\n" + "c=IN IP%s\r\n" "b=AS:%u\r\n" "a=rtcp:%d\r\n" "%s" "a=control:%s\r\n"; unsigned sdpFmtSize = strlen(sdpFmt) + strlen(mediaType) + 5 /* max short len */ + 3 /* max char len */ - + strlen(ipAddressStr.val()) + 20 /* max int len */ + + strlen(ip_ver_list_addr) + 20 /* max int len */ + strlen(rtpmapLine) + strlen(trackId()); char* sdpLines = new char[sdpFmtSize]; @@ -162,7 +162,7 @@ void BasicRTSPOnlySubsession::setSDPLines() { mediaType, // m= rtp_port_audio,//fPortNumForSDP, // m= rtpPayloadType, // m= - ipAddressStr.val(), // c= address + ip_ver_list_addr, // c= address estBitrate, // b=AS: rtp_port_audio + 1, rtpmapLine, // a=rtpmap:... (if present) @@ -187,9 +187,6 @@ void BasicRTSPOnlySubsession::getStreamParameters(unsigned /* clientSessionId */ Port rtcp(rtp_port + 1); serverRTCPPort = rtcp; - if (fSDPLines == NULL) { - setSDPLines(); - } delete Vdestination; Vdestination = new Destinations(clientAddress, clientRTPPort, clientRTCPPort); @@ -200,9 +197,6 @@ void BasicRTSPOnlySubsession::getStreamParameters(unsigned /* clientSessionId */ Port rtcp(rtp_port_audio + 1); serverRTCPPort = rtcp; - if (fSDPLines == NULL) { - setSDPLines(); - } delete Adestination; Adestination = new Destinations(clientAddress, clientRTPPort, clientRTCPPort); diff --git a/src/rtsp/BasicRTSPOnlySubsession.hh b/src/rtsp/BasicRTSPOnlySubsession.hh index 1ac47410c..962b88756 100644 --- a/src/rtsp/BasicRTSPOnlySubsession.hh +++ b/src/rtsp/BasicRTSPOnlySubsession.hh @@ -147,7 +147,7 @@ protected: private: - void setSDPLines(); + void setSDPLines(int addressFamily); MAYBE_UNUSED_ATTRIBUTE Boolean fReuseFirstSource; MAYBE_UNUSED_ATTRIBUTE void* fLastStreamToken;