Skip to content

Commit

Permalink
Add ScreenEncoder.MIMETYPE_VIDEO_AVC to shut up lint on API 19
Browse files Browse the repository at this point in the history
  • Loading branch information
consp1racy committed Jun 25, 2022
1 parent 66c54e5 commit e1d1037
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.genymobile.scrcpy.wrappers.SurfaceControl;

import android.annotation.SuppressLint;
import android.graphics.Rect;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
Expand All @@ -22,6 +23,9 @@ public class ScreenEncoder implements Device.RotationListener {
private static final int REPEAT_FRAME_DELAY_US = 100_000; // repeat after 100ms
private static final String KEY_MAX_FPS_TO_ENCODER = "max-fps-to-encoder";

@SuppressLint("InlinedApi")
public static final String MIMETYPE_VIDEO_AVC = MediaFormat.MIMETYPE_VIDEO_AVC;

// Keep the values in descending order
private static final int[] MAX_SIZE_FALLBACK = {2560, 1920, 1600, 1280, 1024, 800};

Expand Down Expand Up @@ -206,11 +210,11 @@ private static MediaCodec createCodec(String encoderName) throws IOException {
return MediaCodec.createByCodecName(encoderName);
} catch (IllegalArgumentException e) {
MediaCodecInfo[] encoders = MediaCodecListCompat.regular()
.getEncoderInfosForType(MediaFormat.MIMETYPE_VIDEO_AVC);
.getEncoderInfosForType(MIMETYPE_VIDEO_AVC);
throw new InvalidEncoderException(encoderName, encoders);
}
}
MediaCodec codec = MediaCodec.createEncoderByType(MediaFormat.MIMETYPE_VIDEO_AVC);
MediaCodec codec = MediaCodec.createEncoderByType(MIMETYPE_VIDEO_AVC);
Ln.d("Using encoder: '" + codec.getName() + "'");
return codec;
}
Expand All @@ -234,7 +238,7 @@ private static void setCodecOption(MediaFormat format, CodecOption codecOption)

private static MediaFormat createFormat(int bitRate, int maxFps, List<CodecOption> codecOptions) {
MediaFormat format = new MediaFormat();
format.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_VIDEO_AVC);
format.setString(MediaFormat.KEY_MIME, MIMETYPE_VIDEO_AVC);
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate);
// must be present to configure the encoder, but does not impact the actual frame rate, which is variable
format.setInteger(MediaFormat.KEY_FRAME_RATE, 60);
Expand Down

0 comments on commit e1d1037

Please sign in to comment.