From f70ad43f1366ed58d3eeec714c3917b48ffb54b8 Mon Sep 17 00:00:00 2001 From: Hangyu Kuang Date: Fri, 22 Jul 2016 10:47:16 -0700 Subject: [PATCH] media: Add hidden api to set video encoding profile and level. bug: 30284097 Change-Id: I898f9a05571098a0ca0f57fb5abf58567c16fdd1 --- media/java/android/media/MediaRecorder.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index 73485afcecffd..94e894f9ce9d3 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -745,6 +745,27 @@ public class MediaRecorder setParameter("video-param-encoding-bitrate=" + bitRate); } + /** + * Sets the video encoding profile for recording. Call this method before prepare(). + * Prepare() may perform additional checks on the parameter to make sure whether the + * specified profile and level are applicable, and sometimes the passed profile or + * level will be discarded due to codec capablity or to ensure the video recording + * can proceed smoothly based on the capabilities of the platform. + * @hide + * @param profile declared in {@link MediaCodecInfo.CodecProfileLevel}. + * @param level declared in {@link MediaCodecInfo.CodecProfileLevel}. + */ + public void setVideoEncodingProfileLevel(int profile, int level) { + if (profile <= 0) { + throw new IllegalArgumentException("Video encoding profile is not positive"); + } + if (level <= 0) { + throw new IllegalArgumentException("Video encoding level is not positive"); + } + setParameter("video-param-encoder-profile=" + profile); + setParameter("video-param-encoder-level=" + level); + } + /** * Currently not implemented. It does nothing. * @deprecated Time lapse mode video recording using camera still image capture