AudRecordLib
AudRecordInt.h
Go to the documentation of this file.
00001 
00006 #ifndef AUDRECORD_INTERFACE_H
00007 #define AUDRECORD_INTERFACE_H
00008 
00009 #pragma once
00010 
00011 #include "IAudRecordInterface.h"
00012 #include <wmsdk.h>
00013 #include <mmreg.h>
00014 #include <audioclient.h>
00015 #include "rtlresource.h"
00016 #include "convert.h"
00017 #include "exports.h"
00018 
00023 class AudRecord : public IAudRecord
00024 {
00026         struct Formats
00027         {
00028                 WAVEFORMATEX mixer;
00029                 WAVEFORMATEX codecInput;
00030         };
00031 
00033         struct Attribute
00034         {
00036                 LPCWSTR pwszName;
00038                 WMT_ATTR_DATATYPE type;
00040                 LPCVOID pData;
00042                 WORD dataSize;
00043         };
00044 private:
00046         RtlResource memberLock;
00048         Formats formats;
00050         ConverterFnPtr sampleConverterFn;
00052         WinType<HANDLE> hCaptureThread;
00054         WinType<HANDLE> hCaptureThreadExitEvent;
00056         WinType<HANDLE> hCaptureThreadSamplesWaiting;
00060         ComType<IWMWriter> pWriter;
00064         ComType<IWMWriterAdvanced> pWriterAdv;
00066         IAudioClient* pAudioClient;
00068         IAudioCaptureClient* pCaptureClient;
00072         LONG refCount;
00074         DWORD captureThreadId;
00078         UINT samplesWaitingTimerId;
00079 
00080         AudRecord(IWMWriter* pWriter, IWMWriterAdvanced* pWriterAdv);
00081         ~AudRecord();
00082 
00083         DWORD CaptureThreadProc(HANDLE hStartedThread);
00084         static DWORD WINAPI CaptureThreadProcTrampoline(PVOID pv);
00085 
00086         HRESULT DetermineAudioFormats(WAVEFORMATEX* pwfx);
00087 
00088         HRESULT StartRecordingLoop();
00089         void StopRecordingLoop();
00090 
00091         void CaptureSamples(UINT64& framesSeen, const double& timePerSample);
00092 
00093         HRESULT CheckWriterCanWrite();
00094         void SetWriterAttributes(Attribute* pAttributes, DWORD numAttrs);
00095 
00096         HRESULT BeginRecording(struct IMMDevice* pEndpoint);
00097 
00098         // disable copying
00099         AudRecord(const AudRecord&);
00100         void operator=(const AudRecord&);
00101 
00102 public:
00103         static HRESULT Create(IWMWriter* pWriter, CodecConfiguration* pCodecConfig, IAudRecord** ppRecord);
00104 
00105         // IUnknown
00106         STDMETHODIMP QueryInterface(REFIID iid, PVOID* ppObj);
00107         STDMETHODIMP_(ULONG) AddRef();
00108         STDMETHODIMP_(ULONG) Release();
00109 
00110         // IAudRecord
00111         STDMETHODIMP Record(Endpoint* pClient);
00112         STDMETHODIMP ChangeCodec(CodecConfiguration* pNewCodec);
00113         STDMETHODIMP TogglePause(AudPausedState* pCurState);
00114         STDMETHODIMP QueryPause(AudPausedState* pCurState);
00115         STDMETHODIMP Stop();
00116         STDMETHODIMP AddFileTarget(LPCWSTR pwszFileName, PVOID* ppCookie);
00117         STDMETHODIMP AddNetworkBroadcastTarget(DWORD* pPort, DWORD maxConnections, LPWSTR* ppwszUrl, PVOID* ppCookie);
00118         STDMETHODIMP AddCustomTarget(IWMWriterSink* pTarget, PVOID* ppCookie);
00119         STDMETHODIMP RemoveTarget(PVOID pCookie);
00120         STDMETHODIMP GetStatistics(AudRecordStats* pStats);
00121 };
00122 
00123 #endif
00124 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Defines