Skip to main content

DirectShow Source Filter that reads data from application

Mentioned below is an example of a DirectShow source filter that reads data from application

For reference I have taken CPushSource filter from DirectShow samples

Include the code mentioned below in a common header file


DECLARE_INTERFACE_(IMySettingsInterface, IUnknown)
{

STDMETHOD(GetParamInt)(char* szName, int *pParam) = 0;
STDMETHOD(SetParamInt)(char* szName, int nParam) = 0;

};

// {F350FE9E-65BA-4AC1-A6C0-FD9F2979D342}


DEFINE_GUID(IID_IMySettings,

0xf350fe9e, 0x65ba, 0x4ac1, 0xa6, 0xc0, 0xfd, 0x9f, 0x29, 0x79, 0xd3, 0x42);

Change made to CPushSourceDesktop class:

class CPushSourceDesktop : public CSource, public IMySettingsInterface

{

private:

// Constructor is private because you have to use CreateInstance

CPushSourceDesktop(IUnknown *pUnk, HRESULT *phr);

~CPushSourceDesktop();

CPushPinDesktop *m_pPin;

public:

DECLARE_IUNKNOWN;

static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);  

STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);

//Methods the interface supports

STDMETHODIMP GetParamInt(char* szName, int *pParam);

STDMETHODIMP SetParamInt(char* szName, int nParam);

};

Defined these interface methods in my filter

STDMETHODIMP CPushSourceDesktop::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
    if (riid == (IID_IMySettings))
    {
        return GetInterface((IMySettingsInterface*) this, ppv);
    }
    else
    {
        return CSource::NonDelegatingQueryInterface(riid, ppv);
    }
}


STDMETHODIMP CPushSourceDesktop::GetParamInt(char* szName, int *pParam)

{
    // Example

    *pParam = 10;

    return 0;
}

STDMETHODIMP CPushSourceDesktop::SetParamInt(char* szName, int pParam)
{

    //Example
    return 0;
}


Comments

Popular posts from this blog

Getting and Setting Microphone Gain or Microphone Boost on Windows 7 / 8 Programmatically

After hours of searching the net I have finally figured out a way to programmatically get and set the microphone gain (boost) value. The code mentioned below can be built on VS and does the job of setting gain value. #include "stdafx.h" #include <mmdeviceapi.h> #include <endpointvolume.h> #include <Functiondiscoverykeys_devpkey.h> #include "Audioclient.h" #include "comutil.h" #define EXIT_ON_ERROR(hres)   if (FAILED(hres)) { goto Exit; } #define SAFE_RELEASE(punk)   if ((punk) != NULL)  { (punk)->Release(); (punk) = NULL; } HRESULT getMicrophoneBoostVolumeLevel(IMMDevice *pEndptDev, IAudioVolumeLevel** ppVolumeLevel) { HRESULT hr = S_OK; DataFlow flow; IDeviceTopology *pDeviceTopology = NULL; IConnector *pConnFrom = NULL; IConnector *pConnTo = NULL; IPart *pPartPrev = NULL; IPart *pPartNext = NULL; *ppVolumeLevel = NULL; wchar_t microphoneBoostName[] = L"Microphone Boost";//if your system ...

Simple example of strong and weak pointers on Android using RefBase class

Here is a simple example explaining the usage of strong and weak pointers using android's RefBase class and the Android.mk to compile the same. Its a modified version of code written by Daniel in the following link. http://himmele.blogspot.com/2012/03/androids-c-reference-counting.html strong_pointer.cpp file:  #include <stdio.h> #include "utils/RefBase.h" namespace android {  class RefTest : public RefBase { public:     RefTest(int32_t id) : mID(id) {         printf("RefTest ctor: %d\n", mID);     }     virtual ~RefTest() {         printf("RefTest dtor: %d\n", mID);     }     int32_t id() const {         return mID;     } private:     int32_t mID; }; int strong_pointer() {     sp<RefTest> ref1 = new RefTest(1);     sp<RefTest> ref5;   ...

AES-CBC-CTS Decryption using OpenSSL

Recently I was testing few test streams encrypted with AES-CBC-CTS mode, which is another block cipher mode that allows encrypting of data that is not evenly divisible into blocks (unlike AES-CBC mode). I also found that decryption of such streams is not possible using OpenSSL, as it does not support this block cipher mode. Since OpenSSL does support encryption/decryption for AES-CBC mode, I decided to extend this logic to support AES-CBC-CTS mode. I found following article on wikipedia which explains CBC-CTS encryption/decryption in detail. http://en.wikipedia.org/wiki/Ciphertext_stealing#CBC_ciphertext_stealing_decryption_using_a_standard_CBC_interface . Following C Routine can be used to decrypt data encrypted with AES-CBC-CTS block cipher mode. _DecryptData(DRM_KeyCtx_T  KEY_CTX, // KeyCtx_T is a structure containing the Key and IV.                      UINT8 *data, // ...