[Opalvoip-svn] SF.net SVN: opalvoip:[34763] opal/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2016-04-04 13:46:28
|
Revision: 34763 http://sourceforge.net/p/opalvoip/code/34763 Author: rjongbloed Date: 2016-04-04 13:46:25 +0000 (Mon, 04 Apr 2016) Log Message: ----------- Added support for MediaStreamTrack identifiers from SDP. Modified Paths: -------------- opal/trunk/include/rtp/rtp_session.h opal/trunk/src/rtp/rtp_session.cxx opal/trunk/src/sdp/sdp.cxx Modified: opal/trunk/include/rtp/rtp_session.h =================================================================== --- opal/trunk/include/rtp/rtp_session.h 2016-04-04 11:15:11 UTC (rev 34762) +++ opal/trunk/include/rtp/rtp_session.h 2016-04-04 13:46:25 UTC (rev 34763) @@ -327,16 +327,26 @@ */ void SetCanonicalName(const PString & name, RTP_SyncSourceId ssrc = 0, Direction dir = e_Sender); - /**Get the "Media Stream" id for the RTP session SSRC. - See draft-alvestrand-mmusic-msid. + /**Get the "MediaStream" id for the RTP session SSRC. + See http://tools.ietf.org/html/draft-ietf-mmusic-msid-12 */ PString GetMediaStreamId(RTP_SyncSourceId ssrc, Direction dir) const; - /**Set the "Media Stream" id for the RTP session SSRC. - See draft-alvestrand-mmusic-msid. + /**Set the "MediaStream" id for the RTP session SSRC. + See http://tools.ietf.org/html/draft-ietf-mmusic-msid-12 */ void SetMediaStreamId(const PString & id, RTP_SyncSourceId ssrc, Direction dir); + /**Get the "MediaStreamTrack" id for the RTP session SSRC. + See http://tools.ietf.org/html/draft-ietf-mmusic-msid-12 + */ + PString GetMediaTrackId(RTP_SyncSourceId ssrc, Direction dir) const; + + /**Set the "MediaStreamTrack" id for the RTP session SSRC. + See http://tools.ietf.org/html/draft-ietf-mmusic-msid-12 + */ + void SetMediaTrackId(const PString & id, RTP_SyncSourceId ssrc, Direction dir); + /**Get the tool name for the RTP session. */ PString GetToolName() const; @@ -670,6 +680,7 @@ RTP_SyncSourceId m_loopbackIdentifier; PString m_canonicalName; PString m_mediaStreamId; + PString m_mediaTrackId; NotifierMap m_notifiers; Modified: opal/trunk/src/rtp/rtp_session.cxx =================================================================== --- opal/trunk/src/rtp/rtp_session.cxx 2016-04-04 11:15:11 UTC (rev 34762) +++ opal/trunk/src/rtp/rtp_session.cxx 2016-04-04 13:46:25 UTC (rev 34763) @@ -952,13 +952,40 @@ PSafeLockReadWrite lock(*this); SyncSource * info; if (GetSyncSource(ssrc, dir, info)) { + if (info->m_mediaTrackId.IsEmpty() || info->m_mediaTrackId.NumCompare(info->m_mediaStreamId + '+') == EqualTo) + info->m_mediaTrackId = PSTRSTRM(id << '+' << m_mediaType); info->m_mediaStreamId = id; info->m_mediaStreamId.MakeUnique(); - PTRACE(4, *this << "set session id for SSRC=" << RTP_TRACE_SRC(ssrc) << " to \"" << id << '"'); + PTRACE(4, *this << "set MediaStream id for SSRC=" << RTP_TRACE_SRC(ssrc) << " to \"" << id << '"'); } } +PString OpalRTPSession::GetMediaTrackId(RTP_SyncSourceId ssrc, Direction dir) const +{ + PString s; + PSafeLockReadOnly lock(*this); + SyncSource * info; + if (GetSyncSource(ssrc, dir, info)) { + s = info->m_mediaTrackId; + s.MakeUnique(); + } + return s; +} + + +void OpalRTPSession::SetMediaTrackId(const PString & id, RTP_SyncSourceId ssrc, Direction dir) +{ + PSafeLockReadWrite lock(*this); + SyncSource * info; + if (GetSyncSource(ssrc, dir, info)) { + info->m_mediaTrackId = id; + info->m_mediaTrackId.MakeUnique(); + PTRACE(4, *this << "set MediaStreamTrack id for SSRC=" << RTP_TRACE_SRC(ssrc) << " to \"" << id << '"'); + } +} + + PString OpalRTPSession::GetToolName() const { PSafeLockReadOnly lock(*this); Modified: opal/trunk/src/sdp/sdp.cxx =================================================================== --- opal/trunk/src/sdp/sdp.cxx 2016-04-04 11:15:11 UTC (rev 34762) +++ opal/trunk/src/sdp/sdp.cxx 2016-04-04 13:46:25 UTC (rev 34763) @@ -1780,21 +1780,10 @@ strm << "a=rtcp:" << port << ' ' << GetConnectAddressString(m_mediaAddress) << CRLF; } - if (m_ssrcInfo.size() == 1) { - SsrcInfo::const_iterator it1 = m_ssrcInfo.begin(); - for (PStringOptions::const_iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { - strm << "a="; - if (it2->first == "cname") - strm << "ssrc:" << it1->first << ' '; - strm << it2->first << ':' << it2->second << CRLF; - } + for (SsrcInfo::const_iterator it1 = m_ssrcInfo.begin(); it1 != m_ssrcInfo.end(); ++it1) { + for (PStringOptions::const_iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) + strm << "a=ssrc:" << it1->first << ' ' << it2->first << ':' << it2->second << CRLF; } - else { - for (SsrcInfo::const_iterator it1 = m_ssrcInfo.begin(); it1 != m_ssrcInfo.end(); ++it1) { - for (PStringOptions::const_iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) - strm << "a=ssrc:" << it1->first << ' ' << it2->first << ':' << it2->second << CRLF; - } - } // m_rtcp_fb is set via SDPRTPAVPMediaDescription::PreEncode according to various options OuputRTCP_FB(strm, -1, m_rtcp_fb); @@ -1847,6 +1836,17 @@ #endif // OPAL_SRTP +static void SetMediaStreamAndTrackIds(const PString & msid, PStringOptions & info) +{ + info.SetAt("msid", msid); + + PString stream, track; + msid.Split(' ', stream, track); + info.SetAt("mslabel", stream); + info.SetAt("label", track); +} + + void SDPRTPAVPMediaDescription::SetAttribute(const PString & attr, const PString & value) { /* NOTE: must make sure anything passed through to a SDPFormat isntance does @@ -1919,8 +1919,7 @@ if (attr *= "msid") { m_msid = value; for (SsrcInfo::iterator it = m_ssrcInfo.begin(); it != m_ssrcInfo.end(); ++it) { - it->second.SetAt("msid", value); - it->second.SetAt("mslabel", m_msid.Left(m_msid.Find(' '))); + SetMediaStreamAndTrackIds(value, it->second); PTRACE(2, "SSRC: " << RTP_TRACE_SRC(it->first) << " m level msid: \"" << m_msid << '"'); } return; @@ -1935,8 +1934,7 @@ } else { if (!m_msid.IsEmpty()) { - m_ssrcInfo[ssrc].SetAt("msid", m_msid); - m_ssrcInfo[ssrc].SetAt("mslabel", m_msid.Left(m_msid.Find(' '))); + SetMediaStreamAndTrackIds(m_msid, m_ssrcInfo[ssrc]); PTRACE(2, "SSRC: " << RTP_TRACE_SRC(ssrc) << " m level msid: \"" << m_msid << '"'); } @@ -1947,7 +1945,7 @@ if (key == "mslabel" && !m_temporaryFlowSSRC.empty()) m_mediaStreams[val][0] = m_temporaryFlowSSRC; else if (key == "msid" && m_ssrcInfo[ssrc].GetString("mslabel").IsEmpty()) - m_ssrcInfo[ssrc].SetAt("mslabel", val.Left(val.Find(' '))); + SetMediaStreamAndTrackIds(val, m_ssrcInfo[ssrc]); } return; } @@ -1992,7 +1990,7 @@ info.SetAt("cname", cname); PString mslabel = rtpSession->GetMediaStreamId(*it, OpalRTPSession::e_Sender); if (!mslabel.IsEmpty()) { - PString label = mslabel + '+' + session->GetMediaType(); + PString label = rtpSession->GetMediaTrackId(*it, OpalRTPSession::e_Sender); info.SetAt("mslabel", mslabel); info.SetAt("label", label); info.SetAt("msid", mslabel & label); @@ -2052,6 +2050,7 @@ rtpSession->SetAnySyncSource(false); PTRACE(4, "Session " << session->GetSessionID() << ", added receiver SSRC " << RTP_TRACE_SRC(ssrc)); } + rtpSession->SetMediaTrackId(it->second.GetString("label"), ssrc, OpalRTPSession::e_Receiver); rtpSession->SetMediaStreamId(it->second.GetString("mslabel"), ssrc, OpalRTPSession::e_Receiver); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |