当前位置: 首页>>代码示例>>C++>>正文


C++ Sink::process方法代码示例

本文整理汇总了C++中Sink::process方法的典型用法代码示例。如果您正苦于以下问题:C++ Sink::process方法的具体用法?C++ Sink::process怎么用?C++ Sink::process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sink的用法示例。


在下文中一共展示了Sink::process方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, const char **argv)
{
  if ( argc < 3 )
  {
    std::cout <<
"Spdifer\n"
"=======\n"
"This utility encapsulates AC3/DTS/MPEG Audio stream into SPDIF stream\n"
"according to IEC 61937\n"
"\n"
"This utility is a part of AudioFilter project (git://github.com/cbxbiker61/audiofilter.git)\n"
"Copyright (c) 2007-2009 by Alexander Vigovsky\n"
"Copyright (c) 2011 Kelly Anderson\n"
"\n"
"Usage:\n"
"  spdifer input_file output_file [-raw | -wav]\n"
"\n"
"Options:\n"
"  input_file  - file to convert\n"
"  output_file - file to write result to\n"
"  -raw - make raw SPDIF stream output (default)\n"
"  -wav - make PCM WAV file with SPDIF data (for writing to CD Audio)" << std::endl;
    return 0;
  }

  /////////////////////////////////////////////////////////
  // Parse command line

  const char *infile(argv[1]);
  const char *outfile = argv[2];
  Sink *sink = ( argc <= 3 || strcmp(argv[3], "-wav") )
    ? (Sink*)(new RawSink(outfile))
    : (Sink*)(new WavSink(outfile));

  MultiHeaderParser *mhp(new MultiHeaderParser());
  mhp->addParser(new SpdifHeaderParser());
  mhp->addParser(new DtsHeaderParser());
  mhp->addParser(new MpaHeaderParser());
  mhp->addParser(new Ac3HeaderParser());
  FileParser *fp(new FileParser(infile, mhp));
  SpdifWrapper spdif(mhp);
  spdif.addChannelMap(8, 192000);
  spdif.addChannelMap(2, 192000);
  spdif.addChannelMap(2, 48000);
  spdif.addChannelMap(8, 48000);

  int streams(0);
  int frames(0);
  int skipped(0);
  int errors(0);
  size_t size(0);
  vtime_t time(getLocalTime());
  vtime_t old_time(time);
  vtime_t start_time(time);

  Chunk chunk;

  while ( ! fp->eof() )
  {
    if ( fp->loadFrame() )
    {
      ++frames;

      if ( fp->isNewStream() )
        ++streams;

      if ( spdif.parseFrame(fp->getFrame(), fp->getFrameSize()) )
      {
        const Speakers &spk(spdif.getSpeakers());

        if ( spk.isSpdif() )
        {
          static bool hasPrinted(false);

          if ( ! hasPrinted )
          {
            std::cout << "Format Spdif:"
                  << " channels" << spk.getChannelCount()
                  << " sampleRate" << spk.getSampleRate()
                  << std::endl;
            hasPrinted = true;
          }

#if 1
          chunk.setRawData(spk, spdif.getRawData(), spdif.getRawSize());
#else
          chunk.setRawData(
                Speakers(FORMAT_PCM16, MODE_STEREO, spk.getSampleRate())
                , spdif.getRawData(), spdif.getRawSize());
#endif

          if ( sink->process(&chunk) )
            size += chunk.size;
          else
            ++errors;
        }
        else
          ++skipped;
      }
      else
//.........这里部分代码省略.........
开发者ID:cbxbiker61,项目名称:audiofilter,代码行数:101,代码来源:spdifer.cpp


注:本文中的Sink::process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。