Browse files

add support for multiple channel capture, though I haven't tested and…

… seen it work yet...
  • Loading branch information...
1 parent 58e3796 commit 58ab5ac0b6746673e5ea354fca3dc07abfc23c01 @rdp committed Aug 22, 2012
View
BIN source_code/Release/audio_sniffer.dll
Binary file not shown.
View
5 source_code/acam/acam.vcxproj.user
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <LocalDebuggerCommand>C:\Program Files (x86)\Adobe\Flash Media Live Encoder 3.2\FlashMediaLiveEncoder.exe</LocalDebuggerCommand>
+ <LocalDebuggerCommand>c:\installs\ffmpeg-20120816-git-f0896a6-win32-static\bin\ffmpeg.exe</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
- <LocalDebuggerCommandArguments>
- </LocalDebuggerCommandArguments>
+ <LocalDebuggerCommandArguments> -f dshow -i audio=virtual-audio-capturer -y yo.mp3</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommand>C:\Program Files (x86)\VideoLAN\VLC\vlc.exe</LocalDebuggerCommand>
View
1 source_code/acam/common.h
@@ -8,6 +8,7 @@ void ShowOutput(const char *str, ...);
HRESULT set_config_string_setting(LPCTSTR szValueName, wchar_t *szToThis );
int getHtzRate();
+int getChannels();
HRESULT LoopbackCaptureTakeFromBuffer(BYTE pBuf[], int iSize, WAVEFORMATEX* ifNotNullThenJustSetTypeOnly, LONG* sizeWrote);
View
4 source_code/acam/directshow_stuff.cpp
@@ -40,7 +40,7 @@ CVCam::CVCam(LPUNKNOWN lpunk, HRESULT *phr) :
ASSERT(phr);
//m_pClock is null at this point...
m_paStreams = (CSourceStream **) new CVCamStream*[1];
- m_paStreams[0] = new CVCamStream(phr, this, L"Virtual cam5");
+ m_paStreams[0] = new CVCamStream(phr, this, L"Capture Pin");
}
STDMETHODIMP CVCam::Run(REFERENCE_TIME tStart) {
@@ -163,7 +163,7 @@ HRESULT setupPwfex(WAVEFORMATEX *pwfex, AM_MEDIA_TYPE *pmt) {
// TODO match more than just htz...maybe that's all we need? :)
pwfex->wFormatTag = WAVE_FORMAT_PCM;
pwfex->cbSize = 0; // apparently should be zero if using WAVE_FORMAT_PCM http://msdn.microsoft.com/en-us/library/ff538799(VS.85).aspx
- pwfex->nChannels = 2; // 1 for mono, 2 for stereo..
+ pwfex->nChannels = getChannels(); // 1 for mono, 2 for stereo..
pwfex->nSamplesPerSec = getHtzRate();
pwfex->wBitsPerSample = 16; // 16 bit sound
pwfex->nBlockAlign = (WORD)((pwfex->wBitsPerSample * pwfex->nChannels) / BITS_PER_BYTE);
View
40 source_code/acam/loopback-capture.cpp
@@ -50,15 +50,20 @@ const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
const IID IID_IAudioClient = __uuidof(IAudioClient);
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
+void propagateWithRawCurrentFormat(WAVEFORMATEX *toThis) {
+ WAVEFORMATEX *pwfx;
+ IMMDevice *pMMDevice;
+ IAudioClient *pAudioClient;
+ HANDLE hTask;
+ DWORD nTaskIndex = 0;
+ hTask = AvSetMmThreadCharacteristics(L"Capture", &nTaskIndex);
-int getHtzRate() {
- HRESULT hr;
- hr = get_default_device(&m_pMMDevice); // so it can re-place our pointer...
+ HRESULT hr = get_default_device(&pMMDevice);
if (FAILED(hr)) {
- return hr;
+ assert(false);
}
// activate an (the default, for us, since we want loopback) IAudioClient
- hr = m_pMMDevice->Activate(
+ hr = pMMDevice->Activate(
__uuidof(IAudioClient),
CLSCTX_ALL, NULL,
(void**)&pAudioClient
@@ -68,7 +73,6 @@ int getHtzRate() {
assert(false);
}
- WAVEFORMATEX *pwfx;
hr = pAudioClient->GetMixFormat(&pwfx);
if (FAILED(hr)) {
ShowOutput("IAudioClient::GetMixFormat failed: hr = 0x%08x\n", hr);
@@ -79,11 +83,21 @@ int getHtzRate() {
pAudioClient->Stop();
AvRevertMmThreadCharacteristics(hTask);
pAudioClient->Release();
- m_pMMDevice->Release();
- int samples = pwfx->nSamplesPerSec;
+ pMMDevice->Release();
+ memcpy(toThis, pwfx, sizeof(WAVEFORMATEX));
CoTaskMemFree(pwfx);
- return samples;
+}
+
+int getHtzRate() {
+ WAVEFORMATEX format;
+ propagateWithRawCurrentFormat(&format);
+ return format.nSamplesPerSec;
+}
+int getChannels() {
+ WAVEFORMATEX format;
+ propagateWithRawCurrentFormat(&format);
+ return format.nChannels;
}
// we only call this once...per hit of the play button :)
@@ -125,7 +139,7 @@ HRESULT LoopbackCaptureSetup()
// get the default device format (incoming...)
WAVEFORMATEX *pwfx; // incoming wave...
- // apparently propogated only by GetMixFormat...
+ // apparently propogated by GetMixFormat...
hr = pAudioClient->GetMixFormat(&pwfx);
if (FAILED(hr)) {
ShowOutput("IAudioClient::GetMixFormat failed: hr = 0x%08x\n", hr);
@@ -224,6 +238,7 @@ HRESULT LoopbackCaptureSetup()
//IAudioClient *pAudioClient = NULL;
//IAudioCaptureClient *pCaptureClient = NULL;
+ /*
IMMDeviceEnumerator *pEnumerator = NULL;
IMMDevice *pDevice = NULL;
@@ -284,6 +299,7 @@ BYTE *captureData;
// create a new IAudioClient
hr = pDevice->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pAudioClient);
EXIT_ON_ERROR(hr)
+ */
// -============================ now the sniffing code initialization stuff, direct from mauritius... ===================================
@@ -320,6 +336,7 @@ BYTE *captureData;
// register with MMCSS
DWORD nTaskIndex = 0;
+
hTask = AvSetMmThreadCharacteristics(L"Capture", &nTaskIndex);
if (NULL == hTask) {
DWORD dwErr = GetLastError();
@@ -401,7 +418,8 @@ HRESULT propagateBufferOnce() {
if((current_time - start_time > millis_to_fill)) {
// I don't think we ever get to here anymore...thankfully, since it's mostly broken code probably, anyway
if(!gotAnyAtAll) {
- assert(false); // want to know if this ever happens...
+ // We get here [?]
+ assert(false); // want to know if this ever happens...it never should since we are using silence...
}
} else {
Sleep(1); // doesn't seem to hurt cpu--"sleep x ms"
View
3 startup_debug_exe_options.txt
@@ -0,0 +1,3 @@
+C:\Program Files (x86)\Adobe\Flash Media Live Encoder 3.2\FlashMediaLiveEncoder.exe
+C:\Program Files (x86)\VideoLAN\VLC\vlc.exe
+dshow:// :dshow-vdev=none :dshow-adev="virtual-audio-capturer" :dshow-caching=50

0 comments on commit 58ab5ac

Please sign in to comment.