-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from darbyjohnston/refactor5
Refactoring
- Loading branch information
Showing
27 changed files
with
871 additions
and
189 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Contributors to the toucan project. | ||
|
||
#include "TimelineAlgo.h" | ||
|
||
#include <opentimelineio/clip.h> | ||
|
||
namespace toucan | ||
{ | ||
std::vector<OTIO_NS::SerializableObject::Retainer<OTIO_NS::Clip> > | ||
getVideoClips(const OTIO_NS::SerializableObject::Retainer<OTIO_NS::Timeline>& timeline) | ||
{ | ||
std::vector<OTIO_NS::SerializableObject::Retainer<OTIO_NS::Clip> > out; | ||
for (const auto& child : timeline->tracks()->children()) | ||
{ | ||
if (auto track = OTIO_NS::dynamic_retainer_cast<OTIO_NS::Track>(child)) | ||
{ | ||
if (OTIO_NS::Track::Kind::video == track->kind()) | ||
{ | ||
const auto clips = track->find_clips(nullptr, std::nullopt, true); | ||
out.insert(out.end(), clips.begin(), clips.end()); | ||
} | ||
} | ||
} | ||
return out; | ||
} | ||
|
||
std::optional<OTIO_NS::TimeRange> getTimeRange( | ||
const std::vector<OTIO_NS::SerializableObject::Retainer<OTIO_NS::Item> >& items, | ||
const OTIO_NS::RationalTime& startTime, | ||
double rate) | ||
{ | ||
std::optional<OTIO_NS::TimeRange> out; | ||
for (const auto& item : items) | ||
{ | ||
//! \bug Shouldn't trimmed_range_in_parent() check whether the parent | ||
//! is null? | ||
if (item->parent()) | ||
{ | ||
const auto timeRangeOpt = item->trimmed_range_in_parent(); | ||
if (timeRangeOpt.has_value()) | ||
{ | ||
const OTIO_NS::TimeRange timeRange( | ||
timeRangeOpt.value().start_time() + startTime, | ||
timeRangeOpt.value().duration()); | ||
if (out.has_value()) | ||
{ | ||
out = OTIO_NS::TimeRange::range_from_start_end_time_inclusive( | ||
std::min( | ||
out.value().start_time(), | ||
timeRange.start_time().rescaled_to(rate).round()), | ||
std::max( | ||
out.value().end_time_inclusive(), | ||
timeRange.end_time_inclusive().rescaled_to(rate).round())); | ||
} | ||
else | ||
{ | ||
out = OTIO_NS::TimeRange( | ||
timeRange.start_time().rescaled_to(rate).round(), | ||
timeRange.duration().rescaled_to(rate).round()); | ||
} | ||
} | ||
} | ||
} | ||
return out; | ||
} | ||
} |
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,19 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Contributors to the toucan project. | ||
|
||
#pragma once | ||
|
||
#include <opentimelineio/timeline.h> | ||
|
||
namespace toucan | ||
{ | ||
//! Get the video clips in a timeline. | ||
std::vector<OTIO_NS::SerializableObject::Retainer<OTIO_NS::Clip> > | ||
getVideoClips(const OTIO_NS::SerializableObject::Retainer<OTIO_NS::Timeline>&); | ||
|
||
//! Get the range of multiple items. | ||
std::optional<OTIO_NS::TimeRange> getTimeRange( | ||
const std::vector<OTIO_NS::SerializableObject::Retainer<OTIO_NS::Item> >&, | ||
const OTIO_NS::RationalTime& startTime, | ||
double rate); | ||
} |
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.