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
This commit is contained in:
Byron Campen [:bwc] 2019-02-21 20:25:07 +00:00
Родитель 7ab14bdf2c
Коммит 5ca6cf53af
14 изменённых файлов: 242 добавлений и 235 удалений

Просмотреть файл

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please # changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more. # don't change CLOBBER for WebIDL changes any more.
Bug 1524688: Deleting preprocessed manifests requires clobber. Bug 1521879: Adding PMediaTransport.ipdl requires a clobber.

Просмотреть файл

@ -207,6 +207,8 @@ EXPORTS.mozilla.dom += [
'VideoStreamTrack.h', 'VideoStreamTrack.h',
'VideoTrack.h', 'VideoTrack.h',
'VideoTrackList.h', 'VideoTrackList.h',
'webrtc/MediaTransportChild.h',
'webrtc/MediaTransportParent.h',
] ]
UNIFIED_SOURCES += [ UNIFIED_SOURCES += [

Просмотреть файл

@ -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<MediaTransportHandlerIPC> mUser;
};
} // namespace mozilla
#endif

Просмотреть файл

@ -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 <memory>
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<RTCIceServer>&& 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<uint8_t>&& keyDer, nsTArray<uint8_t>&& 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<Impl> mImpl;
};
} // namespace mozilla
#endif //_MTRANSPORTHANDLER_PARENT_H__

Просмотреть файл

@ -25,7 +25,7 @@ struct ParamTraits<std::vector<T>> {
typedef std::vector<T> paramType; typedef std::vector<T> paramType;
static void Write(Message* aMsg, const paramType& aParam) { static void Write(Message* aMsg, const paramType& aParam) {
aMsg->WriteSize(aParam.size()); aMsg->WriteUInt32(aParam.size());
for (const T& elem : aParam) { for (const T& elem : aParam) {
WriteParam(aMsg, elem); WriteParam(aMsg, elem);
} }
@ -33,8 +33,8 @@ struct ParamTraits<std::vector<T>> {
static bool Read(const Message* aMsg, PickleIterator* aIter, static bool Read(const Message* aMsg, PickleIterator* aIter,
paramType* aResult) { paramType* aResult) {
size_t size; uint32_t size;
if (!aMsg->ReadSize(aIter, &size)) { if (!aMsg->ReadUInt32(aIter, &size)) {
return false; return false;
} }
while (size--) { while (size--) {

Просмотреть файл

@ -27,12 +27,12 @@ void MediaPacket::Copy(const uint8_t* data, size_t len, size_t capacity) {
} }
void MediaPacket::Serialize(IPC::Message* aMsg) const { void MediaPacket::Serialize(IPC::Message* aMsg) const {
aMsg->WriteSize(len_); aMsg->WriteUInt32(len_);
aMsg->WriteSize(capacity_); aMsg->WriteUInt32(capacity_);
if (len_) { if (len_) {
aMsg->WriteBytes(data_.get(), len_); aMsg->WriteBytes(data_.get(), len_);
} }
aMsg->WriteSize(encrypted_len_); aMsg->WriteUInt32(encrypted_len_);
if (encrypted_len_) { if (encrypted_len_) {
aMsg->WriteBytes(encrypted_data_.get(), 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) { bool MediaPacket::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) {
Reset(); Reset();
size_t len; uint32_t len;
if (!aMsg->ReadSize(aIter, &len)) { if (!aMsg->ReadUInt32(aIter, &len)) {
return false; return false;
} }
size_t capacity; uint32_t capacity;
if (!aMsg->ReadSize(aIter, &capacity)) { if (!aMsg->ReadUInt32(aIter, &capacity)) {
return false; return false;
} }
if (len) { if (len) {
@ -61,7 +61,7 @@ bool MediaPacket::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) {
capacity_ = capacity; capacity_ = capacity;
} }
if (!aMsg->ReadSize(aIter, &len)) { if (!aMsg->ReadUInt32(aIter, &len)) {
return false; return false;
} }
if (len) { if (len) {

Просмотреть файл

@ -3,6 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MediaTransportHandlerIPC.h" #include "MediaTransportHandlerIPC.h"
#include "mozilla/dom/MediaTransportChild.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "mozilla/net/SocketProcessBridgeChild.h" #include "mozilla/net/SocketProcessBridgeChild.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
@ -15,29 +16,6 @@ static const char* mthipcLogTag = "MediaTransportHandler";
#endif #endif
#define LOGTAG mthipcLogTag #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<MediaTransportHandlerIPC> mUser;
};
MediaTransportHandlerIPC::MediaTransportHandlerIPC( MediaTransportHandlerIPC::MediaTransportHandlerIPC(
nsISerialEventTarget* aCallbackThread) nsISerialEventTarget* aCallbackThread)
: MediaTransportHandler(aCallbackThread) { : MediaTransportHandler(aCallbackThread) {
@ -45,7 +23,7 @@ MediaTransportHandlerIPC::MediaTransportHandlerIPC(
GetMainThreadSerialEventTarget(), __func__, GetMainThreadSerialEventTarget(), __func__,
[this, self = RefPtr<MediaTransportHandlerIPC>(this)]( [this, self = RefPtr<MediaTransportHandlerIPC>(this)](
const RefPtr<net::SocketProcessBridgeChild>& aBridge) { const RefPtr<net::SocketProcessBridgeChild>& aBridge) {
mChild = new MediaTransportHandlerChild(this); mChild = new MediaTransportChild(this);
// SocketProcessBridgeChild owns mChild! When it is done with it, // SocketProcessBridgeChild owns mChild! When it is done with it,
// mChild will let us know it it going away. // mChild will let us know it it going away.
aBridge->SetEventTargetForActor(mChild, GetMainThreadEventTarget()); aBridge->SetEventTargetForActor(mChild, GetMainThreadEventTarget());
@ -158,7 +136,7 @@ void MediaTransportHandlerIPC::Destroy() {
GetMainThreadSerialEventTarget(), __func__, GetMainThreadSerialEventTarget(), __func__,
[=, self = RefPtr<MediaTransportHandlerIPC>(this)](bool /*dummy*/) { [=, self = RefPtr<MediaTransportHandlerIPC>(this)](bool /*dummy*/) {
if (mChild) { if (mChild) {
MediaTransportHandlerChild::Send__delete__(mChild); MediaTransportChild::Send__delete__(mChild);
mChild = nullptr; mChild = nullptr;
} }
}, },
@ -327,30 +305,29 @@ MediaTransportHandlerIPC::GetIceStats(
}); });
} }
MediaTransportHandlerChild::MediaTransportHandlerChild( MediaTransportChild::MediaTransportChild(MediaTransportHandlerIPC* aUser)
MediaTransportHandlerIPC* aUser)
: mUser(aUser) {} : mUser(aUser) {}
MediaTransportHandlerChild::~MediaTransportHandlerChild() { MediaTransportChild::~MediaTransportChild() {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mUser->mChild = nullptr; mUser->mChild = nullptr;
} }
mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnCandidate( mozilla::ipc::IPCResult MediaTransportChild::RecvOnCandidate(
const string& transportId, const CandidateInfo& candidateInfo) { const string& transportId, const CandidateInfo& candidateInfo) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mUser->OnCandidate(transportId, candidateInfo); mUser->OnCandidate(transportId, candidateInfo);
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnAlpnNegotiated( mozilla::ipc::IPCResult MediaTransportChild::RecvOnAlpnNegotiated(
const string& alpn) { const string& alpn) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mUser->OnAlpnNegotiated(alpn); mUser->OnAlpnNegotiated(alpn);
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnGatheringStateChange( mozilla::ipc::IPCResult MediaTransportChild::RecvOnGatheringStateChange(
const int& state) { const int& state) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mUser->OnGatheringStateChange( mUser->OnGatheringStateChange(
@ -358,7 +335,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnGatheringStateChange(
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnConnectionStateChange( mozilla::ipc::IPCResult MediaTransportChild::RecvOnConnectionStateChange(
const int& state) { const int& state) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mUser->OnConnectionStateChange( mUser->OnConnectionStateChange(
@ -366,7 +343,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnConnectionStateChange(
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnPacketReceived( mozilla::ipc::IPCResult MediaTransportChild::RecvOnPacketReceived(
const string& transportId, const MediaPacket& packet) { const string& transportId, const MediaPacket& packet) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
MediaPacket copy(packet); // Laaaaaame! Might be safe to const_cast? MediaPacket copy(packet); // Laaaaaame! Might be safe to const_cast?
@ -374,7 +351,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnPacketReceived(
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnEncryptedSending( mozilla::ipc::IPCResult MediaTransportChild::RecvOnEncryptedSending(
const string& transportId, const MediaPacket& packet) { const string& transportId, const MediaPacket& packet) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
MediaPacket copy(packet); // Laaaaaame! Might be safe to const_cast? MediaPacket copy(packet); // Laaaaaame! Might be safe to const_cast?
@ -382,14 +359,14 @@ mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnEncryptedSending(
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnStateChange( mozilla::ipc::IPCResult MediaTransportChild::RecvOnStateChange(
const string& transportId, const int& state) { const string& transportId, const int& state) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mUser->OnStateChange(transportId, static_cast<TransportLayer::State>(state)); mUser->OnStateChange(transportId, static_cast<TransportLayer::State>(state));
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnRtcpStateChange( mozilla::ipc::IPCResult MediaTransportChild::RecvOnRtcpStateChange(
const string& transportId, const int& state) { const string& transportId, const int& state) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mUser->OnRtcpStateChange(transportId, mUser->OnRtcpStateChange(transportId,

Просмотреть файл

@ -10,7 +10,7 @@
namespace mozilla { namespace mozilla {
class MediaTransportHandlerChild; class MediaTransportChild;
// Implementation of MediaTransportHandler that uses IPC (PMediaTransport) to // Implementation of MediaTransportHandler that uses IPC (PMediaTransport) to
// talk to mtransport on another process. // talk to mtransport on another process.
@ -72,10 +72,10 @@ class MediaTransportHandlerIPC : public MediaTransportHandler {
std::unique_ptr<dom::RTCStatsReportInternal>&& aReport) override; std::unique_ptr<dom::RTCStatsReportInternal>&& aReport) override;
private: private:
friend class MediaTransportHandlerChild; friend class MediaTransportChild;
// We do not own this; it will tell us when it is going away. // 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 // |mChild| can only be initted asynchronously, |mInitPromise| resolves
// when that happens. The |Then| calls make it convenient to dispatch API // when that happens. The |Then| calls make it convenient to dispatch API

Просмотреть файл

@ -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<RTCIceServer>&& 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<uint8_t>&& keyDer, nsTArray<uint8_t>&& 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<MediaTransportHandler> mImpl;
RefPtr<nsIEventTarget> mStsThread;
};
} // namespace mozilla
#endif //_MTRANSPORTHANDLER_PARENT_H__

Просмотреть файл

@ -2,84 +2,99 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * 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 "signaling/src/peerconnection/MediaTransportHandler.h"
#include "nss.h" // For NSS_NoDB_Init #include "nss.h" // For NSS_NoDB_Init
#include "mozilla/PublicSSL.h" // For psm::InitializeCipherSuite #include "mozilla/PublicSSL.h" // For psm::InitializeCipherSuite
#include "sigslot.h"
namespace mozilla { namespace mozilla {
MediaTransportHandlerParent::MediaTransportHandlerParent() // Deals with the MediaTransportHandler interface, so MediaTransportParent
: mImpl(MediaTransportHandler::Create(GetMainThreadSerialEventTarget())) { // doesn't have to..
// We cannot register PMediaTransportParent's Send* API to these signals, class MediaTransportParent::Impl : public sigslot::has_slots<> {
// because this API returns must-use bools, and the params are in some cases public:
// slightly different. explicit Impl(MediaTransportParent* aParent)
mImpl->SignalCandidate.connect(this, : mHandler(
&MediaTransportHandlerParent::OnCandidate); MediaTransportHandler::Create(GetMainThreadSerialEventTarget())),
mImpl->SignalAlpnNegotiated.connect( mParent(aParent) {
this, &MediaTransportHandlerParent::OnAlpnNegotiated); mHandler->SignalCandidate.connect(this,
mImpl->SignalGatheringStateChange.connect( &MediaTransportParent::Impl::OnCandidate);
this, &MediaTransportHandlerParent::OnGatheringStateChange); mHandler->SignalAlpnNegotiated.connect(
mImpl->SignalConnectionStateChange.connect( this, &MediaTransportParent::Impl::OnAlpnNegotiated);
this, &MediaTransportHandlerParent::OnConnectionStateChange); mHandler->SignalGatheringStateChange.connect(
mImpl->SignalPacketReceived.connect( this, &MediaTransportParent::Impl::OnGatheringStateChange);
this, &MediaTransportHandlerParent::OnPacketReceived); mHandler->SignalConnectionStateChange.connect(
mImpl->SignalEncryptedSending.connect( this, &MediaTransportParent::Impl::OnConnectionStateChange);
this, &MediaTransportHandlerParent::OnEncryptedSending); mHandler->SignalPacketReceived.connect(
mImpl->SignalStateChange.connect(this, this, &MediaTransportParent::Impl::OnPacketReceived);
&MediaTransportHandlerParent::OnStateChange); mHandler->SignalEncryptedSending.connect(
mImpl->SignalRtcpStateChange.connect( this, &MediaTransportParent::Impl::OnEncryptedSending);
this, &MediaTransportHandlerParent::OnRtcpStateChange); mHandler->SignalStateChange.connect(
} this, &MediaTransportParent::Impl::OnStateChange);
mHandler->SignalRtcpStateChange.connect(
this, &MediaTransportParent::Impl::OnRtcpStateChange);
}
MediaTransportHandlerParent::~MediaTransportHandlerParent() { virtual ~Impl() {
MOZ_RELEASE_ASSERT(!mImpl); disconnect_all();
} mHandler->Destroy();
mHandler = nullptr;
}
void MediaTransportHandlerParent::OnCandidate( void OnCandidate(const std::string& aTransportId,
const std::string& aTransportId, const CandidateInfo& aCandidateInfo) { const CandidateInfo& aCandidateInfo) {
NS_ENSURE_TRUE_VOID(SendOnCandidate(aTransportId, aCandidateInfo)); NS_ENSURE_TRUE_VOID(mParent->SendOnCandidate(aTransportId, aCandidateInfo));
} }
void MediaTransportHandlerParent::OnAlpnNegotiated(const std::string& aAlpn) { void OnAlpnNegotiated(const std::string& aAlpn) {
NS_ENSURE_TRUE_VOID(SendOnAlpnNegotiated(aAlpn)); NS_ENSURE_TRUE_VOID(mParent->SendOnAlpnNegotiated(aAlpn));
} }
void MediaTransportHandlerParent::OnGatheringStateChange( void OnGatheringStateChange(dom::PCImplIceGatheringState aState) {
dom::PCImplIceGatheringState aState) { NS_ENSURE_TRUE_VOID(
NS_ENSURE_TRUE_VOID(SendOnGatheringStateChange(static_cast<int>(aState))); mParent->SendOnGatheringStateChange(static_cast<int>(aState)));
} }
void MediaTransportHandlerParent::OnConnectionStateChange( void OnConnectionStateChange(dom::PCImplIceConnectionState aState) {
dom::PCImplIceConnectionState aState) { NS_ENSURE_TRUE_VOID(
NS_ENSURE_TRUE_VOID(SendOnConnectionStateChange(static_cast<int>(aState))); mParent->SendOnConnectionStateChange(static_cast<int>(aState)));
} }
void MediaTransportHandlerParent::OnPacketReceived( void OnPacketReceived(const std::string& aTransportId, MediaPacket& aPacket) {
const std::string& aTransportId, MediaPacket& aPacket) { NS_ENSURE_TRUE_VOID(mParent->SendOnPacketReceived(aTransportId, aPacket));
NS_ENSURE_TRUE_VOID(SendOnPacketReceived(aTransportId, aPacket)); }
}
void MediaTransportHandlerParent::OnEncryptedSending( void OnEncryptedSending(const std::string& aTransportId,
const std::string& aTransportId, MediaPacket& aPacket) { MediaPacket& aPacket) {
NS_ENSURE_TRUE_VOID(SendOnEncryptedSending(aTransportId, aPacket)); NS_ENSURE_TRUE_VOID(mParent->SendOnEncryptedSending(aTransportId, aPacket));
} }
void MediaTransportHandlerParent::OnStateChange(const std::string& aTransportId, void OnStateChange(const std::string& aTransportId,
TransportLayer::State aState) { TransportLayer::State aState) {
NS_ENSURE_TRUE_VOID(SendOnStateChange(aTransportId, aState)); NS_ENSURE_TRUE_VOID(mParent->SendOnStateChange(aTransportId, aState));
} }
void MediaTransportHandlerParent::OnRtcpStateChange( void OnRtcpStateChange(const std::string& aTransportId,
const std::string& aTransportId, TransportLayer::State aState) { TransportLayer::State aState) {
NS_ENSURE_TRUE_VOID(SendOnRtcpStateChange(aTransportId, aState)); NS_ENSURE_TRUE_VOID(mParent->SendOnRtcpStateChange(aTransportId, aState));
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceLog( RefPtr<MediaTransportHandler> mHandler;
private:
MediaTransportParent* mParent;
};
MediaTransportParent::MediaTransportParent() : mImpl(new Impl(this)) {}
MediaTransportParent::~MediaTransportParent() {}
mozilla::ipc::IPCResult MediaTransportParent::RecvGetIceLog(
const nsCString& pattern, GetIceLogResolver&& aResolve) { const nsCString& pattern, GetIceLogResolver&& aResolve) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->GetIceLog(pattern)->Then( mImpl->mHandler->GetIceLog(pattern)->Then(
GetMainThreadSerialEventTarget(), __func__, GetMainThreadSerialEventTarget(), __func__,
// IPDL doesn't give us a reject function, so we cannot reject async, so // IPDL doesn't give us a reject function, so we cannot reject async, so
// we are forced to resolve with an empty result. Laaaaaaame. // we are forced to resolve with an empty result. Laaaaaaame.
@ -96,25 +111,25 @@ mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceLog(
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvClearIceLog() { mozilla::ipc::IPCResult MediaTransportParent::RecvClearIceLog() {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->ClearIceLog(); mImpl->mHandler->ClearIceLog();
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvEnterPrivateMode() { mozilla::ipc::IPCResult MediaTransportParent::RecvEnterPrivateMode() {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->EnterPrivateMode(); mImpl->mHandler->EnterPrivateMode();
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvExitPrivateMode() { mozilla::ipc::IPCResult MediaTransportParent::RecvExitPrivateMode() {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->ExitPrivateMode(); mImpl->mHandler->ExitPrivateMode();
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvCreateIceCtx( mozilla::ipc::IPCResult MediaTransportParent::RecvCreateIceCtx(
const string& name, nsTArray<RTCIceServer>&& iceServers, const string& name, nsTArray<RTCIceServer>&& iceServers,
const RTCIceTransportPolicy& icePolicy) { const RTCIceTransportPolicy& icePolicy) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
@ -137,7 +152,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvCreateIceCtx(
nssStarted = true; nssStarted = true;
nsresult rv = mImpl->CreateIceCtx(name, iceServers, icePolicy); nsresult rv = mImpl->mHandler->CreateIceCtx(name, iceServers, icePolicy);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return ipc::IPCResult::Fail(WrapNotNull(this), __func__, return ipc::IPCResult::Fail(WrapNotNull(this), __func__,
"MediaTransportHandler::Init failed"); "MediaTransportHandler::Init failed");
@ -145,83 +160,82 @@ mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvCreateIceCtx(
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvSetProxyServer( mozilla::ipc::IPCResult MediaTransportParent::RecvSetProxyServer(
const PBrowserOrId& browserOrId, const nsCString& alpn) { const PBrowserOrId& browserOrId, const nsCString& alpn) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->SetProxyServer(NrSocketProxyConfig(browserOrId, alpn)); mImpl->mHandler->SetProxyServer(NrSocketProxyConfig(browserOrId, alpn));
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult mozilla::ipc::IPCResult MediaTransportParent::RecvEnsureProvisionalTransport(
MediaTransportHandlerParent::RecvEnsureProvisionalTransport(
const string& transportId, const string& localUfrag, const string& localPwd, const string& transportId, const string& localUfrag, const string& localPwd,
const int& componentCount) { const int& componentCount) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->EnsureProvisionalTransport(transportId, localUfrag, localPwd, mImpl->mHandler->EnsureProvisionalTransport(transportId, localUfrag, localPwd,
componentCount); componentCount);
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvStartIceGathering( mozilla::ipc::IPCResult MediaTransportParent::RecvStartIceGathering(
const bool& defaultRouteOnly, const net::NrIceStunAddrArray& stunAddrs) { const bool& defaultRouteOnly, const net::NrIceStunAddrArray& stunAddrs) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->StartIceGathering(defaultRouteOnly, stunAddrs); mImpl->mHandler->StartIceGathering(defaultRouteOnly, stunAddrs);
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvActivateTransport( mozilla::ipc::IPCResult MediaTransportParent::RecvActivateTransport(
const string& transportId, const string& localUfrag, const string& localPwd, const string& transportId, const string& localUfrag, const string& localPwd,
const int& componentCount, const string& remoteUfrag, const int& componentCount, const string& remoteUfrag,
const string& remotePwd, nsTArray<uint8_t>&& keyDer, const string& remotePwd, nsTArray<uint8_t>&& keyDer,
nsTArray<uint8_t>&& certDer, const int& authType, const bool& dtlsClient, nsTArray<uint8_t>&& certDer, const int& authType, const bool& dtlsClient,
const DtlsDigestList& digests, const bool& privacyRequested) { const DtlsDigestList& digests, const bool& privacyRequested) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->ActivateTransport(transportId, localUfrag, localPwd, componentCount, mImpl->mHandler->ActivateTransport(
remoteUfrag, remotePwd, keyDer, certDer, transportId, localUfrag, localPwd, componentCount, remoteUfrag, remotePwd,
static_cast<SSLKEAType>(authType), dtlsClient, keyDer, certDer, static_cast<SSLKEAType>(authType), dtlsClient, digests,
digests, privacyRequested); privacyRequested);
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvRemoveTransportsExcept( mozilla::ipc::IPCResult MediaTransportParent::RecvRemoveTransportsExcept(
const StringVector& transportIds) { const StringVector& transportIds) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
std::set<std::string> ids(transportIds.begin(), transportIds.end()); std::set<std::string> ids(transportIds.begin(), transportIds.end());
mImpl->RemoveTransportsExcept(ids); mImpl->mHandler->RemoveTransportsExcept(ids);
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvStartIceChecks( mozilla::ipc::IPCResult MediaTransportParent::RecvStartIceChecks(
const bool& isControlling, const bool& isOfferer, const bool& isControlling, const bool& isOfferer,
const StringVector& iceOptions) { const StringVector& iceOptions) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->StartIceChecks(isControlling, isOfferer, iceOptions); mImpl->mHandler->StartIceChecks(isControlling, isOfferer, iceOptions);
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvSendPacket( mozilla::ipc::IPCResult MediaTransportParent::RecvSendPacket(
const string& transportId, const MediaPacket& packet) { const string& transportId, const MediaPacket& packet) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
MediaPacket copy(packet); // Laaaaaaame. MediaPacket copy(packet); // Laaaaaaame.
mImpl->SendPacket(transportId, std::move(copy)); mImpl->mHandler->SendPacket(transportId, std::move(copy));
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvAddIceCandidate( mozilla::ipc::IPCResult MediaTransportParent::RecvAddIceCandidate(
const string& transportId, const string& candidate) { const string& transportId, const string& candidate) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->AddIceCandidate(transportId, candidate); mImpl->mHandler->AddIceCandidate(transportId, candidate);
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvUpdateNetworkState( mozilla::ipc::IPCResult MediaTransportParent::RecvUpdateNetworkState(
const bool& online) { const bool& online) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mImpl->UpdateNetworkState(online); mImpl->mHandler->UpdateNetworkState(online);
return ipc::IPCResult::Ok(); return ipc::IPCResult::Ok();
} }
mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceStats( mozilla::ipc::IPCResult MediaTransportParent::RecvGetIceStats(
const string& transportId, const double& now, const string& transportId, const double& now,
const RTCStatsReportInternal& reportIn, GetIceStatsResolver&& aResolve) { const RTCStatsReportInternal& reportIn, GetIceStatsResolver&& aResolve) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
@ -231,7 +245,7 @@ mozilla::ipc::IPCResult MediaTransportHandlerParent::RecvGetIceStats(
std::unique_ptr<dom::RTCStatsReportInternal> report( std::unique_ptr<dom::RTCStatsReportInternal> report(
new dom::RTCStatsReportInternal(reportIn)); new dom::RTCStatsReportInternal(reportIn));
mImpl->GetIceStats(transportId, now, std::move(report)) mImpl->mHandler->GetIceStats(transportId, now, std::move(report))
->Then( ->Then(
GetMainThreadSerialEventTarget(), __func__, GetMainThreadSerialEventTarget(), __func__,
// IPDL doesn't give us a reject function, so we cannot reject async, // 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(); return ipc::IPCResult::Ok();
} }
void MediaTransportHandlerParent::ActorDestroy(ActorDestroyReason aWhy) { void MediaTransportParent::ActorDestroy(ActorDestroyReason aWhy) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread()); MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
disconnect_all();
mImpl->Destroy();
mImpl = nullptr;
} }
} // namespace mozilla } // namespace mozilla

Просмотреть файл

@ -25,7 +25,7 @@ LOCAL_INCLUDES += [
UNIFIED_SOURCES += [ UNIFIED_SOURCES += [
'MediaTransportHandler.cpp', 'MediaTransportHandler.cpp',
'MediaTransportHandlerIPC.cpp', 'MediaTransportHandlerIPC.cpp',
'MediaTransportHandlerParent.cpp', 'MediaTransportParent.cpp',
'PacketDumper.cpp', 'PacketDumper.cpp',
'PeerConnectionCtx.cpp', 'PeerConnectionCtx.cpp',
'PeerConnectionImpl.cpp', 'PeerConnectionImpl.cpp',

Просмотреть файл

@ -34,8 +34,8 @@ class SocketProcessBridgeChild final : public PSocketProcessBridgeChild,
bool Inited() const { return mInited; }; bool Inited() const { return mInited; };
ProcessId SocketProcessPid() const { return mSocketProcessPid; }; ProcessId SocketProcessPid() const { return mSocketProcessPid; };
dom::PMediaTransportChild* AllocPMediaTransportChild() override; dom::PMediaTransportChild* AllocPMediaTransportChild();
bool DeallocPMediaTransportChild(dom::PMediaTransportChild* aActor) override; bool DeallocPMediaTransportChild(dom::PMediaTransportChild* aActor);
private: private:
DISALLOW_COPY_AND_ASSIGN(SocketProcessBridgeChild); DISALLOW_COPY_AND_ASSIGN(SocketProcessBridgeChild);

Просмотреть файл

@ -8,9 +8,7 @@
#include "mozilla/ipc/BackgroundParent.h" #include "mozilla/ipc/BackgroundParent.h"
#include "SocketProcessChild.h" #include "SocketProcessChild.h"
#ifdef MOZ_WEBRTC #include "mozilla/dom/MediaTransportParent.h"
#include "signaling/src/peerconnection/MediaTransportHandlerParent.h"
#endif
namespace mozilla { namespace mozilla {
namespace net { namespace net {
@ -62,7 +60,7 @@ void SocketProcessBridgeParent::DeferredDestroy() {
dom::PMediaTransportParent* dom::PMediaTransportParent*
SocketProcessBridgeParent::AllocPMediaTransportParent() { SocketProcessBridgeParent::AllocPMediaTransportParent() {
#ifdef MOZ_WEBRTC #ifdef MOZ_WEBRTC
return new MediaTransportHandlerParent; return new MediaTransportParent;
#endif #endif
return nullptr; return nullptr;
} }

Просмотреть файл

@ -29,9 +29,8 @@ class SocketProcessBridgeParent final : public PSocketProcessBridgeParent {
void ActorDestroy(ActorDestroyReason aWhy) override; void ActorDestroy(ActorDestroyReason aWhy) override;
void DeferredDestroy(); void DeferredDestroy();
dom::PMediaTransportParent* AllocPMediaTransportParent() override; dom::PMediaTransportParent* AllocPMediaTransportParent();
bool DeallocPMediaTransportParent( bool DeallocPMediaTransportParent(dom::PMediaTransportParent* aActor);
dom::PMediaTransportParent* aActor) override;
private: private:
~SocketProcessBridgeParent(); ~SocketProcessBridgeParent();