示例#1
0
void QmlVlcVideo::getVideoSize( unsigned* width, unsigned* height )
{
    libvlc_media_t* media = libvlc_media_player_get_media( m_player.get_mp() );
    if( media && !libvlc_media_is_parsed( media ) )
        libvlc_media_parse( media );

    *width = *height = 0;
    libvlc_video_get_size( m_player.get_mp(), 0, width, height );

    if( media && ( !*width || !*height ) ) {
        /*FIXME: It's not absolutely correct way to detect media dimensions,
        since now will be returned dimensions of first track with not zero demensions,
        and there are no any guarantee it will be be current playing track.
        But we nothing can do with it, since there are no way to match current
        playing track and track info received from libvlc_media_get_tracks_info for now.*/
        libvlc_media_track_info_t* info;
        int infoCount = libvlc_media_get_tracks_info( media, &info );
        for( int i = 0; i < infoCount; ++i ) {
            if( libvlc_track_video == info[i].i_type &&
                info[i].u.video.i_width &&
                info[i].u.video.i_height )
            {
                *width = info[i].u.video.i_width;
                *height = info[i].u.video.i_height;
                break;
            }
        }
        libvlc_free( info );
    }
}
示例#2
0
文件: VLC.cpp 项目: Lewn/HitjesFoon
libvlc_media_t *VLC::newMediaFromPath(const char *path) {
    libvlc_media_t *mediaData = libvlc_media_new_path(libvlcInstance, path);
    libvlc_media_parse(mediaData);
    if (!libvlc_media_is_parsed(mediaData) || libvlc_media_get_duration(mediaData) == 0) {
        VLC::release(mediaData);
        return NULL;
    }
    return mediaData;
}
示例#3
0
JNIEXPORT jint JNICALL NAME(nativeGetVideoWidth)(JNIEnv *env, jobject thiz)
{
    libvlc_media_t *media = (libvlc_media_t *) getIntValue(env, thiz, "mLibVlcMedia");
    if (!media || !libvlc_media_is_parsed(media))
        return 0;
    /* FIXME: it returns the first video's information only */
    int i, n;
    int width = 0, height = 0;
    libvlc_media_track_info_t *track = 0;
    n = libvlc_media_get_tracks_info(media, &track);
    if (n <= 0)
        return 0;
    for (i = 0; i < n; i++) {
        libvlc_media_track_info_t t = track[i];
        if (t.i_type == libvlc_track_video) {
            width = t.u.video.i_width;
            height = t.u.video.i_height;
            break;
        }
    }
    free(track);
    return width;
}