美文网首页
getDuration 源码

getDuration 源码

作者: 无善无恶 | 来源:发表于2017-08-13 14:14 被阅读9次
    static jlong IjkMediaPlayer_getDuration(JNIEnv *env, jobject thiz)
    {
        jlong retval = 0;
        IjkMediaPlayer *mp = jni_get_media_player(env, thiz);
        JNI_CHECK_GOTO(mp, env, NULL, "mpjni: getDuration: null mp", LABEL_RETURN);
    
        retval = ijkmp_get_duration(mp);
    
    LABEL_RETURN:
        ijkmp_dec_ref_p(&mp);
        return retval;
    }
    
    
    long ijkmp_get_duration(IjkMediaPlayer *mp)
    {
        assert(mp);
        pthread_mutex_lock(&mp->mutex);
        long retval = ijkmp_get_duration_l(mp);
        pthread_mutex_unlock(&mp->mutex);
        return retval;
    }
    
    static long ijkmp_get_duration_l(IjkMediaPlayer *mp)
    {
        return ffp_get_duration_l(mp->ffplayer);
    }
    
    long ffp_get_duration_l(FFPlayer *ffp)
    {
        assert(ffp);
        VideoState *is = ffp->is;
        if (!is || !is->ic)
            return 0;
    
        int64_t duration = fftime_to_milliseconds(is->ic->duration);
        if (duration < 0)
            return 0;
    
        return (long)duration;
    }
    
    #define fftime_to_milliseconds(ts) (av_rescale(ts, 1000, AV_TIME_BASE))
    
    
    

    相关文章

      网友评论

          本文标题:getDuration 源码

          本文链接:https://www.haomeiwen.com/subject/lnferxtx.html