Search in sources :

Example 21 with RequiresApi

use of androidx.annotation.RequiresApi in project ExoPlayer by google.

the class MediaCodecInfo method alignVideoSizeV21.

@RequiresApi(21)
private static Point alignVideoSizeV21(VideoCapabilities capabilities, int width, int height) {
    int widthAlignment = capabilities.getWidthAlignment();
    int heightAlignment = capabilities.getHeightAlignment();
    return new Point(Util.ceilDivide(width, widthAlignment) * widthAlignment, Util.ceilDivide(height, heightAlignment) * heightAlignment);
}
Also used : Point(android.graphics.Point) Point(android.graphics.Point) RequiresApi(androidx.annotation.RequiresApi)

Example 22 with RequiresApi

use of androidx.annotation.RequiresApi in project ExoPlayer by google.

the class MediaCodecInfo method areSizeAndRateSupportedV21.

@RequiresApi(21)
private static boolean areSizeAndRateSupportedV21(VideoCapabilities capabilities, int width, int height, double frameRate) {
    // Don't ever fail due to alignment. See: https://github.com/google/ExoPlayer/issues/6551.
    Point alignedSize = alignVideoSizeV21(capabilities, width, height);
    width = alignedSize.x;
    height = alignedSize.y;
    // versions of Android, so we only check the size in this case [Internal ref: b/153940404].
    if (frameRate == Format.NO_VALUE || frameRate < 1) {
        return capabilities.isSizeSupported(width, height);
    } else {
        // The signaled frame rate may be slightly higher than the actual frame rate, so we take the
        // floor to avoid situations where a range check in areSizeAndRateSupported fails due to
        // slightly exceeding the limits for a standard format (e.g., 1080p at 30 fps).
        double floorFrameRate = Math.floor(frameRate);
        return capabilities.areSizeAndRateSupported(width, height, floorFrameRate);
    }
}
Also used : Point(android.graphics.Point) RequiresApi(androidx.annotation.RequiresApi)

Example 23 with RequiresApi

use of androidx.annotation.RequiresApi in project ExoPlayer by google.

the class DefaultAudioSink method writeNonBlockingWithAvSyncV21.

@RequiresApi(21)
private int writeNonBlockingWithAvSyncV21(AudioTrack audioTrack, ByteBuffer buffer, int size, long presentationTimeUs) {
    if (Util.SDK_INT >= 26) {
        // The underlying platform AudioTrack writes AV sync headers directly.
        return audioTrack.write(buffer, size, AudioTrack.WRITE_NON_BLOCKING, presentationTimeUs * 1000);
    }
    if (avSyncHeader == null) {
        avSyncHeader = ByteBuffer.allocate(16);
        avSyncHeader.order(ByteOrder.BIG_ENDIAN);
        avSyncHeader.putInt(0x55550001);
    }
    if (bytesUntilNextAvSync == 0) {
        avSyncHeader.putInt(4, size);
        avSyncHeader.putLong(8, presentationTimeUs * 1000);
        avSyncHeader.position(0);
        bytesUntilNextAvSync = size;
    }
    int avSyncHeaderBytesRemaining = avSyncHeader.remaining();
    if (avSyncHeaderBytesRemaining > 0) {
        int result = audioTrack.write(avSyncHeader, avSyncHeaderBytesRemaining, AudioTrack.WRITE_NON_BLOCKING);
        if (result < 0) {
            bytesUntilNextAvSync = 0;
            return result;
        }
        if (result < avSyncHeaderBytesRemaining) {
            return 0;
        }
    }
    int result = writeNonBlockingV21(audioTrack, buffer, size);
    if (result < 0) {
        bytesUntilNextAvSync = 0;
        return result;
    }
    bytesUntilNextAvSync -= result;
    return result;
}
Also used : SuppressLint(android.annotation.SuppressLint) RequiresApi(androidx.annotation.RequiresApi)

Example 24 with RequiresApi

use of androidx.annotation.RequiresApi in project ExoPlayer by google.

the class DefaultAudioSink method setAudioTrackPlaybackParametersV23.

@RequiresApi(23)
private void setAudioTrackPlaybackParametersV23(PlaybackParameters audioTrackPlaybackParameters) {
    if (isAudioTrackInitialized()) {
        PlaybackParams playbackParams = new PlaybackParams().allowDefaults().setSpeed(audioTrackPlaybackParameters.speed).setPitch(audioTrackPlaybackParameters.pitch).setAudioFallbackMode(PlaybackParams.AUDIO_FALLBACK_MODE_FAIL);
        try {
            audioTrack.setPlaybackParams(playbackParams);
        } catch (IllegalArgumentException e) {
            Log.w(TAG, "Failed to set playback params", e);
        }
        // Update the speed using the actual effective speed from the audio track.
        audioTrackPlaybackParameters = new PlaybackParameters(audioTrack.getPlaybackParams().getSpeed(), audioTrack.getPlaybackParams().getPitch());
        audioTrackPositionTracker.setAudioTrackPlaybackSpeed(audioTrackPlaybackParameters.speed);
    }
    this.audioTrackPlaybackParameters = audioTrackPlaybackParameters;
}
Also used : PlaybackParams(android.media.PlaybackParams) PlaybackParameters(com.google.android.exoplayer2.PlaybackParameters) RequiresApi(androidx.annotation.RequiresApi)

Example 25 with RequiresApi

use of androidx.annotation.RequiresApi in project Gadgetbridge by Freeyourgadget.

the class DiscoveryActivity method stopBLEDiscovery.

@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
private void stopBLEDiscovery() {
    if (adapter == null) {
        return;
    }
    BluetoothLeScanner bluetoothLeScanner = adapter.getBluetoothLeScanner();
    if (bluetoothLeScanner == null) {
        LOG.warn("Could not get BluetoothLeScanner()!");
        return;
    }
    if (newBLEScanCallback == null) {
        LOG.warn("newLeScanCallback == null!");
        return;
    }
    try {
        bluetoothLeScanner.stopScan(newBLEScanCallback);
    } catch (NullPointerException e) {
        LOG.warn("Internal NullPointerException when stopping the scan!");
        return;
    }
    LOG.debug("Stopped BLE discovery");
    setIsScanning(Scanning.SCANNING_OFF);
}
Also used : BluetoothLeScanner(android.bluetooth.le.BluetoothLeScanner) RequiresApi(androidx.annotation.RequiresApi)

Aggregations

RequiresApi (androidx.annotation.RequiresApi)161 NotificationChannel (android.app.NotificationChannel)20 Intent (android.content.Intent)16 NonNull (androidx.annotation.NonNull)16 SuppressLint (android.annotation.SuppressLint)14 Uri (android.net.Uri)14 NotificationManager (android.app.NotificationManager)13 IOException (java.io.IOException)13 StatusBarNotification (android.service.notification.StatusBarNotification)10 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)10 Context (android.content.Context)9 Rect (android.graphics.Rect)8 Notification (android.app.Notification)7 ByteBuffer (java.nio.ByteBuffer)7 ArrayList (java.util.ArrayList)7 SecretKey (javax.crypto.SecretKey)7 PendingIntent (android.app.PendingIntent)6 Bitmap (android.graphics.Bitmap)5 Point (android.graphics.Point)5 Build (android.os.Build)5