From 5ca6cf53afe24b1313d62785dd73431d565f96ae Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" Date: Thu, 21 Feb 2019 20:25:07 +0000 Subject: [PATCH] Bug 1521879 - Part 1.1: Compensate for changes to how IPC headers are generated in the last rebase. r=mjf Differential Revision: https://phabricator.services.mozilla.com/D19975 --HG-- rename : media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.h => dom/media/webrtc/MediaTransportParent.h rename : media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.cpp => media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp extra : moz-landing-system : lando --- CLOBBER | 2 +- dom/media/moz.build | 2 + dom/media/webrtc/MediaTransportChild.h | 36 ++++ dom/media/webrtc/MediaTransportParent.h | 62 ++++++ dom/media/webrtc/WebrtcIPCTraits.h | 6 +- media/mtransport/mediapacket.cpp | 16 +- .../MediaTransportHandlerIPC.cpp | 49 ++--- .../peerconnection/MediaTransportHandlerIPC.h | 6 +- .../MediaTransportHandlerParent.h | 78 ------- ...lerParent.cpp => MediaTransportParent.cpp} | 203 +++++++++--------- .../signaling/src/peerconnection/moz.build | 2 +- netwerk/ipc/SocketProcessBridgeChild.h | 4 +- netwerk/ipc/SocketProcessBridgeParent.cpp | 6 +- netwerk/ipc/SocketProcessBridgeParent.h | 5 +- 14 files changed, 242 insertions(+), 235 deletions(-) create mode 100644 dom/media/webrtc/MediaTransportChild.h create mode 100644 dom/media/webrtc/MediaTransportParent.h delete mode 100644 media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.h rename media/webrtc/signaling/src/peerconnection/{MediaTransportHandlerParent.cpp => MediaTransportParent.cpp} (50%) diff --git a/CLOBBER b/CLOBBER index 696cf8df7949..57a71e83d828 100644 --- a/CLOBBER +++ b/CLOBBER @@ -22,4 +22,4 @@ # changes to stick? As of bug 928195, this shouldn't be necessary! Please # don't change CLOBBER for WebIDL changes any more. -Bug 1524688: Deleting preprocessed manifests requires clobber. +Bug 1521879: Adding PMediaTransport.ipdl requires a clobber. diff --git a/dom/media/moz.build b/dom/media/moz.build index 0699c5a72fc0..bfd48f9c700d 100644 --- a/dom/media/moz.build +++ b/dom/media/moz.build @@ -207,6 +207,8 @@ EXPORTS.mozilla.dom += [ 'VideoStreamTrack.h', 'VideoTrack.h', 'VideoTrackList.h', + 'webrtc/MediaTransportChild.h', + 'webrtc/MediaTransportParent.h', ] UNIFIED_SOURCES += [ diff --git a/dom/media/webrtc/MediaTransportChild.h b/dom/media/webrtc/MediaTransportChild.h new file mode 100644 index 000000000000..225de6f14f36 --- /dev/null +++ b/dom/media/webrtc/MediaTransportChild.h @@ -0,0 +1,36 @@ +/* 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/. */ + +#ifndef _MTRANSPORTCHILD_H__ +#define _MTRANSPORTCHILD_H__ + +#include "mozilla/dom/PMediaTransportChild.h" + +namespace mozilla { +class MediaTransportHandlerIPC; + +class MediaTransportChild : public dom::PMediaTransportChild { + public: + explicit MediaTransportChild(MediaTransportHandlerIPC* aUser); + virtual ~MediaTransportChild(); + mozilla::ipc::IPCResult RecvOnCandidate(const string& transportId, + const CandidateInfo& candidateInfo); + mozilla::ipc::IPCResult RecvOnAlpnNegotiated(const string& alpn); + mozilla::ipc::IPCResult RecvOnGatheringStateChange(const int& state); + mozilla::ipc::IPCResult RecvOnConnectionStateChange(const int& state); + mozilla::ipc::IPCResult RecvOnPacketReceived(const string& transportId, + const MediaPacket& packet); + mozilla::ipc::IPCResult RecvOnEncryptedSending(const string& transportId, + const MediaPacket& packet); + mozilla::ipc::IPCResult RecvOnStateChange(const string& transportId, + const int& state); + mozilla::ipc::IPCResult RecvOnRtcpStateChange(const string& transportId, + const int& state); + + private: + RefPtr mUser; +}; + +} // namespace mozilla +#endif diff --git a/dom/media/webrtc/MediaTransportParent.h b/dom/media/webrtc/MediaTransportParent.h new file mode 100644 index 000000000000..ee86da07d9fd --- /dev/null +++ b/dom/media/webrtc/MediaTransportParent.h @@ -0,0 +1,62 @@ +/* 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/. */ + +#ifndef _MTRANSPORTHANDLER_PARENT_H__ +#define _MTRANSPORTHANDLER_PARENT_H__ + +#include "mozilla/dom/PMediaTransportParent.h" +#include + +namespace mozilla { + +class MediaTransportParent : public dom::PMediaTransportParent { + public: + MediaTransportParent(); + virtual ~MediaTransportParent(); + + mozilla::ipc::IPCResult RecvGetIceLog(const nsCString& pattern, + GetIceLogResolver&& aResolve); + mozilla::ipc::IPCResult RecvClearIceLog(); + mozilla::ipc::IPCResult RecvEnterPrivateMode(); + mozilla::ipc::IPCResult RecvExitPrivateMode(); + mozilla::ipc::IPCResult RecvCreateIceCtx( + const string& name, nsTArray&& iceServers, + const RTCIceTransportPolicy& icePolicy); + mozilla::ipc::IPCResult RecvSetProxyServer(const PBrowserOrId& browserOrId, + const nsCString& alpn); + mozilla::ipc::IPCResult RecvEnsureProvisionalTransport( + const string& transportId, const string& localUfrag, + const string& localPwd, const int& componentCount); + mozilla::ipc::IPCResult RecvStartIceGathering( + const bool& defaultRouteOnly, const net::NrIceStunAddrArray& stunAddrs); + mozilla::ipc::IPCResult RecvActivateTransport( + const string& transportId, const string& localUfrag, + const string& localPwd, const int& componentCount, + const string& remoteUfrag, const string& remotePwd, + nsTArray&& keyDer, nsTArray&& certDer, + const int& authType, const bool& dtlsClient, + const DtlsDigestList& digests, const bool& privacyRequested); + mozilla::ipc::IPCResult RecvRemoveTransportsExcept( + const StringVector& transportIds); + mozilla::ipc::IPCResult RecvStartIceChecks(const bool& isControlling, + const bool& isOfferer, + const StringVector& iceOptions); + mozilla::ipc::IPCResult RecvSendPacket(const string& transportId, + const MediaPacket& packet); + mozilla::ipc::IPCResult RecvAddIceCandidate(const string& transportId, + const string& candidate); + mozilla::ipc::IPCResult RecvUpdateNetworkState(const bool& online); + mozilla::ipc::IPCResult RecvGetIceStats( + const string& transportId, const double& now, + const RTCStatsReportInternal& reportIn, GetIceStatsResolver&& aResolve); + + void ActorDestroy(ActorDestroyReason aWhy); + + private: + // Hide the sigslot/MediaTransportHandler stuff from IPC. + class Impl; + std::unique_ptr mImpl; +}; +} // namespace mozilla +#endif //_MTRANSPORTHANDLER_PARENT_H__ diff --git a/dom/media/webrtc/WebrtcIPCTraits.h b/dom/media/webrtc/WebrtcIPCTraits.h index 5038aa89e5ef..15312e652664 100644 --- a/dom/media/webrtc/WebrtcIPCTraits.h +++ b/dom/media/webrtc/WebrtcIPCTraits.h @@ -25,7 +25,7 @@ struct ParamTraits> { typedef std::vector paramType; static void Write(Message* aMsg, const paramType& aParam) { - aMsg->WriteSize(aParam.size()); + aMsg->WriteUInt32(aParam.size()); for (const T& elem : aParam) { WriteParam(aMsg, elem); } @@ -33,8 +33,8 @@ struct ParamTraits> { static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { - size_t size; - if (!aMsg->ReadSize(aIter, &size)) { + uint32_t size; + if (!aMsg->ReadUInt32(aIter, &size)) { return false; } while (size--) { diff --git a/media/mtransport/mediapacket.cpp b/media/mtransport/mediapacket.cpp index 1e8ab106d74d..55095c9dafdd 100644 --- a/media/mtransport/mediapacket.cpp +++ b/media/mtransport/mediapacket.cpp @@ -27,12 +27,12 @@ void MediaPacket::Copy(const uint8_t* data, size_t len, size_t capacity) { } void MediaPacket::Serialize(IPC::Message* aMsg) const { - aMsg->WriteSize(len_); - aMsg->WriteSize(capacity_); + aMsg->WriteUInt32(len_); + aMsg->WriteUInt32(capacity_); if (len_) { aMsg->WriteBytes(data_.get(), len_); } - aMsg->WriteSize(encrypted_len_); + aMsg->WriteUInt32(encrypted_len_); if (encrypted_len_) { aMsg->WriteBytes(encrypted_data_.get(), encrypted_len_); } @@ -42,12 +42,12 @@ void MediaPacket::Serialize(IPC::Message* aMsg) const { bool MediaPacket::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { Reset(); - size_t len; - if (!aMsg->ReadSize(aIter, &len)) { + uint32_t len; + if (!aMsg->ReadUInt32(aIter, &len)) { return false; } - size_t capacity; - if (!aMsg->ReadSize(aIter, &capacity)) { + uint32_t capacity; + if (!aMsg->ReadUInt32(aIter, &capacity)) { return false; } if (len) { @@ -61,7 +61,7 @@ bool MediaPacket::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { capacity_ = capacity; } - if (!aMsg->ReadSize(aIter, &len)) { + if (!aMsg->ReadUInt32(aIter, &len)) { return false; } if (len) { diff --git a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp b/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp index 0664ca22605c..1d0c076cce35 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp +++ b/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.cpp @@ -3,6 +3,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "MediaTransportHandlerIPC.h" +#include "mozilla/dom/MediaTransportChild.h" #include "nsThreadUtils.h" #include "mozilla/net/SocketProcessBridgeChild.h" #include "mozilla/RefPtr.h" @@ -15,29 +16,6 @@ static const char* mthipcLogTag = "MediaTransportHandler"; #endif #define LOGTAG mthipcLogTag -class MediaTransportHandlerChild : public dom::PMediaTransportChild { - public: - explicit MediaTransportHandlerChild(MediaTransportHandlerIPC* aUser); - virtual ~MediaTransportHandlerChild(); - mozilla::ipc::IPCResult RecvOnCandidate( - const string& transportId, const CandidateInfo& candidateInfo) override; - mozilla::ipc::IPCResult RecvOnAlpnNegotiated(const string& alpn) override; - mozilla::ipc::IPCResult RecvOnGatheringStateChange(const int& state) override; - mozilla::ipc::IPCResult RecvOnConnectionStateChange( - const int& state) override; - mozilla::ipc::IPCResult RecvOnPacketReceived( - const string& transportId, const MediaPacket& packet) override; - mozilla::ipc::IPCResult RecvOnEncryptedSending( - const string& transportId, const MediaPacket& packet) override; - mozilla::ipc::IPCResult RecvOnStateChange(const string& transportId, - const int& state) override; - mozilla::ipc::IPCResult RecvOnRtcpStateChange(const string& transportId, - const int& state) override; - - private: - RefPtr mUser; -}; - MediaTransportHandlerIPC::MediaTransportHandlerIPC( nsISerialEventTarget* aCallbackThread) : MediaTransportHandler(aCallbackThread) { @@ -45,7 +23,7 @@ MediaTransportHandlerIPC::MediaTransportHandlerIPC( GetMainThreadSerialEventTarget(), __func__, [this, self = RefPtr(this)]( const RefPtr& aBridge) { - mChild = new MediaTransportHandlerChild(this); + mChild = new MediaTransportChild(this); // SocketProcessBridgeChild owns mChild! When it is done with it, // mChild will let us know it it going away. aBridge->SetEventTargetForActor(mChild, GetMainThreadEventTarget()); @@ -158,7 +136,7 @@ void MediaTransportHandlerIPC::Destroy() { GetMainThreadSerialEventTarget(), __func__, [=, self = RefPtr(this)](bool /*dummy*/) { if (mChild) { - MediaTransportHandlerChild::Send__delete__(mChild); + MediaTransportChild::Send__delete__(mChild); mChild = nullptr; } }, @@ -327,30 +305,29 @@ MediaTransportHandlerIPC::GetIceStats( }); } -MediaTransportHandlerChild::MediaTransportHandlerChild( - MediaTransportHandlerIPC* aUser) +MediaTransportChild::MediaTransportChild(MediaTransportHandlerIPC* aUser) : mUser(aUser) {} -MediaTransportHandlerChild::~MediaTransportHandlerChild() { +MediaTransportChild::~MediaTransportChild() { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); mUser->mChild = nullptr; } -mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnCandidate( +mozilla::ipc::IPCResult MediaTransportChild::RecvOnCandidate( const string& transportId, const CandidateInfo& candidateInfo) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); mUser->OnCandidate(transportId, candidateInfo); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnAlpnNegotiated( +mozilla::ipc::IPCResult MediaTransportChild::RecvOnAlpnNegotiated( const string& alpn) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); mUser->OnAlpnNegotiated(alpn); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnGatheringStateChange( +mozilla::ipc::IPCResult MediaTransportChild::RecvOnGatheringStateChange( const int& state) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); mUser->OnGatheringStateChange( @@ -358,7 +335,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnGatheringStateChange( return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnConnectionStateChange( +mozilla::ipc::IPCResult MediaTransportChild::RecvOnConnectionStateChange( const int& state) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); mUser->OnConnectionStateChange( @@ -366,7 +343,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnConnectionStateChange( return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnPacketReceived( +mozilla::ipc::IPCResult MediaTransportChild::RecvOnPacketReceived( const string& transportId, const MediaPacket& packet) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MediaPacket copy(packet); // Laaaaaame! Might be safe to const_cast? @@ -374,7 +351,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnPacketReceived( return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnEncryptedSending( +mozilla::ipc::IPCResult MediaTransportChild::RecvOnEncryptedSending( const string& transportId, const MediaPacket& packet) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MediaPacket copy(packet); // Laaaaaame! Might be safe to const_cast? @@ -382,14 +359,14 @@ mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnEncryptedSending( return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnStateChange( +mozilla::ipc::IPCResult MediaTransportChild::RecvOnStateChange( const string& transportId, const int& state) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); mUser->OnStateChange(transportId, static_cast(state)); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnRtcpStateChange( +mozilla::ipc::IPCResult MediaTransportChild::RecvOnRtcpStateChange( const string& transportId, const int& state) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); mUser->OnRtcpStateChange(transportId, diff --git a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.h b/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.h index 433ca2412218..0af5a32189a4 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.h +++ b/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerIPC.h @@ -10,7 +10,7 @@ namespace mozilla { -class MediaTransportHandlerChild; +class MediaTransportChild; // Implementation of MediaTransportHandler that uses IPC (PMediaTransport) to // talk to mtransport on another process. @@ -72,10 +72,10 @@ class MediaTransportHandlerIPC : public MediaTransportHandler { std::unique_ptr&& aReport) override; private: - friend class MediaTransportHandlerChild; + friend class MediaTransportChild; // We do not own this; it will tell us when it is going away. - MediaTransportHandlerChild* mChild = nullptr; + MediaTransportChild* mChild = nullptr; // |mChild| can only be initted asynchronously, |mInitPromise| resolves // when that happens. The |Then| calls make it convenient to dispatch API diff --git a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.h b/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.h deleted file mode 100644 index 570e1cf93588..000000000000 --- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.h +++ /dev/null @@ -1,78 +0,0 @@ -/* 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/. */ - -#ifndef _MTRANSPORTHANDLER_PARENT_H__ -#define _MTRANSPORTHANDLER_PARENT_H__ - -#include "mozilla/dom/PMediaTransportParent.h" -#include "signaling/src/peerconnection/MediaTransportHandler.h" -#include "sigslot.h" - -namespace mozilla { - -class MediaTransportHandlerParent : public dom::PMediaTransportParent, - public sigslot::has_slots<> { - public: - MediaTransportHandlerParent(); - virtual ~MediaTransportHandlerParent(); - - void OnCandidate(const std::string& aTransportId, - const CandidateInfo& aCandidateInfo); - void OnAlpnNegotiated(const std::string& aAlpn); - void OnGatheringStateChange(dom::PCImplIceGatheringState aState); - void OnConnectionStateChange(dom::PCImplIceConnectionState aState); - void OnPacketReceived(const std::string& aTransportId, MediaPacket& aPacket); - void OnEncryptedSending(const std::string& aTransportId, - MediaPacket& aPacket); - void OnStateChange(const std::string& aTransportId, - TransportLayer::State aState); - void OnRtcpStateChange(const std::string& aTransportId, - TransportLayer::State aState); - - mozilla::ipc::IPCResult RecvGetIceLog(const nsCString& pattern, - GetIceLogResolver&& aResolve) override; - mozilla::ipc::IPCResult RecvClearIceLog() override; - mozilla::ipc::IPCResult RecvEnterPrivateMode() override; - mozilla::ipc::IPCResult RecvExitPrivateMode() override; - mozilla::ipc::IPCResult RecvCreateIceCtx( - const string& name, nsTArray&& iceServers, - const RTCIceTransportPolicy& icePolicy) override; - mozilla::ipc::IPCResult RecvSetProxyServer(const PBrowserOrId& browserOrId, - const nsCString& alpn) override; - mozilla::ipc::IPCResult RecvEnsureProvisionalTransport( - const string& transportId, const string& localUfrag, - const string& localPwd, const int& componentCount) override; - mozilla::ipc::IPCResult RecvStartIceGathering( - const bool& defaultRouteOnly, - const net::NrIceStunAddrArray& stunAddrs) override; - mozilla::ipc::IPCResult RecvActivateTransport( - const string& transportId, const string& localUfrag, - const string& localPwd, const int& componentCount, - const string& remoteUfrag, const string& remotePwd, - nsTArray&& keyDer, nsTArray&& certDer, - const int& authType, const bool& dtlsClient, - const DtlsDigestList& digests, const bool& privacyRequested) override; - mozilla::ipc::IPCResult RecvRemoveTransportsExcept( - const StringVector& transportIds) override; - mozilla::ipc::IPCResult RecvStartIceChecks( - const bool& isControlling, const bool& isOfferer, - const StringVector& iceOptions) override; - mozilla::ipc::IPCResult RecvSendPacket(const string& transportId, - const MediaPacket& packet) override; - mozilla::ipc::IPCResult RecvAddIceCandidate(const string& transportId, - const string& candidate) override; - mozilla::ipc::IPCResult RecvUpdateNetworkState(const bool& online) override; - mozilla::ipc::IPCResult RecvGetIceStats( - const string& transportId, const double& now, - const RTCStatsReportInternal& reportIn, - GetIceStatsResolver&& aResolve) override; - - void ActorDestroy(ActorDestroyReason aWhy) override; - - private: - RefPtr mImpl; - RefPtr mStsThread; -}; -} // namespace mozilla -#endif //_MTRANSPORTHANDLER_PARENT_H__ diff --git a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.cpp b/media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp similarity index 50% rename from media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.cpp rename to media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp index 11b87dbc6a8c..6c6ec5871dc6 100644 --- a/media/webrtc/signaling/src/peerconnection/MediaTransportHandlerParent.cpp +++ b/media/webrtc/signaling/src/peerconnection/MediaTransportParent.cpp @@ -2,84 +2,99 @@ * 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/. */ -#include "MediaTransportHandlerParent.h" +#include "mozilla/dom/MediaTransportParent.h" #include "signaling/src/peerconnection/MediaTransportHandler.h" #include "nss.h" // For NSS_NoDB_Init #include "mozilla/PublicSSL.h" // For psm::InitializeCipherSuite +#include "sigslot.h" namespace mozilla { -MediaTransportHandlerParent::MediaTransportHandlerParent() - : mImpl(MediaTransportHandler::Create(GetMainThreadSerialEventTarget())) { - // We cannot register PMediaTransportParent's Send* API to these signals, - // because this API returns must-use bools, and the params are in some cases - // slightly different. - mImpl->SignalCandidate.connect(this, - &MediaTransportHandlerParent::OnCandidate); - mImpl->SignalAlpnNegotiated.connect( - this, &MediaTransportHandlerParent::OnAlpnNegotiated); - mImpl->SignalGatheringStateChange.connect( - this, &MediaTransportHandlerParent::OnGatheringStateChange); - mImpl->SignalConnectionStateChange.connect( - this, &MediaTransportHandlerParent::OnConnectionStateChange); - mImpl->SignalPacketReceived.connect( - this, &MediaTransportHandlerParent::OnPacketReceived); - mImpl->SignalEncryptedSending.connect( - this, &MediaTransportHandlerParent::OnEncryptedSending); - mImpl->SignalStateChange.connect(this, - &MediaTransportHandlerParent::OnStateChange); - mImpl->SignalRtcpStateChange.connect( - this, &MediaTransportHandlerParent::OnRtcpStateChange); -} +// Deals with the MediaTransportHandler interface, so MediaTransportParent +// doesn't have to.. +class MediaTransportParent::Impl : public sigslot::has_slots<> { + public: + explicit Impl(MediaTransportParent* aParent) + : mHandler( + MediaTransportHandler::Create(GetMainThreadSerialEventTarget())), + mParent(aParent) { + mHandler->SignalCandidate.connect(this, + &MediaTransportParent::Impl::OnCandidate); + mHandler->SignalAlpnNegotiated.connect( + this, &MediaTransportParent::Impl::OnAlpnNegotiated); + mHandler->SignalGatheringStateChange.connect( + this, &MediaTransportParent::Impl::OnGatheringStateChange); + mHandler->SignalConnectionStateChange.connect( + this, &MediaTransportParent::Impl::OnConnectionStateChange); + mHandler->SignalPacketReceived.connect( + this, &MediaTransportParent::Impl::OnPacketReceived); + mHandler->SignalEncryptedSending.connect( + this, &MediaTransportParent::Impl::OnEncryptedSending); + mHandler->SignalStateChange.connect( + this, &MediaTransportParent::Impl::OnStateChange); + mHandler->SignalRtcpStateChange.connect( + this, &MediaTransportParent::Impl::OnRtcpStateChange); + } -MediaTransportHandlerParent::~MediaTransportHandlerParent() { - MOZ_RELEASE_ASSERT(!mImpl); -} + virtual ~Impl() { + disconnect_all(); + mHandler->Destroy(); + mHandler = nullptr; + } -void MediaTransportHandlerParent::OnCandidate( - const std::string& aTransportId, const CandidateInfo& aCandidateInfo) { - NS_ENSURE_TRUE_VOID(SendOnCandidate(aTransportId, aCandidateInfo)); -} + void OnCandidate(const std::string& aTransportId, + const CandidateInfo& aCandidateInfo) { + NS_ENSURE_TRUE_VOID(mParent->SendOnCandidate(aTransportId, aCandidateInfo)); + } -void MediaTransportHandlerParent::OnAlpnNegotiated(const std::string& aAlpn) { - NS_ENSURE_TRUE_VOID(SendOnAlpnNegotiated(aAlpn)); -} + void OnAlpnNegotiated(const std::string& aAlpn) { + NS_ENSURE_TRUE_VOID(mParent->SendOnAlpnNegotiated(aAlpn)); + } -void MediaTransportHandlerParent::OnGatheringStateChange( - dom::PCImplIceGatheringState aState) { - NS_ENSURE_TRUE_VOID(SendOnGatheringStateChange(static_cast(aState))); -} + void OnGatheringStateChange(dom::PCImplIceGatheringState aState) { + NS_ENSURE_TRUE_VOID( + mParent->SendOnGatheringStateChange(static_cast(aState))); + } -void MediaTransportHandlerParent::OnConnectionStateChange( - dom::PCImplIceConnectionState aState) { - NS_ENSURE_TRUE_VOID(SendOnConnectionStateChange(static_cast(aState))); -} + void OnConnectionStateChange(dom::PCImplIceConnectionState aState) { + NS_ENSURE_TRUE_VOID( + mParent->SendOnConnectionStateChange(static_cast(aState))); + } -void MediaTransportHandlerParent::OnPacketReceived( - const std::string& aTransportId, MediaPacket& aPacket) { - NS_ENSURE_TRUE_VOID(SendOnPacketReceived(aTransportId, aPacket)); -} + void OnPacketReceived(const std::string& aTransportId, MediaPacket& aPacket) { + NS_ENSURE_TRUE_VOID(mParent->SendOnPacketReceived(aTransportId, aPacket)); + } -void MediaTransportHandlerParent::OnEncryptedSending( - const std::string& aTransportId, MediaPacket& aPacket) { - NS_ENSURE_TRUE_VOID(SendOnEncryptedSending(aTransportId, aPacket)); -} + void OnEncryptedSending(const std::string& aTransportId, + MediaPacket& aPacket) { + NS_ENSURE_TRUE_VOID(mParent->SendOnEncryptedSending(aTransportId, aPacket)); + } -void MediaTransportHandlerParent::OnStateChange(const std::string& aTransportId, - TransportLayer::State aState) { - NS_ENSURE_TRUE_VOID(SendOnStateChange(aTransportId, aState)); -} + void OnStateChange(const std::string& aTransportId, + TransportLayer::State aState) { + NS_ENSURE_TRUE_VOID(mParent->SendOnStateChange(aTransportId, aState)); + } -void MediaTransportHandlerParent::OnRtcpStateChange( - const std::string& aTransportId, TransportLayer::State aState) { - NS_ENSURE_TRUE_VOID(SendOnRtcpStateChange(aTransportId, aState)); -} + void OnRtcpStateChange(const std::string& aTransportId, + TransportLayer::State aState) { + NS_ENSURE_TRUE_VOID(mParent->SendOnRtcpStateChange(aTransportId, aState)); + } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceLog( + RefPtr mHandler; + + private: + MediaTransportParent* mParent; +}; + +MediaTransportParent::MediaTransportParent() : mImpl(new Impl(this)) {} + +MediaTransportParent::~MediaTransportParent() {} + +mozilla::ipc::IPCResult MediaTransportParent::RecvGetIceLog( const nsCString& pattern, GetIceLogResolver&& aResolve) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->GetIceLog(pattern)->Then( + mImpl->mHandler->GetIceLog(pattern)->Then( GetMainThreadSerialEventTarget(), __func__, // IPDL doesn't give us a reject function, so we cannot reject async, so // we are forced to resolve with an empty result. Laaaaaaame. @@ -96,25 +111,25 @@ mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceLog( return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvClearIceLog() { +mozilla::ipc::IPCResult MediaTransportParent::RecvClearIceLog() { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->ClearIceLog(); + mImpl->mHandler->ClearIceLog(); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvEnterPrivateMode() { +mozilla::ipc::IPCResult MediaTransportParent::RecvEnterPrivateMode() { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->EnterPrivateMode(); + mImpl->mHandler->EnterPrivateMode(); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvExitPrivateMode() { +mozilla::ipc::IPCResult MediaTransportParent::RecvExitPrivateMode() { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->ExitPrivateMode(); + mImpl->mHandler->ExitPrivateMode(); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvCreateIceCtx( +mozilla::ipc::IPCResult MediaTransportParent::RecvCreateIceCtx( const string& name, nsTArray&& iceServers, const RTCIceTransportPolicy& icePolicy) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); @@ -137,7 +152,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvCreateIceCtx( nssStarted = true; - nsresult rv = mImpl->CreateIceCtx(name, iceServers, icePolicy); + nsresult rv = mImpl->mHandler->CreateIceCtx(name, iceServers, icePolicy); if (NS_FAILED(rv)) { return ipc::IPCResult::Fail(WrapNotNull(this), __func__, "MediaTransportHandler::Init failed"); @@ -145,83 +160,82 @@ mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvCreateIceCtx( return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvSetProxyServer( +mozilla::ipc::IPCResult MediaTransportParent::RecvSetProxyServer( const PBrowserOrId& browserOrId, const nsCString& alpn) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->SetProxyServer(NrSocketProxyConfig(browserOrId, alpn)); + mImpl->mHandler->SetProxyServer(NrSocketProxyConfig(browserOrId, alpn)); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult -MediaTransportHandlerParent::RecvEnsureProvisionalTransport( +mozilla::ipc::IPCResult MediaTransportParent::RecvEnsureProvisionalTransport( const string& transportId, const string& localUfrag, const string& localPwd, const int& componentCount) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->EnsureProvisionalTransport(transportId, localUfrag, localPwd, - componentCount); + mImpl->mHandler->EnsureProvisionalTransport(transportId, localUfrag, localPwd, + componentCount); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvStartIceGathering( +mozilla::ipc::IPCResult MediaTransportParent::RecvStartIceGathering( const bool& defaultRouteOnly, const net::NrIceStunAddrArray& stunAddrs) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->StartIceGathering(defaultRouteOnly, stunAddrs); + mImpl->mHandler->StartIceGathering(defaultRouteOnly, stunAddrs); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvActivateTransport( +mozilla::ipc::IPCResult MediaTransportParent::RecvActivateTransport( const string& transportId, const string& localUfrag, const string& localPwd, const int& componentCount, const string& remoteUfrag, const string& remotePwd, nsTArray&& keyDer, nsTArray&& certDer, const int& authType, const bool& dtlsClient, const DtlsDigestList& digests, const bool& privacyRequested) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->ActivateTransport(transportId, localUfrag, localPwd, componentCount, - remoteUfrag, remotePwd, keyDer, certDer, - static_cast(authType), dtlsClient, - digests, privacyRequested); + mImpl->mHandler->ActivateTransport( + transportId, localUfrag, localPwd, componentCount, remoteUfrag, remotePwd, + keyDer, certDer, static_cast(authType), dtlsClient, digests, + privacyRequested); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvRemoveTransportsExcept( +mozilla::ipc::IPCResult MediaTransportParent::RecvRemoveTransportsExcept( const StringVector& transportIds) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); std::set ids(transportIds.begin(), transportIds.end()); - mImpl->RemoveTransportsExcept(ids); + mImpl->mHandler->RemoveTransportsExcept(ids); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvStartIceChecks( +mozilla::ipc::IPCResult MediaTransportParent::RecvStartIceChecks( const bool& isControlling, const bool& isOfferer, const StringVector& iceOptions) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->StartIceChecks(isControlling, isOfferer, iceOptions); + mImpl->mHandler->StartIceChecks(isControlling, isOfferer, iceOptions); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvSendPacket( +mozilla::ipc::IPCResult MediaTransportParent::RecvSendPacket( const string& transportId, const MediaPacket& packet) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MediaPacket copy(packet); // Laaaaaaame. - mImpl->SendPacket(transportId, std::move(copy)); + mImpl->mHandler->SendPacket(transportId, std::move(copy)); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvAddIceCandidate( +mozilla::ipc::IPCResult MediaTransportParent::RecvAddIceCandidate( const string& transportId, const string& candidate) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->AddIceCandidate(transportId, candidate); + mImpl->mHandler->AddIceCandidate(transportId, candidate); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvUpdateNetworkState( +mozilla::ipc::IPCResult MediaTransportParent::RecvUpdateNetworkState( const bool& online) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - mImpl->UpdateNetworkState(online); + mImpl->mHandler->UpdateNetworkState(online); return ipc::IPCResult::Ok(); } -mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceStats( +mozilla::ipc::IPCResult MediaTransportParent::RecvGetIceStats( const string& transportId, const double& now, const RTCStatsReportInternal& reportIn, GetIceStatsResolver&& aResolve) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); @@ -231,7 +245,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceStats( std::unique_ptr report( new dom::RTCStatsReportInternal(reportIn)); - mImpl->GetIceStats(transportId, now, std::move(report)) + mImpl->mHandler->GetIceStats(transportId, now, std::move(report)) ->Then( GetMainThreadSerialEventTarget(), __func__, // IPDL doesn't give us a reject function, so we cannot reject async, @@ -250,11 +264,8 @@ mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceStats( return ipc::IPCResult::Ok(); } -void MediaTransportHandlerParent::ActorDestroy(ActorDestroyReason aWhy) { +void MediaTransportParent::ActorDestroy(ActorDestroyReason aWhy) { MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); - disconnect_all(); - mImpl->Destroy(); - mImpl = nullptr; } } // namespace mozilla diff --git a/media/webrtc/signaling/src/peerconnection/moz.build b/media/webrtc/signaling/src/peerconnection/moz.build index 9237ec3bc504..c25a18de2f9e 100644 --- a/media/webrtc/signaling/src/peerconnection/moz.build +++ b/media/webrtc/signaling/src/peerconnection/moz.build @@ -25,7 +25,7 @@ LOCAL_INCLUDES += [ UNIFIED_SOURCES += [ 'MediaTransportHandler.cpp', 'MediaTransportHandlerIPC.cpp', - 'MediaTransportHandlerParent.cpp', + 'MediaTransportParent.cpp', 'PacketDumper.cpp', 'PeerConnectionCtx.cpp', 'PeerConnectionImpl.cpp', diff --git a/netwerk/ipc/SocketProcessBridgeChild.h b/netwerk/ipc/SocketProcessBridgeChild.h index 61b9b2237eb2..fae46b647022 100644 --- a/netwerk/ipc/SocketProcessBridgeChild.h +++ b/netwerk/ipc/SocketProcessBridgeChild.h @@ -34,8 +34,8 @@ class SocketProcessBridgeChild final : public PSocketProcessBridgeChild, bool Inited() const { return mInited; }; ProcessId SocketProcessPid() const { return mSocketProcessPid; }; - dom::PMediaTransportChild* AllocPMediaTransportChild() override; - bool DeallocPMediaTransportChild(dom::PMediaTransportChild* aActor) override; + dom::PMediaTransportChild* AllocPMediaTransportChild(); + bool DeallocPMediaTransportChild(dom::PMediaTransportChild* aActor); private: DISALLOW_COPY_AND_ASSIGN(SocketProcessBridgeChild); diff --git a/netwerk/ipc/SocketProcessBridgeParent.cpp b/netwerk/ipc/SocketProcessBridgeParent.cpp index f22ac4947a7b..ce6c9ff56024 100644 --- a/netwerk/ipc/SocketProcessBridgeParent.cpp +++ b/netwerk/ipc/SocketProcessBridgeParent.cpp @@ -8,9 +8,7 @@ #include "mozilla/ipc/BackgroundParent.h" #include "SocketProcessChild.h" -#ifdef MOZ_WEBRTC -#include "signaling/src/peerconnection/MediaTransportHandlerParent.h" -#endif +#include "mozilla/dom/MediaTransportParent.h" namespace mozilla { namespace net { @@ -62,7 +60,7 @@ void SocketProcessBridgeParent::DeferredDestroy() { dom::PMediaTransportParent* SocketProcessBridgeParent::AllocPMediaTransportParent() { #ifdef MOZ_WEBRTC - return new MediaTransportHandlerParent; + return new MediaTransportParent; #endif return nullptr; } diff --git a/netwerk/ipc/SocketProcessBridgeParent.h b/netwerk/ipc/SocketProcessBridgeParent.h index 3373f3a962bb..23b98a6775d0 100644 --- a/netwerk/ipc/SocketProcessBridgeParent.h +++ b/netwerk/ipc/SocketProcessBridgeParent.h @@ -29,9 +29,8 @@ class SocketProcessBridgeParent final : public PSocketProcessBridgeParent { void ActorDestroy(ActorDestroyReason aWhy) override; void DeferredDestroy(); - dom::PMediaTransportParent* AllocPMediaTransportParent() override; - bool DeallocPMediaTransportParent( - dom::PMediaTransportParent* aActor) override; + dom::PMediaTransportParent* AllocPMediaTransportParent(); + bool DeallocPMediaTransportParent(dom::PMediaTransportParent* aActor); private: ~SocketProcessBridgeParent();