1 /* 2 * This file is part of libbluray 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with this library. If not, see 16 * <http://www.gnu.org/licenses/>. 17 */ 18 19 package org.videolan.media.content.video.dvb.mpeg.drip; 20 21 import java.awt.Component; 22 import java.awt.Dimension; 23 import java.awt.Rectangle; 24 25 import org.dvb.media.VideoPresentationControl; 26 import org.havi.ui.HScreen; 27 import org.havi.ui.HScreenRectangle; 28 import org.havi.ui.HVideoConfiguration; 29 import org.videolan.StreamInfo; 30 31 public class VideoControl implements VideoPresentationControl { VideoControl(Handler player)32 protected VideoControl(Handler player) { 33 //this.player = player; 34 } 35 getNormalizedRectangle(Dimension dimension, Rectangle rectangle)36 protected HScreenRectangle getNormalizedRectangle(Dimension dimension, Rectangle rectangle) { 37 if ((dimension.width == 0) || (dimension.height == 0)) 38 return new HScreenRectangle(0, 0, 0, 0); 39 float x = (float)rectangle.x / dimension.width; 40 float y = (float)rectangle.y / dimension.height; 41 float w = (float)rectangle.width / dimension.width; 42 float h = (float)rectangle.height / dimension.height; 43 return new HScreenRectangle(x, y, w, h); 44 } 45 getRectangle(Dimension dimension, HScreenRectangle rectangle)46 protected Rectangle getRectangle(Dimension dimension, HScreenRectangle rectangle) { 47 int x = (int)(rectangle.x * dimension.width); 48 int y = (int)(rectangle.y * dimension.height); 49 int w = (int)(rectangle.width * dimension.width); 50 int h = (int)(rectangle.height * dimension.height); 51 return new Rectangle(x, y, w, h); 52 } 53 getPositionOnScreen(float pos)54 protected float getPositionOnScreen(float pos) { 55 if (pos < 0.0f) 56 return 0.0f; 57 if (pos > 1.0f) 58 return 1.0f; 59 return pos; 60 } 61 getRectangleOnScreen(HScreenRectangle rectangle)62 protected HScreenRectangle getRectangleOnScreen(HScreenRectangle rectangle) { 63 float x1 = getPositionOnScreen(rectangle.x); 64 float y1 = getPositionOnScreen(rectangle.y); 65 float x2 = getPositionOnScreen(rectangle.x + rectangle.width); 66 float y2 = getPositionOnScreen(rectangle.y + rectangle.height); 67 return new HScreenRectangle(x1, y1, x2 - x1, y2 - y1); 68 } 69 getScreenSize()70 protected Dimension getScreenSize() { 71 HVideoConfiguration hvc = HScreen.getDefaultHScreen().getDefaultHVideoDevice().getCurrentConfiguration(); 72 return hvc.getPixelResolution(); 73 } 74 setVideoArea(HScreenRectangle rectangle)75 protected void setVideoArea(HScreenRectangle rectangle) { 76 dstArea = rectangle; 77 // TODO 78 } 79 getInputVideoSize()80 public Dimension getInputVideoSize() { 81 return new Dimension(0, 0); 82 } 83 getVideoSize()84 public Dimension getVideoSize() { 85 Rectangle dr = getRectangle(getScreenSize(), dstArea); 86 return new Dimension(dr.width, dr.height); 87 } 88 getActiveVideoArea()89 public HScreenRectangle getActiveVideoArea() { 90 return new HScreenRectangle(dstArea.x, dstArea.y, dstArea.width, dstArea.height); 91 } 92 getActiveVideoAreaOnScreen()93 public HScreenRectangle getActiveVideoAreaOnScreen() { 94 return getRectangleOnScreen(dstArea); 95 } 96 getTotalVideoArea()97 public HScreenRectangle getTotalVideoArea() { 98 return getActiveVideoArea(); 99 } 100 getTotalVideoAreaOnScreen()101 public HScreenRectangle getTotalVideoAreaOnScreen() { 102 return getActiveVideoAreaOnScreen(); 103 } 104 supportsClipping()105 public boolean supportsClipping() { 106 return true; 107 } 108 getClipRegion()109 public Rectangle getClipRegion() { 110 return getRectangle(getVideoSize(), srcArea); 111 } 112 setClipRegion(Rectangle clipRect)113 public Rectangle setClipRegion(Rectangle clipRect) { 114 Dimension vd = getInputVideoSize(); 115 if ((vd.width == 0) || (vd.height == 0)) 116 return new Rectangle(0, 0); 117 if (clipRect != null) 118 srcArea = getRectangleOnScreen(getNormalizedRectangle(vd, clipRect)); 119 else 120 srcArea = new HScreenRectangle(0.0f, 0.0f, 1.0f, 1.0f); 121 122 //TODO 123 org.videolan.Logger.unimplemented("VideoControl", "setClipRegion"); 124 125 return getRectangle(vd, srcArea); 126 } 127 supportsArbitraryHorizontalScaling()128 public float[] supportsArbitraryHorizontalScaling() { 129 return new float[] { 0.001f, 4.0f }; 130 } 131 supportsArbitraryVerticalScaling()132 public float[] supportsArbitraryVerticalScaling() { 133 return new float[] { 0.001f, 4.0f }; 134 } 135 getHorizontalScalingFactors()136 public float[] getHorizontalScalingFactors() { 137 org.videolan.Logger.unimplemented("VideoControl", "getHorizontalScalingFactors"); 138 throw new Error("Not implemented"); // TODO implement 139 } 140 getVerticalScalingFactors()141 public float[] getVerticalScalingFactors() { 142 org.videolan.Logger.unimplemented("VideoControl", "getVerticalScalingFactors"); 143 throw new Error("Not implemented"); // TODO implement 144 } 145 getPositioningCapability()146 public byte getPositioningCapability() { 147 return POS_CAP_FULL; 148 } 149 getControlComponent()150 public Component getControlComponent() { 151 org.videolan.Logger.unimplemented("VideoControl", "getControlComponent"); 152 throw new Error("Not implemented"); // TODO implement 153 } 154 155 //private Handler player; 156 private HScreenRectangle srcArea = new HScreenRectangle(0.0f, 0.0f, 1.0f, 1.0f); 157 private HScreenRectangle dstArea = new HScreenRectangle(0.0f, 0.0f, 1.0f, 1.0f); 158 } 159