Skip to content

Commit

Permalink
Bug 1521879 - Part 1.1: Compensate for changes to how IPC headers are…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
docfaraday committed Feb 21, 2019
1 parent 4604113 commit bc939b7
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 235 deletions.
2 changes: 1 addition & 1 deletion CLOBBER
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 2 additions & 0 deletions dom/media/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ EXPORTS.mozilla.dom += [
'VideoStreamTrack.h',
'VideoTrack.h',
'VideoTrackList.h',
'webrtc/MediaTransportChild.h',
'webrtc/MediaTransportParent.h',
]

UNIFIED_SOURCES += [
Expand Down
36 changes: 36 additions & 0 deletions dom/media/webrtc/MediaTransportChild.h
Original file line number Diff line number Diff line change
@@ -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
62 changes: 62 additions & 0 deletions dom/media/webrtc/MediaTransportParent.h
Original file line number Diff line number Diff line change
@@ -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__
6 changes: 3 additions & 3 deletions dom/media/webrtc/WebrtcIPCTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ struct ParamTraits<std::vector<T>> {
typedef std::vector<T> 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);
}
}

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--) {
Expand Down
16 changes: 8 additions & 8 deletions media/mtransport/mediapacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -15,37 +16,14 @@ 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<MediaTransportHandlerIPC> mUser;
};

MediaTransportHandlerIPC::MediaTransportHandlerIPC(
nsISerialEventTarget* aCallbackThread)
: MediaTransportHandler(aCallbackThread) {
mInitPromise = net::SocketProcessBridgeChild::GetSocketProcessBridge()->Then(
GetMainThreadSerialEventTarget(), __func__,
[this, self = RefPtr<MediaTransportHandlerIPC>(this)](
const RefPtr<net::SocketProcessBridgeChild>& 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());
Expand Down Expand Up @@ -158,7 +136,7 @@ void MediaTransportHandlerIPC::Destroy() {
GetMainThreadSerialEventTarget(), __func__,
[=, self = RefPtr<MediaTransportHandlerIPC>(this)](bool /*dummy*/) {
if (mChild) {
MediaTransportHandlerChild::Send__delete__(mChild);
MediaTransportChild::Send__delete__(mChild);
mChild = nullptr;
}
},
Expand Down Expand Up @@ -327,69 +305,68 @@ 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(
static_cast<dom::PCImplIceGatheringState>(state));
return ipc::IPCResult::Ok();
}

mozilla::ipc::IPCResult MediaTransportHandlerChild::RecvOnConnectionStateChange(
mozilla::ipc::IPCResult MediaTransportChild::RecvOnConnectionStateChange(
const int& state) {
MOZ_ASSERT(GetMainThreadEventTarget()->IsOnCurrentThread());
mUser->OnConnectionStateChange(
static_cast<dom::PCImplIceConnectionState>(state));
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?
mUser->OnPacketReceived(transportId, copy);
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?
mUser->OnEncryptedSending(transportId, copy);
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<TransportLayer::State>(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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace mozilla {

class MediaTransportHandlerChild;
class MediaTransportChild;

// Implementation of MediaTransportHandler that uses IPC (PMediaTransport) to
// talk to mtransport on another process.
Expand Down Expand Up @@ -72,10 +72,10 @@ class MediaTransportHandlerIPC : public MediaTransportHandler {
std::unique_ptr<dom::RTCStatsReportInternal>&& 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
Expand Down
Loading

0 comments on commit bc939b7

Please sign in to comment.