本文整理汇总了C++中SResources::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ SResources::begin方法的具体用法?C++ SResources::begin怎么用?C++ SResources::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SResources
的用法示例。
在下文中一共展示了SResources::begin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindMime
static bool FindMime(SResources resources, std::string mime)
{
for(SResources::iterator it = resources.begin(); it != resources.end(); it++)
{
if(StringUtils::StartsWithNoCase(it->mime, mime))
return true;
}
return false;
}
示例2: FindMime
static bool FindMime(SResources resources, CStdString mime)
{
for(SResources::iterator it = resources.begin(); it != resources.end(); it++)
{
if(it->mime.Left(mime.length()).Equals(mime))
return true;
}
return false;
}
示例3: ParseItem
static void ParseItem(CFileItem* item, TiXmlElement* root, const std::string& path)
{
SResources resources;
ParseItem(item, resources, root, path);
const char* prio[] = { "media:content", "voddler:trailer", "rss:enclosure", "svtplay:broadcasts", "svtplay:xmllink", "rss:link", "rss:guid", NULL };
std::string mime;
if (FindMime(resources, "video/"))
mime = "video/";
else if(FindMime(resources, "audio/"))
mime = "audio/";
else if(FindMime(resources, "application/rss"))
mime = "application/rss";
else if(FindMime(resources, "image/"))
mime = "image/";
int maxrate = CSettings::Get().GetInt(CSettings::SETTING_NETWORK_BANDWIDTH);
if(maxrate == 0)
maxrate = INT_MAX;
SResources::iterator best = resources.end();
for(const char** type = prio; *type && best == resources.end(); type++)
{
for(SResources::iterator it = resources.begin(); it != resources.end(); it++)
{
if(!StringUtils::StartsWith(it->mime, mime))
continue;
if(it->tag == *type)
{
if(best == resources.end())
{
best = it;
continue;
}
if(it->bitrate == best->bitrate)
{
if(it->width*it->height > best->width*best->height)
best = it;
continue;
}
if(it->bitrate > maxrate)
{
if(it->bitrate < best->bitrate)
best = it;
continue;
}
if(it->bitrate > best->bitrate)
{
best = it;
continue;
}
}
}
}
if(best != resources.end())
{
item->SetMimeType(best->mime);
item->SetPath(best->path);
item->m_dwSize = best->size;
if(best->duration)
item->SetProperty("duration", StringUtils::SecondsToTimeString(best->duration));
/* handling of mimetypes fo directories are sub optimal at best */
if(best->mime == "application/rss+xml" && StringUtils::StartsWithNoCase(item->GetPath(), "http://"))
item->SetPath("rss://" + item->GetPath().substr(7));
if(StringUtils::StartsWithNoCase(item->GetPath(), "rss://"))
item->m_bIsFolder = true;
else
item->m_bIsFolder = false;
}
if(!item->m_strTitle.empty())
item->SetLabel(item->m_strTitle);
if(item->HasVideoInfoTag())
{
CVideoInfoTag* vtag = item->GetVideoInfoTag();
if(item->HasProperty("duration") && !vtag->GetDuration())
vtag->m_duration = StringUtils::TimeStringToSeconds(item->GetProperty("duration").asString());
if(item->HasProperty("description") && vtag->m_strPlot.empty())
vtag->m_strPlot = item->GetProperty("description").asString();
if(vtag->m_strPlotOutline.empty() && !vtag->m_strPlot.empty())
{
size_t pos = vtag->m_strPlot.find('\n');
if(pos != std::string::npos)
vtag->m_strPlotOutline = vtag->m_strPlot.substr(0, pos);
else
vtag->m_strPlotOutline = vtag->m_strPlot;
}
//.........这里部分代码省略.........
示例4: ParseItem
static void ParseItem(CFileItem* item, TiXmlElement* root, const CStdString& path)
{
SResources resources;
ParseItem(item, resources, root, path);
const char* prio[] = { "media:content", "voddler:trailer", "rss:enclosure", "svtplay:broadcasts", "svtplay:xmllink", "rss:link", "rss:guid", NULL };
CStdString mime;
if (FindMime(resources, "video/"))
mime = "video/";
else if(FindMime(resources, "audio/"))
mime = "audio/";
else if(FindMime(resources, "application/rss"))
mime = "application/rss";
else if(FindMime(resources, "image/"))
mime = "image/";
int maxrate = g_guiSettings.GetInt("network.bandwidth");
if(maxrate == 0)
maxrate = INT_MAX;
SResources::iterator best = resources.end();
for(const char** type = prio; *type && best == resources.end(); type++)
{
for(SResources::iterator it = resources.begin(); it != resources.end(); it++)
{
if(it->mime.Left(mime.length()) != mime)
continue;
if(it->tag == *type)
{
if(best == resources.end())
{
best = it;
continue;
}
if(it->bitrate == best->bitrate)
{
if(it->width*it->height > best->width*best->height)
best = it;
continue;
}
if(it->bitrate > maxrate)
{
if(it->bitrate < best->bitrate)
best = it;
continue;
}
if(it->bitrate > best->bitrate)
{
best = it;
continue;
}
}
}
}
if(best != resources.end())
{
item->SetMimeType(best->mime);
item->SetPath(best->path);
item->m_dwSize = best->size;
if(best->duration)
item->SetProperty("duration", StringUtils::SecondsToTimeString(best->duration));
/* handling of mimetypes fo directories are sub optimal at best */
if(best->mime == "application/rss+xml" && item->GetPath().Left(7).Equals("http://"))
item->SetPath("rss://" + item->GetPath().Mid(7));
if(item->GetPath().Left(6).Equals("rss://"))
item->m_bIsFolder = true;
else
item->m_bIsFolder = false;
}
if(!item->m_strTitle.IsEmpty())
item->SetLabel(item->m_strTitle);
if(item->HasVideoInfoTag())
{
CVideoInfoTag* vtag = item->GetVideoInfoTag();
if(item->HasProperty("duration") && !vtag->GetDuration())
vtag->m_duration = StringUtils::TimeStringToSeconds(item->GetProperty("duration").asString());
if(item->HasProperty("description") && vtag->m_strPlot.IsEmpty())
vtag->m_strPlot = item->GetProperty("description").asString();
if(vtag->m_strPlotOutline.IsEmpty() && !vtag->m_strPlot.IsEmpty())
{
int pos = vtag->m_strPlot.Find('\n');
if(pos >= 0)
vtag->m_strPlotOutline = vtag->m_strPlot.Left(pos);
else
vtag->m_strPlotOutline = vtag->m_strPlot;
}
//.........这里部分代码省略.........
示例5: ParseItem
static void ParseItem(CFileItem* item, TiXmlElement* root)
{
SResources resources;
ParseItem(item, resources, root);
const char* prio[] = { "media:content", "voddler:trailer", "rss:enclosure", "svtplay:xmllink", "rss:link", "rss:guid", NULL };
CStdString mime;
if (FindMime(resources, "video/"))
mime = "video/";
else if(FindMime(resources, "audio/"))
mime = "audio/";
else if(FindMime(resources, "application/rss"))
mime = "application/rss";
else if(FindMime(resources, "image/"))
mime = "image/";
SResources::iterator best = resources.end();
for(const char** type = prio; *type && best == resources.end(); type++)
{
for(SResources::iterator it = resources.begin(); it != resources.end(); it++)
{
if(it->mime.Left(mime.length()) != mime)
continue;
if(it->tag == *type)
{
if(best == resources.end())
best = it;
else if(it->width && it->height || best->width && best->height)
{
if(it->width*it->height > best->width*best->height)
best = it;
}
else if(it->bitrate > best->bitrate)
best = it;
}
}
}
if(best != resources.end())
{
item->SetMimeType(best->mime);
item->m_strPath = best->path;
item->m_dwSize = best->size;
if(best->duration)
item->SetProperty("duration", StringUtils::SecondsToTimeString(best->duration));
/* handling of mimetypes fo directories are sub optimal at best */
if(best->mime == "application/rss+xml" && item->m_strPath.Left(7).Equals("http://"))
item->m_strPath.replace(0, 7, "rss://");
if(item->m_strPath.Left(6).Equals("rss://"))
item->m_bIsFolder = true;
else
item->m_bIsFolder = false;
}
if(!item->m_strTitle.IsEmpty())
item->SetLabel(item->m_strTitle);
if(item->HasVideoInfoTag())
{
CVideoInfoTag* vtag = item->GetVideoInfoTag();
// clean up ", " added during build
vtag->m_strDirector.Delete(0, 2);
vtag->m_strWritingCredits.Delete(0, 2);
if(item->HasProperty("duration") && vtag->m_strRuntime.IsEmpty())
vtag->m_strRuntime = item->GetProperty("duration");
if(item->HasProperty("description") && vtag->m_strPlot.IsEmpty())
vtag->m_strPlot = item->GetProperty("description");
if(vtag->m_strPlotOutline.IsEmpty() && !vtag->m_strPlot.IsEmpty())
{
int pos = vtag->m_strPlot.Find('\n');
if(pos >= 0)
vtag->m_strPlotOutline = vtag->m_strPlot.Left(pos);
else
vtag->m_strPlotOutline = vtag->m_strPlot;
}
if(!vtag->m_strRuntime.IsEmpty())
item->SetLabel2(vtag->m_strRuntime);
}
}