Skip to content
Snippets Groups Projects
Commit 34aa12ef authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Improve libvlc aspect ratios

parent 1346e5dd
No related branches found
No related tags found
1 merge request!1221Implement ML 0.11.x API changes
......@@ -393,12 +393,32 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
//Video size constants
public enum ScaleType {
SURFACE_BEST_FIT,
SURFACE_FIT_SCREEN,
SURFACE_FILL,
SURFACE_16_9,
SURFACE_4_3,
SURFACE_ORIGINAL
SURFACE_BEST_FIT(null),
SURFACE_FIT_SCREEN(null),
SURFACE_FILL(null),
SURFACE_16_9(16F/9F),
SURFACE_4_3(4F/3F),
SURFACE_16_10(16F/10F),
SURFACE_221_1(2.21F),
SURFACE_235_1(2.35F),
SURFACE_239_1(2.39F),
SURFACE_5_4(5F/4F),
SURFACE_ORIGINAL(null);
private final Float ratio;
ScaleType(Float ratio) {
this.ratio = ratio;
}
public Float getRatio() {
return ratio;
}
static public ScaleType[] getMainScaleTypes() {
return new ScaleType[]{SURFACE_BEST_FIT, SURFACE_FIT_SCREEN, SURFACE_FILL, SURFACE_16_9, SURFACE_4_3, SURFACE_ORIGINAL};
}
}
public static final int SURFACE_SCALES_COUNT = ScaleType.values().length;
......
......@@ -175,6 +175,26 @@ class VideoHelper implements IVLCVout.OnNewVideoLayoutListener {
mMediaPlayer.setAspectRatio("16:9");
mMediaPlayer.setScale(0);
break;
case SURFACE_16_10:
mMediaPlayer.setAspectRatio("16:10");
mMediaPlayer.setScale(0);
break;
case SURFACE_221_1:
mMediaPlayer.setAspectRatio("2.21:1");
mMediaPlayer.setScale(0);
break;
case SURFACE_235_1:
mMediaPlayer.setAspectRatio("2.35:1");
mMediaPlayer.setScale(0);
break;
case SURFACE_239_1:
mMediaPlayer.setAspectRatio("2.39:1");
mMediaPlayer.setScale(0);
break;
case SURFACE_5_4:
mMediaPlayer.setAspectRatio("5:4");
mMediaPlayer.setScale(0);
break;
case SURFACE_4_3:
mMediaPlayer.setAspectRatio("4:3");
mMediaPlayer.setScale(0);
......@@ -277,24 +297,17 @@ class VideoHelper implements IVLCVout.OnNewVideoLayoutListener {
break;
case SURFACE_FILL:
break;
case SURFACE_16_9:
ar = 16.0 / 9.0;
if (dar < ar)
dh = dw / ar;
else
dw = dh * ar;
case SURFACE_ORIGINAL:
dh = mVideoVisibleHeight;
dw = vw;
break;
case SURFACE_4_3:
ar = 4.0 / 3.0;
default:
ar = mCurrentScaleType.getRatio();
if (dar < ar)
dh = dw / ar;
else
dw = dh * ar;
break;
case SURFACE_ORIGINAL:
dh = mVideoVisibleHeight;
dw = vw;
break;
}
// set display size
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment