Debian Codegraph @

Xpjproject/pjsip-apps/src/pjsua/winrt/gui/uwp/VoipHost/VoipHost.cpp

raw symbols SCIP
1 //*********************************************************
2 //
3 // Copyright (c) Microsoft. All rights reserved.
4 // This code is licensed under the MIT License (MIT).
5 // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
6 // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
7 // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
8 // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
9 //
10 //*********************************************************
11
12 #include <wrl\module.h>
13 #include <roapi.h>
14 #include <Windows.ApplicationModel.Core.h>
15
16 using namespace ABI::Windows::ApplicationModel::Core;
17 using namespace Microsoft::WRL;
18
19 class ExeServerGetActivationFactory : public RuntimeClass<
20 ABI::Windows::Foundation::IGetActivationFactory,
21 FtmBase>
22 {
23 public:
24 IFACEMETHODIMP GetActivationFactory(_In_ HSTRING activatableClassId, _COM_Outptr_ IInspectable **factory)
25 {
26 *factory = nullptr;
27 ComPtr<IActivationFactory> activationFactory;
28 auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
29 HRESULT hr = module.GetActivationFactory(activatableClassId, &activationFactory);
30 if (SUCCEEDED(hr))
31 {
32 *factory = activationFactory.Detach();
33 }
34 return hr;
35 }
36 };
37
38 int CALLBACK WinMain(_In_ HINSTANCE, _In_ HINSTANCE, _In_ LPSTR, _In_ int)
39 {
40 HRESULT hr = Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
41 if (SUCCEEDED(hr))
42 {
43 // Scoping for smart pointers
44 {
45 ComPtr<ICoreApplication> spApplicationFactory;
46 hr = Windows::Foundation::GetActivationFactory(Wrappers::HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), &spApplicationFactory);
47 if (SUCCEEDED(hr))
48 {
49 ComPtr<ABI::Windows::Foundation::IGetActivationFactory> spGetActivationFactory = Make<ExeServerGetActivationFactory>();
50 spApplicationFactory->RunWithActivationFactories(spGetActivationFactory.Get());
51 }
52 }
53 Windows::Foundation::Uninitialize();
54 }
55 }