本文整理汇总了C++中VERBOSE函数的典型用法代码示例。如果您正苦于以下问题:C++ VERBOSE函数的具体用法?C++ VERBOSE怎么用?C++ VERBOSE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VERBOSE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: traverse_level
/*
* Traverse the file system in the level-order way. The description
* and example is in the header file.
*/
int
traverse_level(struct fs_traverse *ftp)
{
char path[PATH_MAX + 1]; /* full path name of the current dir */
char nm[NAME_MAX + 1]; /* directory entry name */
char *lp; /* last position on the path */
int next_dir, rv;
int pl, el; /* path and directory entry length */
cstack_t *sp;
fs_fhandle_t pfh, efh;
struct stat64 pst, est;
traverse_state_t *tsp;
struct fst_node pn, en; /* parent and entry nodes */
dent_arg_t darg;
if (!ftp || !ftp->ft_path || !*ftp->ft_path || !ftp->ft_callbk) {
NDMP_LOG(LOG_DEBUG, "Invalid argument");
errno = EINVAL;
return (-1);
}
/* set the default log function if it's not already set */
if (!ftp->ft_logfp) {
ftp->ft_logfp = (ft_log_t)syslog;
NDMP_LOG(LOG_DEBUG, "Log to system log \"%s\"", ftp->ft_path);
}
if (!ftp->ft_lpath) {
NDMP_LOG(LOG_DEBUG,
"report the same paths \"%s\"", ftp->ft_path);
ftp->ft_lpath = ftp->ft_path;
}
pl = strlen(ftp->ft_lpath);
if (pl + 1 > PATH_MAX) { /* +1 for the '/' */
NDMP_LOG(LOG_DEBUG, "lpath too long \"%s\"", ftp->ft_path);
errno = ENAMETOOLONG;
return (-1);
}
(void) strcpy(path, ftp->ft_lpath);
(void) memset(&pfh, 0, sizeof (pfh));
rv = fs_getstat(ftp->ft_lpath, &pfh, &pst);
if (rv != 0) {
NDMP_LOG(LOG_DEBUG,
"Error %d on fs_getstat(%s)", rv, ftp->ft_path);
return (-1);
}
en.tn_path = NULL;
en.tn_fh = NULL;
en.tn_st = NULL;
if (!S_ISDIR(pst.st_mode)) {
pn.tn_path = ftp->ft_lpath;
pn.tn_fh = &pfh;
pn.tn_st = &pst;
rv = CALLBACK(&pn, &en);
if (VERBOSE(ftp))
NDMP_LOG(LOG_DEBUG, "CALLBACK(%s): %d", pn.tn_path, rv);
free(pfh.fh_fpath);
return (rv);
}
sp = cstack_new();
if (!sp) {
free(pfh.fh_fpath);
errno = ENOMEM;
return (-1);
}
tsp = new_tsp(path);
if (!tsp) {
cstack_delete(sp);
free(pfh.fh_fpath);
errno = ENOMEM;
return (-1);
}
darg.da_buf = ndmp_malloc(MAX_DENT_BUF_SIZE);
if (!darg.da_buf) {
cstack_delete(sp);
free(pfh.fh_fpath);
free(tsp);
errno = ENOMEM;
return (-1);
}
darg.da_size = MAX_DENT_BUF_SIZE;
tsp->ts_ent = tsp->ts_end;
tsp->ts_fh = pfh;
tsp->ts_st = pst;
pn.tn_path = path;
pn.tn_fh = &tsp->ts_fh;
pn.tn_st = &tsp->ts_st;
/* call the callback function on the path itself */
traverse_stats.fss_dir_calls++;
rv = CALLBACK(&pn, &en);
//.........这里部分代码省略.........
示例2: exif_data_new_from_file
long GalleryUtil::GetNaturalRotation(const QString &filePathString)
{
long rotateAngle = 0;
#ifdef EXIF_SUPPORT
QByteArray filePathBA = filePathString.toLocal8Bit();
const char *filePath = filePathBA.constData();
try
{
char *exifvalue = new char[1024];
ExifData *data = exif_data_new_from_file (filePath);
if (data)
{
for (int i = 0; i < EXIF_IFD_COUNT; i++)
{
ExifEntry *entry = exif_content_get_entry (data->ifd[i],
EXIF_TAG_ORIENTATION);
ExifByteOrder byteorder = exif_data_get_byte_order (data);
if (entry)
{
ExifShort v_short = exif_get_short (entry->data, byteorder);
VERBOSE(VB_GENERAL|VB_EXTRA, QString("Exif entry=%1").arg(v_short));
/* See http://sylvana.net/jpegcrop/exif_orientation.html*/
if (v_short == 8)
{
rotateAngle = -90;
}
else if (v_short == 6)
{
rotateAngle = 90;
}
break;
}
}
exif_data_free(data);
}
else
{
VERBOSE(VB_FILE, LOC_ERR +
QString("Could not load exif data from '%1'")
.arg(filePath));
}
delete [] exifvalue;
#if 0
Exiv2::ExifData exifData;
int rc = exifData.read(filePath);
if (!rc)
{
Exiv2::ExifKey key = Exiv2::ExifKey("Exif.Image.Orientation");
Exiv2::ExifData::iterator pos = exifData.findKey(key);
if (pos != exifData.end())
{
long orientation = pos->toLong();
switch (orientation)
{
case 6:
rotateAngle = 90;
break;
case 8:
rotateAngle = -90;
break;
default:
rotateAngle = 0;
break;
}
}
}
#endif
}
catch (...)
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
QString("Failed to extract EXIF headers from '%1'")
.arg(filePathString));
}
#else
// Shut the compiler up about the unused argument
(void)filePathString;
#endif // EXIF_SUPPORT
return rotateAngle;
}
示例3: main
int main (int argc, char **argv)
{
#ifdef CC_HAVE_WIN_UTF8
// UTF8 argv. g_win_utf8_enabled affects cc_fopen and cc_fprintf
argv = win_utf8_argv(argc, argv, &g_win_utf8_enabled);
#endif
int rv = 1;
int needs_usage_on_err = 1;
int opt_verbose = 0;
int opt_overwrite = 0;
int opt_progress = 0;
int opt_dummy = 0;
char *in_name = NULL;
char *out_name = NULL;
FILE *in_file = NULL;
FILE *out_file = NULL;
int i = 0;
opterr = 0; // suppress getopt error prints, we're handling them.
int c;
while (1) {
// This is weird. GNU getopt can be made to work in POSIX compliant mode,
// but in a way which breaks POSIX compliance...
// We want to use getopt in standard posix mode, where it doesn't
// permute argv, and returns -1 when it encounters a non-option.
// GNU getopt doesn't default to posix mode. It uses posix mode either
// when the env POSIXLY_CORRECT is set, or when optstring starts with +.
// But + prefix is a GNU extension - proper posix getopt don't recognize
// it as an indicator, therefore interpreting it as a valid option char.
// So to cover both variants, we use the '+' to make GNU posix compliant,
// but also expect it and then and reject it as an unknown option on posix getopt.
if ((c = getopt (argc, argv, "+hdvfpo:")) != -1) {
switch (c) {
case 'h': help();
exit(0);
case 'v': opt_verbose = 1;
break;
case 'f': opt_overwrite = 1;
break;
case 'p': opt_progress = 1;
break;
case 'd': opt_dummy = 1;
break;
case 'o': out_name = optarg;
// Will also exit the while loop and start the ranges
break;
case '+': optopt = '+'; // fallthrough - proper POSIX (bsd, OS X, ...)
case '?': if (optopt == 'o')
ERR_EXIT("-o: missing output file name");
ERR_EXIT("unknown option -%c%s", optopt,
(optopt >= '0' && optopt <= '9') ?
" (missing -o OUT_FILE before the ranges?)" : "");
default : ERR_EXIT("(Internal) getopt - unexpected code %d", c);
}
} else if (optind < argc) { // still more arguments, so it's a value
if (!in_name) {
// still no input file, so this is it.
in_name = argv[optind];
optind++; // skip the value and continue parsing.
} else {
ERR_EXIT("unexpected '%s' (missing -o OUT_FILE before the ranges?)", argv[optind]);
}
} else { // no more arguments to parse
break;
}
if (out_name) // Once we got the output file, the rest should be ranges
break;
}
// from here onwards, optind should point to the first range in argv
VERBOSE("- Verbose mode enabled.\n");
if (opt_overwrite)
VERBOSE("- Force overwrite output file if exists.\n");
if (opt_progress)
VERBOSE("- Progress display enabled.\n");
if (opt_dummy)
VERBOSE("- Dummy mode enabled.\n");
if (!in_name)
ERR_EXIT("missing input file name");
if (!out_name)
//.........这里部分代码省略.........
示例4: smb_readdir
/*
* Read a directory, using filldir to fill the dirent memory.
* smb_proc_readdir does the actual reading from the smb server.
*
* The cache code is almost directly taken from ncpfs
*/
static int
smb_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
struct dentry *dentry = filp->f_dentry;
struct inode *dir = dentry->d_inode;
struct smb_sb_info *server = server_from_dentry(dentry);
union smb_dir_cache *cache = NULL;
struct smb_cache_control ctl;
struct page *page = NULL;
int result;
ctl.page = NULL;
ctl.cache = NULL;
VERBOSE("reading %s/%s, f_pos=%d\n",
DENTRY_PATH(dentry), (int) filp->f_pos);
result = 0;
lock_kernel();
switch ((unsigned int) filp->f_pos) {
case 0:
if (filldir(dirent, ".", 1, 0, dir->i_ino, DT_DIR) < 0)
goto out;
filp->f_pos = 1;
/* fallthrough */
case 1:
if (filldir(dirent, "..", 2, 1, parent_ino(dentry), DT_DIR) < 0)
goto out;
filp->f_pos = 2;
}
/*
* Make sure our inode is up-to-date.
*/
result = smb_revalidate_inode(dentry);
if (result)
goto out;
page = grab_cache_page(&dir->i_data, 0);
if (!page)
goto read_really;
ctl.cache = cache = kmap(page);
ctl.head = cache->head;
if (!PageUptodate(page) || !ctl.head.eof) {
VERBOSE("%s/%s, page uptodate=%d, eof=%d\n",
DENTRY_PATH(dentry), PageUptodate(page),ctl.head.eof);
goto init_cache;
}
if (filp->f_pos == 2) {
if (jiffies - ctl.head.time >= SMB_MAX_AGE(server))
goto init_cache;
/*
* N.B. ncpfs checks mtime of dentry too here, we don't.
* 1. common smb servers do not update mtime on dir changes
* 2. it requires an extra smb request
* (revalidate has the same timeout as ctl.head.time)
*
* Instead smbfs invalidates its own cache on local changes
* and remote changes are not seen until timeout.
*/
}
if (filp->f_pos > ctl.head.end)
goto finished;
ctl.fpos = filp->f_pos + (SMB_DIRCACHE_START - 2);
ctl.ofs = ctl.fpos / SMB_DIRCACHE_SIZE;
ctl.idx = ctl.fpos % SMB_DIRCACHE_SIZE;
for (;;) {
if (ctl.ofs != 0) {
ctl.page = find_lock_page(&dir->i_data, ctl.ofs);
if (!ctl.page)
goto invalid_cache;
ctl.cache = kmap(ctl.page);
if (!PageUptodate(ctl.page))
goto invalid_cache;
}
while (ctl.idx < SMB_DIRCACHE_SIZE) {
struct dentry *dent;
int res;
dent = smb_dget_fpos(ctl.cache->dentry[ctl.idx],
dentry, filp->f_pos);
if (!dent)
goto invalid_cache;
//.........这里部分代码省略.........
示例5: main
int main()
{
int an_int;
SQLUSMALLINT num_cols;
float a_float;
SQLCHAR buf1[MAX_LEN];
SQLCHAR buf2[MAX_LEN];
SQLUSMALLINT col;
SQLSMALLINT col_len;
SQLSMALLINT type;
SQLUINTEGER sz;
SQLSMALLINT scale;
SQLSMALLINT can_null;
GET_LOGIN_VARS();
VERBOSE("calling SQLAllocHandle(EnvHandle) \n");
rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &EnvHandle);
assert(rc == SQL_SUCCESS);
assert(EnvHandle != (SQLHANDLE) NULL);
rc = SQLSetEnvAttr(EnvHandle, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_UINTEGER);
assert(rc == SQL_SUCCESS);
VERBOSE("calling SQLAllocHandle(ConHandle) \n");
rc = SQLAllocHandle(SQL_HANDLE_DBC, EnvHandle, &ConHandle);
assert(ConHandle != (SQLHANDLE) NULL);
assert(rc == SQL_SUCCESS);
if (dsn[0])
rc = SQLDriverConnect(ConHandle, NULL, dsn,
SQL_NTS, NULL, 0, NULL,
SQL_DRIVER_NOPROMPT);
else
rc = SQLConnect(ConHandle, twoTask, SQL_NTS,
(SQLCHAR *) userName, SQL_NTS, (SQLCHAR *) pswd,
SQL_NTS);
assert(rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO);
VERBOSE("connected to database %s\n", twoTask);
VERBOSE("allocing handle\n");
rc = SQLAllocStmt(ConHandle, &StmtHandle);
assert(rc == SQL_SUCCESS);
sprintf(SQLStmt, "select max(an_int) from some_types");
VERBOSE("executing %s\n", SQLStmt);
rc = SQLExecDirect(StmtHandle, SQLStmt, SQL_NTS);
assert(rc == SQL_SUCCESS);
rc = SQLNumResultCols(StmtHandle, &num_cols);
assert(rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO);
assert(num_cols == 1);
for (col = 1; col <= num_cols; col++) {
rc = SQLDescribeCol(StmtHandle, col, buf1, MAX_LEN, &col_len,
&type, &sz, &scale, &can_null);
assert(rc == SQL_SUCCESS);
VERBOSE
("col=%d name:%s len=%d type=%d size=%d scale=%d nullable=%d\n",
col, buf1, col_len, type, sz, scale, can_null);
/*
if(col==1)assert(type==SQL_INTEGER);
if(col==2)assert(type==SQL_C_DOUBLE);
if(col==3)assert(type==SQL_VARCHAR);
*/
rc = SQLColAttribute(StmtHandle, col, SQL_DESC_NAME,
buf2, sizeof(buf2), &type, NULL);
assert(rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO);
assert(strcmp(buf1, buf2) == 0);
}
rc = SQLBindCol(StmtHandle, 1, SQL_C_SLONG,
&an_int, sizeof(an_int), NULL);
assert(rc == SQL_SUCCESS);
do {
rc = SQLFetch(StmtHandle);
VERBOSE("an_int=%d \n", an_int);
} while (rc == SQL_SUCCESS);
assert(rc == SQL_NO_DATA);
assert(an_int > 0);
rc = SQLDisconnect(ConHandle);
assert(rc == SQL_SUCCESS);
//.........这里部分代码省略.........
示例6: TokenizeXml
/**
* Process a sentence with xml annotation
* Xml tags may specifiy additional/replacing translation options
* and reordering constraints
*
* \param line in: sentence, out: sentence without the xml
* \param res vector with translation options specified by xml
* \param reorderingConstraint reordering constraint zones specified by xml
* \param walls reordering constraint walls specified by xml
*/
bool TreeInput::ProcessAndStripXMLTags(string &line, std::vector<XMLParseOutput> &sourceLabels, std::vector<XmlOption*> &xmlOptions)
{
//parse XML markup in translation line
// no xml tag? we're done.
if (line.find_first_of('<') == string::npos) {
return true;
}
// hack. What pt should XML trans opt be assigned to?
PhraseDictionary *firstPt = NULL;
if (PhraseDictionary::GetColl().size() == 0) {
firstPt = PhraseDictionary::GetColl()[0];
}
// break up input into a vector of xml tags and text
// example: (this), (<b>), (is a), (</b>), (test .)
vector<string> xmlTokens = TokenizeXml(line);
// we need to store opened tags, until they are closed
// tags are stored as tripled (tagname, startpos, contents)
typedef pair< string, pair< size_t, string > > OpenedTag;
vector< OpenedTag > tagStack; // stack that contains active opened tags
string cleanLine; // return string (text without xml)
size_t wordPos = 0; // position in sentence (in terms of number of words)
// keep this handy for later
const vector<FactorType> &outputFactorOrder = StaticData::Instance().GetOutputFactorOrder();
// const string &factorDelimiter = StaticData::Instance().GetFactorDelimiter();
// loop through the tokens
for (size_t xmlTokenPos = 0 ; xmlTokenPos < xmlTokens.size() ; xmlTokenPos++) {
// not a xml tag, but regular text (may contain many words)
if(!isXmlTag(xmlTokens[xmlTokenPos])) {
// add a space at boundary, if necessary
if (cleanLine.size()>0 &&
cleanLine[cleanLine.size() - 1] != ' ' &&
xmlTokens[xmlTokenPos][0] != ' ') {
cleanLine += " ";
}
cleanLine += xmlTokens[xmlTokenPos]; // add to output
wordPos = Tokenize(cleanLine).size(); // count all the words
}
// process xml tag
else {
// *** get essential information about tag ***
// strip extra boundary spaces and "<" and ">"
string tag = Trim(TrimXml(xmlTokens[xmlTokenPos]));
VERBOSE(3,"XML TAG IS: " << tag << std::endl);
if (tag.size() == 0) {
TRACE_ERR("ERROR: empty tag name: " << line << endl);
return false;
}
// check if unary (e.g., "<wall/>")
bool isUnary = ( tag[tag.size() - 1] == '/' );
// check if opening tag (e.g. "<a>", not "</a>")g
bool isClosed = ( tag[0] == '/' );
bool isOpen = !isClosed;
if (isClosed && isUnary) {
TRACE_ERR("ERROR: can't have both closed and unary tag <" << tag << ">: " << line << endl);
return false;
}
if (isClosed)
tag = tag.substr(1); // remove "/" at the beginning
if (isUnary)
tag = tag.substr(0,tag.size()-1); // remove "/" at the end
// find the tag name and contents
string::size_type endOfName = tag.find_first_of(' ');
string tagName = tag;
string tagContent = "";
if (endOfName != string::npos) {
tagName = tag.substr(0,endOfName);
tagContent = tag.substr(endOfName+1);
}
// *** process new tag ***
if (isOpen || isUnary) {
// put the tag on the tag stack
OpenedTag openedTag = make_pair( tagName, make_pair( wordPos, tagContent ) );
tagStack.push_back( openedTag );
//.........这里部分代码省略.........
示例7: handle_command
int handle_command(const MythCommandLineParser &cmdline)
{
QString eventString = cmdline.GetEventString();
if (!eventString.isEmpty())
{
if (gCoreContext->ConnectToMasterServer())
{
if (eventString.startsWith("SYSTEM_EVENT"))
{
eventString += QString(" SENDER %1")
.arg(gCoreContext->GetHostName());
}
RemoteSendMessage(eventString);
return GENERIC_EXIT_OK;
}
return GENERIC_EXIT_NO_MYTHCONTEXT;
}
if (cmdline.WantUPnPRebuild())
{
VERBOSE(VB_GENERAL, "Rebuilding UPNP Media Map is no longer supported. Rescan videos using MythVideo.");
return GENERIC_EXIT_OK;
}
if (cmdline.SetVerbose())
{
if (gCoreContext->ConnectToMasterServer())
{
QString message = "SET_VERBOSE ";
message += cmdline.GetNewVerbose();
RemoteSendMessage(message);
VERBOSE(VB_IMPORTANT, QString("Sent '%1' message").arg(message));
return GENERIC_EXIT_OK;
}
else
{
VERBOSE(VB_IMPORTANT,
"Unable to connect to backend, verbose level unchanged ");
return GENERIC_EXIT_CONNECT_ERROR;
}
}
if (cmdline.ClearSettingsCache())
{
if (gCoreContext->ConnectToMasterServer())
{
RemoteSendMessage("CLEAR_SETTINGS_CACHE");
VERBOSE(VB_IMPORTANT, "Sent CLEAR_SETTINGS_CACHE message");
return GENERIC_EXIT_OK;
}
else
{
VERBOSE(VB_IMPORTANT, "Unable to connect to backend, settings "
"cache will not be cleared.");
return GENERIC_EXIT_CONNECT_ERROR;
}
}
if (cmdline.IsPrintScheduleEnabled() ||
cmdline.IsTestSchedulerEnabled())
{
sched = new Scheduler(false, &tvList);
if (!cmdline.IsTestSchedulerEnabled() &&
gCoreContext->ConnectToMasterServer())
{
cout << "Retrieving Schedule from Master backend.\n";
sched->FillRecordListFromMaster();
}
else
{
cout << "Calculating Schedule from database.\n" <<
"Inputs, Card IDs, and Conflict info may be invalid "
"if you have multiple tuners.\n";
sched->FillRecordListFromDB();
}
print_verbose_messages |= VB_SCHEDULE;
sched->PrintList(true);
return GENERIC_EXIT_OK;
}
if (cmdline.Reschedule())
{
bool ok = false;
if (gCoreContext->ConnectToMasterServer())
{
VERBOSE(VB_IMPORTANT, "Connected to master for reschedule");
ScheduledRecording::signalChange(-1);
ok = true;
}
else
VERBOSE(VB_IMPORTANT, "Cannot connect to master for reschedule");
return (ok) ? GENERIC_EXIT_OK : GENERIC_EXIT_CONNECT_ERROR;
}
if (cmdline.ScanVideos())
//.........这里部分代码省略.........
示例8: connect_to_master
int connect_to_master(void)
{
MythSocket *tempMonitorConnection = new MythSocket();
if (tempMonitorConnection->connect(
gCoreContext->GetSetting("MasterServerIP", "127.0.0.1"),
gCoreContext->GetNumSetting("MasterServerPort", 6543)))
{
if (!gCoreContext->CheckProtoVersion(tempMonitorConnection))
{
VERBOSE(VB_IMPORTANT, "Master backend is incompatible with "
"this backend.\nCannot become a slave.");
return GENERIC_EXIT_CONNECT_ERROR;
}
QStringList tempMonitorDone("DONE");
QStringList tempMonitorAnnounce("ANN Monitor tzcheck 0");
tempMonitorConnection->writeStringList(tempMonitorAnnounce);
tempMonitorConnection->readStringList(tempMonitorAnnounce);
if (tempMonitorAnnounce.empty() ||
tempMonitorAnnounce[0] == "ERROR")
{
tempMonitorConnection->DownRef();
tempMonitorConnection = NULL;
if (tempMonitorAnnounce.empty())
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
"Failed to open event socket, timeout");
}
else
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
"Failed to open event socket" +
((tempMonitorAnnounce.size() >= 2) ?
QString(", error was %1").arg(tempMonitorAnnounce[1]) :
QString(", remote error")));
}
}
QStringList tzCheck("QUERY_TIME_ZONE");
if (tempMonitorConnection)
{
tempMonitorConnection->writeStringList(tzCheck);
tempMonitorConnection->readStringList(tzCheck);
}
if (tzCheck.size() && !checkTimeZone(tzCheck))
{
// Check for different time zones, different offsets, different
// times
VERBOSE(VB_IMPORTANT, "The time and/or time zone settings on "
"this system do not match those in use on the master "
"backend. Please ensure all frontend and backend "
"systems are configured to use the same time zone and "
"have the current time properly set.");
VERBOSE(VB_IMPORTANT,
"Unable to run with invalid time settings. Exiting.");
tempMonitorConnection->writeStringList(tempMonitorDone);
tempMonitorConnection->DownRef();
return GENERIC_EXIT_INVALID_TIMEZONE;
}
else
{
VERBOSE(VB_IMPORTANT,
QString("Backend is running in %1 time zone.")
.arg(getTimeZoneID()));
}
if (tempMonitorConnection)
tempMonitorConnection->writeStringList(tempMonitorDone);
}
if (tempMonitorConnection)
tempMonitorConnection->DownRef();
return GENERIC_EXIT_OK;
}
示例9: ERROR
//.........这里部分代码省略.........
//成功渲染视频
if(Ret>=0 || Ret == ERR_DEVICE_NOSET)
{
//得到同步时间点,
double SyncPTS = pDemux->GetSyncPTS();
INFO("pDemux->GetSyncPTS() %f",SyncPTS);
if(SyncPTS<0.0)
{
//设定同步时间点
pDemux->SetSyncPTS(FramePTS);
//设定时钟的起始时间点
pClock->SetOriginClock (FramePTS);
//surface fixed
pVStubRender->ShowPicture (mpFrame);
//如果没有音频数据流设定为Synced;
if(pDemux->GetAudioStreamIndex()<0)
{
pDemux->SetSynced(true);
}
mbFirstKeyFrame = false;
mbNextFrame = true;
}
}
}
else
{
double CurClock = pClock->GetCurrentClock ();
double Diff = FramePTS - CurClock;
DEBUG ("V:CurClock=%f, FramePTS=%f, Diff=%f", CurClock, FramePTS, Diff);
if (fabs(Diff) < CMasterClock::AVThresholdNoSync)
{
mbNextFrame = true;
if (Diff <= 0)
{
VERBOSE ("show it at once.");
}
else
{
unsigned int usec = Diff * 1000 * 1000;
VERBOSE ("wait %d usec", usec);
usleep (usec);
}
Ret = pVStubRender->ShowPicture (mpFrame);
}
else
{
if (Diff < 0)
{
mbNextFrame = true;
//如果系统时钟是以视频时钟为基准的,调整系统时钟
if(pClock->GetClockType()==CMasterClock::CLOCK_VIDEO)
{
WARN("we reset master timer to video FramePTS");
double ClockTime = PlayCore::GetInstance()->av_gettime() / 1000000.0;
pClock->SetOriginClock (FramePTS, ClockTime);
Ret = pVStubRender->ShowPicture (mpFrame);
}
else//否则是以其他(音频,系统时间)为系统时钟,此时视频严重落后于同步的时间范围值,
{ //对于直播不需要设定需要查找最近的关键帧标识
DEBUG("we need ReSync video FramePTS Diff %f",Diff);
}
}
else
{
WARN ("video FramePTS far early than curr_pts Diff %f",Diff);
unsigned int usec = Diff * 1000 * 1000;
mbNextFrame = false;
usleep (1*1000);
}
}
DEBUG("ShowPicture Ret %d",Ret);
}
}
else
{
ERROR ("you have not set Master Clock!!! will not show pictures!");
}
PlayCore::GetInstance()->av_free_packet (&AVPkt);
memset((void*)&AVPkt,0,sizeof(AVPacket));
}
Reset();
if (AVPkt.data != 0)
{
PlayCore::GetInstance()->av_free_packet (&AVPkt);
}
DEBUG ("end of video out thread!");
}
示例10: VERBOSE
KRB5Context::~KRB5Context()
{
VERBOSE("Destroying Kerberos Context");
krb5_free_context(m_context);
}
示例11: max
int DVBRecorder::OpenFilterFd(uint pid, int pes_type, uint stream_type)
{
if (_open_pid_filters >= _max_pid_filters)
return -1;
// bits per millisecond
uint bpms = (StreamID::IsVideo(stream_type)) ? 19200 : 500;
// msec of buffering we want
uint msec_of_buffering = max(POLL_WARNING_TIMEOUT + 50, 1500);
// actual size of buffer we need
uint pid_buffer_size = ((bpms*msec_of_buffering + 7) / 8);
// rounded up to the nearest page
pid_buffer_size = ((pid_buffer_size + 4095) / 4096) * 4096;
VERBOSE(VB_RECORD, LOC + QString("Adding pid 0x%1 size(%2)")
.arg(pid,0,16).arg(pid_buffer_size));
// Open the demux device
QString dvbdev = CardUtil::GetDeviceName(
DVB_DEV_DEMUX, _card_number_option);
QByteArray dev = dvbdev.toAscii();
int fd_tmp = open(dev.constData(), O_RDWR);
if (fd_tmp < 0)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Could not open demux device." + ENO);
_max_pid_filters = _open_pid_filters;
return -1;
}
// Try to make the demux buffer large enough to
// allow for longish disk writes.
uint sz = pid_buffer_size;
uint usecs = msec_of_buffering * 1000;
while (ioctl(fd_tmp, DMX_SET_BUFFER_SIZE, sz) < 0 && sz > 1024*8)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to set demux buffer size for "+
QString("pid 0x%1 to %2").arg(pid,0,16).arg(sz) + ENO);
sz /= 2;
sz = ((sz+4095)/4096)*4096;
usecs /= 2;
}
/*
VERBOSE(VB_RECORD, LOC + "Set demux buffer size for " +
QString("pid 0x%1 to %2,\n\t\t\twhich gives us a %3 msec buffer.")
.arg(pid,0,16).arg(sz).arg(usecs/1000));
*/
// Set the filter type
struct dmx_pes_filter_params params;
memset(¶ms, 0, sizeof(params));
params.input = DMX_IN_FRONTEND;
params.output = DMX_OUT_TS_TAP;
params.flags = DMX_IMMEDIATE_START;
params.pid = pid;
params.pes_type = (dmx_pes_type_t) pes_type;
if (ioctl(fd_tmp, DMX_SET_PES_FILTER, ¶ms) < 0)
{
close(fd_tmp);
VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to set demux filter." + ENO);
_max_pid_filters = _open_pid_filters;
return -1;
}
_open_pid_filters++;
return fd_tmp;
}
示例12: close
bool DVBPIDInfo::Open(const QString &dvb_dev, bool use_section_reader)
{
if (filter_fd >= 0)
{
close(filter_fd);
filter_fd = -1;
}
QString demux_fn = CardUtil::GetDeviceName(DVB_DEV_DEMUX, dvb_dev);
QByteArray demux_ba = demux_fn.toAscii();
VERBOSE(VB_RECORD, LOC + QString("Opening filter for pid 0x%1")
.arg(_pid, 0, 16));
int mux_fd = open(demux_ba.constData(), O_RDWR | O_NONBLOCK);
if (mux_fd == -1)
{
VERBOSE(VB_IMPORTANT, LOC +
QString("Failed to open demux device %1 "
"for filter on pid 0x%2")
.arg(demux_fn).arg(_pid, 0, 16));
return false;
}
if (!use_section_reader)
{
struct dmx_pes_filter_params pesFilterParams;
memset(&pesFilterParams, 0, sizeof(struct dmx_pes_filter_params));
pesFilterParams.pid = (__u16) _pid;
pesFilterParams.input = DMX_IN_FRONTEND;
pesFilterParams.output = DMX_OUT_TS_TAP;
pesFilterParams.flags = DMX_IMMEDIATE_START;
pesFilterParams.pes_type = DMX_PES_OTHER;
if (ioctl(mux_fd, DMX_SET_PES_FILTER, &pesFilterParams) < 0)
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
QString("Failed to set TS filter (pid 0x%1)")
.arg(_pid, 0, 16));
close(mux_fd);
return false;
}
}
else
{
struct dmx_sct_filter_params sctFilterParams;
memset(&sctFilterParams, 0, sizeof(struct dmx_sct_filter_params));
switch ( (__u16) _pid )
{
case 0x0: // PAT
sctFilterParams.filter.filter[0] = 0;
sctFilterParams.filter.mask[0] = 0xff;
break;
case 0x0010: // assume this is for an NIT, NITo, PMT
// This filter will give us table ids 0x00-0x03, 0x40-0x43
// we expect to see table ids 0x02, 0x40 and 0x41 on this PID
// NOTE: In theory, this will break with ATSC when PID 0x10
// is used for ATSC/MPEG tables. This is frowned upon,
// but PMTs have been seen on in the wild.
sctFilterParams.filter.filter[0] = 0x00;
sctFilterParams.filter.mask[0] = 0xbc;
break;
case 0x0011: // assume this is for an SDT, SDTo, PMT
// This filter will give us table ids 0x02, 0x06, 0x42 and 0x46
// All but 0x06 are ones we want to see.
// NOTE: In theory this will break with ATSC when pid 0x11
// is used for random ATSC tables. In practice only
// video data has been seen on 0x11.
sctFilterParams.filter.filter[0] = 0x02;
sctFilterParams.filter.mask[0] = 0xbb;
break;
case 0x1ffb: // assume this is for various ATSC tables
// MGT 0xC7, Terrestrial VCT 0xC8, Cable VCT 0xC9, RRT 0xCA,
// STT 0xCD, DCCT 0xD3, DCCSCT 0xD4, Caption 0x86
sctFilterParams.filter.filter[0] = 0x80;
sctFilterParams.filter.mask[0] = 0xa0;
break;
default:
// otherwise assume it could be any table
sctFilterParams.filter.filter[0] = 0x00;
sctFilterParams.filter.mask[0] = 0x00;
break;
}
sctFilterParams.pid = (__u16) _pid;
sctFilterParams.timeout = 0;
sctFilterParams.flags = DMX_IMMEDIATE_START;
if (ioctl(mux_fd, DMX_SET_FILTER, &sctFilterParams) < 0)
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
"Failed to set \"section\" filter " +
QString("(pid 0x%1) (filter %2)").arg(_pid, 0, 16)
.arg(sctFilterParams.filter.filter[0]));
close(mux_fd);
return false;
}
}
filter_fd = mux_fd;
//.........这里部分代码省略.........
示例13: open
/** \fn DVBStreamHandler::RunTS(void)
* \brief Uses TS filtering devices to read a DVB device for tables & data
*
* This supports all types of MPEG based stream data, but is extreemely
* slow with DVB over USB 1.0 devices which for efficiency reasons buffer
* a stream until a full block transfer buffer full of the requested
* tables is available. This takes a very long time when you are just
* waiting for a PAT or PMT table, and the buffer is hundreds of packets
* in size.
*/
void DVBStreamHandler::RunTS(void)
{
QByteArray dvr_dev_path = _dvr_dev_path.toAscii();
int dvr_fd;
for (int tries = 1; ; ++tries)
{
dvr_fd = open(dvr_dev_path.constData(), O_RDONLY | O_NONBLOCK);
if (dvr_fd >= 0)
break;
VERBOSE(VB_IMPORTANT, LOC_WARN +
QString("Opening DVR device %1 failed : %2")
.arg(_dvr_dev_path).arg(strerror(errno)));
if (tries >= 20 || (errno != EBUSY && errno != EAGAIN))
{
VERBOSE(VB_IMPORTANT, LOC +
QString("Failed to open DVR device %1 : %2")
.arg(_dvr_dev_path).arg(strerror(errno)));
_error = true;
return;
}
usleep(50000);
}
int remainder = 0;
int buffer_size = TSPacket::kSize * 15000;
unsigned char *buffer = new unsigned char[buffer_size];
if (!buffer)
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to allocate memory");
close(dvr_fd);
_error = true;
return;
}
bzero(buffer, buffer_size);
DeviceReadBuffer *drb = NULL;
if (_needs_buffering)
{
drb = new DeviceReadBuffer(this);
if (!drb->Setup(_device, dvr_fd))
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to allocate DRB buffer");
delete drb;
delete[] buffer;
close(dvr_fd);
_error = true;
return;
}
drb->Start();
}
SetRunning(true, _needs_buffering, false);
{
QMutexLocker locker(&_start_stop_lock);
_drb = drb;
}
VERBOSE(VB_RECORD, LOC + "RunTS(): begin");
bool _error = false;
fd_set fd_select_set;
FD_ZERO( &fd_select_set);
FD_SET (dvr_fd, &fd_select_set);
while (_running_desired && !_error)
{
RetuneMonitor();
UpdateFiltersFromStreamData();
ssize_t len = 0;
if (drb)
{
len = drb->Read(
&(buffer[remainder]), buffer_size - remainder);
// Check for DRB errors
if (drb->IsErrored())
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Device error detected");
_error = true;
}
if (drb->IsEOF())
{
VERBOSE(VB_IMPORTANT, LOC_ERR + "Device EOF detected");
_error = true;
}
//.........这里部分代码省略.........
示例14: VERBOSE
ULONG __stdcall IWaterMarkUI::AddRef()
{
VERBOSE(DLLTEXT("IWaterMarkUI:AddRef entry.\r\n"));
return InterlockedIncrement(&m_cRef) ;
}
示例15: setupTVs
bool setupTVs(bool ismaster, bool &error)
{
error = false;
QString localhostname = gCoreContext->GetHostName();
MSqlQuery query(MSqlQuery::InitCon());
if (ismaster)
{
// Hack to make sure recorded.basename gets set if the user
// downgrades to a prior version and creates new entries
// without it.
if (!query.exec("UPDATE recorded SET basename = CONCAT(chanid, '_', "
"DATE_FORMAT(starttime, '%Y%m%d%H%i00'), '_', "
"DATE_FORMAT(endtime, '%Y%m%d%H%i00'), '.nuv') "
"WHERE basename = '';"))
MythDB::DBError("Updating record basename",
query.lastQuery());
// Hack to make sure record.station gets set if the user
// downgrades to a prior version and creates new entries
// without it.
if (!query.exec("UPDATE channel SET callsign=chanid "
"WHERE callsign IS NULL OR callsign='';"))
MythDB::DBError("Updating channel callsign", query.lastQuery());
if (query.exec("SELECT MIN(chanid) FROM channel;"))
{
query.first();
int min_chanid = query.value(0).toInt();
if (!query.exec(QString("UPDATE record SET chanid = %1 "
"WHERE chanid IS NULL;").arg(min_chanid)))
MythDB::DBError("Updating record chanid", query.lastQuery());
}
else
MythDB::DBError("Querying minimum chanid", query.lastQuery());
MSqlQuery records_without_station(MSqlQuery::InitCon());
records_without_station.prepare("SELECT record.chanid,"
" channel.callsign FROM record LEFT JOIN channel"
" ON record.chanid = channel.chanid WHERE record.station='';");
if (records_without_station.exec() && records_without_station.next())
{
MSqlQuery update_record(MSqlQuery::InitCon());
update_record.prepare("UPDATE record SET station = :CALLSIGN"
" WHERE chanid = :CHANID;");
do
{
update_record.bindValue(":CALLSIGN",
records_without_station.value(1));
update_record.bindValue(":CHANID",
records_without_station.value(0));
if (!update_record.exec())
{
MythDB::DBError("Updating record station",
update_record.lastQuery());
}
} while (records_without_station.next());
}
}
if (!query.exec(
"SELECT cardid, hostname "
"FROM capturecard "
"ORDER BY cardid"))
{
MythDB::DBError("Querying Recorders", query);
return false;
}
vector<uint> cardids;
vector<QString> hosts;
while (query.next())
{
uint cardid = query.value(0).toUInt();
QString host = query.value(1).toString();
QString cidmsg = QString("Card %1").arg(cardid);
if (host.isEmpty())
{
QString msg = cidmsg + " does not have a hostname defined.\n"
"Please run setup and confirm all of the capture cards.\n";
VERBOSE(VB_IMPORTANT, msg);
gCoreContext->LogEntry("mythbackend", LP_CRITICAL,
"Problem with capture cards", msg);
continue;
}
cardids.push_back(cardid);
hosts.push_back(host);
}
for (uint i = 0; i < cardids.size(); i++)
{
if (hosts[i] == localhostname)
new TVRec(cardids[i]);
}
for (uint i = 0; i < cardids.size(); i++)
//.........这里部分代码省略.........