-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
25 changed files
with
393 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright 2016, 2017 Octavio Calleya | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.transgressoft.timecode.fps30; | ||
|
||
import com.transgressoft.timecode.*; | ||
|
||
import static com.transgressoft.timecode.TimecodeException.ErrorCase.*; | ||
|
||
/** | ||
* Class that represents a {@link Timecode} implementation of | ||
* a 30 fps video timecode. | ||
* | ||
* @author Octavio Calleya | ||
* @version 1.0 | ||
* @see <a href="https://en.wikipedia.org/wiki/SMPTE_timecode">SMPTE Timecode</a> | ||
*/ | ||
public class Fps30Timecode extends TimecodeBase { | ||
|
||
/** | ||
* Maximum amount of frames accepted, since the maximum value | ||
* of the Timecode can be 23:59:59:30: | ||
* | ||
* <p>24 * 60 * 60 * 30 = 2 592 000</p> | ||
*/ | ||
private static final int FRAME_COUNT_LIMIT = 2592000; | ||
private static final int FRAME_MAX = 30; | ||
|
||
private Fps30Timecode(int hours, int minutes, int seconds, int frames) { | ||
super(hours, minutes, seconds, frames); | ||
countFrames(hours, minutes, seconds, frames); | ||
} | ||
|
||
private Fps30Timecode(int frameCount) { | ||
super(frameCount); | ||
countUnits(frameCount); | ||
} | ||
|
||
public static Fps30Timecode of(int hours, int minutes, int seconds, int frames) { | ||
if (! FrameRateType.FPS30.areValidValues(hours, minutes, seconds, frames)) | ||
throw new IllegalArgumentException(INVALID_TIMECODE.getErrorMessage()); | ||
return new Fps30Timecode(hours, minutes, seconds, frames); | ||
} | ||
|
||
public static Fps30Timecode of(int frameCount) { | ||
if (frameCount < 0) | ||
throw new IllegalArgumentException(FRAME_COUNT_LESS_0.getErrorMessage()); | ||
if (frameCount >= FRAME_COUNT_LIMIT) | ||
throw new IllegalArgumentException(FRAME_COUNT_GREATER_LIMIT.getErrorMessage() + " " + FRAME_COUNT_LIMIT); | ||
return new Fps30Timecode(frameCount); | ||
} | ||
|
||
@Override | ||
public Timecode add(Timecode timecode) throws TimecodeException { | ||
if (! (timecode instanceof Fps30Timecode)) | ||
throw new TimecodeException(INVALID_ADDITION); | ||
addition(timecode); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Timecode subtract(Timecode timecode) throws TimecodeException { | ||
if (! (timecode instanceof Fps30Timecode)) | ||
throw new TimecodeException(INVALID_SUBTRACTION); | ||
subtraction(timecode); | ||
return this; | ||
} | ||
|
||
@Override | ||
protected int getFrameMax() { | ||
return FRAME_MAX; | ||
} | ||
|
||
@Override | ||
public int getFrameCountLimit() { | ||
return FRAME_COUNT_LIMIT; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/com/transgressoft/timecode/fps30/Fps30TimecodeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2016, 2017 Octavio Calleya | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.transgressoft.timecode.fps30; | ||
|
||
import com.transgressoft.timecode.*; | ||
|
||
/** | ||
* Factory class that creates {@link Fps30Timecode} objects. | ||
* | ||
* @author Octavio Calleya | ||
* @version 1.0 | ||
*/ | ||
public class Fps30TimecodeFactory extends TimecodeFactory { | ||
|
||
@Override | ||
public Timecode createTimeCode(int hours, int minutes, int seconds, int frames) { | ||
return Fps30Timecode.of(hours, minutes, seconds, frames); | ||
} | ||
|
||
@Override | ||
public Timecode createTimeCode(int frameCount) { | ||
return Fps30Timecode.of(frameCount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.