www.pudn.com > mediator15src.zip > VideoCodecEnumerator.cpp


/* 
 * VideoCodecEnumerator.cpp 
 * Copyright (C) 2002 Arno Hornberger  
 * Original Version Copyright (C) Alberto Vigata - January 2000 - ultraflask@yahoo.com 
 * 
 * This file is part of MPEG Mediator, a free MPEG stream converter. 
 * 
 * MPEG Mediator is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * MPEG Mediator is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 */ 
 
#include "VideoCodecEnumerator.h" 
 
VideoCodecEnumerator::VideoCodecEnumerator() 
{ 
  TVideoCodecInfo cnfo; 
  ICINFO codecInfo; 
  HIC hic;  
  int j = 0; 
 
	for (int i = 0; ICInfo(ICTYPE_VIDEO, i, &codecInfo); i++)  
  {  
    if (hic = ICOpen(codecInfo.fccType, codecInfo.fccHandler, ICMODE_COMPRESS))  
    { 
      ICGetInfo(hic, &codecInfo, sizeof(ICINFO)); 
       
      cnfo.hic = hic; 
      cnfo.fccHandler = codecInfo.fccHandler; 
  
			memcpy(cnfo.szDescription, codecInfo.szDescription, 128 * sizeof(WCHAR)); 
      memcpy(cnfo.szDriver, codecInfo.szDriver, 128 * sizeof(WCHAR)); 
      memcpy(cnfo.szName, codecInfo.szName, 16 * sizeof(WCHAR)); 
       
      m_vInstalledCodecList.SetAtGrow(j++, cnfo);  
    } 
  } 
} 
 
VideoCodecEnumerator::~VideoCodecEnumerator() 
{ 
  for (int i = 0; i < m_vInstalledCodecList.GetSize(); i++)  
    ICClose(m_vInstalledCodecList[i].hic); 
} 
 
void VideoCodecEnumerator::Enumerate(LPBITMAPINFOHEADER lpbih) 
{ 
  TVideoCodecInfo cnfo; 
  BITMAPINFO bi; 
	int j = 0; 
   
	m_vVideoCodecList.RemoveAll(); 
   
	memcpy(&bi.bmiHeader, lpbih, sizeof(BITMAPINFOHEADER)); 
   
  for (int i = 0; i < m_vInstalledCodecList.GetSize(); i++)  
  {  
    if (ICCompressQuery(m_vInstalledCodecList[i].hic, &bi, NULL) != ICERR_OK)  
			continue;  
 
    cnfo.hic = m_vInstalledCodecList[i].hic; 
    cnfo.fccHandler = m_vInstalledCodecList[i].fccHandler; 
 
    memcpy(cnfo.szDescription, m_vInstalledCodecList[i].szDescription, 128 * sizeof(WCHAR)); 
    memcpy(cnfo.szDriver, m_vInstalledCodecList[i].szDriver, 128 * sizeof(WCHAR)); 
    memcpy(cnfo.szName, m_vInstalledCodecList[i].szName, 16 * sizeof(WCHAR)); 
       
    m_vVideoCodecList.SetAtGrow(j++, cnfo); 
  } 
} 
 
bool VideoCodecEnumerator::IsEnumerated(DWORD fccHandler, int *idx) 
{ 
  for (int i = 0; i < m_vVideoCodecList.GetSize(); i++) 
    if (m_vVideoCodecList[i].fccHandler == fccHandler) 
    { 
      *idx = i; 
      return true; 
    } 
 
  return false; 
} 
 
const CArray&  
				VideoCodecEnumerator::GetEnumeratedCodecs() 
{ 
	return m_vVideoCodecList; 
}