Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mofo7777 authored Sep 17, 2018
1 parent 4692a24 commit 93d941b
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 0 deletions.
72 changes: 72 additions & 0 deletions MFSrScreenCapture/ScreenCapture.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//----------------------------------------------------------------------------------------------
// ScreenCapture.h
// Copyright (C) 2013 Dumonteil David
//
// MFNode is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MFNode is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------------------------
#ifndef SCREENCAPTURE_H
#define SCREENCAPTURE_H

class CScreenCapture : public BaseObject, IMFMediaSource{

public:

static HRESULT CreateInstance(CScreenCapture**);

// IUnknown
STDMETHODIMP QueryInterface(REFIID, void**);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();

// IMFMediaEventGenerator
STDMETHODIMP BeginGetEvent(IMFAsyncCallback*, IUnknown*);
STDMETHODIMP EndGetEvent(IMFAsyncResult*, IMFMediaEvent**);
STDMETHODIMP GetEvent(DWORD, IMFMediaEvent**);
STDMETHODIMP QueueEvent(MediaEventType, REFGUID, HRESULT, const PROPVARIANT*);

// IMFMediaSource
STDMETHODIMP CreatePresentationDescriptor(IMFPresentationDescriptor**);
STDMETHODIMP GetCharacteristics(DWORD*);
STDMETHODIMP Pause();
STDMETHODIMP Shutdown();
STDMETHODIMP Start(IMFPresentationDescriptor*, const GUID*, const PROPVARIANT*);
STDMETHODIMP Stop();

HRESULT Initialize(){ AutoLock lock(m_CriticSection); m_State = SourceStopped; return S_OK; }
SourceState GetState() const { return m_State; }

private:

CScreenCapture(HRESULT&);
virtual ~CScreenCapture(){ TRACE_SOURCE((L"Capture::DTOR")); Shutdown(); }

CriticSection m_CriticSection;
volatile long m_nRefCount;

CScreenCaptureStream* m_pScreenCaptureStream;

IMFMediaEventQueue* m_pEventQueue;
IMFPresentationDescriptor* m_pPresentationDescriptor;;

SourceState m_State;

HRESULT CreateScreenCapturePresentationDescriptor();
HRESULT CreateVideoMediaType(IMFMediaType**);
HRESULT ValidatePresentationDescriptor(IMFPresentationDescriptor*);
HRESULT QueueNewStreamEvent(IMFPresentationDescriptor*);

HRESULT CheckShutdown() const{ return (m_State == SourceShutdown ? MF_E_SHUTDOWN : S_OK); }
};

#endif
45 changes: 45 additions & 0 deletions MFSrScreenCapture/ScreenCaptureSchemeHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//----------------------------------------------------------------------------------------------
// ScreenCaptureSchemeHandler.h
// Copyright (C) 2013 Dumonteil David
//
// MFNode is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MFNode is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------------------------
#ifndef SCREENCAPTURESCHEMEHANDLER_H
#define SCREENCAPTURESCHEMEHANDLER_H

class CScreenCaptureSchemeHandler : BaseObject, public IMFSchemeHandler{

public:

static HRESULT CreateInstance(IUnknown*, REFIID, void**);

// IUnknown
STDMETHODIMP QueryInterface(REFIID, void**);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();

// IMFSchemeHandler
STDMETHODIMP BeginCreateObject(LPCWSTR, DWORD, IPropertyStore*, IUnknown**, IMFAsyncCallback*, IUnknown*);
STDMETHODIMP CancelObjectCreation(IUnknown*){ return E_NOTIMPL; }
STDMETHODIMP EndCreateObject(IMFAsyncResult*, MF_OBJECT_TYPE*, IUnknown**);

private:

CScreenCaptureSchemeHandler() : m_nRefCount(1){ TRACE_SCHEME((L"Scheme::CTOR")); }
virtual ~CScreenCaptureSchemeHandler(){ TRACE_SCHEME((L"Scheme::DTOR")); }

volatile long m_nRefCount;
};

#endif
80 changes: 80 additions & 0 deletions MFSrScreenCapture/ScreenCaptureStream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//----------------------------------------------------------------------------------------------
// ScreenCaptureStream.h
// Copyright (C) 2013 Dumonteil David
//
// MFNode is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MFNode is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//----------------------------------------------------------------------------------------------
#ifndef SCREENCAPTURESTREAM_H
#define SCREENCAPTURESTREAM_H

class CScreenCapture;

class CScreenCaptureStream : BaseObject, public IMFMediaStream{

public:

static HRESULT CreateInstance(CScreenCaptureStream**, CScreenCapture*, IMFStreamDescriptor*, const DWORD, HRESULT&);

// IUnknown
STDMETHODIMP QueryInterface(REFIID, void**);
STDMETHODIMP_(ULONG) AddRef();
STDMETHODIMP_(ULONG) Release();

// IMFMediaEventGenerator
STDMETHODIMP BeginGetEvent(IMFAsyncCallback*, IUnknown*);
STDMETHODIMP EndGetEvent(IMFAsyncResult*, IMFMediaEvent**);
STDMETHODIMP GetEvent(DWORD, IMFMediaEvent**);
STDMETHODIMP QueueEvent(MediaEventType, REFGUID, HRESULT, const PROPVARIANT*);

// IMFMediaStream
STDMETHODIMP GetMediaSource(IMFMediaSource**);
STDMETHODIMP GetStreamDescriptor(IMFStreamDescriptor**);
STDMETHODIMP RequestSample(IUnknown*);

// CKinectStream
HRESULT Shutdown();
HRESULT Flush(){ return S_OK; }

private:

CScreenCaptureStream(CScreenCapture*, IMFStreamDescriptor*, const DWORD, HRESULT&);
virtual ~CScreenCaptureStream(){ TRACE_STREAMSOURCE((L"Stream::DTOR")); Shutdown(); }

CScreenCapture* m_pScreenCapture;

CriticSection m_CriticSection;
volatile long m_nRefCount;
SourceState m_State;

LONGLONG m_rtCurrentPosition;

IMFMediaEventQueue* m_pEventQueue;
IMFStreamDescriptor* m_pStreamDescriptor;

IMFMediaBuffer* m_pMediaBuffer;
BYTE* m_pVideoBuffer;
DWORD m_dwVideoSize;

#ifdef REVERSE_GDI_IMAGE
IMFMediaBuffer* m_pMediaGdiBuffer;
BYTE* m_pVideoGdiBuffer;
#endif

HRESULT CreateScreenVideoSample(IMFSample**);
HRESULT CaptureGDIScreen();

HRESULT CheckShutdown() const{ return (m_State == SourceShutdown ? MF_E_SHUTDOWN : S_OK); }
};

#endif

0 comments on commit 93d941b

Please sign in to comment.