org.videolan.libvlc.util.HWDecoderUtil Java Examples

The following examples show how to use org.videolan.libvlc.util.HWDecoderUtil. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VideoPlayerActivity.java    From VCL-Android with Apache License 2.0 7 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.player_remote);

    mSurfaceView = (SurfaceView) findViewById(R.id.remote_player_surface);
    mSubtitlesSurfaceView = (SurfaceView) findViewById(R.id.remote_subtitles_surface);
    mSurfaceFrame = (FrameLayout) findViewById(R.id.remote_player_surface_frame);

    if (HWDecoderUtil.HAS_SUBTITLES_SURFACE) {
        mSubtitlesSurfaceView.setZOrderMediaOverlay(true);
        mSubtitlesSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    } else
        mSubtitlesSurfaceView.setVisibility(View.GONE);
    VideoPlayerActivity activity = (VideoPlayerActivity)getOwnerActivity();
    if (activity == null) {
        Log.e(TAG, "Failed to get the VideoPlayerActivity instance, secondary display won't work");
        return;
    }

    Log.i(TAG, "Secondary display created");
}
 
Example #2
Source File: Media.java    From libvlc-android-sdk with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Add or remove hw acceleration media options
 *
 * @param enabled if true, hw decoder will be used
 * @param force force hw acceleration even for unknown devices
 */
public void setHWDecoderEnabled(boolean enabled, boolean force) {
    HWDecoderUtil.Decoder decoder = enabled ?
            HWDecoderUtil.getDecoderFromDevice() :
            HWDecoderUtil.Decoder.NONE;

    /* Unknown device but the user asked for hardware acceleration */
    if (decoder == HWDecoderUtil.Decoder.UNKNOWN && force)
        decoder = HWDecoderUtil.Decoder.ALL;

    if (decoder == HWDecoderUtil.Decoder.NONE || decoder == HWDecoderUtil.Decoder.UNKNOWN) {
        addOption(":codec=all");
        return;
    }

    /*
     * Set higher caching values if using iomx decoding, since some omx
     * decoders have a very high latency, and if the preroll data isn't
     * enough to make the decoder output a frame, the playback timing gets
     * started too soon, and every decoded frame appears to be too late.
     * On Nexus One, the decoder latency seems to be 25 input packets
     * for 320x170 H.264, a few packets less on higher resolutions.
     * On Nexus S, the decoder latency seems to be about 7 packets.
     */
    if (!mFileCachingSet)
        addOption(":file-caching=1500");
    if (!mNetworkCachingSet)
        addOption(":network-caching=1500");

    final StringBuilder sb = new StringBuilder(":codec=");
    if (decoder == HWDecoderUtil.Decoder.MEDIACODEC || decoder == HWDecoderUtil.Decoder.ALL)
        sb.append(getMediaCodecModule()).append(",");
    if (force && (decoder == HWDecoderUtil.Decoder.OMX || decoder == HWDecoderUtil.Decoder.ALL))
        sb.append("iomx,");
    sb.append("all");

    addOption(sb.toString());
}
 
Example #3
Source File: Media.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * Add or remove hw acceleration media options
 *
 * @param enabled if true, hw decoder will be used
 * @param force force hw acceleration even for unknown devices
 */
public void setHWDecoderEnabled(boolean enabled, boolean force) {
    HWDecoderUtil.Decoder decoder = enabled ?
            HWDecoderUtil.getDecoderFromDevice() :
            HWDecoderUtil.Decoder.NONE;

    /* Unknown device but the user asked for hardware acceleration */
    if (decoder == HWDecoderUtil.Decoder.UNKNOWN && force)
        decoder = HWDecoderUtil.Decoder.ALL;

    if (decoder == HWDecoderUtil.Decoder.NONE || decoder == HWDecoderUtil.Decoder.UNKNOWN) {
        addOption(":codec=all");
        return;
    }

    /*
     * Set higher caching values if using iomx decoding, since some omx
     * decoders have a very high latency, and if the preroll data isn't
     * enough to make the decoder output a frame, the playback timing gets
     * started too soon, and every decoded frame appears to be too late.
     * On Nexus One, the decoder latency seems to be 25 input packets
     * for 320x170 H.264, a few packets less on higher resolutions.
     * On Nexus S, the decoder latency seems to be about 7 packets.
     */
    addOption(":file-caching=1500");
    addOption(":network-caching=1500");

    final StringBuilder sb = new StringBuilder(":codec=");
    if (decoder == HWDecoderUtil.Decoder.MEDIACODEC || decoder == HWDecoderUtil.Decoder.ALL)
        sb.append(getMediaCodecModule()).append(",");
    if (force && (decoder == HWDecoderUtil.Decoder.OMX || decoder == HWDecoderUtil.Decoder.ALL))
        sb.append("iomx,");
    sb.append("all");

    addOption(sb.toString());
}
 
Example #4
Source File: Media.java    From OTTLivePlayer_vlc with MIT License 5 votes vote down vote up
/**
 * Add or remove hw acceleration media options
 *
 * @param enabled if true, hw decoder will be used
 * @param force force hw acceleration even for unknown devices
 */
public void setHWDecoderEnabled(boolean enabled, boolean force) {
    HWDecoderUtil.Decoder decoder = enabled ?
            HWDecoderUtil.getDecoderFromDevice() :
            HWDecoderUtil.Decoder.NONE;

    /* Unknown device but the user asked for hardware acceleration */
    if (decoder == HWDecoderUtil.Decoder.UNKNOWN && force)
        decoder = HWDecoderUtil.Decoder.ALL;

    if (decoder == HWDecoderUtil.Decoder.NONE || decoder == HWDecoderUtil.Decoder.UNKNOWN) {
        addOption(":codec=all");
        return;
    }

    /*
     * Set higher caching values if using iomx decoding, since some omx
     * decoders have a very high latency, and if the preroll data isn't
     * enough to make the decoder output a frame, the playback timing gets
     * started too soon, and every decoded frame appears to be too late.
     * On Nexus One, the decoder latency seems to be 25 input packets
     * for 320x170 H.264, a few packets less on higher resolutions.
     * On Nexus S, the decoder latency seems to be about 7 packets.
     */
    addOption(":file-caching=1500");
    addOption(":network-caching=1500");

    final StringBuilder sb = new StringBuilder(":codec=");
    if (decoder == HWDecoderUtil.Decoder.MEDIACODEC || decoder == HWDecoderUtil.Decoder.ALL)
        sb.append(getMediaCodecModule()).append(",");
    if (force && (decoder == HWDecoderUtil.Decoder.OMX || decoder == HWDecoderUtil.Decoder.ALL))
        sb.append("iomx,");
    sb.append("all");

    addOption(sb.toString());
}
 
Example #5
Source File: Media.java    From vlc-example-streamplayer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add or remove hw acceleration media options
 *
 * @param enabled if true, hw decoder will be used
 * @param force force hw acceleration even for unknown devices
 */
public void setHWDecoderEnabled(boolean enabled, boolean force) {
    HWDecoderUtil.Decoder decoder = enabled ?
            HWDecoderUtil.getDecoderFromDevice() :
            HWDecoderUtil.Decoder.NONE;

    /* Unknown device but the user asked for hardware acceleration */
    if (decoder == HWDecoderUtil.Decoder.UNKNOWN && force)
        decoder = HWDecoderUtil.Decoder.ALL;

    if (decoder == HWDecoderUtil.Decoder.NONE || decoder == HWDecoderUtil.Decoder.UNKNOWN) {
        addOption(":codec=all");
        return;
    }

    /*
     * Set higher caching values if using iomx decoding, since some omx
     * decoders have a very high latency, and if the preroll data isn't
     * enough to make the decoder output a frame, the playback timing gets
     * started too soon, and every decoded frame appears to be too late.
     * On Nexus One, the decoder latency seems to be 25 input packets
     * for 320x170 H.264, a few packets less on higher resolutions.
     * On Nexus S, the decoder latency seems to be about 7 packets.
     */
    addOption(":file-caching=1500");
    addOption(":network-caching=1500");

    final StringBuilder sb = new StringBuilder(":codec=");
    if (decoder == HWDecoderUtil.Decoder.MEDIACODEC || decoder == HWDecoderUtil.Decoder.ALL)
        sb.append(getMediaCodecModule()).append(",");
    if (force && (decoder == HWDecoderUtil.Decoder.OMX || decoder == HWDecoderUtil.Decoder.ALL))
        sb.append("iomx,");
    sb.append("all");

    addOption(sb.toString());
}
 
Example #6
Source File: LibVLC.java    From libvlc-sdk-android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a LibVLC withs options
 *
 * @param options
 */
public LibVLC(Context context, ArrayList<String> options) {
    mAppContext = context.getApplicationContext();
    loadLibraries();

    if (options == null)
        options = new ArrayList<String>();
    boolean setAout = true, setChroma = true;
    // check if aout/vout options are already set
    for (String option : options) {
        if (option.startsWith("--aout="))
            setAout = false;
        if (option.startsWith("--android-display-chroma"))
            setChroma = false;
        if (!setAout && !setChroma)
            break;
    }

    // set aout/vout options if they are not set
    if (setAout || setChroma) {
        if (setAout) {
            final HWDecoderUtil.AudioOutput hwAout = HWDecoderUtil.getAudioOutputFromDevice();
            if (hwAout == HWDecoderUtil.AudioOutput.OPENSLES)
                options.add("--aout=opensles");
            else
                options.add("--aout=android_audiotrack");
        }
        if (setChroma) {
            options.add("--android-display-chroma");
            options.add("RV16");
        }
    }
    nativeNew(options.toArray(new String[options.size()]), context.getDir("vlc", Context.MODE_PRIVATE).getAbsolutePath());
}
 
Example #7
Source File: Media.java    From libvlc-sdk-android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Add or remove hw acceleration media options
 *
 * @param enabled if true, hw decoder will be used
 * @param force   force hw acceleration even for unknown devices
 */
public void setHWDecoderEnabled(boolean enabled, boolean force) {
    HWDecoderUtil.Decoder decoder = enabled ?
            HWDecoderUtil.getDecoderFromDevice() :
            HWDecoderUtil.Decoder.NONE;

    /* Unknown device but the user asked for hardware acceleration */
    if (decoder == HWDecoderUtil.Decoder.UNKNOWN && force)
        decoder = HWDecoderUtil.Decoder.ALL;

    if (decoder == HWDecoderUtil.Decoder.NONE || decoder == HWDecoderUtil.Decoder.UNKNOWN) {
        addOption(":codec=all");
        return;
    }

    /*
     * Set higher caching values if using iomx decoding, since some omx
     * decoders have a very high latency, and if the preroll data isn't
     * enough to make the decoder output a frame, the playback timing gets
     * started too soon, and every decoded frame appears to be too late.
     * On Nexus One, the decoder latency seems to be 25 input packets
     * for 320x170 H.264, a few packets less on higher resolutions.
     * On Nexus S, the decoder latency seems to be about 7 packets.
     */
    if (!mFileCachingSet)
        addOption(":file-caching=1500");
    if (!mNetworkCachingSet)
        addOption(":network-caching=1500");

    final StringBuilder sb = new StringBuilder(":codec=");
    if (decoder == HWDecoderUtil.Decoder.MEDIACODEC || decoder == HWDecoderUtil.Decoder.ALL)
        sb.append(getMediaCodecModule()).append(",");
    if (force && (decoder == HWDecoderUtil.Decoder.OMX || decoder == HWDecoderUtil.Decoder.ALL))
        sb.append("iomx,");
    sb.append("all");

    addOption(sb.toString());
}
 
Example #8
Source File: LibVLC.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Create a LibVLC withs options
 *
 * @param options
 */
public LibVLC(ArrayList<String> options) {
    boolean setAout = true, setChroma = true;
    // check if aout/vout options are already set
    if (options != null) {
        for (String option : options) {
            if (option.startsWith("--aout="))
                setAout = false;
            if (option.startsWith("--androidwindow-chroma"))
                setChroma = false;
            if (!setAout && !setChroma)
                break;
        }
    }

    // set aout/vout options if they are not set
    if (setAout || setChroma) {
        if (options == null)
            options = new ArrayList<String>();
        if (setAout) {
            final HWDecoderUtil.AudioOutput hwAout = HWDecoderUtil.getAudioOutputFromDevice();
            if (hwAout == HWDecoderUtil.AudioOutput.OPENSLES)
                options.add("--aout=opensles");
            else
                options.add("--aout=android_audiotrack");
        }
        if (setChroma) {
            options.add("--androidwindow-chroma");
            options.add("RV32");
        }
    }

    nativeNew(options.toArray(new String[options.size()]));
}
 
Example #9
Source File: Media.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Add or remove hw acceleration media options
 *
 * @param enabled if true, hw decoder will be used
 * @param force force hw acceleration even for unknown devices
 */
public void setHWDecoderEnabled(boolean enabled, boolean force) {
    final HWDecoderUtil.Decoder decoder = enabled ?
            HWDecoderUtil.getDecoderFromDevice() :
            HWDecoderUtil.Decoder.NONE;

    if (decoder == HWDecoderUtil.Decoder.NONE ||
            (decoder == HWDecoderUtil.Decoder.UNKNOWN && !force)) {
        addOption(":codec=all");
        return;
    }

    /*
     * Set higher caching values if using iomx decoding, since some omx
     * decoders have a very high latency, and if the preroll data isn't
     * enough to make the decoder output a frame, the playback timing gets
     * started too soon, and every decoded frame appears to be too late.
     * On Nexus One, the decoder latency seems to be 25 input packets
     * for 320x170 H.264, a few packets less on higher resolutions.
     * On Nexus S, the decoder latency seems to be about 7 packets.
     */
    addOption(":file-caching=1500");
    addOption(":network-caching=1500");

    final StringBuilder sb = new StringBuilder(":codec=");
    if (decoder == HWDecoderUtil.Decoder.MEDIACODEC)
        sb.append(getMediaCodecModule()).append(",");
    else if (decoder == HWDecoderUtil.Decoder.OMX)
        sb.append("iomx,");
    else
        sb.append(getMediaCodecModule()).append(",iomx,");
    sb.append("all");

    addOption(sb.toString());
}
 
Example #10
Source File: VLCOptions.java    From VCL-Android with Apache License 2.0 5 votes vote down vote up
public static String getAout(SharedPreferences pref) {
    int aout = -1;
    try {
        aout = Integer.parseInt(pref.getString("aout", "-1"));
    } catch (NumberFormatException ignored) {}
    final HWDecoderUtil.AudioOutput hwaout = HWDecoderUtil.getAudioOutputFromDevice();
    if (hwaout == HWDecoderUtil.AudioOutput.AUDIOTRACK || hwaout == HWDecoderUtil.AudioOutput.OPENSLES)
        aout = hwaout == HWDecoderUtil.AudioOutput.OPENSLES ? AOUT_OPENSLES : AOUT_AUDIOTRACK;

    return aout == AOUT_OPENSLES ? "opensles_android" : "android_audiotrack";
}