Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e4272d4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Set default video parameters in Tx VideoFormatResolver" am: 014af402...

Merge "Set default video parameters in Tx VideoFormatResolver" am: 014af402 am: 1796c893 am: 2380d538 am: 37c4940c

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1887497

Change-Id: I8ae12f75fc95c43352d177517dbf5521cf3f5c7c
parents 7a382545 37c4940c
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -949,6 +949,8 @@ public final class MediaTranscodingManager {
             *
             * @return the video track format to be used if transcoding should be performed,
             *         and null otherwise.
             * @throws IllegalArgumentException if the hinted source video format contains invalid
             *         parameters.
             */
            @Nullable
            public MediaFormat resolveVideoFormat() {
@@ -959,21 +961,20 @@ public final class MediaTranscodingManager {
                MediaFormat videoTrackFormat = new MediaFormat(mSrcVideoFormatHint);
                videoTrackFormat.setString(MediaFormat.KEY_MIME, MediaFormat.MIMETYPE_VIDEO_AVC);

                int width = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_WIDTH);
                int height = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_HEIGHT);
                int width = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_WIDTH, -1);
                int height = mSrcVideoFormatHint.getInteger(MediaFormat.KEY_HEIGHT, -1);
                if (width <= 0 || height <= 0) {
                    throw new IllegalArgumentException(
                            "Source Width and height must be larger than 0");
                }

                float frameRate = 30.0f; // default to 30fps.
                if (mSrcVideoFormatHint.containsKey(MediaFormat.KEY_FRAME_RATE)) {
                    frameRate = mSrcVideoFormatHint.getFloat(MediaFormat.KEY_FRAME_RATE);
                float frameRate =
                        mSrcVideoFormatHint.getNumber(MediaFormat.KEY_FRAME_RATE, 30.0)
                        .floatValue();
                if (frameRate <= 0) {
                    throw new IllegalArgumentException(
                            "frameRate must be larger than 0");
                }
                }

                int bitrate = getAVCBitrate(width, height, frameRate);
                videoTrackFormat.setInteger(MediaFormat.KEY_BIT_RATE, bitrate);