taudiofilterosd.cpp.svn-base

来自「ffshow源码」· SVN-BASE 代码 · 共 88 行

SVN-BASE
88
字号
/* * 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 "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();}

⌨️ 快捷键说明

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