2013年6月26日水曜日

ストリーム数を調べる:IWMProfile::GetStreamCount

未整理


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
空のCLRプロジェクト
*/
 
#include <stdio.h>  //printf とかで必要
#include <wmsdk.h>  //HRESULT とかで必要
 
#pragma comment(lib, "wmvcore.lib")   //IWMMetadataEditor とかで必要
#pragma comment ( lib, "ole32.lib" )//CoInitialize で必要
 
using namespace System;//Console::ReadLine()で必要
 
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(x) \
 if(x != NULL)        \
{                    \
 x->Release();     \
 x = NULL;         \
}
#endif
 
int main(void)
{
 
 HRESULT hr = S_OK;
 
 IWMProfile * pProfile= NULL;; //
 IWMSyncReader * mSyncReader;
 
 hr = WMCreateSyncReader(NULL, 0, &mSyncReader);
 // Create a profile manager object.
 // プロファイルマネージャオブジェクトを作成します。
 
 hr = mSyncReader->Open(L"G:\\sampleMovie\\sample.mp3");
 
 if (FAILED(hr))
 {
  printf("-------------失敗----------------");
  return E_FAIL;
 }
 
 hr = mSyncReader->QueryInterface(IID_IWMProfile,(void**)&pProfile);
 
 DWORD dwStreamCount = 0;
 hr = pProfile->GetStreamCount(&dwStreamCount);
 
 for (DWORD dwIndex = 0; dwIndex < dwStreamCount; dwIndex++)
 {
  printf("%d-------------\r\n",dwIndex);
  IWMStreamConfig *pConfig = NULL;
  hr = pProfile->GetStream(dwIndex, &pConfig);
  if (FAILED(hr))
  {
   printf("%d------失敗-------");
   printf("Could not get the stream: (hr=0x%08x)\n", hr);
   return hr;
  }
 
  GUID guid = GUID_NULL;
  hr = pConfig->GetStreamType(&guid);
  if (FAILED(hr))
  {
   printf("------失敗1-------");
   printf("Could not get the stream type: (hr=0x%08x)\n", hr);
   return hr;
  }
  else
  {
   if (WMMEDIATYPE_Video == guid)
   {
    printf("WMMEDIATYPE_Video\r\n");
   }
   else if (WMMEDIATYPE_Audio == guid)
   {
    printf("WMMEDIATYPE_Audioo\r\n");
   }
   else if (WMMEDIATYPE_Script == guid)
   {
    printf("WMMEDIATYPE_Script\r\n");
   }
   else{
    printf("その他\r\n");
   }
  }
 }
 
 printf("-------------プログラム終了----------------");
 
 Console::ReadLine();//入力待-ウインドウ維持
}


0 件のコメント:

コメントを投稿