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


C++ MemoryWriter::setStream方法代码示例

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


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

示例1: Extract

bool Extract(params_t &params, FilePath *inPath, FilePath *outPath, FilePath *annoPath)
{	
	ssi_char_t *toPath = 0;
	if (ssi_strcmp(outPath->getExtension(), annoPath ? SSI_FILE_TYPE_SAMPLES : SSI_FILE_TYPE_STREAM, false))
	{
		toPath = ssi_strcpy(outPath->getPath());
	}
	else
	{
		toPath = ssi_strcpy(outPath->getPathFull());
	}

	Chain *chain = ssi_create_id(Chain, 0, "chain");
	chain->getOptions()->set(params.chainPathAbsolute);	

	ssi_stream_t from;
	bool result = false;

	bool isVideoFile = IsVideoFile(inPath->getNameFull());
	bool isAudioFile = IsAudioFile(inPath->getNameFull());

	if (isVideoFile)
	{				
		if (annoPath)
		{
			ssi_wrn("cannot extract video features for an annotation");
			return false;
		}

		FFMPEGReader *reader = ssi_create(FFMPEGReader, 0, false);
		reader->getOptions()->setUrl(inPath->getPathFull());
		reader->getOptions()->bestEffort = true;

		FileWriter *writer = ssi_create(FileWriter, 0, false);
		writer->getOptions()->overwrite = true;
		writer->getOptions()->setPath(toPath);
		writer->getOptions()->type = File::BINARY;
		
		FileProvider *provider = new FileProvider(writer, chain);
		reader->setProvider(SSI_FFMPEGREADER_VIDEO_PROVIDER_NAME, provider);

		reader->connect();
		reader->start();
		reader->wait();		
		reader->stop();
		reader->disconnect();
		
		delete provider;
		delete reader;
		delete writer;
	}
	else if (isAudioFile)
	{
		FFMPEGReader *reader = ssi_create(FFMPEGReader, 0, false);
		reader->getOptions()->setUrl(inPath->getPathFull());
		reader->getOptions()->ablock = 0.05;
		reader->getOptions()->bestEffort = true;

		if (!reader->initAudioStream(inPath->getPathFull(), from)
			|| from.num == 0)
		{			
			return false;
		}

		MemoryWriter *writer = ssi_create(MemoryWriter, 0, false);
		writer->setStream(from);		

		FileProvider *provider = new FileProvider(writer);
		reader->setProvider(SSI_FFMPEGREADER_AUDIO_PROVIDER_NAME, provider);

		reader->connect();
		reader->start();
		reader->wait();
		reader->stop();
		reader->disconnect();

		delete provider;
		delete reader;
		delete writer;

 		result = true;
	}
	else
	{
		result = FileTools::ReadStreamFile(inPath->getPathFull(), from);
	}

	if (result)
	{
		ssi_stream_t to;

		if (annoPath)
		{			
			Annotation annotation;
			if (result &= annotation.load(annoPath->getPathFull()))
			{
				if (annotation.getScheme()->type != SSI_SCHEME_TYPE::DISCRETE)
				{
					ssi_wrn("cannot extract features from a continuous annotation");
					return false;
//.........这里部分代码省略.........
开发者ID:hcmlab,项目名称:mobileSSI,代码行数:101,代码来源:Main.cpp


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