I need to implement this interface ISampleGrabber
https://learn.microsoft.com/en-us/windows/win32/directshow/isamplegrabber
This file as far as I understand should be in Windows SDK, so I downloaded Windows SDK from Visual Studio installer
But still I get Cannot open source file
What am I doing wrong?
EDIT
By link given on page above I downloaded such file winsdk_web.exe
when I try to install it I get such popup
According to this popup massage I need to install .NET Framework 4.0
from this link
http://go.microsoft.com/fwlink/?LinkID=187668
So, I downloaded this file tried to install it, but got another message
What is a problem here?
EDIT
I am new in C++, but it looks weird for me:) like you have a documentation where it is written that in order to do something you need to use specific interface, but this interface you can't find almost anywhere, but here you can download sdk, but eventually it all doesn't help and only solution is to add this code, nice:)
#pragma once
#include <dshow.h>
#include <dvdmedia.h>
#include <dmodshow.h>
class __declspec(uuid("{C1F400A4-3F08-11D3-9F0B-006008039E37}")) NullRenderer;
class __declspec(uuid("{C1F400A0-3F08-11D3-9F0B-006008039E37}")) SampleGrabber;
#pragma region SampleGrabber
struct __declspec(uuid("0579154a-2b53-4994-b0d0-e773148eff85"))
ISampleGrabberCB : IUnknown
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall SampleCB(
double SampleTime,
struct IMediaSample * pSample) = 0;
virtual HRESULT __stdcall BufferCB(
double SampleTime,
unsigned char * pBuffer,
long BufferLen) = 0;
};
struct __declspec(uuid("6b652fff-11fe-4fce-92ad-0266b5d7c78f"))
ISampleGrabber : IUnknown
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall SetOneShot(
long OneShot) = 0;
virtual HRESULT __stdcall SetMediaType(
struct _AMMediaType * pType) = 0;
virtual HRESULT __stdcall GetConnectedMediaType(
struct _AMMediaType * pType) = 0;
virtual HRESULT __stdcall SetBufferSamples(
long BufferThem) = 0;
virtual HRESULT __stdcall GetCurrentBuffer(
/*[in,out]*/ long * pBufferSize,
/*[out]*/ long * pBuffer) = 0;
virtual HRESULT __stdcall GetCurrentSample(
/*[out,retval]*/ struct IMediaSample * * ppSample) = 0;
virtual HRESULT __stdcall SetCallback(
struct ISampleGrabberCB * pCallback,
long WhichMethodToCallback) = 0;
};
struct __declspec(uuid("c1f400a0-3f08-11d3-9f0b-006008039e37"))
SampleGrabber;
// [ default ] interface ISampleGrabber
#pragma endregion
class TV_AudioDecoder : public ISampleGrabber
{
public:
TV_AudioDecoder();
~TV_AudioDecoder();
public:
virtual HRESULT __stdcall SetOneShot(long OneShot) override;
virtual HRESULT __stdcall SetMediaType(struct _AMMediaType * pType) override;
virtual HRESULT __stdcall GetConnectedMediaType(struct _AMMediaType * pType) override;
virtual HRESULT __stdcall SetBufferSamples(long BufferThem) override;
virtual HRESULT __stdcall GetCurrentBuffer(/*[in,out]*/ long * pBufferSize, /*[out]*/ long * pBuffer) override;
virtual HRESULT __stdcall GetCurrentSample(/*[out,retval]*/ struct IMediaSample * * ppSample) override;
virtual HRESULT __stdcall SetCallback(struct ISampleGrabberCB * pCallback, long WhichMethodToCallback) override;
};
Let's say this is my code, is it a right way to use it? I didn't miss nothing?
Qedit.h was excluded from Windows SDK at some point in past with deprecation of DirectShow Editing Services. Still runtime has been present in all versions of Windows since then.
You don't need to install anything and, vice versa, installation of ancient SDK will not make your life any easier.
Just copy/paste necessary headers into your project and you are good to go.
Things to copy/paste are mentioned in, for example, this 2009 topic. You can find my answer there with #import
and it should work too. As of now in 2020 I would still recommend copy/pasting missing headers.
UPD.
// <your regular includes>
#include <dshow.h>
#include <dvdmedia.h>
#include <dmodshow.h>
class __declspec(uuid("{C1F400A4-3F08-11D3-9F0B-006008039E37}")) NullRenderer;
class __declspec(uuid("{C1F400A0-3F08-11D3-9F0B-006008039E37}")) SampleGrabber;
#pragma region SampleGrabber
struct __declspec(uuid("0579154a-2b53-4994-b0d0-e773148eff85"))
ISampleGrabberCB : IUnknown
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall SampleCB (
double SampleTime,
struct IMediaSample * pSample ) = 0;
virtual HRESULT __stdcall BufferCB (
double SampleTime,
unsigned char * pBuffer,
long BufferLen ) = 0;
};
struct __declspec(uuid("6b652fff-11fe-4fce-92ad-0266b5d7c78f"))
ISampleGrabber : IUnknown
{
//
// Raw methods provided by interface
//
virtual HRESULT __stdcall SetOneShot (
long OneShot ) = 0;
virtual HRESULT __stdcall SetMediaType (
struct _AMMediaType * pType ) = 0;
virtual HRESULT __stdcall GetConnectedMediaType (
struct _AMMediaType * pType ) = 0;
virtual HRESULT __stdcall SetBufferSamples (
long BufferThem ) = 0;
virtual HRESULT __stdcall GetCurrentBuffer (
/*[in,out]*/ long * pBufferSize,
/*[out]*/ long * pBuffer ) = 0;
virtual HRESULT __stdcall GetCurrentSample (
/*[out,retval]*/ struct IMediaSample * * ppSample ) = 0;
virtual HRESULT __stdcall SetCallback (
struct ISampleGrabberCB * pCallback,
long WhichMethodToCallback ) = 0;
};
struct __declspec(uuid("c1f400a0-3f08-11d3-9f0b-006008039e37"))
SampleGrabber;
// [ default ] interface ISampleGrabber
#pragma endregion
// <your code>
See also:
I am new in C++, but it looks weird for me:) [...]
It is not exactly about C++. It is about how to use abandoned OS part in your C++ project by reintroducing its declaration removed from standard SDK. Yeah, in C++ we can do it, as well as other cool tricks.