AspectModeManager { RectangleF doMeasureSource(VideoInfo videoInfo, RectangleF screen) { if (AspectHelper.is_ar_equals(videoInfo.size.getAR(), videoInfo.aspectRatio)) { return AspectHelper.fitInside(videoInfo.size, screen); } else { if (AspectHelper.is_16_9(videoInfo.aspectRatio)) { return AspectHelper.fitInside(AspectHelper.RectF_16_9.copy(), screen); } else { if (videoInfo.size.getAR() < videoInfo.aspectRatio) { return AspectHelper.fitInside(videoInfo.size.copy().updateWidthUsingAspectRatio(AspectHelper.ar_4_3), screen); } else { return AspectHelper.fitInside(videoInfo.size, screen); } } } }  RectangleF doMeasure(VideoInfo info, RectangleF uiSize, float uiAR); String[] getARModes(); static String DEFAULT_ASPECT_MODE; static String ASPECT_MODES; }
@Test public void testMeasureSource16_9_in_16_9() { RectangleF ui = new RectangleF(0,0,1920, 1920 / AspectHelper.ar_16_9); RectangleF vid = new RectangleF(0,0,1280, 1280 / AspectHelper.ar_16_9); System.out.println("UI: " + ui); System.out.println("VID: " + vid); assertTrue(AspectHelper.is_16_9(ui.getAR())); assertTrue(AspectHelper.is_16_9(vid.getAR())); VideoInfo vi = new VideoInfo(); vi.update(vid.asIntRect().width, vid.asIntRect().height, vid.getAR()); vi.updateARMode("Source"); AspectModeManager amm = new AspectModeManager(); Rectangle destVid = amm.doMeasureSource(vi, ui).asIntRect(); System.out.println("DESTVID: " + destVid); assertTrue("Destination and UI should be same size", destVid.equals(ui.asIntRect())); }
@Test public void testMeasureSource4_3_in_16_9() { RectangleF ui = new RectangleF(0,0,1920, 1920 / AspectHelper.ar_16_9); RectangleF vid = new RectangleF(0,0,640, 640 / AspectHelper.ar_4_3); System.out.println("UI: " + ui); System.out.println("VID: " + vid); assertTrue(AspectHelper.is_16_9(ui.getAR())); assertTrue(AspectHelper.is_4_3(vid.getAR())); VideoInfo vi = new VideoInfo(); vi.update(vid.asIntRect().width, vid.asIntRect().height, vid.getAR()); vi.updateARMode("Source"); AspectModeManager amm = new AspectModeManager(); Rectangle destVid = amm.doMeasureSource(vi, ui).asIntRect(); System.out.println("DESTVID: " + destVid); assertEquals(ui.asIntRect().height, destVid.height); assertEquals(destVid.x * 2 + destVid.width, ui.asIntRect().width); }