summaryrefslogtreecommitdiff
path: root/pjsip-apps/src/pjsua/winrt/gui/uwp/VoipHost/VoipHost.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pjsip-apps/src/pjsua/winrt/gui/uwp/VoipHost/VoipHost.cpp')
-rw-r--r--pjsip-apps/src/pjsua/winrt/gui/uwp/VoipHost/VoipHost.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/pjsip-apps/src/pjsua/winrt/gui/uwp/VoipHost/VoipHost.cpp b/pjsip-apps/src/pjsua/winrt/gui/uwp/VoipHost/VoipHost.cpp
new file mode 100644
index 00000000..77dedb4e
--- /dev/null
+++ b/pjsip-apps/src/pjsua/winrt/gui/uwp/VoipHost/VoipHost.cpp
@@ -0,0 +1,55 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+//
+//*********************************************************
+
+#include <wrl\module.h>
+#include <roapi.h>
+#include <Windows.ApplicationModel.Core.h>
+
+using namespace ABI::Windows::ApplicationModel::Core;
+using namespace Microsoft::WRL;
+
+class ExeServerGetActivationFactory : public RuntimeClass<
+ ABI::Windows::Foundation::IGetActivationFactory,
+ FtmBase>
+{
+public:
+ IFACEMETHODIMP GetActivationFactory(_In_ HSTRING activatableClassId, _COM_Outptr_ IInspectable **factory)
+ {
+ *factory = nullptr;
+ ComPtr<IActivationFactory> activationFactory;
+ auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
+ HRESULT hr = module.GetActivationFactory(activatableClassId, &activationFactory);
+ if (SUCCEEDED(hr))
+ {
+ *factory = activationFactory.Detach();
+ }
+ return hr;
+ }
+};
+
+int CALLBACK WinMain(_In_ HINSTANCE, _In_ HINSTANCE, _In_ LPSTR, _In_ int)
+{
+ HRESULT hr = Windows::Foundation::Initialize(RO_INIT_MULTITHREADED);
+ if (SUCCEEDED(hr))
+ {
+ // Scoping for smart pointers
+ {
+ ComPtr<ICoreApplication> spApplicationFactory;
+ hr = Windows::Foundation::GetActivationFactory(Wrappers::HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), &spApplicationFactory);
+ if (SUCCEEDED(hr))
+ {
+ ComPtr<ABI::Windows::Foundation::IGetActivationFactory> spGetActivationFactory = Make<ExeServerGetActivationFactory>();
+ spApplicationFactory->RunWithActivationFactories(spGetActivationFactory.Get());
+ }
+ }
+ Windows::Foundation::Uninitialize();
+ }
+}