1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef _include_ipc_glue_UtilityAudioDecoderChild_h__
7 #define _include_ipc_glue_UtilityAudioDecoderChild_h__
9 #include "mozilla/ProcInfo.h"
10 #include "mozilla/ProfilerMarkers.h"
11 #include "mozilla/RefPtr.h"
13 #include "mozilla/ipc/Endpoint.h"
14 #include "mozilla/ipc/UtilityProcessParent.h"
15 #include "mozilla/ipc/UtilityProcessSandboxing.h"
16 #include "mozilla/ipc/UtilityAudioDecoder.h"
17 #include "mozilla/ipc/PUtilityAudioDecoderChild.h"
19 #ifdef MOZ_WMF_MEDIA_ENGINE
20 # include "mozilla/gfx/GPUProcessListener.h"
21 # include "mozilla/gfx/gfxVarReceiver.h"
24 #include "PDMFactory.h"
26 namespace mozilla::ipc
{
28 class UtilityAudioDecoderChildShutdownObserver
: public nsIObserver
{
30 explicit UtilityAudioDecoderChildShutdownObserver(SandboxingKind aKind
)
35 NS_IMETHOD
Observe(nsISupports
* aSubject
, const char* aTopic
,
36 const char16_t
* aData
) override
;
39 virtual ~UtilityAudioDecoderChildShutdownObserver() = default;
41 const SandboxingKind mSandbox
;
44 // This controls performing audio decoding on the utility process and it is
45 // intended to live on the main process side
46 class UtilityAudioDecoderChild final
: public PUtilityAudioDecoderChild
47 #ifdef MOZ_WMF_MEDIA_ENGINE
49 public gfx::gfxVarReceiver
,
50 public gfx::GPUProcessListener
54 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(UtilityAudioDecoderChild
, override
);
55 mozilla::ipc::IPCResult
RecvUpdateMediaCodecsSupported(
56 const RemoteDecodeIn
& aLocation
,
57 const media::MediaCodecsSupported
& aSupported
);
59 UtilityActorName
GetActorName() { return GetAudioActorName(mSandbox
); }
61 nsresult
BindToUtilityProcess(RefPtr
<UtilityProcessParent
> aUtilityParent
);
63 void ActorDestroy(ActorDestroyReason aReason
) override
;
65 void Bind(Endpoint
<PUtilityAudioDecoderChild
>&& aEndpoint
);
67 static void Shutdown(SandboxingKind aKind
);
69 static RefPtr
<UtilityAudioDecoderChild
> GetSingleton(SandboxingKind aKind
);
71 #ifdef MOZ_WMF_MEDIA_ENGINE
72 mozilla::ipc::IPCResult
RecvCompleteCreatedVideoBridge();
74 void OnVarChanged(const gfx::GfxVarUpdate
& aVar
) override
;
76 void OnCompositorUnexpectedShutdown() override
;
78 // True if creating a video bridge sucessfully. Currently only used for media
80 bool CreateVideoBridge();
84 void GetKeySystemCapabilities(dom::Promise
* aPromise
);
88 explicit UtilityAudioDecoderChild(SandboxingKind aKind
);
89 ~UtilityAudioDecoderChild() = default;
91 const SandboxingKind mSandbox
;
93 #ifdef MOZ_WMF_MEDIA_ENGINE
94 // True if the utility process has created a video bridge with the GPU prcess.
95 // Currently only used for media egine cdm. Main thread only.
96 enum class State
{ None
, Creating
, Created
};
97 State mHasCreatedVideoBridge
= State::None
;
100 TimeStamp mAudioDecoderChildStart
;
103 } // namespace mozilla::ipc
105 #endif // _include_ipc_glue_UtilityAudioDecoderChild_h__