From 92a7dcc5b77e4f78ad97cc9e8b870f9635422c6c Mon Sep 17 00:00:00 2001 From: "Nils Ohlmeier [:drno]" Date: Wed, 13 Jun 2018 14:29:20 -0700 Subject: Bug 1464063 - Remove sdp_getchoosetok. r=bwc, a=RyanVM WebRTC --- media/webrtc/signaling/src/sdp/sipcc/sdp_private.h | 2 - media/webrtc/signaling/src/sdp/sipcc/sdp_token.c | 20 +++---- media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c | 63 ---------------------- 3 files changed, 7 insertions(+), 78 deletions(-) (limited to 'media/webrtc/signaling/src') diff --git a/media/webrtc/signaling/src/sdp/sipcc/sdp_private.h b/media/webrtc/signaling/src/sdp/sipcc/sdp_private.h index a98f4b119..3459b0c0e 100644 --- a/media/webrtc/signaling/src/sdp/sipcc/sdp_private.h +++ b/media/webrtc/signaling/src/sdp/sipcc/sdp_private.h @@ -347,8 +347,6 @@ extern uint32_t sdp_getnextnumtok(const char *str, const char **str_end, extern uint32_t sdp_getnextnumtok_or_null(const char *str, const char **str_end, const char *delim, tinybool *null_ind, sdp_result_e *result); -extern tinybool sdp_getchoosetok(const char *str, const char **str_end, - const char *delim, sdp_result_e *result); extern tinybool verify_sdescriptions_mki(char *buf, char *mkiVal, uint16_t *mkiLen); diff --git a/media/webrtc/signaling/src/sdp/sipcc/sdp_token.c b/media/webrtc/signaling/src/sdp/sipcc/sdp_token.c index a002f9a73..f9eb04198 100644 --- a/media/webrtc/signaling/src/sdp/sipcc/sdp_token.c +++ b/media/webrtc/signaling/src/sdp/sipcc/sdp_token.c @@ -1162,15 +1162,11 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, uint16_t level, const char *ptr) } port_ptr = port; for (i=0; i < SDP_MAX_PORT_PARAMS; i++) { - if (sdp_getchoosetok(port_ptr, &port_ptr, "/ \t", &result) == TRUE) { - num[i] = SDP_CHOOSE_PARAM; - } else { - num[i] = sdp_getnextnumtok(port_ptr, (const char **)&port_ptr, - "/ \t", &result); - if (result != SDP_SUCCESS) { - break; - } - } + num[i] = sdp_getnextnumtok(port_ptr, (const char **)&port_ptr, + "/ \t", &result); + if (result != SDP_SUCCESS) { + break; + } num_port_params++; } @@ -1396,10 +1392,8 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, uint16_t level, const char *ptr) } port_ptr = port; - if (sdp_getchoosetok(port_ptr, &port_ptr, "/ \t", &result)) { - sctp_port = SDP_CHOOSE_PARAM; - } else { - sctp_port = sdp_getnextnumtok(port_ptr, (const char **)&port_ptr, + { + sctp_port = sdp_getnextnumtok(port_ptr, (const char **)&port_ptr, "/ \t", &result); if (result != SDP_SUCCESS) { sdp_parse_error(sdp_p, diff --git a/media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c b/media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c index a02035c72..8acb3dbbf 100644 --- a/media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c +++ b/media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c @@ -431,69 +431,6 @@ uint32_t sdp_getnextnumtok (const char *str, const char **str_end, } -/* See if the next token in a string is the choose character. The delim - * characters are passed in as a param. The check also will not go past - * a new line char or the end of the string. Skip any delimiters before - * the token. - */ -tinybool sdp_getchoosetok (const char *str, const char **str_end, - const char *delim, sdp_result_e *result) -{ - const char *b; - int flag2moveon; - - if ((str == NULL) || (str_end == NULL)) { - *result = SDP_FAILURE; - return(FALSE); - } - - /* Locate front of token, skipping any delimiters */ - for ( ; ((*str != '\0') && (*str != '\n') && (*str != '\r')); str++) { - flag2moveon = 1; /* Default to move on unless we find a delimiter */ - for (b=delim; *b; b++) { - if (*str == *b) { - flag2moveon = 0; - break; - } - } - if( flag2moveon ) { - break; /* We're at the beginning of the token */ - } - } - - /* Make sure there's really a token present. */ - if ((*str == '\0') || (*str == '\n') || (*str == '\r')) { - *result = SDP_FAILURE; - *str_end = (char *)str; - return(FALSE); - } - - /* See if the token is '$' followed by a delimiter char or end of str. */ - if (*str == '$') { - str++; - if ((*str == '\0') || (*str == '\n') || (*str == '\r')) { - *result = SDP_SUCCESS; - /* skip the choose char in the string. */ - *str_end = (char *)(str+1); - return(TRUE); - } - for (b=delim; *b; b++) { - if (*str == *b) { - *result = SDP_SUCCESS; - /* skip the choose char in the string. */ - *str_end = (char *)(str+1); - return(TRUE); - } - } - } - - /* If the token was not '$' followed by a delim, token is not choose */ - *result = SDP_SUCCESS; - *str_end = (char *)str; - return(FALSE); - -} - /* * SDP Crypto Utility Functions. * -- cgit v1.2.3 From ca3a3b63eed0de7d86291dab8479dcc3e4fc4b8f Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 1 Jul 2018 12:57:51 +0200 Subject: WebRTC: Add DeleteStreams to media conduits. --- media/webrtc/signaling/src/media-conduit/AudioConduit.h | 2 ++ media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h | 2 ++ media/webrtc/signaling/src/media-conduit/VideoConduit.cpp | 4 ++-- media/webrtc/signaling/src/media-conduit/VideoConduit.h | 3 ++- media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp | 7 ++++++- 5 files changed, 14 insertions(+), 4 deletions(-) (limited to 'media/webrtc/signaling/src') diff --git a/media/webrtc/signaling/src/media-conduit/AudioConduit.h b/media/webrtc/signaling/src/media-conduit/AudioConduit.h index 228736dcc..fcc7e0f37 100755 --- a/media/webrtc/signaling/src/media-conduit/AudioConduit.h +++ b/media/webrtc/signaling/src/media-conduit/AudioConduit.h @@ -161,6 +161,8 @@ public: virtual uint64_t CodecPluginID() override { return 0; } + virtual void DeleteStreams() override {} + WebrtcAudioConduit(): mVoiceEngine(nullptr), mTransportMonitor("WebrtcAudioConduit"), diff --git a/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h b/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h index 05c34fea0..0654b1175 100755 --- a/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h +++ b/media/webrtc/signaling/src/media-conduit/MediaConduitInterface.h @@ -227,6 +227,8 @@ public: uint64_t* bytesSent) = 0; virtual uint64_t CodecPluginID() = 0; + + virtual void DeleteStreams() = 0; NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaSessionConduit) diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp index 3f0445122..b406fded5 100755 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp @@ -109,7 +109,7 @@ WebrtcVideoConduit::~WebrtcVideoConduit() // Release AudioConduit first by dropping reference on MainThread, where it expects to be SyncTo(nullptr); - Destroy(); + MOZ_ASSERT(!mSendStream && !mRecvStream, "Call DeleteStreams prior to ~WebrtcVideoConduit."); } bool WebrtcVideoConduit::SetLocalSSRC(unsigned int ssrc) @@ -478,7 +478,7 @@ WebrtcVideoConduit::Init() } void -WebrtcVideoConduit::Destroy() +WebrtcVideoConduit::DeleteStreams() { // The first one of a pair to be deleted shuts down media for both //Deal with External Capturer diff --git a/media/webrtc/signaling/src/media-conduit/VideoConduit.h b/media/webrtc/signaling/src/media-conduit/VideoConduit.h index 323a6a284..ff50d80b5 100755 --- a/media/webrtc/signaling/src/media-conduit/VideoConduit.h +++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.h @@ -269,6 +269,8 @@ public: return mSendingHeight; } + virtual void DeleteStreams() override; + unsigned int SendingMaxFs() override { if(mCurSendCodecConfig) { return mCurSendCodecConfig->mEncodingConstraints.maxFs; @@ -288,7 +290,6 @@ public: MediaConduitErrorCode InitMain(); virtual MediaConduitErrorCode Init(); - virtual void Destroy(); int GetChannel() { return mChannel; } webrtc::VideoEngine* GetVideoEngine() { return mVideoEngine; } diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp index 4f42b0bb7..6477a7d78 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp @@ -1,4 +1,4 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public +:SelfDestruct_m/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -1036,6 +1036,11 @@ PeerConnectionMedia::SelfDestruct_m() mLocalSourceStreams.Clear(); mRemoteSourceStreams.Clear(); + // Clean up our send and receive streams + for (auto i = mConduits.begin(); i != mConduits.end(); ++i) { + i->second.second->DeleteStreams(); + } + mMainThread = nullptr; // Final self-destruct. -- cgit v1.2.3 From 46450ce7de0aa5e27a2dfb49afe66b0de6130556 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 1 Jul 2018 16:16:55 +0200 Subject: Remove errant paste --- media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'media/webrtc/signaling/src') diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp index 6477a7d78..0d388a8f4 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp @@ -1,4 +1,4 @@ -:SelfDestruct_m/* This Source Code Form is subject to the terms of the Mozilla Public +/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -- cgit v1.2.3