001    package railo.runtime.video;
002    
003    public class VideoProfileImpl implements VideoProfile {
004    
005            private String type;
006            private String dimension;
007            private long audioBitrate =0;
008            private long videoBitrate =0;
009            private long videoBitrateMin =0;
010            private long videoBitrateMax =0;
011            private long videoBitrateTolerance =0;
012            //private boolean sameQualityAsSource =false;
013            private double framerate =0;
014            private double audioSamplerate=0;
015            private int aspectRatio=0;
016            private int scanMode=0;
017            private String videoCodec;
018            private String audioCodec;
019            //private long bufferSize;
020            private long bufferSize;
021            private int pass=0;
022            
023    
024            public VideoProfileImpl(String type, String dimension, long audioBitrate,
025                            long videoBitrate, long videoBitrateMin, long videoBitrateMax,
026                            long videoBitrateTolerance,double framerate, int aspectRatio, int scanMode,
027                            String audioCodec, String videoCodec,double audioSamplerate) {
028                    super();
029                    this.type = type;
030                    this.dimension = dimension;
031                    this.audioBitrate = audioBitrate;
032                    this.videoBitrate = videoBitrate;
033                    this.videoBitrateMin = videoBitrateMin;
034                    this.videoBitrateMax = videoBitrateMax;
035                    this.videoBitrateTolerance = videoBitrateTolerance;
036                    this.framerate = framerate;
037                    this.aspectRatio = aspectRatio;
038                    this.scanMode = scanMode;
039                    this.audioCodec = audioCodec;
040                    this.videoCodec = videoCodec;
041                    this.audioSamplerate = audioSamplerate;
042            }
043            public VideoProfileImpl() {}
044    
045            public VideoProfile duplicate() {
046                    
047                    
048                    return new VideoProfileImpl(type,dimension,audioBitrate,videoBitrate,videoBitrateMin,videoBitrateMax,
049                                    videoBitrateTolerance,framerate,aspectRatio,scanMode,audioCodec,videoCodec,audioSamplerate);
050            }
051            
052    
053            /**
054             * set the type of the output format (see constants "TYPE_xxx" of this class)
055             * @param type 
056             */
057            public void setType(String type){
058                    this.type=type;
059            }
060    
061            /**
062             * @return the type
063             */
064            public String getType() {
065                    return type;
066            }
067    
068            /**
069             * @return the dimension
070             */
071            public String getDimension() {
072                    return dimension;
073            }
074    
075            public void setDimension(int width, int height)  {
076                    checkDimension(width,"width");
077                    checkDimension(height,"height");
078                    this.dimension=width+"X"+height;
079            }
080    
081            private void checkDimension(int value, String label) {
082                    //if(((value/2)*2)!=value)
083                            //throw new VideoException("dimension ["+value+"] "+label+" must be the muliple of 2 (2,4,8,16 ...)");
084            }
085    
086            /**
087             * @return the bitrate
088             */
089            public double getVideoBitrate() {
090                    return videoBitrate;
091            }
092    
093            /**
094             * set video bitrate in kbit/s (default 200)
095             * @param bitrate the bitrate to set
096             */
097            public void setVideoBitrate(long bitrate) {
098                    this.videoBitrate = bitrate;
099            }
100    
101            /**
102             * @return the framerate
103             */
104            public double getFramerate() {
105                    return framerate;
106            }
107    
108            /**
109             * sets the framerate (default 25)
110             * @param framerate the framerate to set
111             */
112            public void setFramerate(double framerate) {
113                    this.framerate = framerate;
114            }
115    
116            /**
117             * @return the aspectRatio
118             */
119            public int getAspectRatio() {
120                    return aspectRatio;
121            }
122    
123            /**
124             * sets the aspectRatio (VideoOutput.ASPECT_RATIO_xxx)
125             * @param aspectRatio the aspectRatio to set
126             */
127            public void setAspectRatio(int aspectRatio) {
128                    this.aspectRatio = aspectRatio;
129            }
130            
131    
132            public void setAspectRatio(String strAspectRatio) {
133                    strAspectRatio=strAspectRatio.trim().toLowerCase();
134                    if("16:9".equals(strAspectRatio))this.aspectRatio=ASPECT_RATIO_16_9;
135                    else if("4:3".equals(strAspectRatio))this.aspectRatio=ASPECT_RATIO_4_3;
136            }
137    
138            /**
139             * @return the bitrateMin
140             */
141            public double getVideoBitrateMin() {
142                    return videoBitrateMin;
143            }
144    
145            /**
146             * set min video bitrate tolerance (in kbit/s)
147             * @param bitrateMin the bitrateMin to set
148             */
149            public void setVideoBitrateMin(long bitrateMin) {
150                    this.videoBitrateMin = bitrateMin;
151            }
152    
153            /**
154             * @return the bitrateMax
155             */
156            public double getVideoBitrateMax() {
157                    return videoBitrateMax;
158            }
159    
160            /**
161             * set max video bitrate tolerance (in kbit/s)
162             * @param bitrateMax the bitrateMax to set
163             */
164            public void setVideoBitrateMax(long bitrateMax) {
165                    this.videoBitrateMax = bitrateMax;
166            }
167    
168            /**
169             * @return the bitrateTolerance
170             */
171            public double getVideoBitrateTolerance() {
172                    return videoBitrateTolerance;
173            }
174    
175            /**
176             * set video bitrate tolerance (in kbit/s)
177             * @param bitrateTolerance the bitrateTolerance to set
178             */
179            public void setVideoBitrateTolerance(long bitrateTolerance) {
180                    this.videoBitrateTolerance = bitrateTolerance;
181            }
182    
183            /**
184             * @return the audioBitrate
185             */
186            public double getAudioBitrate() {
187                    return audioBitrate;
188            }
189    
190            /**
191             * @return the scanMode
192             */
193            public int getScanMode() {
194                    return scanMode;
195            }
196            /**
197             * @param scanMode the scanMode to set
198             */
199            public void setScanMode(int scanMode) {
200                    this.scanMode = scanMode;
201            }
202            /**
203             * @param audioBitrate the audioBitrate to set
204             */
205            public void setAudioBitrate(long audioBitrate) {
206                    this.audioBitrate = audioBitrate;
207            }
208            public void setAudioCodec(String codec) {
209                    this.audioCodec=codec;
210            }
211            public void setVideoCodec(String codec) {
212                    this.videoCodec=codec;
213            }
214            /**
215             * @return the videoCodec
216             */
217            public String getVideoCodec() {
218                    return videoCodec;
219            }
220            /**
221             * @return the audioCodec
222             */
223            public String getAudioCodec() {
224                    return audioCodec;
225            }
226            /**
227             * @return the audioSamplerate
228             */
229            public double getAudioSamplerate() {
230                    return audioSamplerate;
231            }
232            /**
233             * @param audioSamplerate the audioSamplerate to set
234             */
235            public void setAudioSamplerate(double audioSamplerate) {
236                    this.audioSamplerate = audioSamplerate;
237            }
238            /**
239             * @return the bufferSize
240             */
241            public long getBufferSize() {
242                    return bufferSize;
243            }
244            /**
245             * @param bufferSize the bufferSize to set
246             */
247            public void setBufferSize(long bufferSize) {
248                    this.bufferSize = bufferSize;
249            }
250            /**
251             * @return the pass
252             */
253            public int getPass() {
254                    return pass;
255            }
256            /**
257             * @param pass the pass to set
258             */
259            public void setPass(int pass) {
260                    this.pass = pass;
261            }
262    }