当前位置: 首页>>代码示例>>C++>>正文


C++ AVClass类代码示例

本文整理汇总了C++中AVClass的典型用法代码示例。如果您正苦于以下问题:C++ AVClass类的具体用法?C++ AVClass怎么用?C++ AVClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AVClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: format_line

static void format_line(void *ptr, int level, const char *fmt, va_list vl,
                        char part[3][LINE_SZ], int part_size, int *print_prefix, int type[2])
{
    AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
    part[0][0] = part[1][0] = part[2][0] = 0;
    if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
    if (*print_prefix && avc) {
        if (avc->parent_log_context_offset) {
            AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +
                                   avc->parent_log_context_offset);
            if (parent && *parent) {
                snprintf(part[0], part_size, "[%s @ %p] ",
                         (*parent)->item_name(parent), parent);
                if(type) type[0] = get_category(parent);
            }
        }
        snprintf(part[1], part_size, "[%s @ %p] ",
                 avc->item_name(ptr), ptr);
        if(type) type[1] = get_category(ptr);
    }

    vsnprintf(part[2], part_size, fmt, vl);

    if(*part[0] || *part[1] || *part[2]) {
        char lastc = strlen(part[2]) ? part[2][strlen(part[2]) - 1] : 0;
        *print_prefix = lastc == '\n' || lastc == '\r';
    }
}
开发者ID:gkhighelf,项目名称:avplayer,代码行数:28,代码来源:log.c

示例2: av_log_wx_callback

void av_log_wx_callback(void* ptr, int level, const char* fmt, va_list vl)
{
   int av_log_level = AV_LOG_WARNING;
   AVClass* avc = ptr ? *(AVClass**)ptr : NULL;
   if (level > av_log_level)
      return;
   wxString printstring(wxT(""));

   if (avc) {
      printstring.Append(wxString::Format(wxT("[%s @ %p] "), wxString::FromUTF8(avc->item_name(ptr)).c_str(), avc));
   }

   wxString frm(fmt,wxConvLibc);
   printstring.Append(wxString::FormatV(frm,vl));

   wxString cpt;
   switch (level)
   {
   case 0: cpt = wxT("Error"); break;
   case 1: cpt = wxT("Info"); break;
   case 2: cpt = wxT("Debug"); break;
   default: cpt = wxT("Log"); break;
   }
   wxLogMessage(wxT("%s: %s"),cpt.c_str(),printstring.c_str());
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:25,代码来源:FFmpeg.cpp

示例3: ffmpeg_log_cb

static void ffmpeg_log_cb(void* ptr, int level, const char* fmt, va_list vl)
{
    const char *LOG_SENDER = "ffmpeg";
    enum { LOG_LEVEL = 5 };
    char buf[100];
    int bufsize = sizeof(buf), len;
    pj_str_t fmt_st;

    /* Custom callback needs to filter log level by itself */
    if (level > av_log_get_level())
	return;
    
    /* Add original ffmpeg sender to log format */
    if (ptr) {
	AVClass* avc = *(AVClass**)ptr;
	len = pj_ansi_snprintf(buf, bufsize, "%s: ", avc->item_name(ptr));
	bufsize -= len;
    }

    /* Copy original log format */
    len = pj_ansi_strlen(fmt);
    if (len > bufsize-1)
	len = bufsize-1;
    pj_memcpy(buf+sizeof(buf)-bufsize, fmt, len);
    bufsize -= len;

    /* Trim log format */
    pj_strset(&fmt_st, buf, sizeof(buf)-bufsize);
    pj_strrtrim(&fmt_st);
    buf[fmt_st.slen] = '\0';

    pj_log(LOG_SENDER, LOG_LEVEL, buf, vl);
}
开发者ID:xhook,项目名称:asterisk-v11,代码行数:33,代码来源:ffmpeg_util.c

示例4: format_line

static void format_line(void *ptr, int level, const char *fmt, va_list vl,
                        AVBPrint part[3], int *print_prefix, int type[2])
{
    AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
    av_bprint_init(part+0, 0, 1);
    av_bprint_init(part+1, 0, 1);
    av_bprint_init(part+2, 0, 65536);

    if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16;
    if (*print_prefix && avc) {
        if (avc->parent_log_context_offset) {
            AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +
                                   avc->parent_log_context_offset);
            if (parent && *parent) {
                av_bprintf(part+0, "[%s @ %p] ",
                         (*parent)->item_name(parent), parent);
                if(type) type[0] = get_category(parent);
            }
        }
        av_bprintf(part+1, "[%s @ %p] ",
                 avc->item_name(ptr), ptr);
        if(type) type[1] = get_category(ptr);
    }

    av_vbprintf(part+2, fmt, vl);

    if(*part[0].str || *part[1].str || *part[2].str) {
        char lastc = part[2].len ? part[2].str[part[2].len - 1] : 0;
        *print_prefix = lastc == '\n' || lastc == '\r';
    }
}
开发者ID:AquaSoftGmbH,项目名称:FFmpeg,代码行数:31,代码来源:log.c

示例5: av_log_windebug_callback

void av_log_windebug_callback(void* ptr, int level, const char* fmt, va_list vl) {
	static int print_prefix=1;
	static int count;
	static char line[1024] = {0}, prev[1024] = {0};
	AVClass* avc = ptr ? *(AVClass**)ptr : NULL;
	if(level > av_log_get_level())
		return;

	int written = 0;
	if(print_prefix && avc) {
		written = snprintf(line, sizeof(line), "[%s @ %p]", avc->item_name(ptr), ptr);
	}

	written += vsnprintf(line + written, sizeof(line) - written, fmt, vl);

	print_prefix = line[written-1] == '\n';
	line[sizeof(line) - 1] = 0;
	if(print_prefix && !strcmp(line, prev)){
		count++;
		return;
	}
	if(count > 0){
		std::stringstream ss;
		ss << "    Last message repeated " << count << " times\n";
		OutputDebugStringA(ss.str().c_str());
		count = 0;
	}
	OutputDebugStringA(line);
	strcpy(prev, line);
}
开发者ID:1974kpkpkp,项目名称:ffms2,代码行数:30,代码来源:ffms.cpp

示例6: mp_msg_av_log_callback

static void mp_msg_av_log_callback(void *ptr, int level, const char *fmt,
                                   va_list vl)
{
    AVClass *avc = ptr ? *(AVClass **)ptr : NULL;
    int mp_level = av_log_level_to_mp_level(level);

    // Note: mp_log is thread-safe, but destruction of the log instances is not.
    pthread_mutex_lock(&log_lock);

    if (!log_mpv_instance) {
        pthread_mutex_unlock(&log_lock);
        // Fallback to stderr
        vfprintf(stderr, fmt, vl);
        return;
    }

    struct mp_log *log = get_av_log(ptr);

    if (mp_msg_test(log, mp_level)) {
        char buffer[4096] = "";
        int pos = 0;
        const char *prefix = avc ? avc->item_name(ptr) : NULL;
        if (log_print_prefix && prefix)
            pos = snprintf(buffer, sizeof(buffer), "%s: ", prefix);
        log_print_prefix = fmt[strlen(fmt) - 1] == '\n';

        pos = MPMIN(MPMAX(pos, 0), sizeof(buffer));
        vsnprintf(buffer + pos, sizeof(buffer) - pos, fmt, vl);

        mp_msg(log, mp_level, "%s", buffer);
    }

    pthread_mutex_unlock(&log_lock);
}
开发者ID:wiiaboo,项目名称:mpv,代码行数:34,代码来源:av_log.c

示例7: mp_msg_av_log_callback

static void mp_msg_av_log_callback(void *ptr, int level, const char *fmt,
                                   va_list vl)
{
    AVClass *avc = ptr ? *(AVClass **)ptr : NULL;
    int mp_level = av_log_level_to_mp_level(level);

    // Note: mp_log is thread-safe, but destruction of the log instances is not.
    pthread_mutex_lock(&log_lock);

    if (!log_mpv_instance) {
        pthread_mutex_unlock(&log_lock);
        // Fallback to stderr
        vfprintf(stderr, fmt, vl);
        return;
    }

    struct mp_log *log = get_av_log(ptr);

    if (mp_msg_test(log, mp_level)) {
        if (log_print_prefix)
            mp_msg(log, mp_level, "%s: ", avc ? avc->item_name(ptr) : "?");
        log_print_prefix = fmt[strlen(fmt) - 1] == '\n';

        mp_msg_va(log, mp_level, fmt, vl);
    }

    pthread_mutex_unlock(&log_lock);
}
开发者ID:Bl4Cc4t,项目名称:mpv,代码行数:28,代码来源:av_log.c

示例8: logging_callback

/// libav logging hook
void logging_callback(void* ptr, int level, const char* fmt,
                      std::va_list arg_list)
{
    using boost::lexical_cast;

    AVClass* avc = ptr ? (*reinterpret_cast<AVClass**>(ptr)) : 0;

    std::string prefix;

    if (avc)
    {
        if (avc->parent_log_context_offset)
        {
            AVClass** parent = *reinterpret_cast<AVClass ***> (ptr) +
                               avc->parent_log_context_offset;
            if (parent && *parent)
            {
                prefix += '[';
                prefix += (*parent)->class_name;
                prefix += ' ';
                prefix += (*parent)->item_name(parent);
                prefix += " @ ";
                prefix += lexical_cast<std::string>(parent);
                prefix += "] ";
            }
        }
        prefix += '[';
        prefix += avc->class_name;
        prefix += ' ';
        prefix += avc->item_name(ptr);
        prefix += " @ ";
        prefix += lexical_cast<std::string>(ptr);
        prefix += "] ";
    }

    switch(level)
    {
    case AV_LOG_PANIC:
    case AV_LOG_FATAL:
    case AV_LOG_ERROR:
        LOG(ERROR) << prefix << stringf(fmt, arg_list).get();
        break;
    case AV_LOG_WARNING:
        LOG(WARNING) << prefix << stringf(fmt, arg_list).get();
        break;
    case AV_LOG_INFO:
        VLOG(3) << prefix << stringf(fmt, arg_list).get();
        break;
    case AV_LOG_VERBOSE:
        VLOG(4) << prefix << stringf(fmt, arg_list).get();
        break;
    case AV_LOG_DEBUG:
        VLOG(5) << prefix << stringf(fmt, arg_list).get();
        break;
    default:
        LOG(ERROR) << prefix
                   << "*" << stringf(fmt, arg_list).get();
    }
}
开发者ID:podshumok,项目名称:libav-stream-plusplus,代码行数:60,代码来源:stream_transcoder.cpp

示例9: xuggler_log_callback

  /*
   * This function will be called back by Ffmpeg anytime
   * it wants to log.  We then use it to dump
   * stuff into our own logs.
   */
  static void
  xuggler_log_callback(void* ptr, int level, const char* fmt, va_list va)
  {
    static Logger* ffmpegLogger = 0;
    AVClass* avc = ptr ? *(AVClass**)ptr : 0;

    int currentLevel = av_log_get_level();
//    fprintf(stderr, "current level: %d; log level: %d\n", level, currentLevel);
    if (level > currentLevel || currentLevel < AV_LOG_PANIC)
      // just return
      return;

    if (!ffmpegLogger)
    {
      Global::lock();
      if (!ffmpegLogger)
        ffmpegLogger = Logger::getStaticLogger( "org.ffmpeg" );
      Global::unlock();
    }

    Logger::Level logLevel;
    if (level <= AV_LOG_ERROR)
      logLevel = Logger::LEVEL_ERROR;
    else if (level <= AV_LOG_WARNING)
      logLevel = Logger::LEVEL_WARN;
    else if (level <= AV_LOG_INFO)
      logLevel = Logger::LEVEL_INFO;
    else if (level <= AV_LOG_DEBUG)
      logLevel = Logger::LEVEL_DEBUG;
    else
      logLevel = Logger::LEVEL_TRACE;

    // Revise the format string to add additional useful info
    char revisedFmt[1024];
    revisedFmt[sizeof(revisedFmt)-1] = 0;
    if (avc)
    {
      snprintf(revisedFmt, sizeof(revisedFmt), "[%s @ %p] %s",
          avc->item_name(ptr), ptr, fmt);
    }
    else
    {
      snprintf(revisedFmt, sizeof(revisedFmt), "%s", fmt);
    }
    int len = strlen(revisedFmt);
    if (len > 0 && revisedFmt[len-1] == '\n')
    {
      revisedFmt[len-1]=0;
      --len;
    }
    if (len > 0)
      // it's not useful to pass in filenames and line numbers here.
      ffmpegLogger->logVA(0, 0, logLevel, revisedFmt, va);
  }
开发者ID:mfpgt,项目名称:xuggle-xuggler,代码行数:59,代码来源:Global.cpp

示例10: http_av_log

static void http_av_log(void *ptr, int level, const char *fmt, va_list vargs)
{
    static int print_prefix = 1;
    AVClass *avc = ptr ? *(AVClass**)ptr : NULL;
    if (level > av_log_get_level())
        return;
    if (print_prefix && avc)
        http_log("[%s @ %p]", avc->item_name(ptr), ptr);
    print_prefix = strstr(fmt, "\n") != NULL;
    http_vlog(fmt, vargs);
}
开发者ID:mobdim,项目名称:ffmpeg-streaming,代码行数:11,代码来源:ffserver.c

示例11: get_category

static int get_category(void *ptr){
    AVClass *avc = *(AVClass **) ptr;
    if(    !avc
        || (avc->version&0xFF)<100
        ||  avc->version < (51 << 16 | 59 << 8)
        ||  avc->category >= AV_CLASS_CATEGORY_NB) return AV_CLASS_CATEGORY_NA + 16;

    if(avc->get_category)
        return avc->get_category(ptr) + 16;

    return avc->category + 16;
}
开发者ID:AquaSoftGmbH,项目名称:FFmpeg,代码行数:12,代码来源:log.c

示例12: qtav_ffmpeg_log_callback

static void qtav_ffmpeg_log_callback(void* ctx, int level,const char* fmt, va_list vl)
{
    // AV_LOG_DEBUG is used by ffmpeg developers
    if (level > AV_LOG_VERBOSE)
        return;
    AVClass *c = ctx ? *(AVClass**)ctx : 0;
    QString qmsg = QString().sprintf("[FFmpeg:%s] ", c ? c->item_name(ctx) : "?") + QString().vsprintf(fmt, vl);
    qmsg = qmsg.trimmed();
    if (level > AV_LOG_WARNING)
        qDebug() << qmsg;
    else if (level > AV_LOG_PANIC)
        qWarning() << qmsg;
}
开发者ID:morfeyka,项目名称:QtAV,代码行数:13,代码来源:QtAV_Global.cpp

示例13: setOptionsToFFmpegObj

void setOptionsToFFmpegObj(const QVariant& opt, void* obj)
{
    if (!opt.isValid())
        return;
    AVClass *c = obj ? *(AVClass**)obj : 0;
    if (c)
        qDebug() << QString("%1.%2 options:").arg(c->class_name).arg(c->item_name(obj));
    else
        qDebug() << "options:";
    if (opt.type() == QVariant::Map) {
        QVariantMap options(opt.toMap());
        if (options.isEmpty())
            return;
        QMapIterator<QString, QVariant> i(options);
        while (i.hasNext()) {
            i.next();
            const QVariant::Type vt = i.value().type();
            if (vt == QVariant::Map)
                continue;
            const QByteArray key(i.key().toLower().toUtf8());
            qDebug("%s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
            if (vt == QVariant::Int || vt == QVariant::UInt || vt == QVariant::Bool) {
                // QVariant.toByteArray(): "true" or "false", can not recognized by avcodec
                av_opt_set_int(obj, key.constData(), i.value().toInt(), 0);
            } else if (vt == QVariant::LongLong || vt == QVariant::ULongLong) {
                av_opt_set_int(obj, key.constData(), i.value().toLongLong(), 0);
            } else if (vt == QVariant::Double) {
                av_opt_set_double(obj, key.constData(), i.value().toDouble(), 0);
            }
        }
        return;
    }
    QVariantHash options(opt.toHash());
    if (options.isEmpty())
        return;
    QHashIterator<QString, QVariant> i(options);
    while (i.hasNext()) {
        i.next();
        const QVariant::Type vt = i.value().type();
        if (vt == QVariant::Hash)
            continue;
        const QByteArray key(i.key().toLower().toUtf8());
        qDebug("%s=>%s", i.key().toUtf8().constData(), i.value().toByteArray().constData());
        if (vt == QVariant::Int || vt == QVariant::UInt || vt == QVariant::Bool) {
            av_opt_set_int(obj, key.constData(), i.value().toInt(), 0);
        } else if (vt == QVariant::LongLong || vt == QVariant::ULongLong) {
            av_opt_set_int(obj, key.constData(), i.value().toLongLong(), 0);
        }
    }
}
开发者ID:alishir,项目名称:QtAV,代码行数:50,代码来源:internal.cpp

示例14: av_log_default_callback

void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
{
    static int print_prefix = 1;
    static int count;
    static char prev[1024];
    char line[1024];
    static int is_atty;
    AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
    if (level > av_log_level)
        return;
    line[0] = 0;
#undef fprintf
    if (print_prefix && avc) {
        if (avc->parent_log_context_offset) {
            AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) +
                                   avc->parent_log_context_offset);
            if (parent && *parent) {
                snprintf(line, sizeof(line), "[%s @ %p] ",
                         (*parent)->item_name(parent), parent);
            }
        }
        snprintf(line + strlen(line), sizeof(line) - strlen(line), "[%s @ %p] ",
                 avc->item_name(ptr), ptr);
    }

    vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl);

    print_prefix = strlen(line) && line[strlen(line) - 1] == '\n';

#if HAVE_ISATTY
    if (!is_atty)
        is_atty = isatty(2) ? 1 : -1;
#endif

    if (print_prefix && (flags & AV_LOG_SKIP_REPEATED) &&
        !strncmp(line, prev, sizeof line)) {
        count++;
        if (is_atty == 1)
            fprintf(stderr, "    Last message repeated %d times\r", count);
        return;
    }
    if (count > 0) {
        fprintf(stderr, "    Last message repeated %d times\n", count);
        count = 0;
    }
    colored_fputs(av_clip(level >> 3, 0, 6), line);
    av_strlcpy(prev, line, sizeof line);
}
开发者ID:Arcen,项目名称:libav,代码行数:48,代码来源:log.c

示例15: mp_msg_av_log_callback

static void mp_msg_av_log_callback(void *ptr, int level, const char *fmt,
                                   va_list vl)
{
    static bool print_prefix = 1;
    AVClass *avc = ptr ? *(AVClass **)ptr : NULL;
    int mp_level = av_log_level_to_mp_level(level);
    int type = extract_msg_type_from_ctx(ptr);

    if (!mp_msg_test(type, mp_level))
        return;

    if (print_prefix && avc)
        mp_msg(type, mp_level, "[%s @ %p]", avc->item_name(ptr), avc);
    print_prefix = fmt[strlen(fmt) - 1] == '\n';

    mp_msg_va(type, mp_level, fmt, vl);
}
开发者ID:kax4,项目名称:mpv,代码行数:17,代码来源:av_log.c


注:本文中的AVClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。