Merge pull request #3293 from a-wi:MSMF_remove_ATL_dependency_v3

pull/3308/head
Maksim Shabunin 10 years ago
commit 478dd01c91
  1. 4
      modules/videoio/src/cap_msmf.cpp
  2. 113
      modules/videoio/src/cap_msmf.hpp

@ -72,6 +72,7 @@
#include <stdarg.h>
#include <string.h>
#ifdef _MSC_VER
#pragma warning(disable:4503)
#pragma comment(lib, "mfplat")
#pragma comment(lib, "mf")
@ -81,6 +82,7 @@
#if (WINVER >= 0x0602) // Available since Win 8
#pragma comment(lib, "MinCore_Downlevel")
#endif
#endif
#include <mferror.h>
@ -260,7 +262,7 @@ public:
#include "ppltasks_winrt.h"
#endif
#else
#include <atlbase.h>
#include <comdef.h>
#endif
struct IMFMediaType;

@ -594,27 +594,65 @@ hr = orig.As(&obj);
#define _ComPtr Microsoft::WRL::ComPtr
#else
#define _COM_SMARTPTR_DECLARE(T,var) T ## Ptr var
template <class T>
class ComPtr : public ATL::CComPtr<T>
class ComPtr
{
public:
ComPtr() throw()
{
}
ComPtr(int nNull) throw() :
CComPtr<T>((T*)nNull)
ComPtr(int nNull) throw()
{
assert(nNull == 0);
p = NULL;
}
ComPtr(T* lp) throw()
{
p = lp;
}
ComPtr(_In_ const ComPtr<T>& lp) throw()
{
p = lp.p;
}
virtual ~ComPtr()
{
}
T** operator&() throw()
{
assert(p == NULL);
return p.operator&();
}
T* operator->() const throw()
{
assert(p != NULL);
return p.operator->();
}
bool operator!() const throw()
{
return p.operator==(NULL);
}
bool operator==(_In_opt_ T* pT) const throw()
{
return p.operator==(pT);
}
// For comparison to NULL
bool operator==(int nNull) const
{
assert(nNull == 0);
return p.operator==(NULL);
}
ComPtr(T* lp) throw() :
CComPtr<T>(lp)
bool operator!=(_In_opt_ T* pT) const throw()
{
return p.operator!=(pT);
}
ComPtr(_In_ const CComPtr<T>& lp) throw() :
CComPtr<T>(lp.p)
operator bool()
{
return p.operator!=(NULL);
}
virtual ~ComPtr() {}
T* const* GetAddressOf() const throw()
{
@ -628,7 +666,7 @@ public:
T** ReleaseAndGetAddressOf() throw()
{
InternalRelease();
p.Release();
return &p;
}
@ -636,27 +674,38 @@ public:
{
return p;
}
ComPtr& operator=(decltype(__nullptr)) throw()
// Attach to an existing interface (does not AddRef)
void Attach(_In_opt_ T* p2) throw()
{
InternalRelease();
return *this;
p.Attach(p2);
}
ComPtr& operator=(_In_ const int nNull) throw()
// Detach the interface (does not Release)
T* Detach() throw()
{
ASSERT(nNull == 0);
(void)nNull;
InternalRelease();
return *this;
return p.Detach();
}
unsigned long Reset()
_Check_return_ HRESULT CopyTo(_Deref_out_opt_ T** ppT) throw()
{
return InternalRelease();
assert(ppT != NULL);
if (ppT == NULL)
return E_POINTER;
*ppT = p;
if (p != NULL)
p->AddRef();
return S_OK;
}
void Reset()
{
p.Release();
}
// query for U interface
template<typename U>
HRESULT As(_Inout_ U** lp) const throw()
{
return p->QueryInterface(__uuidof(U), (void**)lp);
return p->QueryInterface(__uuidof(U), reinterpret_cast<void**>(lp));
}
// query for U interface
template<typename U>
@ -665,19 +714,8 @@ public:
return p->QueryInterface(__uuidof(U), reinterpret_cast<void**>(lp->ReleaseAndGetAddressOf()));
}
private:
unsigned long InternalRelease() throw()
{
unsigned long ref = 0;
T* temp = p;
if (temp != nullptr)
{
p = nullptr;
ref = temp->Release();
}
return ref;
}
_COM_SMARTPTR_TYPEDEF(T, __uuidof(T));
_COM_SMARTPTR_DECLARE(T, p);
};
#define _ComPtr ComPtr
@ -2256,6 +2294,11 @@ public:
// succeed but return a nullptr pointer. By default, the list does not allow nullptr
// pointers.
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4127) // constant expression
#endif
template <class T, bool NULLABLE = FALSE>
class ComPtrList : public List<T*>
{
@ -2346,6 +2389,10 @@ protected:
}
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif
/* Be sure to declare webcam device capability in manifest
For better media capture support, add the following snippet with correct module name to the project manifest
(videoio needs DLL activation class factoryentry points):

Loading…
Cancel
Save