diff options
| author | j-leungyy <[email protected]> | 2021-05-25 09:06:09 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-25 09:06:09 -0700 |
| commit | 4fe5787f122fdfc45253b45f9fad3983f53d86df (patch) | |
| tree | a11e06f8951d4b7b847f6f5a708f86df87d637db /general/SimpleMediaSource/MediaSource/dllMain.cpp | |
| parent | 53afd12aadb8aff15097f1546d4f80c6074e0bdc (diff) | |
update simplemediasource sample (#614)
* update simplemediasource wrl to winrtcpp COM, add mediatype NV12 (SimpleFrameGenerator), fix Mediatype missing attribute (bitrate), add IMFActivate, IMFSampleAllocator interface and implementation, update hardcode arg with named variables, cleanup sample for StreamIndex and StreamId, add sample KSControl
* address PR-it1 comments
* address comment from PR-it2, replace manual define of IKSControl by ksproxy.h
* remove unuse header
* address comment from PR
* fix sdk to latest, add driversign algorithm
* remove nudget, use submodule
Diffstat (limited to 'general/SimpleMediaSource/MediaSource/dllMain.cpp')
| -rw-r--r-- | general/SimpleMediaSource/MediaSource/dllMain.cpp | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/general/SimpleMediaSource/MediaSource/dllMain.cpp b/general/SimpleMediaSource/MediaSource/dllMain.cpp index aed44eb0..f021b4aa 100644 --- a/general/SimpleMediaSource/MediaSource/dllMain.cpp +++ b/general/SimpleMediaSource/MediaSource/dllMain.cpp @@ -1,35 +1,68 @@ -/// <copyright file="dllmain.cpp" company="Microsoft"> -/// Copyright (c) Microsoft Corporation. All rights reserved. -/// </copyright> +// +// Copyright (C) Microsoft Corporation. All rights reserved. +// + // dllmain.cpp : Defines the entry point for the DLL application. -#include "stdafx.h" +#include "pch.h" -#include <wrl\module.h> +HINSTANCE g_hInst; -#if !defined(__WRL_CLASSIC_COM__) -STDAPI DllGetActivationFactory(_In_ HSTRING activatibleClassId, _COM_Outptr_ IActivationFactory** factory) +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _COM_Outptr_ void** ppv) { - return Module<InProc>::GetModule().GetActivationFactory(activatibleClassId, factory); -} + try + { + *ppv = nullptr; + + if (rclsid == __uuidof(winrt::WindowsSample::implementation::SimpleMediaSourceActivate)) + { + return winrt::make_self<SimpleMediaSourceActivateFactory>()->QueryInterface(riid, ppv); + } + +#ifdef _WRL_MODULE_H_ + return ::Microsoft::WRL::Module<::Microsoft::WRL::InProc>::GetModule().GetClassObject(rclsid, riid, ppv); +#else + return winrt::hresult_class_not_available().to_abi(); #endif + } + catch (...) + { + return winrt::to_hresult(); + } +} -#if !defined(__WRL_WINRT_STRICT__) -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, _COM_Outptr_ void** ppv) +bool __stdcall winrt_can_unload_now() noexcept { - return Module<InProc>::GetModule().GetClassObject(rclsid, riid, ppv); + if (winrt::get_module_lock()) + { + return false; + } + + winrt::clear_factory_cache(); + return true; } -#endif -STDAPI DllCanUnloadNow() +int32_t __stdcall WINRT_CanUnloadNow() noexcept { - return Module<InProc>::GetModule().Terminate() ? S_OK : S_FALSE; +#ifdef _WRL_MODULE_H_ + if (!::Microsoft::WRL::Module<::Microsoft::WRL::InProc>::GetModule().Terminate()) + { + return 1; + } +#endif + + return winrt_can_unload_now() ? 0 : 1; } STDAPI_(BOOL) DllMain(_In_opt_ HINSTANCE hinst, DWORD reason, _In_opt_ void*) { - if (reason == DLL_PROCESS_ATTACH) + switch (reason) { - DisableThreadLibraryCalls(hinst); + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + g_hInst = hinst; } return TRUE; } |
