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

📄 pluginlist.cpp

📁 Qtopia下的多媒体录音源码
💻 CPP
字号:
/******************************************************************************** Copyright (C) 2000-2006 TROLLTECH ASA. All rights reserved.**** This file is part of the Phone Edition of the Qtopia Toolkit.**** Licensees holding a valid license agreement from Trolltech or any of its** authorized distributors may use this file in accordance with** the License Agreement provided with the Licensed Software.**** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for**   information about Trolltech's Commercial License Agreements.**** Contact info@trolltech.com if any conditions of this licensing are** not clear to you.********** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.******************************************************************************/#include "pluginlist.h"#include <qtopia/qtopiaapplication.h>#include <qtopia/qpluginmanager.h>#include <qtopia/qtopialog.h>#include <qdir.h>#ifdef QT_NO_COMPONENT// Plugins that are compiled in when no plugin architecture available.#include "../../plugins/codecs/wavrecord/wavrecordimpl.h"#endif // QT_NO_COMPONENTMediaRecorderPluginList::MediaRecorderPluginList(){#ifndef QT_NO_COMPONENT    loader = new QPluginManager( "codecs" );    foreach( QString name, loader->list() ) {	MediaRecorderCodecPlugin *plugin = 0;	qDebug() << "querying: " << name;        QObject *obj = loader->instance( name );                if( ( plugin = qobject_cast<MediaRecorderCodecPlugin*>( obj ) ) != 0 ) {            if( plugin->keys().contains( "MediaRecorderCodecPlugin" ) ) {		addFormats( plugin );	    }	}    }    if ( pluginList.count() ) 	qDebug() << pluginList.count() << " encoders found"; // No tr    else	qDebug() << "No encoders found"; // No tr#else    // No component support - load the compiled-in encoders.    loader = 0;    MediaRecorderPluginInterface *iface = new WavRecorderPluginImpl();    addFormats( iface );#endif}MediaRecorderPluginList::~MediaRecorderPluginList(){#ifndef QT_NO_COMPONENT    if ( loader ) {        foreach( MediaRecorderPlugin codec, pluginList ) {	    if ( codec.plugin )		delete codec.plugin;        }	pluginList.clear();	delete loader;	loader = 0;    }#else    pluginList.clear();#endif}MediaRecorderEncoder *MediaRecorderPluginList::fromType( const QString& type, const QString& tag ){    uint numPlugins;    uint plugin;    MediaRecorderEncoder *encoder;    QString format;    numPlugins = count();    for ( plugin = 0; plugin < numPlugins; ++plugin ) {	encoder = pluginList[plugin].encoder;	format = pluginList[plugin].format;	if ( type == encoder->pluginMimeType() && tag == format ) {	    return encoder;	}    }    return 0;}int MediaRecorderPluginList::indexFromType( const QString& type, const QString& tag ){    uint numPlugins;    uint plugin;    MediaRecorderEncoder *encoder;    QString format;    numPlugins = count();    for ( plugin = 0; plugin < numPlugins; ++plugin ) {	encoder = pluginList[plugin].encoder;	format = pluginList[plugin].format;	if ( type == encoder->pluginMimeType() && tag == format ) {	    return (int)plugin;	}    }    return -1;}void MediaRecorderPluginList::addFormats( MediaRecorderCodecPlugin *iface ){    MediaRecorderPlugin plugin;    MediaRecorderEncoder *encoder;    int nformats, format;    encoder = iface->encoder();    nformats = encoder->pluginNumFormats();    for ( format = 0; format < nformats; ++format ) {	plugin.plugin = iface;	plugin.encoder = encoder;	plugin.format = encoder->pluginFormatTag( format );	plugin.formatName = encoder->pluginFormatName( format );	pluginList.append( plugin );        qDebug() << "recorder found for " // No tr	         << plugin.encoder->pluginMimeType()		 << " ["		 << plugin.format		 << "]";	iface = 0;    }}

⌨️ 快捷键说明

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