Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin Jae-yeon committed Jul 14, 2017
1 parent 0174dcd commit 9464200
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 19 deletions.
43 changes: 29 additions & 14 deletions DaramCam.MediaFoundationGenerator/DaramCam.MFGenerator.Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ class DCMFAudioGenerator : public DCAudioGenerator

DARAMCAMMEDIAFOUNDATIONGENERATOR_EXPORTS DCAudioGenerator * DCCreateMFAudioGenerator ( DWORD containerFormat, DWORD audioFormat )
{
if ( containerFormat == DCMFCONTAINER_ADTS || containerFormat == DCMFCONTAINER_MP4 )
{
if ( audioFormat != DCMFAF_AAC )
return nullptr;
}
return new DCMFAudioGenerator ( containerFormat, audioFormat );
}

Expand Down Expand Up @@ -69,8 +74,6 @@ DWORD WINAPI MFAG_Progress ( LPVOID vg )
audioGen->capturer->Begin ();
audioGen->sinkWriter->BeginWriting ();

HRESULT hr;

MFTIME totalDuration = 0;
while ( audioGen->threadRunning )
{
Expand Down Expand Up @@ -104,7 +107,7 @@ DWORD WINAPI MFAG_Progress ( LPVOID vg )

sample->Release ();

Sleep ( 1 );
Sleep ( 0 );
}

audioGen->sinkWriter->Flush ( audioGen->streamIndex );
Expand All @@ -128,17 +131,29 @@ void DCMFAudioGenerator::Begin ( IStream * _stream, DCAudioCapturer * _capturer
IMFMediaType * audioMediaType;
if ( FAILED ( hr = MFCreateMediaType ( &audioMediaType ) ) )
return;
audioMediaType->SetGUID ( MF_MT_MAJOR_TYPE, MFMediaType_Audio );
audioMediaType->SetGUID ( MF_MT_SUBTYPE, MFAudioFormat_AAC );
audioMediaType->SetUINT32 ( MF_MT_AUDIO_BITS_PER_SAMPLE, 16 );
audioMediaType->SetUINT32 ( MF_MT_AUDIO_SAMPLES_PER_SECOND, _capturer->GetSamplerate () );
audioMediaType->SetUINT32 ( MF_MT_AUDIO_NUM_CHANNELS, _capturer->GetChannels () );
audioMediaType->SetUINT32 ( MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 24000 );
audioMediaType->SetUINT32 ( MF_MT_AAC_PAYLOAD_TYPE, 0 );

if ( FAILED ( hr = MFCreateMPEG4MediaSink ( byteStream, nullptr, audioMediaType, &mediaSink ) ) )
//if ( FAILED ( hr = MFCreateADTSMediaSink ( byteStream, audioMediaType, &mediaSink ) ) )
return;
if ( audioFormat == DCMFAF_AAC )
{
audioMediaType->SetGUID ( MF_MT_MAJOR_TYPE, MFMediaType_Audio );
audioMediaType->SetGUID ( MF_MT_SUBTYPE, MFAudioFormat_AAC );
audioMediaType->SetUINT32 ( MF_MT_AUDIO_BITS_PER_SAMPLE, 16 );
audioMediaType->SetUINT32 ( MF_MT_AUDIO_SAMPLES_PER_SECOND, _capturer->GetSamplerate () );
audioMediaType->SetUINT32 ( MF_MT_AUDIO_NUM_CHANNELS, _capturer->GetChannels () );
audioMediaType->SetUINT32 ( MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 24000 );
audioMediaType->SetUINT32 ( MF_MT_AAC_PAYLOAD_TYPE, 0 );
}
else return;

if ( containerFormat == DCMFCONTAINER_MP4 )
{
if ( FAILED ( hr = MFCreateMPEG4MediaSink ( byteStream, nullptr, audioMediaType, &mediaSink ) ) )
return;
}
else if ( containerFormat == DCMFCONTAINER_ADTS )
{
if ( FAILED ( hr = MFCreateADTSMediaSink ( byteStream, audioMediaType, &mediaSink ) ) )
return;
}
else return;

audioMediaType->Release ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class DCMFAudioVideoGenerator : public DCAudioVideoGenerator

DARAMCAMMEDIAFOUNDATIONGENERATOR_EXPORTS DCAudioVideoGenerator * DCCreateMFAudioVideoGenerator ( DWORD containerFormat, DWORD videoFormat, DWORD audioFormat, unsigned frameTick )
{
if ( containerFormat != DCMFCONTAINER_MP4 ) return nullptr;

return new DCMFAudioVideoGenerator ( containerFormat, videoFormat, audioFormat, frameTick );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class DCMFVideoGenerator : public DCVideoGenerator

DARAMCAMMEDIAFOUNDATIONGENERATOR_EXPORTS DCVideoGenerator * DCCreateMFVideoGenerator ( DWORD containerFormat, DWORD videoFormat, unsigned frameTick )
{
if ( containerFormat != DCMFCONTAINER_MP4 ) return nullptr;

return new DCMFVideoGenerator ( containerFormat, videoFormat, frameTick );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

enum {
DCMFCONTAINER_MP4,
DCMFCONTAINER_ADTS,
};

enum {
Expand Down
8 changes: 4 additions & 4 deletions DaramCam.Test/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main ( void )
hWnd = DCGetActiveWindowFromProcess ( process );*/

///// Image Capture
/**/
/*
SHCreateStreamOnFileEx ( TEXT ( "Z:\\Test.png" ), STGM_READWRITE | STGM_CREATE, 0, false, 0, &stream );
//DCScreenCapturer * screenCapturer = new DCCreateGDIScreenCapturer ( hWnd );
Expand Down Expand Up @@ -91,14 +91,14 @@ int main ( void )
scanf ( "%d", &selected );
DCAudioCapturer * audioCapturer = DCCreateWASAPIAudioCapturer ( devices [ selected ] );/**/
/*
/**/
DCAudioCapturer * audioCapturer = DCCreateWASAPILoopbackAudioCapturer ();

//SHCreateStreamOnFileEx ( TEXT ( "Z:\\Test.adts" ), STGM_READWRITE | STGM_CREATE, 0, false, 0, &stream );
SHCreateStreamOnFileEx ( TEXT ( "Z:\\Test.m4a" ), STGM_READWRITE | STGM_CREATE, 0, false, 0, &stream );
SHCreateStreamOnFileEx ( TEXT ( "Z:\\Test.adts" ), STGM_READWRITE | STGM_CREATE, 0, false, 0, &stream );

//DCAudioGenerator * audGen = DCCreateWaveAudioGenerator ();
DCAudioGenerator * audGen = DCCreateMFAudioGenerator ( DCMFCONTAINER_MP4, DCMFAF_AAC );
DCAudioGenerator * audGen = DCCreateMFAudioGenerator ( DCMFCONTAINER_ADTS, DCMFAF_AAC );

audGen->Begin ( stream, audioCapturer );
Sleep ( 10000 );
Expand Down
2 changes: 1 addition & 1 deletion DaramCam/External Libraries/DXGIManager/DXGIManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ HRESULT DXGIManager::GetOutputBits(BYTE* pBits )
if(FAILED(hr))
return hr;

//DrawMousePointer(pBuf, rcOutput, rcOutput);
DrawMousePointer(pBuf, rcOutput, rcOutput);

return hr;
}
Expand Down

0 comments on commit 9464200

Please sign in to comment.