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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sts=2 et sw=2 tw=80: */
/* 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 _include_ipc_glue_UtilityAudioDecoderChild_h__
#define _include_ipc_glue_UtilityAudioDecoderChild_h__
#include "mozilla/ProcInfo.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/RefPtr.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/ipc/UtilityProcessParent.h"
#include "mozilla/ipc/UtilityProcessSandboxing.h"
#include "mozilla/ipc/UtilityAudioDecoder.h"
#include "mozilla/ipc/PUtilityAudioDecoderChild.h"
#ifdef MOZ_WMF_MEDIA_ENGINE
# include "mozilla/gfx/GPUProcessListener.h"
# include "mozilla/gfx/gfxVarReceiver.h"
#endif
#include "PDMFactory.h"
namespace mozilla::ipc {
class UtilityAudioDecoderChildShutdownObserver : public nsIObserver {
public:
explicit UtilityAudioDecoderChildShutdownObserver(SandboxingKind aKind)
: mSandbox(aKind){};
NS_DECL_ISUPPORTS
NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) override;
private:
virtual ~UtilityAudioDecoderChildShutdownObserver() = default;
const SandboxingKind mSandbox;
};
// This controls performing audio decoding on the utility process and it is
// intended to live on the main process side
class UtilityAudioDecoderChild final : public PUtilityAudioDecoderChild
#ifdef MOZ_WMF_MEDIA_ENGINE
,
public gfx::gfxVarReceiver,
public gfx::GPUProcessListener
#endif
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(UtilityAudioDecoderChild, override);
mozilla::ipc::IPCResult RecvUpdateMediaCodecsSupported(
const RemoteDecodeIn& aLocation,
const media::MediaCodecsSupported& aSupported);
UtilityActorName GetActorName() { return GetAudioActorName(mSandbox); }
nsresult BindToUtilityProcess(RefPtr<UtilityProcessParent> aUtilityParent) {
Endpoint<PUtilityAudioDecoderChild> utilityAudioDecoderChildEnd;
Endpoint<PUtilityAudioDecoderParent> utilityAudioDecoderParentEnd;
nsresult rv = PUtilityAudioDecoder::CreateEndpoints(
aUtilityParent->OtherPid(), base::GetCurrentProcId(),
&utilityAudioDecoderParentEnd, &utilityAudioDecoderChildEnd);
if (NS_FAILED(rv)) {
MOZ_ASSERT(false, "Protocol endpoints failure");
return NS_ERROR_FAILURE;
}
if (!aUtilityParent->SendStartUtilityAudioDecoderService(
std::move(utilityAudioDecoderParentEnd))) {
MOZ_ASSERT(false, "StartUtilityAudioDecoder service failure");
return NS_ERROR_FAILURE;
}
Bind(std::move(utilityAudioDecoderChildEnd));
PROFILER_MARKER_UNTYPED(
"UtilityAudioDecoderChild::BindToUtilityProcess", IPC,
MarkerOptions(
MarkerTiming::IntervalUntilNowFrom(mAudioDecoderChildStart)));
return NS_OK;
}
void ActorDestroy(ActorDestroyReason aReason) override;
void Bind(Endpoint<PUtilityAudioDecoderChild>&& aEndpoint);
static void Shutdown(SandboxingKind aKind);
static RefPtr<UtilityAudioDecoderChild> GetSingleton(SandboxingKind aKind);
#ifdef MOZ_WMF_MEDIA_ENGINE
mozilla::ipc::IPCResult RecvCompleteCreatedVideoBridge();
bool HasCreatedVideoBridge() const;
void OnVarChanged(const gfx::GfxVarUpdate& aVar) override;
void OnCompositorUnexpectedShutdown() override;
// True if creating a video bridge sucessfully. Currently only used for media
// engine cdm.
bool CreateVideoBridge();
#endif
#ifdef MOZ_WMF_CDM
void GetKeySystemCapabilities(dom::Promise* aPromise);
#endif
private:
explicit UtilityAudioDecoderChild(SandboxingKind aKind);
~UtilityAudioDecoderChild() = default;
const SandboxingKind mSandbox;
#ifdef MOZ_WMF_MEDIA_ENGINE
// True if the utility process has created a video bridge with the GPU prcess.
// Currently only used for media egine cdm. Main thread only.
bool mHasCreatedVideoBridge = false;
#endif
TimeStamp mAudioDecoderChildStart;
};
} // namespace mozilla::ipc
#endif // _include_ipc_glue_UtilityAudioDecoderChild_h__
|