mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 830247: Reapply Bas's video capture patch (bug 731407) rs=me
This commit is contained in:
parent
349a3e90c7
commit
1f221d9724
@ -16,7 +16,6 @@
|
||||
#include "ref_count.h"
|
||||
#include "trace.h"
|
||||
|
||||
#include <Streams.h>
|
||||
#include <Dvdmedia.h>
|
||||
|
||||
namespace webrtc
|
||||
@ -42,6 +41,23 @@ const DelayValues WindowsCaptureDelays[NoWindowsCaptureDelays] = {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
void _FreeMediaType(AM_MEDIA_TYPE& mt)
|
||||
{
|
||||
if (mt.cbFormat != 0)
|
||||
{
|
||||
CoTaskMemFree((PVOID)mt.pbFormat);
|
||||
mt.cbFormat = 0;
|
||||
mt.pbFormat = NULL;
|
||||
}
|
||||
if (mt.pUnk != NULL)
|
||||
{
|
||||
// pUnk should not be used.
|
||||
mt.pUnk->Release();
|
||||
mt.pUnk = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
DeviceInfoDS* DeviceInfoDS::Create(const WebRtc_Word32 id)
|
||||
{
|
||||
@ -680,7 +696,7 @@ WebRtc_Word32 DeviceInfoDS::CreateCapabilityMap(
|
||||
capability->width, capability->height,
|
||||
capability->rawType, capability->maxFPS);
|
||||
}
|
||||
DeleteMediaType(pmt);
|
||||
_FreeMediaType(*pmt);
|
||||
pmt = NULL;
|
||||
}
|
||||
RELEASE_AND_CLEAR(streamConfig);
|
||||
|
@ -21,6 +21,9 @@
|
||||
DEFINE_GUID(CLSID_SINKFILTER, 0x88cdbbdc, 0xa73b, 0x4afa, 0xac, 0xbf, 0x15, 0xd5,
|
||||
0xe2, 0xce, 0x12, 0xc3);
|
||||
|
||||
using namespace mozilla::media;
|
||||
using namespace mozilla;
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace videocapturemodule
|
||||
@ -37,10 +40,10 @@ typedef struct tagTHREADNAME_INFO
|
||||
CaptureInputPin::CaptureInputPin (WebRtc_Word32 moduleId,
|
||||
IN TCHAR * szName,
|
||||
IN CaptureSinkFilter* pFilter,
|
||||
IN CCritSec * pLock,
|
||||
IN CriticalSection * pLock,
|
||||
OUT HRESULT * pHr,
|
||||
IN LPCWSTR pszName)
|
||||
: CBaseInputPin (szName, pFilter, pLock, pHr, pszName),
|
||||
: BaseInputPin (szName, pFilter, pLock, pHr, pszName),
|
||||
_requestedCapability(),
|
||||
_resultingCapability()
|
||||
{
|
||||
@ -53,7 +56,7 @@ CaptureInputPin::~CaptureInputPin()
|
||||
}
|
||||
|
||||
HRESULT
|
||||
CaptureInputPin::GetMediaType (IN int iPosition, OUT CMediaType * pmt)
|
||||
CaptureInputPin::GetMediaType (IN int iPosition, OUT MediaType * pmt)
|
||||
{
|
||||
// reset the thread handle
|
||||
_threadHandle = NULL;
|
||||
@ -161,7 +164,7 @@ CaptureInputPin::GetMediaType (IN int iPosition, OUT CMediaType * pmt)
|
||||
}
|
||||
|
||||
HRESULT
|
||||
CaptureInputPin::CheckMediaType ( IN const CMediaType * pMediaType)
|
||||
CaptureInputPin::CheckMediaType ( IN const MediaType * pMediaType)
|
||||
{
|
||||
// reset the thread handle
|
||||
_threadHandle = NULL;
|
||||
@ -319,8 +322,8 @@ CaptureInputPin::Receive ( IN IMediaSample * pIMediaSample )
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
ASSERT (m_pFilter);
|
||||
ASSERT (pIMediaSample);
|
||||
assert (mFilter);
|
||||
assert (pIMediaSample);
|
||||
|
||||
// get the thread handle of the delivering thread inc its priority
|
||||
if( _threadHandle == NULL)
|
||||
@ -348,8 +351,8 @@ CaptureInputPin::Receive ( IN IMediaSample * pIMediaSample )
|
||||
|
||||
}
|
||||
|
||||
reinterpret_cast <CaptureSinkFilter *>(m_pFilter)->LockReceive();
|
||||
hr = CBaseInputPin::Receive (pIMediaSample);
|
||||
reinterpret_cast <CaptureSinkFilter *>(mFilter)->LockReceive();
|
||||
hr = BaseInputPin::Receive (pIMediaSample);
|
||||
|
||||
if (SUCCEEDED (hr))
|
||||
{
|
||||
@ -358,17 +361,17 @@ CaptureInputPin::Receive ( IN IMediaSample * pIMediaSample )
|
||||
unsigned char* pBuffer = NULL;
|
||||
if(S_OK != pIMediaSample->GetPointer(&pBuffer))
|
||||
{
|
||||
reinterpret_cast <CaptureSinkFilter *>(m_pFilter)->UnlockReceive();
|
||||
reinterpret_cast <CaptureSinkFilter *>(mFilter)->UnlockReceive();
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
// NOTE: filter unlocked within Send call
|
||||
reinterpret_cast <CaptureSinkFilter *> (m_pFilter)->ProcessCapturedFrame(
|
||||
reinterpret_cast <CaptureSinkFilter *> (mFilter)->ProcessCapturedFrame(
|
||||
pBuffer,length,_resultingCapability);
|
||||
}
|
||||
else
|
||||
{
|
||||
reinterpret_cast <CaptureSinkFilter *>(m_pFilter)->UnlockReceive();
|
||||
reinterpret_cast <CaptureSinkFilter *>(mFilter)->UnlockReceive();
|
||||
}
|
||||
|
||||
return hr;
|
||||
@ -389,13 +392,15 @@ CaptureSinkFilter::CaptureSinkFilter (IN TCHAR * tszName,
|
||||
OUT HRESULT * phr,
|
||||
VideoCaptureExternal& captureObserver,
|
||||
WebRtc_Word32 moduleId)
|
||||
: CBaseFilter(tszName,punk,& m_crtFilter,CLSID_SINKFILTER),
|
||||
: BaseFilter(tszName, CLSID_SINKFILTER),
|
||||
m_crtFilter("CaptureSinkFilter::m_crtFilter"),
|
||||
m_crtRecv("CaptureSinkFilter::m_crtRecv"),
|
||||
m_pInput(NULL),
|
||||
_captureObserver(captureObserver),
|
||||
_moduleId(moduleId)
|
||||
{
|
||||
(* phr) = S_OK;
|
||||
m_pInput = new CaptureInputPin(moduleId,NAME ("VideoCaptureInputPin"),
|
||||
m_pInput = new CaptureInputPin(moduleId, L"VideoCaptureInputPin",
|
||||
this,
|
||||
& m_crtFilter,
|
||||
phr, L"VideoCapture");
|
||||
@ -418,10 +423,10 @@ int CaptureSinkFilter::GetPinCount()
|
||||
return 1;
|
||||
}
|
||||
|
||||
CBasePin *
|
||||
BasePin *
|
||||
CaptureSinkFilter::GetPin(IN int Index)
|
||||
{
|
||||
CBasePin * pPin;
|
||||
BasePin * pPin;
|
||||
LockFilter ();
|
||||
if (Index == 0)
|
||||
{
|
||||
@ -438,22 +443,22 @@ CaptureSinkFilter::GetPin(IN int Index)
|
||||
STDMETHODIMP CaptureSinkFilter::Pause()
|
||||
{
|
||||
LockFilter();
|
||||
if (m_State == State_Stopped)
|
||||
if (mState == State_Stopped)
|
||||
{
|
||||
// change the state, THEN activate the input pin
|
||||
m_State = State_Paused;
|
||||
mState = State_Paused;
|
||||
if (m_pInput && m_pInput->IsConnected())
|
||||
{
|
||||
m_pInput->Active();
|
||||
}
|
||||
if (m_pInput && !m_pInput->IsConnected())
|
||||
{
|
||||
m_State = State_Running;
|
||||
mState = State_Running;
|
||||
}
|
||||
}
|
||||
else if (m_State == State_Running)
|
||||
else if (mState == State_Running)
|
||||
{
|
||||
m_State = State_Paused;
|
||||
mState = State_Paused;
|
||||
}
|
||||
UnlockFilter();
|
||||
return S_OK;
|
||||
@ -465,7 +470,7 @@ STDMETHODIMP CaptureSinkFilter::Stop()
|
||||
LockFilter();
|
||||
|
||||
// set the state
|
||||
m_State = State_Stopped;
|
||||
mState = State_Stopped;
|
||||
|
||||
// inactivate the pins
|
||||
if (m_pInput)
|
||||
@ -479,7 +484,7 @@ STDMETHODIMP CaptureSinkFilter::Stop()
|
||||
void CaptureSinkFilter::SetFilterGraph(IGraphBuilder* graph)
|
||||
{
|
||||
LockFilter();
|
||||
m_pGraph = graph;
|
||||
mGraph = graph;
|
||||
UnlockFilter();
|
||||
}
|
||||
|
||||
@ -488,7 +493,7 @@ void CaptureSinkFilter::ProcessCapturedFrame(unsigned char* pBuffer,
|
||||
const VideoCaptureCapability& frameInfo)
|
||||
{
|
||||
// we have the receiver lock
|
||||
if (m_State == State_Running)
|
||||
if (mState == State_Running)
|
||||
{
|
||||
_captureObserver.IncomingFrame(pBuffer, length, frameInfo);
|
||||
|
||||
|
@ -11,9 +11,10 @@
|
||||
#ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_
|
||||
#define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_
|
||||
|
||||
#include <Streams.h> // Include base DS filter header files
|
||||
|
||||
#include "video_capture_defines.h"
|
||||
#include "BaseInputPin.h"
|
||||
#include "BaseFilter.h"
|
||||
#include "MediaType.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
@ -26,7 +27,7 @@ class CaptureSinkFilter;
|
||||
* input pin for camera input
|
||||
*
|
||||
*/
|
||||
class CaptureInputPin: public CBaseInputPin
|
||||
class CaptureInputPin: public mozilla::media::BaseInputPin
|
||||
{
|
||||
public:
|
||||
WebRtc_Word32 _moduleId;
|
||||
@ -38,18 +39,18 @@ public:
|
||||
CaptureInputPin ( WebRtc_Word32 moduleId,
|
||||
IN TCHAR* szName,
|
||||
IN CaptureSinkFilter* pFilter,
|
||||
IN CCritSec * pLock,
|
||||
IN mozilla::CriticalSection * pLock,
|
||||
OUT HRESULT * pHr,
|
||||
IN LPCWSTR pszName);
|
||||
virtual ~CaptureInputPin();
|
||||
|
||||
HRESULT GetMediaType (IN int iPos, OUT CMediaType * pmt);
|
||||
HRESULT CheckMediaType (IN const CMediaType * pmt);
|
||||
HRESULT GetMediaType (IN int iPos, OUT mozilla::media::MediaType * pmt);
|
||||
HRESULT CheckMediaType (IN const mozilla::media::MediaType * pmt);
|
||||
STDMETHODIMP Receive (IN IMediaSample *);
|
||||
HRESULT SetMatchingMediaType(const VideoCaptureCapability& capability);
|
||||
};
|
||||
|
||||
class CaptureSinkFilter: public CBaseFilter
|
||||
class CaptureSinkFilter: public mozilla::media::BaseFilter
|
||||
{
|
||||
|
||||
public:
|
||||
@ -66,34 +67,55 @@ public:
|
||||
void ProcessCapturedFrame(unsigned char* pBuffer, WebRtc_Word32 length,
|
||||
const VideoCaptureCapability& frameInfo);
|
||||
// explicit receiver lock aquisition and release
|
||||
void LockReceive() { m_crtRecv.Lock();}
|
||||
void UnlockReceive() {m_crtRecv.Unlock();}
|
||||
void LockReceive() { m_crtRecv.Enter();}
|
||||
void UnlockReceive() {m_crtRecv.Leave();}
|
||||
|
||||
// explicit filter lock aquisition and release
|
||||
void LockFilter() {m_crtFilter.Lock();}
|
||||
void UnlockFilter() { m_crtFilter.Unlock(); }
|
||||
void LockFilter() {m_crtFilter.Enter();}
|
||||
void UnlockFilter() { m_crtFilter.Leave(); }
|
||||
void SetFilterGraph(IGraphBuilder* graph); // Used if EVR
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// COM interfaces
|
||||
DECLARE_IUNKNOWN ;
|
||||
STDMETHODIMP QueryInterface(REFIID aIId, void **aInterface)
|
||||
{
|
||||
return mozilla::media::BaseFilter::QueryInterface(aIId, aInterface);
|
||||
}
|
||||
STDMETHODIMP_(ULONG) AddRef()
|
||||
{
|
||||
return ::InterlockedIncrement(&mRefCnt);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) Release()
|
||||
{
|
||||
unsigned long newRefCnt = ::InterlockedDecrement(&mRefCnt);
|
||||
|
||||
if (!newRefCnt) {
|
||||
delete this;
|
||||
}
|
||||
|
||||
return newRefCnt;
|
||||
}
|
||||
|
||||
STDMETHODIMP SetMatchingMediaType(const VideoCaptureCapability& capability);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// CBaseFilter methods
|
||||
int GetPinCount ();
|
||||
CBasePin * GetPin ( IN int Index);
|
||||
mozilla::media::BasePin * GetPin ( IN int Index);
|
||||
STDMETHODIMP Pause ();
|
||||
STDMETHODIMP Stop ();
|
||||
STDMETHODIMP GetClassID ( OUT CLSID * pCLSID);
|
||||
// --------------------------------------------------------------------
|
||||
// class factory calls this
|
||||
static CUnknown * CreateInstance (IN LPUNKNOWN punk, OUT HRESULT * phr);
|
||||
static IUnknown * CreateInstance (IN LPUNKNOWN punk, OUT HRESULT * phr);
|
||||
private:
|
||||
CCritSec m_crtFilter; // filter lock
|
||||
CCritSec m_crtRecv; // receiver lock; always acquire before filter lock
|
||||
mozilla::CriticalSection m_crtFilter; // filter lock
|
||||
mozilla::CriticalSection m_crtRecv; // receiver lock; always acquire before filter lock
|
||||
CaptureInputPin * m_pInput;
|
||||
VideoCaptureExternal& _captureObserver;
|
||||
WebRtc_Word32 _moduleId;
|
||||
unsigned long mRefCnt;
|
||||
};
|
||||
} // namespace videocapturemodule
|
||||
} // namespace webrtc
|
||||
|
Loading…
Reference in New Issue
Block a user