001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.video; 020 021public class VideoProfileImpl implements VideoProfile { 022 023 private String type; 024 private String dimension; 025 private long audioBitrate =0; 026 private long videoBitrate =0; 027 private long videoBitrateMin =0; 028 private long videoBitrateMax =0; 029 private long videoBitrateTolerance =0; 030 //private boolean sameQualityAsSource =false; 031 private double framerate =0; 032 private double audioSamplerate=0; 033 private int aspectRatio=0; 034 private int scanMode=0; 035 private String videoCodec; 036 private String audioCodec; 037 //private long bufferSize; 038 private long bufferSize; 039 private int pass=0; 040 041 042 public VideoProfileImpl(String type, String dimension, long audioBitrate, 043 long videoBitrate, long videoBitrateMin, long videoBitrateMax, 044 long videoBitrateTolerance,double framerate, int aspectRatio, int scanMode, 045 String audioCodec, String videoCodec,double audioSamplerate) { 046 super(); 047 this.type = type; 048 this.dimension = dimension; 049 this.audioBitrate = audioBitrate; 050 this.videoBitrate = videoBitrate; 051 this.videoBitrateMin = videoBitrateMin; 052 this.videoBitrateMax = videoBitrateMax; 053 this.videoBitrateTolerance = videoBitrateTolerance; 054 this.framerate = framerate; 055 this.aspectRatio = aspectRatio; 056 this.scanMode = scanMode; 057 this.audioCodec = audioCodec; 058 this.videoCodec = videoCodec; 059 this.audioSamplerate = audioSamplerate; 060 } 061 public VideoProfileImpl() {} 062 063 public VideoProfile duplicate() { 064 065 066 return new VideoProfileImpl(type,dimension,audioBitrate,videoBitrate,videoBitrateMin,videoBitrateMax, 067 videoBitrateTolerance,framerate,aspectRatio,scanMode,audioCodec,videoCodec,audioSamplerate); 068 } 069 070 071 /** 072 * set the type of the output format (see constants "TYPE_xxx" of this class) 073 * @param type 074 */ 075 public void setType(String type){ 076 this.type=type; 077 } 078 079 /** 080 * @return the type 081 */ 082 public String getType() { 083 return type; 084 } 085 086 /** 087 * @return the dimension 088 */ 089 public String getDimension() { 090 return dimension; 091 } 092 093 public void setDimension(int width, int height) { 094 checkDimension(width,"width"); 095 checkDimension(height,"height"); 096 this.dimension=width+"X"+height; 097 } 098 099 private void checkDimension(int value, String label) { 100 //if(((value/2)*2)!=value) 101 //throw new VideoException("dimension ["+value+"] "+label+" must be the muliple of 2 (2,4,8,16 ...)"); 102 } 103 104 /** 105 * @return the bitrate 106 */ 107 public double getVideoBitrate() { 108 return videoBitrate; 109 } 110 111 /** 112 * set video bitrate in kbit/s (default 200) 113 * @param bitrate the bitrate to set 114 */ 115 public void setVideoBitrate(long bitrate) { 116 this.videoBitrate = bitrate; 117 } 118 119 /** 120 * @return the framerate 121 */ 122 public double getFramerate() { 123 return framerate; 124 } 125 126 /** 127 * sets the framerate (default 25) 128 * @param framerate the framerate to set 129 */ 130 public void setFramerate(double framerate) { 131 this.framerate = framerate; 132 } 133 134 /** 135 * @return the aspectRatio 136 */ 137 public int getAspectRatio() { 138 return aspectRatio; 139 } 140 141 /** 142 * sets the aspectRatio (VideoOutput.ASPECT_RATIO_xxx) 143 * @param aspectRatio the aspectRatio to set 144 */ 145 public void setAspectRatio(int aspectRatio) { 146 this.aspectRatio = aspectRatio; 147 } 148 149 150 public void setAspectRatio(String strAspectRatio) { 151 strAspectRatio=strAspectRatio.trim().toLowerCase(); 152 if("16:9".equals(strAspectRatio))this.aspectRatio=ASPECT_RATIO_16_9; 153 else if("4:3".equals(strAspectRatio))this.aspectRatio=ASPECT_RATIO_4_3; 154 } 155 156 /** 157 * @return the bitrateMin 158 */ 159 public double getVideoBitrateMin() { 160 return videoBitrateMin; 161 } 162 163 /** 164 * set min video bitrate tolerance (in kbit/s) 165 * @param bitrateMin the bitrateMin to set 166 */ 167 public void setVideoBitrateMin(long bitrateMin) { 168 this.videoBitrateMin = bitrateMin; 169 } 170 171 /** 172 * @return the bitrateMax 173 */ 174 public double getVideoBitrateMax() { 175 return videoBitrateMax; 176 } 177 178 /** 179 * set max video bitrate tolerance (in kbit/s) 180 * @param bitrateMax the bitrateMax to set 181 */ 182 public void setVideoBitrateMax(long bitrateMax) { 183 this.videoBitrateMax = bitrateMax; 184 } 185 186 /** 187 * @return the bitrateTolerance 188 */ 189 public double getVideoBitrateTolerance() { 190 return videoBitrateTolerance; 191 } 192 193 /** 194 * set video bitrate tolerance (in kbit/s) 195 * @param bitrateTolerance the bitrateTolerance to set 196 */ 197 public void setVideoBitrateTolerance(long bitrateTolerance) { 198 this.videoBitrateTolerance = bitrateTolerance; 199 } 200 201 /** 202 * @return the audioBitrate 203 */ 204 public double getAudioBitrate() { 205 return audioBitrate; 206 } 207 208 /** 209 * @return the scanMode 210 */ 211 public int getScanMode() { 212 return scanMode; 213 } 214 /** 215 * @param scanMode the scanMode to set 216 */ 217 public void setScanMode(int scanMode) { 218 this.scanMode = scanMode; 219 } 220 /** 221 * @param audioBitrate the audioBitrate to set 222 */ 223 public void setAudioBitrate(long audioBitrate) { 224 this.audioBitrate = audioBitrate; 225 } 226 public void setAudioCodec(String codec) { 227 this.audioCodec=codec; 228 } 229 public void setVideoCodec(String codec) { 230 this.videoCodec=codec; 231 } 232 /** 233 * @return the videoCodec 234 */ 235 public String getVideoCodec() { 236 return videoCodec; 237 } 238 /** 239 * @return the audioCodec 240 */ 241 public String getAudioCodec() { 242 return audioCodec; 243 } 244 /** 245 * @return the audioSamplerate 246 */ 247 public double getAudioSamplerate() { 248 return audioSamplerate; 249 } 250 /** 251 * @param audioSamplerate the audioSamplerate to set 252 */ 253 public void setAudioSamplerate(double audioSamplerate) { 254 this.audioSamplerate = audioSamplerate; 255 } 256 /** 257 * @return the bufferSize 258 */ 259 public long getBufferSize() { 260 return bufferSize; 261 } 262 /** 263 * @param bufferSize the bufferSize to set 264 */ 265 public void setBufferSize(long bufferSize) { 266 this.bufferSize = bufferSize; 267 } 268 /** 269 * @return the pass 270 */ 271 public int getPass() { 272 return pass; 273 } 274 /** 275 * @param pass the pass to set 276 */ 277 public void setPass(int pass) { 278 this.pass = pass; 279 } 280}