Package io.opentimeline.opentimelineio
Class Composition
java.lang.Object
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Composition extends Item
Base class for an OTIO Item that contains other Items.
Should be subclassed (for example by Track and Stack), not used directly.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Composition.CompositionBuilder
Nested classes/interfaces inherited from class io.opentimeline.opentimelineio.Composable
Composable.ComposableBuilder
Nested classes/interfaces inherited from class io.opentimeline.opentimelineio.SerializableObjectWithMetadata
SerializableObjectWithMetadata.SerializableObjectWithMetadataBuilder
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
Composition()
Composition(Composition.CompositionBuilder builder)
Composition(java.lang.String name, TimeRange sourceRange, AnyDictionary metadata, java.util.List<Effect> effects, java.util.List<Marker> markers)
-
Method Summary
Modifier and Type Method Description boolean
appendChild(Composable child, ErrorStatus errorStatus)
Append the child to the end of the Composition.void
clearChildren()
Remove all children from the composition and clear their parents.java.util.stream.Stream<Composable>
eachChild(TimeRange searchRange, boolean shallowSearch, ErrorStatus errorStatus)
Stream that returns each child contained in the composition in the order in which it is found.<T extends Composable>
java.util.stream.Stream<T>eachChild(TimeRange searchRange, java.lang.Class<T> descendedFrom, boolean shallowSearch, ErrorStatus errorStatus)
Stream that returns each child of specified type contained in the composition in the order in which it is found.<T extends Composable>
java.util.stream.Stream<T>eachChild(java.lang.Class<T> descendedFrom, ErrorStatus errorStatus)
Stream that returns each child of specified type contained in the composition in the order in which it is found.Composable
getChildAtTime(RationalTime searchTime, boolean shallowSearch, ErrorStatus errorStatus)
Return the child that overlaps with time searchTime.Composable
getChildAtTime(RationalTime searchTime, ErrorStatus errorStatus)
Return the child that overlaps with time searchTime.java.util.List<Composable>
getChildren()
java.lang.String
getCompositionKind()
Returns a label specifying the kind of composition.Pair<RationalTime,RationalTime>
getHandlesOfChild(Composable child, ErrorStatus errorStatus)
If media beyond the ends of this child are visible due to adjacent Transitions (only applicable in a Track) then this will return the head and tail offsets as a Pair of RationalTime objects.java.util.HashMap<Composable,TimeRange>
getRangeOfAllChildren(ErrorStatus errorStatus)
Return a HashMap mapping children to their range in this object.TimeRange
getRangeOfChild(Composable child, ErrorStatus errorStatus)
The range of the child not trimmed based on this composition's sourceRange.TimeRange
getRangeOfChildAtIndex(int index, ErrorStatus errorStatus)
Return the range of a child item in the time range of this composition.TimeRange
getTrimmedRangeOfChild(Composable child, ErrorStatus errorStatus)
Get range of the child, after the sourceRange is applied.TimeRange
getTrimmedRangeOfChildAtIndex(int index, ErrorStatus errorStatus)
Return the trimmed range of the child item at index in the time range of this composition.boolean
hasChild(Composable child)
boolean
insertChild(int index, Composable child, ErrorStatus errorStatus)
Insert a child Composable at an index.boolean
isParentOf(Composable composable)
boolean
removeChild(int index, ErrorStatus errorStatus)
Remove the child at any index.boolean
setChild(int index, Composable child, ErrorStatus errorStatus)
Set the child at a particular index.void
setChildren(java.util.List<Composable> children, ErrorStatus errorStatus)
Set children for this Composition.java.lang.String
toString()
TimeRange
trimChildRange(TimeRange childRange)
Trim childRange to this.sourceRangeMethods inherited from class io.opentimeline.opentimelineio.Item
getAvailableRange, getDuration, getEffects, getMarkers, getRangeInParent, getSourceRange, getTransformedTime, getTransformedTimeRange, getTrimmedRange, getTrimmedRangeInParent, getVisibleRange, isOverlapping, isVisible, setSourceRange
Methods inherited from class io.opentimeline.opentimelineio.SerializableObjectWithMetadata
getMetadata, getName, setMetadata, setName
Methods inherited from class io.opentimeline.opentimelineio.SerializableObject
clone, currentRefCount, dynamicFields, equals, fromJSONFile, fromJSONString, isEquivalentTo, isUnknownSchema, schemaName, schemaVersion, toJSONFile, toJSONFile, toJSONString, toJSONString
-
Constructor Details
-
Composition
protected Composition() -
Composition
public Composition(java.lang.String name, TimeRange sourceRange, AnyDictionary metadata, java.util.List<Effect> effects, java.util.List<Marker> markers) -
Composition
-
-
Method Details
-
getCompositionKind
public java.lang.String getCompositionKind()Returns a label specifying the kind of composition.- Returns:
- the composition kind
-
getChildren
- Returns:
- all the chidlren held by this Composition.
-
clearChildren
public void clearChildren()Remove all children from the composition and clear their parents. -
setChildren
Set children for this Composition.- Parameters:
children
- a list of ComposableserrorStatus
- errorStatus to report an error if any child cannot be added.
-
insertChild
Insert a child Composable at an index.- Parameters:
index
- index at which child is to be inserted.child
- child Composable to be inserted.errorStatus
- errorStatus to report an error if child cannot be inserted.- Returns:
- was the child inserted successfully?
-
setChild
Set the child at a particular index. The needs to exist for the child to be set.- Parameters:
index
- index to set the childchild
- child Composable to be seterrorStatus
- errorStatus to report an error if child cannot be set.- Returns:
- was the child set successfully?
-
removeChild
Remove the child at any index.- Parameters:
index
- index from which the child needs to be removed.errorStatus
- errorStatus to report an error if child cannot be removed.- Returns:
- was the child removed successfully?
-
appendChild
Append the child to the end of the Composition.- Parameters:
child
- child to be appendederrorStatus
- errorStatus to report an error if child cannot be appended.- Returns:
- was the child appended successfully?
-
isParentOf
- Parameters:
composable
- Composable to check ancestry of- Returns:
- true if this is a parent or ancestor of the composable.
-
getHandlesOfChild
public Pair<RationalTime,RationalTime> getHandlesOfChild(Composable child, ErrorStatus errorStatus)If media beyond the ends of this child are visible due to adjacent Transitions (only applicable in a Track) then this will return the head and tail offsets as a Pair of RationalTime objects. If no handles are present on either side, then null is returned instead of a RationalTime.- Parameters:
child
- child Composable to get handleserrorStatus
- errorStatus to report error while fetching handles- Returns:
- head and tail offsets as a Pair of RationalTime objects
-
getRangeOfChildAtIndex
Return the range of a child item in the time range of this composition. For example, with a track: [ClipA][ClipB][ClipC] this.getRangeOfChildAtIndex(2, errorStatus) will return: TimeRange(ClipA.duration + ClipB.duration, ClipC.duration)- Parameters:
index
- index of child whose range is to be fetchederrorStatus
- errorStatus to report error if range cannot be fetched- Returns:
- range of child at index
-
getTrimmedRangeOfChildAtIndex
Return the trimmed range of the child item at index in the time range of this composition.For example, with a track: [ ] [ClipA][ClipB][ClipC] The range of index 2 (ClipC) will be just like getRangeOfChildAtIndex() but trimmed based on this Composition's sourceRange.
- Parameters:
index
- index of child whose trimmed range is to be fetchederrorStatus
- errorStatus to report error if trimmed range cannot be fetched- Returns:
- trimmed range of child at index
-
getRangeOfChild
The range of the child not trimmed based on this composition's sourceRange. For example: | [-----] | seq [-----------------] Clip A If ClipA has duration 17, and seq has sourceRange: 5, duration 15, seq.getRangeOfChild(Clip A) will return (0, 17) ignoring the sourceRange of seq.To get the range of the child with the sourceRange applied, use the getTrimmedRangeOfChild() method.
- Parameters:
child
- child Composable whose range is to be fetchederrorStatus
- errorStatus to report error if range cannot be fetched- Returns:
- range of the child not trimmed based on this composition's sourceRange
-
getTrimmedRangeOfChild
Get range of the child, after the sourceRange is applied. Example | [-----] | seq [-----------------] Clip A If ClipA has duration 17, and seq has sourceRange: 5, duration 10, seq.getTrimmedRangeOfChild(Clip A) will return (5, 10) Which is trimming the range according to the sourceRange of seq. To get the range of the child without the sourceRange applied, use the getRangeOfChild() method. Another example | [-----] | seq sourceRange starts on frame 4 and goes to frame 8 [ClipA][ClipB] (each 6 frames long)seq.getRangeOfChild(ClipA) = 0, duration 6 seq.getTrimmedRangeOfChild(ClipB) = 4, duration 2
- Parameters:
child
- child Composable whose trimmed range is to be fetchederrorStatus
- errorStatus to report error if range cannot be fetched- Returns:
- range of the child trimmed based on this composition's sourceRange
-
trimChildRange
Trim childRange to this.sourceRange- Parameters:
childRange
- range to be trimmed- Returns:
- null if childRange has no intersection with this.sourceRange, else trimmed range
-
hasChild
- Parameters:
child
- child to find- Returns:
- does the composition contain the child?
-
getRangeOfAllChildren
Return a HashMap mapping children to their range in this object.- Parameters:
errorStatus
- errorStatus to report any error while fetching ranges- Returns:
- a HashMap mapping children to their range in this object
-
getChildAtTime
public Composable getChildAtTime(RationalTime searchTime, boolean shallowSearch, ErrorStatus errorStatus)Return the child that overlaps with time searchTime. searchTime is in the space of self. If shallowSearch is false, will recurse into compositions.- Parameters:
searchTime
- the time at which the child is to be fetchedshallowSearch
- should the algorithm recurse into compositions or not?errorStatus
- errorStatus to report any error while fetching the child- Returns:
- the child that overlaps with time searchTime
-
getChildAtTime
Return the child that overlaps with time searchTime. searchTime is in the space of self. This function will recurse into compositions.- Parameters:
searchTime
- the time at which the child is to be fetchederrorStatus
- errorStatus to report any error while fetching the child- Returns:
- the child that overlaps with time searchTime
-
eachChild
public <T extends Composable> java.util.stream.Stream<T> eachChild(TimeRange searchRange, java.lang.Class<T> descendedFrom, boolean shallowSearch, ErrorStatus errorStatus)Stream that returns each child of specified type contained in the composition in the order in which it is found.- Type Parameters:
T
- type of children to fetch- Parameters:
searchRange
- if not null, only children whose range overlaps with the search range will be in the stream.descendedFrom
- only children who are a descendent of the descendedFrom type will be in the streamshallowSearch
- should the algorithm recurse into compositions or not?errorStatus
- errorStatus to report any error while iterating- Returns:
- a Stream consisting of all the children of specified type in the composition in the order in which it is found
-
eachChild
public java.util.stream.Stream<Composable> eachChild(TimeRange searchRange, boolean shallowSearch, ErrorStatus errorStatus)Stream that returns each child contained in the composition in the order in which it is found.- Parameters:
searchRange
- if not null, only children whose range overlaps with the search range will be in the stream.shallowSearch
- should the algorithm recurse into compositions or not?errorStatus
- errorStatus to report any error while iterating- Returns:
- a Stream consisting of all the children in the composition (in the searchRange) in the order in which it is found
-
eachChild
public <T extends Composable> java.util.stream.Stream<T> eachChild(java.lang.Class<T> descendedFrom, ErrorStatus errorStatus)Stream that returns each child of specified type contained in the composition in the order in which it is found. This stream will recurse into compositions.- Type Parameters:
T
- type of children to fetch- Parameters:
descendedFrom
- only children who are a descendent of the descendedFrom type will be in the streamerrorStatus
- errorStatus to report any error while iterating- Returns:
- a Stream consisting of all the children of specified type in the composition in the order in which it is found
-
toString
public java.lang.String toString()
-