source: trunk/Utilities/Miscellaneous/MfNativeMediaType01/Application.cpp @ 693

Last change on this file since 693 was 693, checked in by roman, 7 years ago
File size: 1.6 KB
Line 
1// NOTE: http://stackoverflow.com/questions/40849420/media-foundation-amr-decode
2
3#include <sdkddkver.h>
4
5#include <stdio.h>
6#include <tchar.h>
7
8#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS      // some CString constructors will be explicit
9
10#include <atlbase.h>
11#include <atlstr.h>
12
13#include <mfapi.h>
14#include <mfidl.h>
15#include <mfreadwrite.h>
16
17#pragma comment(lib, "mfplat.lib")
18#pragma comment(lib, "mfuuid.lib")
19#pragma comment(lib, "mfreadwrite.lib")
20
21int main()
22{
23        _ATLTRY
24        {
25                ATLENSURE_SUCCEEDED(MFStartup(MF_VERSION));
26                CComPtr<IMFSourceReader> pReader;
27                CComPtr<IMFMediaType> pAudioType;
28                static const LPCTSTR g_pszPath = 
29                        _T("D:\\Projects\\Alax.Info\\Repository-Private\\Utilities\\MediaFoundation\\ProbeMediaSource\\example.amr");
30                ATLENSURE_SUCCEEDED(MFCreateSourceReaderFromURL(g_pszPath, NULL, &pReader));
31                ATLENSURE_SUCCEEDED(pReader->SetStreamSelection(MF_SOURCE_READER_ALL_STREAMS, false));
32                ATLENSURE_SUCCEEDED(pReader->SetStreamSelection(MF_SOURCE_READER_FIRST_AUDIO_STREAM, true));
33                ATLENSURE_SUCCEEDED(pReader->GetCurrentMediaType(MF_SOURCE_READER_FIRST_AUDIO_STREAM, &pAudioType));
34                UINT32 numChannels, sampleRate;
35                ATLENSURE_SUCCEEDED(pAudioType->GetUINT32(MF_MT_AUDIO_NUM_CHANNELS, &numChannels));
36                ATLENSURE_SUCCEEDED(pAudioType->GetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, &sampleRate));
37                _tprintf(_T("numChannels %d, sampleRate %d\n"), numChannels, sampleRate);
38                // NOTE: Sample output:
39                //       numChannels 1, sampleRate 8000
40        }
41        _ATLCATCHALL()
42        {
43                _tprintf(_T("Fatal Error\n"));
44        }
45    return 0;
46}
47
Note: See TracBrowser for help on using the repository browser.