⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 taudiofilterosd.cpp

📁 从FFMPEG转换而来的H264解码程序,VC下编译..
💻 CPP
字号:
/*
 * Copyright (c) 2005,2006 Milan Cutka
 *
 * This program 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.
 *
 * This program 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include "stdafx.h"
#include "TaudioFilterOSD.h"
#include "ToutputAudioSettings.h"
#include "TOSDsettings.h"
#include "IffdshowBase.h"
#include "IffdshowDec.h"
#include "IffdshowDecVideo.h"
#include "dsutil.h"

TaudioFilterOSD::TaudioFilterOSD(IffdshowBase *Ideci,Tfilters *Iparent):
 TaudioFilter(Ideci,Iparent),
 lasttime(-CLOCKS_PER_SEC*10),registered(NULL),
 oldIs(-1),
 TOSDprovider(deci,deciD)
{
}

TaudioFilterOSD::~TaudioFilterOSD()
{
 unregister();
}

bool TaudioFilterOSD::is(const TsampleFormat &fmt,const TfilterSettingsAudio *cfg0)
{
 const TOSDsettingsAudio *cfg=(const TOSDsettingsAudio*)cfg0;
 return cfg->is || cfg->getFormat(0);
}

HRESULT TaudioFilterOSD::process(TfilterQueue::iterator it,TsampleFormat &fmt,void *samples,size_t numsamples,const TfilterSettingsAudio *cfg0)
{
 const TOSDsettingsAudio *cfg=(const TOSDsettingsAudio*)cfg0;tempcfg=cfg;

 clock_t curtime=-1;
 if (!registered && (cfg->is && (oldIs!=cfg->is || (curtime=clock())-lasttime>CLOCKS_PER_SEC*10))) //try every 10 seconds
  {
   if (curtime==-1) curtime=clock();
   lasttime=curtime;
   IFilterGraph *graph=NULL;
   if (deci->getGraph(&graph)==S_OK && graph)
    {
     comptr<IffdshowDecVideo> deciV;
     if (searchFilterInterface(graph,getGUID<IffdshowDecVideo>(),(IUnknown**)&deciV))
      if (SUCCEEDED(deciV->registerOSDprovider(this,"Audio track:")))
       registered=deciV;
    }
  }
 oldIs=cfg->is;
 return parent->deliverSamples(++it,fmt,samples,numsamples);
}

void TaudioFilterOSD::unregister(void)
{
 if (registered)
  {
   IFilterGraph *graph=NULL;
   if (deci->getGraph(&graph)==S_OK && graph)
    {
     comptr<IffdshowDecVideo> deciV;
     if (searchFilterInterface(graph,getGUID<IffdshowDecVideo>(),(IUnknown**)&deciV))
      if (deciV==registered)
       deciV->unregisterOSDprovider(this);
    }
   registered=NULL;
  }
}

void TaudioFilterOSD::onDisconnect(PIN_DIRECTION dir)
{
 unregister();
}

bool TaudioFilterOSD::getOutputFmt(TsampleFormat &fmt,const TfilterSettingsAudio *cfg)
{
 if (outsfs==TsampleFormat::SF_LPCM16)
  fmt.sf=TsampleFormat::SF_LPCM16;
 if (outsfs==TsampleFormat::SF_AC3)
  fmt.sf=TsampleFormat::SF_AC3;
 else
  if ((fmt.sf & outsfs)==0)
   fmt.sf=TsampleFormat::sf_bestMatch(fmt.sf,outsfs);
 return true;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -