本文整理汇总了C++中CEncoder类的典型用法代码示例。如果您正苦于以下问题:C++ CEncoder类的具体用法?C++ CEncoder怎么用?C++ CEncoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CEncoder类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CJpegEncoder
CEncoder * CEncoder::CreateEncoder( ECodecId eCodecId, LPCTSTR strName /* = NULL */ )
{
CEncoder *pEec = NULL;
switch( eCodecId )
{
case CODEC_JPEG:
pEec = new CJpegEncoder();
break;
default:
Log() << _T( "Unknown encoder!" ) << eCodecId << endl;
_ASSERT( FALSE );
return 0;
break;
}
BOOL bResult = pEec->Init();
if ( !bResult )
{
Log() << _T( "Encoder init Fail!" ) << endl;
}
_ASSERT( bResult );
if ( !bResult )
{
Release( pEec );
pEec = NULL;
}
RegDec( strName, pEec );
return pEec;
}
示例2: file
bool CCDDARipJob::DoWork()
{
CLog::Log(LOGINFO, "Start ripping track %s to %s", m_input.c_str(),
m_output.c_str());
// if we are ripping to a samba share, rip it to hd first and then copy it it the share
CFileItem file(m_output, false);
if (file.IsRemote())
m_output = SetupTempFile();
if (m_output.empty())
{
CLog::Log(LOGERROR, "CCDDARipper: Error opening file");
return false;
}
// init ripper
CFile reader;
CEncoder* encoder = nullptr;
if (!reader.Open(m_input,READ_CACHED) || !(encoder=SetupEncoder(reader)))
{
CLog::Log(LOGERROR, "Error: CCDDARipper::Init failed");
return false;
}
// setup the progress dialog
CGUIDialogExtendedProgressBar* pDlgProgress =
CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogExtendedProgressBar>(WINDOW_DIALOG_EXT_PROGRESS);
CGUIDialogProgressBarHandle* handle = pDlgProgress->GetHandle(g_localizeStrings.Get(605));
int iTrack = atoi(m_input.substr(13, m_input.size() - 13 - 5).c_str());
std::string strLine0 = StringUtils::Format("%02i. %s - %s", iTrack,
m_tag.GetArtistString().c_str(),
m_tag.GetTitle().c_str());
handle->SetText(strLine0);
// start ripping
int percent=0;
int oldpercent=0;
bool cancelled(false);
int result;
while (!cancelled && (result=RipChunk(reader, encoder, percent)) == 0)
{
cancelled = ShouldCancel(percent,100);
if (percent > oldpercent)
{
oldpercent = percent;
handle->SetPercentage(static_cast<float>(percent));
}
}
// close encoder ripper
encoder->CloseEncode();
delete encoder;
reader.Close();
if (file.IsRemote() && !cancelled && result == 2)
{
// copy the ripped track to the share
if (!CFile::Copy(m_output, file.GetPath()))
{
CLog::Log(LOGERROR, "CDDARipper: Error copying file from %s to %s",
m_output.c_str(), file.GetPath().c_str());
CFile::Delete(m_output);
return false;
}
// delete cached file
CFile::Delete(m_output);
}
if (cancelled)
{
CLog::Log(LOGWARNING, "User Cancelled CDDA Rip");
CFile::Delete(m_output);
}
else if (result == 1)
CLog::Log(LOGERROR, "CDDARipper: Error ripping %s", m_input.c_str());
else if (result < 0)
CLog::Log(LOGERROR, "CDDARipper: Error encoding %s", m_input.c_str());
else
{
CLog::Log(LOGINFO, "Finished ripping %s", m_input.c_str());
if (m_eject)
{
CLog::Log(LOGINFO, "Ejecting CD");
g_mediaManager.EjectTray();
}
}
handle->MarkFinished();
return !cancelled && result == 2;
}
示例3: enc
CEncoder* CCDDARipJob::SetupEncoder(CFile& reader)
{
CEncoder* encoder = nullptr;
const std::string audioEncoder = CServiceBroker::GetSettingsComponent()->GetSettings()->GetString(CSettings::SETTING_AUDIOCDS_ENCODER);
if (audioEncoder == "audioencoder.kodi.builtin.aac" || audioEncoder == "audioencoder.kodi.builtin.wma")
{
std::shared_ptr<IEncoder> enc(new CEncoderFFmpeg());
encoder = new CEncoder(enc);
}
else
{
const BinaryAddonBasePtr addonInfo = CServiceBroker::GetBinaryAddonManager().GetInstalledAddonInfo(audioEncoder, ADDON_AUDIOENCODER);
if (addonInfo)
{
std::shared_ptr<IEncoder> enc = std::make_shared<CAudioEncoder>(addonInfo);
encoder = new CEncoder(enc);
}
}
if (!encoder)
return NULL;
// we have to set the tags before we init the Encoder
const std::string strTrack = StringUtils::Format("%li", strtol(m_input.substr(13, m_input.size() - 13 - 5).c_str(), nullptr, 10));
const std::string itemSeparator = CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_musicItemSeparator;
encoder->SetComment(std::string("Ripped with ") + CSysInfo::GetAppName());
encoder->SetArtist(StringUtils::Join(m_tag.GetArtist(), itemSeparator));
encoder->SetTitle(m_tag.GetTitle());
encoder->SetAlbum(m_tag.GetAlbum());
encoder->SetAlbumArtist(StringUtils::Join(m_tag.GetAlbumArtist(), itemSeparator));
encoder->SetGenre(StringUtils::Join(m_tag.GetGenre(), itemSeparator));
encoder->SetTrack(strTrack);
encoder->SetTrackLength(static_cast<int>(reader.GetLength()));
encoder->SetYear(m_tag.GetYearString());
// init encoder
if (!encoder->Init(m_output.c_str(), m_channels, m_rate, m_bps))
delete encoder, encoder = nullptr;
return encoder;
}
示例4: switch
CEncoder* CCDDARipJob::SetupEncoder(CFile& reader)
{
CEncoder* encoder;
switch (m_encoder)
{
#ifdef HAVE_LIBVORBISENC
case CDDARIP_ENCODER_VORBIS:
encoder = new CEncoderVorbis();
break;
#endif
#ifdef HAVE_LIBMP3LAME
case CDDARIP_ENCODER_LAME:
encoder = new CEncoderLame();
break;
#endif
case CDDARIP_ENCODER_FLAC:
encoder = new CEncoderFlac();
break;
case CDDARIP_ENCODER_FFMPEG_M4A:
case CDDARIP_ENCODER_FFMPEG_WMA:
encoder = new CEncoderFFmpeg();
break;
case CDDARIP_ENCODER_WAV:
default:
encoder = new CEncoderWav();
break;
}
if (!encoder)
return NULL;
// we have to set the tags before we init the Encoder
CStdString strTrack = StringUtils::Format("%i", strtol(m_input.substr(13, m_input.size() - 13 - 5).c_str(),NULL,10));
encoder->SetComment("Ripped with XBMC");
encoder->SetArtist(StringUtils::Join(m_tag.GetArtist(),
g_advancedSettings.m_musicItemSeparator));
encoder->SetTitle(m_tag.GetTitle());
encoder->SetAlbum(m_tag.GetAlbum());
encoder->SetAlbumArtist(StringUtils::Join(m_tag.GetAlbumArtist(),
g_advancedSettings.m_musicItemSeparator));
encoder->SetGenre(StringUtils::Join(m_tag.GetGenre(),
g_advancedSettings.m_musicItemSeparator));
encoder->SetTrack(strTrack);
encoder->SetTrackLength(static_cast<int>(reader.GetLength()));
encoder->SetYear(m_tag.GetYearString());
// init encoder
if (!encoder->Init(m_output.c_str(), m_channels, m_rate, m_bps))
delete encoder, encoder = NULL;
return encoder;
}
示例5: enc
CEncoder* CCDDARipJob::SetupEncoder(CFile& reader)
{
CEncoder* encoder;
if (CSettings::Get().GetString("audiocds.encoder") == "audioencoder.xbmc.builtin.wav")
{
boost::shared_ptr<IEncoder> enc(new CEncoderWav());
encoder = new CEncoder(enc);
}
else if (CSettings::Get().GetString("audiocds.encoder") == "audioencoder.xbmc.builtin.aac" ||
CSettings::Get().GetString("audiocds.encoder") == "audioencoder.xbmc.builtin.wma")
{
encoder = new CEncoderFFmpeg();
}
else
{
AddonPtr addon;
CAddonMgr::Get().GetAddon(CSettings::Get().GetString("audiocds.encoder"), addon);
if (addon)
{
boost::shared_ptr<CAudioEncoder> aud = boost::static_pointer_cast<CAudioEncoder>(addon);
aud->Create();
boost::shared_ptr<IEncoder> enc = boost::static_pointer_cast<IEncoder>(aud);
encoder = new CEncoder(enc);
}
}
if (!encoder)
return NULL;
// we have to set the tags before we init the Encoder
CStdString strTrack = StringUtils::Format("%i", strtol(m_input.substr(13, m_input.size() - 13 - 5).c_str(),NULL,10));
encoder->SetComment("Ripped with XBMC");
encoder->SetArtist(StringUtils::Join(m_tag.GetArtist(),
g_advancedSettings.m_musicItemSeparator));
encoder->SetTitle(m_tag.GetTitle());
encoder->SetAlbum(m_tag.GetAlbum());
encoder->SetAlbumArtist(StringUtils::Join(m_tag.GetAlbumArtist(),
g_advancedSettings.m_musicItemSeparator));
encoder->SetGenre(StringUtils::Join(m_tag.GetGenre(),
g_advancedSettings.m_musicItemSeparator));
encoder->SetTrack(strTrack);
encoder->SetTrackLength(static_cast<int>(reader.GetLength()));
encoder->SetYear(m_tag.GetYearString());
// init encoder
if (!encoder->Init(m_output.c_str(), m_channels, m_rate, m_bps))
delete encoder, encoder = NULL;
return encoder;
}
示例6: enc
CEncoder* CCDDARipJob::SetupEncoder(CFile& reader)
{
CEncoder* encoder = NULL;
if (CServiceBroker::GetSettings().GetString(CSettings::SETTING_AUDIOCDS_ENCODER) == "audioencoder.xbmc.builtin.aac" ||
CServiceBroker::GetSettings().GetString(CSettings::SETTING_AUDIOCDS_ENCODER) == "audioencoder.xbmc.builtin.wma")
{
std::shared_ptr<IEncoder> enc(new CEncoderFFmpeg());
encoder = new CEncoder(enc);
}
else
{
AddonPtr addon;
CAddonMgr::GetInstance().GetAddon(CServiceBroker::GetSettings().GetString(CSettings::SETTING_AUDIOCDS_ENCODER), addon);
if (addon)
{
std::shared_ptr<CAudioEncoder> aud = std::static_pointer_cast<CAudioEncoder>(addon);
aud->Create();
std::shared_ptr<IEncoder> enc = std::static_pointer_cast<IEncoder>(aud);
encoder = new CEncoder(enc);
}
}
if (!encoder)
return NULL;
// we have to set the tags before we init the Encoder
std::string strTrack = StringUtils::Format("%li", strtol(m_input.substr(13, m_input.size() - 13 - 5).c_str(),NULL,10));
encoder->SetComment(std::string("Ripped with ") + CSysInfo::GetAppName());
encoder->SetArtist(StringUtils::Join(m_tag.GetArtist(),
g_advancedSettings.m_musicItemSeparator));
encoder->SetTitle(m_tag.GetTitle());
encoder->SetAlbum(m_tag.GetAlbum());
encoder->SetAlbumArtist(StringUtils::Join(m_tag.GetAlbumArtist(),
g_advancedSettings.m_musicItemSeparator));
encoder->SetGenre(StringUtils::Join(m_tag.GetGenre(),
g_advancedSettings.m_musicItemSeparator));
encoder->SetTrack(strTrack);
encoder->SetTrackLength(static_cast<int>(reader.GetLength()));
encoder->SetYear(m_tag.GetYearString());
// init encoder
if (!encoder->Init(m_output.c_str(), m_channels, m_rate, m_bps))
delete encoder, encoder = NULL;
return encoder;
}
示例7: file
bool CCDDARipJob::DoWork()
{
CLog::Log(LOGINFO, "Start ripping track %s to %s", m_input.c_str(),
m_output.c_str());
// if we are ripping to a samba share, rip it to hd first and then copy it it the share
CFileItem file(m_output, false);
if (file.IsRemote())
m_output = SetupTempFile();
if (m_output.IsEmpty())
{
CLog::Log(LOGERROR, "CCDDARipper: Error opening file");
return false;
}
// init ripper
CFile reader;
CEncoder* encoder;
if (!reader.Open(m_input,READ_CACHED) || !(encoder=SetupEncoder(reader)))
{
CLog::Log(LOGERROR, "Error: CCDDARipper::Init failed");
return false;
}
// setup the progress dialog
CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
CStdString strLine0, strLine1;
int iTrack = atoi(m_input.substr(13, m_input.size() - 13 - 5).c_str());
strLine0.Format("%s %i", g_localizeStrings.Get(606).c_str(), iTrack); // Track Number: %i
strLine1.Format("%s %s", g_localizeStrings.Get(607).c_str(), m_output.c_str()); // To: %s
pDlgProgress->SetHeading(605); // Ripping
pDlgProgress->SetLine(0, strLine0);
pDlgProgress->SetLine(1, strLine1);
pDlgProgress->SetLine(2, "");
pDlgProgress->StartModal();
pDlgProgress->ShowProgressBar(true);
// show progress dialog
pDlgProgress->Progress();
// start ripping
int percent=0;
int oldpercent=0;
bool cancelled(false);
int result;
while (!cancelled && (result=RipChunk(reader, encoder, percent)) == 0)
{
cancelled = ShouldCancel(percent,100);
cancelled |= pDlgProgress->IsCanceled();
if (percent > oldpercent)
{
oldpercent = percent;
pDlgProgress->SetPercentage(percent);
pDlgProgress->Progress();
}
}
pDlgProgress->Close();
// close encoder ripper
encoder->Close();
delete encoder;
reader.Close();
if (file.IsRemote() && !cancelled && result == 2)
{
// copy the ripped track to the share
if (!CFile::Cache(m_output, file.GetPath()))
{
CLog::Log(LOGERROR, "CDDARipper: Error copying file from %s to %s",
m_output.c_str(), file.GetPath().c_str());
CFile::Delete(m_output);
return false;
}
// delete cached file
CFile::Delete(m_output);
}
if (cancelled)
{
CLog::Log(LOGWARNING, "User Cancelled CDDA Rip");
CFile::Delete(m_output);
}
else if (result == 1)
CLog::Log(LOGERROR, "CDDARipper: Error ripping %s", m_input.c_str());
else if (result < 0)
CLog::Log(LOGERROR, "CDDARipper: Error encoding %s", m_input.c_str());
else
{
CLog::Log(LOGINFO, "Finished ripping %s", m_input.c_str());
if (m_eject)
{
CLog::Log(LOGINFO, "Ejecting CD");
g_mediaManager.EjectTray();
}
}
return !cancelled && result == 2;
}
示例8: TradeOrder
bool CCESUT::TradeOrder(PTradeOrderTxnInput pTxnInput,
INT32 iTradeType, bool bExecutorIsAccountOwner) {
ei_x_buff x;
ei_x_new_with_version(&x);
ei_x_encode_tuple_header(&x, 2);
{
ei_x_encode_atom(&x, "ok");
ei_x_encode_tuple_header(&x, 2);
{
ei_x_encode_atom(&x, APP ".BH.TO");
ei_x_encode_tuple_header(&x, 3);
{
m_Encoder.encode(&x, "trade_type", iTradeType);
m_Encoder.encode(&x, "executor_is_account_owner", bExecutorIsAccountOwner);
m_Encoder.encode(&x, *pTxnInput);
}
}
}
int result = driver_output(m_ErlDrvPort, x.buff, x.index);
#ifdef _TRACE
cout << "[TO] ! " << *pTxnInput << ", result=" << result << '\r' << endl;
#endif
ei_x_free(&x);
return result;
}
示例9: TradeCleanup
bool CDMSUT::TradeCleanup(PTradeCleanupTxnInput pTxnInput) {
ei_x_buff x;
ei_x_new_with_version(&x);
ei_x_encode_tuple_header(&x, 2);
{
ei_x_encode_atom(&x, "ok");
ei_x_encode_tuple_header(&x, 2);
{
ei_x_encode_atom(&x, APP ".BH.TC");
m_Encoder.encode(&x, *pTxnInput);
}
}
int result = driver_output(m_ErlDrvPort, x.buff, x.index);
#ifdef _TRACE
cout << "[TC] ! " << *pTxnInput << ", result=" << result << '\r' << endl;
#endif
ei_x_free(&x);
return result;
}
示例10: MarketWatch
bool CCESUT::MarketWatch(PMarketWatchTxnInput pTxnInput) {
ei_x_buff x;
ei_x_new_with_version(&x);
ei_x_encode_tuple_header(&x, 2);
{
ei_x_encode_atom(&x, "ok");
ei_x_encode_tuple_header(&x, 2);
{
ei_x_encode_atom(&x, APP ".BH.MW");
m_Encoder.encode(&x, *pTxnInput);
}
}
int result = driver_output(m_ErlDrvPort, x.buff, x.index);
#ifdef _TRACE
cout << "[MW] ! " << *pTxnInput << ", result=" << result << '\r' << endl;
#endif
ei_x_free(&x);
return result;
}