1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/* 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_IPC_H__
#define _MTRANSPORTHANDLER_IPC_H__
#include "jsapi/MediaTransportHandler.h"
#include "mozilla/dom/PMediaTransportChild.h"
namespace mozilla {
class MediaTransportChild;
// Implementation of MediaTransportHandler that uses IPC (PMediaTransport) to
// talk to mtransport on another process.
class MediaTransportHandlerIPC : public MediaTransportHandler {
public:
explicit MediaTransportHandlerIPC(nsISerialEventTarget* aCallbackThread);
RefPtr<IceLogPromise> GetIceLog(const nsCString& aPattern) override;
void ClearIceLog() override;
void EnterPrivateMode() override;
void ExitPrivateMode() override;
void CreateIceCtx(const std::string& aName) override;
nsresult SetIceConfig(const nsTArray<dom::RTCIceServer>& aIceServers,
dom::RTCIceTransportPolicy aIcePolicy) override;
// We will probably be able to move the proxy lookup stuff into
// this class once we move mtransport to its own process.
void SetProxyConfig(NrSocketProxyConfig&& aProxyConfig) override;
void EnsureProvisionalTransport(const std::string& aTransportId,
const std::string& aLocalUfrag,
const std::string& aLocalPwd,
int aComponentCount) override;
void SetTargetForDefaultLocalAddressLookup(const std::string& aTargetIp,
uint16_t aTargetPort) override;
// We set default-route-only as late as possible because it depends on what
// capture permissions have been granted on the window, which could easily
// change between Init (ie; when the PC is created) and StartIceGathering
// (ie; when we set the local description).
void StartIceGathering(bool aDefaultRouteOnly, bool aObfuscateHostAddresses,
// TODO: It probably makes sense to look
// this up internally
const nsTArray<NrIceStunAddr>& aStunAddrs) override;
void ActivateTransport(
const std::string& aTransportId, const std::string& aLocalUfrag,
const std::string& aLocalPwd, size_t aComponentCount,
const std::string& aUfrag, const std::string& aPassword,
const nsTArray<uint8_t>& aKeyDer, const nsTArray<uint8_t>& aCertDer,
SSLKEAType aAuthType, bool aDtlsClient, const DtlsDigestList& aDigests,
bool aPrivacyRequested) override;
void RemoveTransportsExcept(
const std::set<std::string>& aTransportIds) override;
void StartIceChecks(bool aIsControlling,
const std::vector<std::string>& aIceOptions) override;
void SendPacket(const std::string& aTransportId,
MediaPacket&& aPacket) override;
void AddIceCandidate(const std::string& aTransportId,
const std::string& aCandidate, const std::string& aUfrag,
const std::string& aObfuscatedAddress) override;
void UpdateNetworkState(bool aOnline) override;
RefPtr<dom::RTCStatsPromise> GetIceStats(const std::string& aTransportId,
DOMHighResTimeStamp aNow) override;
private:
friend class MediaTransportChild;
void Destroy() override;
// We do not own this; it will tell us when it is going away.
dom::PMediaTransportChild* mChild = nullptr;
// |mChild| can only be initted asynchronously, |mInitPromise| resolves
// when that happens. The |Then| calls make it convenient to dispatch API
// calls to main, which is a bonus.
// Init promise is not exclusive; this lets us call |Then| on it for every
// API call we get, instead of creating another promise each time.
typedef MozPromise<bool, nsCString, false> InitPromise;
RefPtr<InitPromise> mInitPromise;
};
} // namespace mozilla
#endif //_MTRANSPORTHANDLER_IPC_H__
|