本文整理汇总了C++中Metadata类的典型用法代码示例。如果您正苦于以下问题:C++ Metadata类的具体用法?C++ Metadata怎么用?C++ Metadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Metadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VERBOSE
void Playlist::savePlaylist(QString a_name, QString a_host)
{
name = a_name.simplified();
if (name.length() < 1)
{
VERBOSE(VB_GENERAL, LOC_WARN +
"Not saving unnamed playlist");
return;
}
if (a_host.length() < 1)
{
VERBOSE(VB_GENERAL, LOC_WARN +
"Not saving playlist without a host name");
return;
}
if (name.length() < 1)
return;
fillSonglistFromSongs();
MSqlQuery query(MSqlQuery::InitCon());
int length = 0, songcount = 0, playtime = 0, an_int;
QStringList list = raw_songlist.split(",", QString::SkipEmptyParts);
QStringList::iterator it = list.begin();
for (; it != list.end(); it++)
{
an_int = QString(*it).toInt();
if (an_int != 0)
{
songcount++;
if (an_int > 0)
{
Metadata *md = all_available_music->getMetadata(an_int);
if (md)
length = md->Length();
}
else
{
query.prepare("SELECT length FROM music_playlists "
"WHERE playlist_id = :ID ;");
an_int *= -1;
query.bindValue(":ID", an_int);
if (query.exec() && query.next())
{
length = query.value(0).toInt();
}
}
playtime += length;
}
}
bool save_host = ("default_playlist_storage" == a_name
|| "backup_playlist_storage" == a_name);
if (playlistid > 0)
{
QString str_query = "UPDATE music_playlists SET "
"playlist_songs = :LIST, "
"playlist_name = :NAME, "
"songcount = :SONGCOUNT, "
"length = :PLAYTIME";
if (save_host)
str_query += ", hostname = :HOSTNAME";
str_query += " WHERE playlist_id = :ID ;";
query.prepare(str_query);
query.bindValue(":ID", playlistid);
}
else
{
QString str_query = "INSERT INTO music_playlists"
" (playlist_name, playlist_songs,"
" songcount, length";
if (save_host)
str_query += ", hostname";
str_query += ") VALUES(:NAME, :LIST, :SONGCOUNT, :PLAYTIME";
if (save_host)
str_query += ", :HOSTNAME";
str_query += ");";
query.prepare(str_query);
}
query.bindValue(":LIST", raw_songlist);
query.bindValue(":NAME", a_name);
query.bindValue(":SONGCOUNT", songcount);
query.bindValue(":PLAYTIME", playtime);
if (save_host)
query.bindValue(":HOSTNAME", a_host);
if (!query.exec() || (playlistid < 1 && query.numRowsAffected() < 1))
{
MythDB::DBError("Problem saving playlist", query);
}
if (playlistid < 1)
playlistid = query.lastInsertId().toInt();
}
示例2: query
// NOTE we don't clear the existing tracks just load any new ones found in the DB
// maybe we should also check for any removed tracks?
void AllMusic::resync()
{
m_done_loading = false;
QString aquery = "SELECT music_songs.song_id, music_artists.artist_id, music_artists.artist_name, "
"music_comp_artists.artist_name AS compilation_artist, "
"music_albums.album_id, music_albums.album_name, music_songs.name, music_genres.genre, music_songs.year, "
"music_songs.track, music_songs.length, music_songs.directory_id, "
"CONCAT_WS('/', music_directories.path, music_songs.filename) AS filename, "
"music_songs.rating, music_songs.numplays, music_songs.lastplay, music_songs.date_entered, "
"music_albums.compilation, music_songs.format, music_songs.track_count "
"FROM music_songs "
"LEFT JOIN music_directories ON music_songs.directory_id=music_directories.directory_id "
"LEFT JOIN music_artists ON music_songs.artist_id=music_artists.artist_id "
"LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
"LEFT JOIN music_artists AS music_comp_artists ON music_albums.artist_id=music_comp_artists.artist_id "
"LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
"ORDER BY music_songs.song_id;";
QString filename, artist, album, title, compartist;
MSqlQuery query(MSqlQuery::InitCon());
if (!query.exec(aquery))
MythDB::DBError("AllMusic::resync", query);
m_numPcs = query.size() * 2;
m_numLoaded = 0;
if (query.isActive() && query.size() > 0)
{
while (query.next())
{
int id = query.value(0).toInt();
if (!music_map.contains(id))
{
filename = query.value(12).toString();
Metadata *mdata = new Metadata(
filename,
query.value(2).toString(), // artist
query.value(3).toString(), // compilation artist
query.value(5).toString(), // album
query.value(6).toString(), // title
query.value(7).toString(), // genre
query.value(8).toInt(), // year
query.value(9).toInt(), // track no.
query.value(10).toInt(), // length
query.value(0).toInt(), // id
query.value(13).toInt(), // rating
query.value(14).toInt(), // playcount
query.value(15).toDateTime(), // lastplay
query.value(16).toDateTime(), // date_entered
(query.value(17).toInt() > 0), // compilation
query.value(18).toString()); // format
mdata->setDirectoryId(query.value(11).toInt());
mdata->setArtistId(query.value(1).toInt());
mdata->setAlbumId(query.value(4).toInt());
mdata->setTrackCount(query.value(19).toInt());
// Don't delete mdata, as PtrList now owns it
m_all_music.append(mdata);
music_map[id] = mdata;
}
// compute max/min playcount,lastplay for all music
if (query.at() == 0)
{
// first song
m_playcountMin = m_playcountMax = query.value(13).toInt();
m_lastplayMin = m_lastplayMax = query.value(14).toDateTime().toTime_t();
}
else
{
int playCount = query.value(13).toInt();
double lastPlay = query.value(14).toDateTime().toTime_t();
m_playcountMin = min(playCount, m_playcountMin);
m_playcountMax = max(playCount, m_playcountMax);
m_lastplayMin = min(lastPlay, m_lastplayMin);
m_lastplayMax = max(lastPlay, m_lastplayMax);
}
m_numLoaded++;
}
}
else
{
LOG(VB_GENERAL, LOG_ERR, "MythMusic hasn't found any tracks! "
"That's ok with me if it's ok with you.");
}
m_done_loading = true;
}
示例3: LOG
int Playlist::CreateCDMP3(void)
{
// Check & get global settings
if (!gCoreContext->GetNumSetting("CDWriterEnabled"))
{
LOG(VB_GENERAL, LOG_ERR, "CD Writer is not enabled.");
return 1;
}
QString scsidev = MediaMonitor::defaultCDWriter();
if (scsidev.isEmpty())
{
LOG(VB_GENERAL, LOG_ERR, "No CD Writer device defined.");
return 1;
}
int disksize = gCoreContext->GetNumSetting("CDDiskSize", 2);
QString writespeed = gCoreContext->GetSetting("CDWriteSpeed", "2");
bool MP3_dir_flag = gCoreContext->GetNumSetting("CDCreateDir", 1);
double size_in_MB = 0.0;
QStringList reclist;
SongList::const_iterator it = songs.begin();
for (; it != songs.end(); ++it)
{
if ((*it)->getCDFlag())
continue;
if ((*it)->getValue() == 0)
{
LOG(VB_GENERAL, LOG_ERR, kID0err);
}
else if ((*it)->getValue() > 0)
{
// Normal track
Metadata *tmpdata =
all_available_music->getMetadata((*it)->getValue());
if (tmpdata)
{
// check filename..
QFileInfo testit(tmpdata->Filename());
if (!testit.exists())
continue;
size_in_MB += testit.size() / 1000000.0;
QString outline;
if (MP3_dir_flag)
{
if (tmpdata->Artist().length() > 0)
outline += tmpdata->Artist() + "/";
if (tmpdata->Album().length() > 0)
outline += tmpdata->Album() + "/";
}
outline += "=";
outline += tmpdata->Filename();
reclist += outline;
}
}
else if ((*it)->getValue() < 0)
{
// FIXME: handle playlists
}
}
int max_size;
if (disksize == 0)
max_size = 650;
else
max_size = 700;
if (size_in_MB >= max_size)
{
LOG(VB_GENERAL, LOG_ERR, "MP3 CD creation aborted -- cd size too big.");
return 1;
}
// probably should tie stdout of mkisofs to stdin of cdrecord sometime
QString tmptemplate("/tmp/mythmusicXXXXXX");
QString tmprecordlist = createTempFile(tmptemplate);
if (tmprecordlist == tmptemplate)
{
LOG(VB_GENERAL, LOG_ERR, "Unable to open temporary file");
return 1;
}
QString tmprecordisofs = createTempFile(tmptemplate);
if (tmprecordisofs == tmptemplate)
{
LOG(VB_GENERAL, LOG_ERR, "Unable to open temporary file");
return 1;
}
QFile reclistfile(tmprecordlist);
if (!reclistfile.open(QIODevice::WriteOnly))
{
//.........这里部分代码省略.........
示例4: if
void RequestThread::run(threaded_process_status &p_status, abort_callback &p_abort) {
Metadata *metadata = nullptr;
try {
metadata = query->perform(p_abort);
// Extracting releases from 3 possible locations
// /metadata/release
if (auto release = metadata->extract_release()) {
mbc->add(release);
// /metadata/discid/release-list/release
} else if (auto discid = metadata->get_discid()) {
if (auto release_list = discid->get_release_list()) {
auto id = discid->get_id();
auto count = release_list->count();
for (size_t i = 0; i < count; i++) {
auto release = release_list->extract(0);
// FIXME: this is incorrect, as only one of the discs has
// this discid, but it won't affect anyone (release must
// have two or more discs with the same amount of tracks,
// and user must choose the wrong one). Will be fixed when
// web service adds support for inc=discids param.
for (size_t i = 0; i < release->medium_count(); i++) {
release->get_medium(i)->set_discid(id);
}
mbc->add(release);
}
}
// /metadata/release-list/release
} else if (auto release_list = metadata->get_release_list()) {
auto count = release_list->count();
for (size_t i = 0; i < count; i++) {
release = release_list->get(i);
// Progress and title
p_status.set_progress(i + 1, count + 1);
pfc::string8 title = "Fetching: ";
title << release->get_artist_credit()->get_name() << " - " << release->get_title();
auto date = release->get_date();
if (date.get_year() != 0) {
title << " (" << static_cast<pfc::string8>(date) << ")";
}
p_status.set_title(title);
Query query("release", release->get_id());
query.add_param("inc", "artists+labels+recordings+release-groups+artist-credits", false);
auto release = query.perform(p_abort)->extract_release();
if (release != nullptr) {
mbc->add(release);
}
}
}
// Removing discs from multidisc releases with different track count
auto track_count = tracks->get_count();
for (size_t i = 0; i < mbc->count(); i++) {
auto release = mbc->get(i);
if (release->track_count() == track_count) continue;
for (size_t j = 0; j < release->medium_count(); j++) {
if (release->get_medium(j)->track_count() != track_count) {
release->remove_medium(j);
j--;
}
}
if (release->medium_count() == 0) {
mbc->remove(i);
i--;
}
}
if (mbc->count() == 0) {
throw NotFound();
}
MetadataProcessor::apply_all(*mbc);
mbc->sort();
ShowWindow(window, SW_SHOW);
} catch (GenericException e) {
PostMessage(window, WM_CLOSE, 0, 0);
popup_message::g_show(e.what(), COMPONENT_TITLE, popup_message::icon_error);
} catch (...) {
PostMessage(window, WM_CLOSE, 0, 0);
delete metadata;
delete query;
throw;
}
delete metadata;
delete query;
}
示例5: getFilename
//virtual
Metadata *CdDecoder::getMetadata()
{
QString artist, album, compilation_artist, title, genre;
int year = 0;
unsigned long length = 0;
track_t tracknum = 0;
if (-1 == m_settracknum)
tracknum = getFilename().toUInt();
else
{
tracknum = m_settracknum;
setFilename(QString("%1" CDEXT).arg(tracknum));
}
QMutexLocker lock(&getCdioMutex());
StCdioDevice cdio(m_devicename);
if (!cdio)
return NULL;
const track_t lastTrack = cdio_get_last_track_num(cdio);
if (CDIO_INVALID_TRACK == lastTrack)
return NULL;
if (TRACK_FORMAT_AUDIO != cdio_get_track_format(cdio, tracknum))
return NULL;
// Assume disc changed if max LSN different
bool isDiscChanged = false;
static lsn_t s_totalSectors;
lsn_t totalSectors = cdio_get_track_lsn(cdio, CDIO_CDROM_LEADOUT_TRACK);
if (s_totalSectors != totalSectors)
{
s_totalSectors = totalSectors;
isDiscChanged = true;
}
// NB cdio_get_track_last_lsn is unreliable for the last audio track
// of discs with data tracks beyond
lsn_t end = cdio_get_track_last_lsn(cdio, tracknum);
if (isDiscChanged)
{
const track_t audioTracks = getNumCDAudioTracks();
s_lastAudioLsn = cdio_get_track_last_lsn(cdio, audioTracks);
if (audioTracks < lastTrack)
{
cdrom_drive_t *dev = cdio_cddap_identify_cdio(cdio, 0, NULL);
if (NULL != dev)
{
if (DRIVER_OP_SUCCESS == cdio_cddap_open(dev))
{
// NB this can be S L O W but is reliable
lsn_t end2 = cdio_cddap_track_lastsector(dev,
getNumCDAudioTracks());
if (CDIO_INVALID_LSN != end2)
s_lastAudioLsn = end2;
}
cdio_cddap_close_no_free_cdio(dev);
}
}
}
if (s_lastAudioLsn && s_lastAudioLsn < end)
end = s_lastAudioLsn;
const lsn_t start = cdio_get_track_lsn(cdio, tracknum);
if (CDIO_INVALID_LSN != start && CDIO_INVALID_LSN != end)
{
length = ((end - start + 1) * 1000 + CDIO_CD_FRAMES_PER_SEC/2) /
CDIO_CD_FRAMES_PER_SEC;
}
bool isCompilation = false;
#define CDTEXT 0 // Disabled - cd-text access on discs without it is S L O W
#if CDTEXT
static int s_iCdtext;
if (isDiscChanged)
s_iCdtext = -1;
if (s_iCdtext)
{
// cdio_get_cdtext can't take >5 seconds on some CD's without cdtext
if (s_iCdtext < 0)
LOG(VB_MEDIA, LOG_INFO,
QString("Getting cdtext for track %1...").arg(tracknum));
cdtext_t * cdtext = cdio_get_cdtext(m_cdio, tracknum);
if (NULL != cdtext)
{
genre = cdtext_get_const(CDTEXT_GENRE, cdtext);
artist = cdtext_get_const(CDTEXT_PERFORMER, cdtext);
title = cdtext_get_const(CDTEXT_TITLE, cdtext);
const char* isrc = cdtext_get_const(CDTEXT_ISRC, cdtext);
/* ISRC codes are 12 characters long, in the form CCXXXYYNNNNN
* CC = country code
* XXX = registrant e.g. BMG
* CC = year withou century
//.........这里部分代码省略.........
示例6: query
void SearchView::updateTracksList(void)
{
m_tracksList->Reset();
MythUIButtonListItem *item = m_fieldList->GetItemCurrent();
if (!item)
return;
QString searchStr = m_criteriaEdit->GetText();
int field = item->GetData().toInt();
QString sql;
MSqlQuery query(MSqlQuery::InitCon());
if (searchStr.isEmpty())
{
sql = "SELECT song_id "
"FROM music_songs ";
query.prepare(sql);
}
else
{
switch(field)
{
case 1: // artist
{
sql = "SELECT song_id "
"FROM music_songs "
"LEFT JOIN music_artists ON "
" music_songs.artist_id=music_artists.artist_id "
"WHERE music_artists.artist_name LIKE '%" + searchStr + "%' ";
query.prepare(sql);
break;
}
case 2: // album
{
sql = "SELECT song_id "
"FROM music_songs "
"LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
"WHERE music_albums.album_name LIKE '%" + searchStr + "%' ";
query.prepare(sql);
break;
}
case 3: // title
{
sql = "SELECT song_id "
"FROM music_songs "
"WHERE music_songs.name LIKE '%" + searchStr + "%' ";
query.prepare(sql);
break;
}
case 4: // genre
{
sql = "SELECT song_id "
"FROM music_songs "
"LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
"WHERE music_genres.genre LIKE '%" + searchStr + "%' ";
query.prepare(sql);
break;
}
case 5: // tags
{
//TODO add tag query
}
case 0: // all fields
default:
{
sql = "SELECT song_id "
"FROM music_songs "
"LEFT JOIN music_artists ON "
" music_songs.artist_id=music_artists.artist_id "
"LEFT JOIN music_albums ON music_songs.album_id=music_albums.album_id "
"LEFT JOIN music_artists AS music_comp_artists ON "
" music_albums.artist_id=music_comp_artists.artist_id "
"LEFT JOIN music_genres ON music_songs.genre_id=music_genres.genre_id "
"WHERE music_songs.name LIKE '%" + searchStr + "%' "
"OR music_artists.artist_name LIKE '%" + searchStr + "%' "
"OR music_albums.album_name LIKE '%" + searchStr + "%' "
"OR music_genres.genre LIKE '%" + searchStr + "%' ";
query.prepare(sql);
}
}
}
if (!query.exec() || !query.isActive())
{
MythDB::DBError("Search music database", query);
return;
}
while (query.next())
{
int trackid = query.value(0).toInt();
Metadata *mdata = gMusicData->all_music->getMetadata(trackid);
if (mdata)
{
//.........这里部分代码省略.........
示例7: getKnapsackOptimizer
// CBMEN, HL, Begin
void
CacheStrategyUtility::_handleGetCacheStrategyAsMetadata(Metadata *m)
{
Metadata *dm = m->addMetadata("CacheStrategyUtility");
if (!dm) {
return;
}
dm->setParameter("knapsack_optimizer", getKnapsackOptimizer()->getName());
dm->setParameter("global_optimizer", getGlobalOptimizer()->getPrettyName());
dm->setParameter("utility_function", getUtilityFunction()->getPrettyName());
dm->setParameter("utility_compute_period_ms", computePeriodMs);
dm->setParameter("poll_period_ms", pollPeriodMs);
dm->setParameter("event_based_purging", purgeOnInsert ? "enabled" : "disabled");
dm->setParameter("keep_in_bloomfilter", keep_in_bloomfilter ? "enabled" : "disabled");
dm->setParameter("bloomfilter_remove_delay_ms", bloomfilter_remove_delay_ms);
dm->setParameter("handle_zero_size", handle_zero_size ? "enabled" : "disabled");
dm->setParameter("manage_only_remote_files", manage_only_remote_files ? "enabled" : "disabled");
dm->setParameter("manage_locally_sent_files", manage_locally_sent_files ? "enabled" : "disabled");
dm->setParameter("allow_db_purging", allow_db_purging ? "enabled" : "disabled");
dm->setParameter("db_size_threshold", db_size_threshold);
dm->setParameter("current_size_kb", current_size / (long long) 1024);
dm->setParameter("max_capacity_kb", max_capacity_kb);
dm->setParameter("current_capacity_ratio", 100*current_size/((double)max_capacity_kb * 1024));
dm->setParameter("watermark_capacity_kb", watermark_capacity_kb);
dm->setParameter("watermark_capacity_ratio", 100*current_size/((double)watermark_capacity_kb * 1024));
dm->setParameter("current_num_do", current_num_do);
dm->setParameter("total_db_evicted", total_db_evicted);
dm->setParameter("current_dupe_do_recv", current_dupe_do_recv);
dm->setParameter("current_drop_on_insert", current_drop_on_insert);
dm->setParameter("total_do_inserted", total_do_inserted);
dm->setParameter("total_do_inserted_bytes", total_do_inserted_bytes);
dm->setParameter("total_do_evicted", total_do_evicted);
dm->setParameter("total_do_evicted_bytes", total_do_evicted_bytes);
dm->setParameter("total_do_hard_evicted", total_do_hard_evicted);
dm->setParameter("total_do_hard_evicted_bytes", total_do_hard_evicted_bytes);
PrintHelperHeapItem::PrinterHelperType_t types[] = {PrintHelperHeapItem::HIGH_UTIL, PrintHelperHeapItem::LOW_UTIL, PrintHelperHeapItem::HIGH_COST, PrintHelperHeapItem::OLD_CREATION};
string names[] = {"Top10Utility", "Bottom10Utility", "Top10Largest", "Top10Oldest"};
do_util_metadata_list_t metadata_list;
for (size_t i = 0; i < 4; i++)
{
Metadata *dmm = dm->addMetadata(names[i]);
if (!dmm) {
continue;
}
PrintHelperHeapItem::getTopKHelper(10, types[i], utilMetadata, &metadata_list);
for (do_util_metadata_list_t::iterator it = metadata_list.begin(); it != metadata_list.end(); it++) {
Metadata *dmmm = dmm->addMetadata("DataObject");
if (!dmmm) {
break;
}
DataObjectUtilityMetadata *do_metadata = *it;
dmmm->setParameter("id", do_metadata->getId());
dmmm->setParameter("create_time", do_metadata->getCreateTime().getAsString());
dmmm->setParameter("computed_time", do_metadata->getComputedTime().getAsString());
dmmm->setParameter("cost", do_metadata->getCost());
dmmm->setParameter("utility", do_metadata->getUtility());
}
metadata_list.clear();
}
kernel->addEvent(new Event(EVENT_TYPE_SEND_OBSERVER_DATAOBJECT, m->copy()));
}
示例8: HAGGLE_ERR
void
CacheStrategyUtility::_onConfig(
const Metadata& m)
{
const char *param;
const Metadata *dm;
if (m.getName() != getName()) {
HAGGLE_ERR("Wrong config.\n");
return;
}
// load knapsack optimizer
param = m.getParameter("knapsack_optimizer");
if (!param) {
HAGGLE_DBG("No knapsack optimizer specified, using default.\n");
ksOptimizer = CacheKnapsackOptimizerFactory::getNewKnapsackOptimizer(getManager()->getKernel());
}
else {
ksOptimizer = CacheKnapsackOptimizerFactory::getNewKnapsackOptimizer(getManager()->getKernel(), param);
}
if (!ksOptimizer) {
HAGGLE_ERR("Could not initialize knapsack optimizer.\n");
return;
}
dm = m.getMetadata(param);
if (dm) {
ksOptimizer->onConfig(*dm);
}
// load global optimizer
param = m.getParameter("global_optimizer");
if (!param) {
HAGGLE_DBG("No specified, using default.\n");
globalOptimizer = CacheGlobalOptimizerFactory::getNewGlobalOptimizer(getManager()->getKernel());
}
else {
globalOptimizer = CacheGlobalOptimizerFactory::getNewGlobalOptimizer(getManager()->getKernel(), param);
}
if (!globalOptimizer) {
HAGGLE_ERR("Could not initialize global optimizer.\n");
return;
}
dm = m.getMetadata(param);
if (dm) {
globalOptimizer->onConfig(*dm);
}
// load utility function
param = m.getParameter("utility_function");
if (!param) {
HAGGLE_DBG("No utility function specified, using default.\n");
utilFunction = CacheUtilityFunctionFactory::getNewUtilityFunction(getManager(), globalOptimizer);
}
else {
utilFunction = CacheUtilityFunctionFactory::getNewUtilityFunction(getManager(), globalOptimizer, param);
}
if (!utilFunction) {
HAGGLE_ERR("Could not initialize utility function.\n");
return;
}
dm = m.getMetadata(param);
if (dm) {
utilFunction->onConfig(*dm);
}
param = m.getParameter("max_capacity_kb");
if (!param) {
HAGGLE_ERR("No maximum capacity specified\n");
return;
}
max_capacity_kb = atoi(param);
if (max_capacity_kb < 0) {
HAGGLE_ERR("Invalid max capacity.\n");
return;
}
param = m.getParameter("watermark_capacity_kb");
if (!param) {
HAGGLE_ERR("No watermark capacity specified\n");
return;
}
watermark_capacity_kb = atoi(param);
if ((watermark_capacity_kb < 0) || (watermark_capacity_kb > max_capacity_kb)) {
HAGGLE_ERR("Invalid watermark capacity.\n");
return;
//.........这里部分代码省略.........
示例9: HAGGLE_DBG
void DataManager::onConfig(Metadata *m)
{
bool agingHasChanged = false;
const char *param = m->getParameter("set_createtime_on_bloomfilter_update");
if (param) {
if (strcmp(param, "true") == 0) {
setCreateTimeOnBloomfilterUpdate = true;
HAGGLE_DBG("setCreateTimeOnBloomfilterUpdate set to 'true'\n");
}
else if (strcmp(param, "false") == 0) {
setCreateTimeOnBloomfilterUpdate = false;
HAGGLE_DBG("setCreateTimeOnBloomfilterUpdate set to 'false'\n");
}
}
// MOS
param = m->getParameter("periodic_bloomfilter_update_interval");
if (param) {
char *endptr = NULL;
unsigned long period = strtoul(param, &endptr, 10);
if (endptr && endptr != param) {
if (periodicBloomfilterUpdateInterval == 0 &&
period > 0 &&
!periodicBloomfilterUpdateEvent->isScheduled()) {
kernel->addEvent(new Event(periodicBloomfilterUpdateCallback, NULL));
}
periodicBloomfilterUpdateInterval = period;
HAGGLE_DBG("periodic_bloomfilter_update_interval=%lu\n",
periodicBloomfilterUpdateInterval);
}
}
// MOS - experimental setting
param = m->getParameter("node_desc_update_on_reception");
if (param) {
if (strcmp(param, "true") == 0) {
isNodeDescUpdateOnReceptionEnabled = true;
HAGGLE_DBG("node_desc_update_on_reception set to 'true'\n");
}
else if (strcmp(param, "false") == 0) {
isNodeDescUpdateOnReceptionEnabled = false;
HAGGLE_DBG("node_desc_update_on_reception set to 'false'\n");
}
}
Metadata *dm = m->getMetadata("Bloomfilter");
if (dm) {
bool reset_bloomfilter = false;
const char *param = dm->getParameter("default_error_rate");
if (param) {
char *endptr = NULL;
double error_rate = strtod(param, &endptr);
if (endptr && endptr != param) {
Bloomfilter::setDefaultErrorRate(error_rate);
HAGGLE_DBG("config default bloomfilter error rate %.3lf\n",
Bloomfilter::getDefaultErrorRate());
reset_bloomfilter = true;
}
}
param = dm->getParameter("default_capacity");
if (param) {
char *endptr = NULL;
unsigned int capacity = (unsigned int)strtoul(param, &endptr, 10);
if (endptr && endptr != param) {
Bloomfilter::setDefaultCapacity(capacity);
HAGGLE_DBG("config default bloomfilter capacity %u\n",
Bloomfilter::getDefaultCapacity());
reset_bloomfilter = true;
}
}
if (reset_bloomfilter) {
if (localBF)
delete localBF;
localBF = Bloomfilter::create(Bloomfilter::TYPE_COUNTING);
if (!localBF) {
HAGGLE_ERR("Could not create data manager bloomfilter\n");
}
}
}
// Database timeout configuration
// Set default to 1.5 sec
max_wait.tv_sec = 1;
max_wait.tv_usec = 500000;
// Set default to true
//.........这里部分代码省略.........
示例10: InsertImage
int CoreCallback::InsertImage(const MM::Device* caller, const unsigned char* buf, unsigned width, unsigned height, unsigned byteDepth, const char* serializedMetadata, const bool doProcess)
{
Metadata md;
md.Restore(serializedMetadata);
return InsertImage(caller, buf, width, height, byteDepth, &md, doProcess);
}
示例11: if
void PosixUtils::metadataToPosixMode ( const Metadata& md, mode_t& mode )
{
mode = 0;
if ( md.type() == Metadata::File || md.type() == Metadata::KeyValueFile )
mode |= S_IFREG;
else if ( md.type() == Metadata::Directory )
mode |= S_IFDIR;
else if ( md.type() == Metadata::Symlink )
mode |= S_IFLNK;
if ( md.modes().user().read() )
mode |= S_IRUSR;
if ( md.modes().user().write() )
mode |= S_IWUSR;
if ( md.modes().user().execute() )
mode |= S_IXUSR;
if ( md.modes().group().read() )
mode |= S_IRGRP;
if ( md.modes().group().write() )
mode |= S_IWGRP;
if ( md.modes().group().execute() )
mode |= S_IXGRP;
if ( md.modes().other().read() )
mode |= S_IROTH;
if ( md.modes().other().write() )
mode |= S_IWOTH;
if ( md.modes().other().execute() )
mode |= S_IXOTH;
}
示例12: getenv
//.........这里部分代码省略.........
if (stat == 200) // One unique match
{
QString album;
QString artist;
bool compn = false;
QString genre = cddb.section(' ', 0, 0);
int year = 0;
// Now we can lookup all its details:
URL2 = URL + "cddb+read+" + genre + "+"
+ hexID + "&hello=" + helloID + "&proto=5";
cddb = HttpComms::getHttp(URL2);
#if 0
LOG(VB_MEDIA, LOG_INFO, "CDDB detail: " + URL2);
LOG(VB_MEDIA, LOG_INFO, "...returned: " + cddb);
#endif
// Successful lookup.
// Clear current titles (filenames), because we append to them
for (trk = 0; trk < totalTracks; ++trk)
m_mData[trk]->setTitle("");
// Parse returned data:
cddb.replace(QRegExp(".*#"), ""); // Remove comment block
while (cddb.length())
{
// Lines should be of the form "FIELD=value\r\n"
QString art;
QString line = cddb.section(QRegExp("(\r|\n)+"), 0, 0);
QString value = line.section('=', 1, 1);
if (value.contains(" / "))
{
art = value.section(" / ", 0, 0); // Artist in *TITLE
value = value.section(" / ", 1, 1);
}
if (line.startsWith("DGENRE="))
genre = value;
else if (line.startsWith("DYEAR="))
year = value.toInt();
else if (line.startsWith("DTITLE="))
{
// Albums (and maybe artists?) can wrap over multiple lines:
artist += art;
album += value;
}
else if (line.startsWith("TTITLE"))
{
trk = line.remove("TTITLE").remove(QRegExp("=.*")).toUInt();
if (trk < totalTracks)
{
Metadata *m = m_mData[trk];
// Titles can wrap over multiple lines, so we load+store:
m->setTitle(m->Title() + value);
if (art.length())
{
compn = true; // Probably a compilation
m->setArtist(M_QSTRING_UNICODE(art));
}
}
else
LOG(VB_GENERAL, LOG_INFO,
QString("CDDB returned %1 on a %2 track disk!")
.arg(trk+1).arg(totalTracks));
}
// Get next THINGY=value line:
cddb = cddb.section('\n', 1, 0xffffffff);
}
for (trk = 0; trk < totalTracks; ++trk)
{
Metadata *m = m_mData[trk];
if (compn)
m->setCompilation(true);
m->setGenre(M_QSTRING_UNICODE(genre));
if (year)
m->setYear(year);
if (album.length())
m->setAlbum(M_QSTRING_UNICODE(album));
if (artist.length())
if (compn)
m->setCompilationArtist(M_QSTRING_UNICODE(artist));
else
m->setArtist(M_QSTRING_UNICODE(artist));
}
}
}
示例13:
//add other Metadata, without first 2 entries ("default" metadata)
void Metadata::operator+=(const Metadata &other)
{
for (unsigned int i=2; i<other.size(); i++)
this->add(other.getLabel(i), other.getEntry(i));
}
示例14: RunProlog
void CDRipperThread::run(void)
{
RunProlog();
if (!m_tracks->size() > 0)
{
RunEpilog();
return;
}
Metadata *track = m_tracks->at(0)->metadata;
QString tots;
if (track->Compilation())
{
tots = track->CompilationArtist() + " ~ " + track->Album();
}
else
{
tots = track->Artist() + " ~ " + track->Album();
}
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kOverallTextEvent, tots));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kOverallProgressEvent, 0));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kTrackProgressEvent, 0));
QString textstatus;
QString encodertype = gCoreContext->GetSetting("EncoderType");
bool mp3usevbr = gCoreContext->GetNumSetting("Mp3UseVBR", 0);
m_totalSectors = 0;
m_totalSectorsDone = 0;
for (int trackno = 0; trackno < m_tracks->size(); trackno++)
{
m_totalSectors += getSectorCount(m_CDdevice, trackno + 1);
}
QApplication::postEvent(m_parent,
new RipStatusEvent(RipStatusEvent::kOverallStartEvent, m_totalSectors));
if (LCD *lcd = LCD::Get())
{
QString lcd_tots = QObject::tr("Importing ") + tots;
QList<LCDTextItem> textItems;
textItems.append(LCDTextItem(1, ALIGN_CENTERED,
lcd_tots, "Generic", false));
lcd->switchToGeneric(textItems);
}
Metadata *titleTrack = NULL;
QString outfile;
std::auto_ptr<Encoder> encoder;
for (int trackno = 0; trackno < m_tracks->size(); trackno++)
{
if (isCancelled())
break;
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kStatusTextEvent,
QString("Track %1 of %2")
.arg(trackno + 1).arg(m_tracks->size())));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kTrackProgressEvent, 0));
track = m_tracks->at(trackno)->metadata;
if (track)
{
textstatus = track->Title();
QApplication::postEvent(
m_parent,
new RipStatusEvent(
RipStatusEvent::kTrackTextEvent, textstatus));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kTrackProgressEvent, 0));
QApplication::postEvent(
m_parent,
new RipStatusEvent(RipStatusEvent::kTrackPercentEvent, 0));
// do we need to start a new file?
if (m_tracks->at(trackno)->active)
{
titleTrack = track;
titleTrack->setLength(m_tracks->at(trackno)->length);
outfile = Ripper::filenameFromMetadata(track);
if (m_quality < 3)
{
//.........这里部分代码省略.........
示例15: allocate
void allocate()
{
metadata.setAllocated(true);
}