Skip to content

Commit

Permalink
Merge branch 'main' into ab_sync2
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Feb 26, 2024
2 parents eeb7c06 + 363c610 commit 6ef184f
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 247 deletions.
2 changes: 0 additions & 2 deletions lib/tlTimeline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ set(HEADERS
PlayerInline.h
PlayerOptions.h
PlayerOptionsInline.h
ReadCache.h
RenderOptions.h
RenderOptionsInline.h
RenderUtil.h
Expand Down Expand Up @@ -50,7 +49,6 @@ set(SOURCE
Player.cpp
PlayerOptions.cpp
PlayerPrivate.cpp
ReadCache.cpp
RenderUtil.cpp
TimeUnits.cpp
Timeline.cpp
Expand Down
80 changes: 0 additions & 80 deletions lib/tlTimeline/ReadCache.cpp

This file was deleted.

55 changes: 0 additions & 55 deletions lib/tlTimeline/ReadCache.h

This file was deleted.

16 changes: 9 additions & 7 deletions lib/tlTimeline/Timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ namespace tl
{
namespace timeline
{
namespace
{
const size_t readCacheMax = 10;
}

TLRENDER_ENUM_IMPL(
FileSequenceAudio,
"None",
Expand Down Expand Up @@ -45,8 +50,7 @@ namespace tl
void Timeline::_init(
const otio::SerializableObject::Retainer<otio::Timeline>& otioTimeline,
const std::shared_ptr<system::Context>& context,
const Options& options,
const std::shared_ptr<ReadCache>& readCache)
const Options& options)
{
TLRENDER_P();

Expand Down Expand Up @@ -80,8 +84,8 @@ namespace tl
}

p.context = context;
p.options = options;
p.otioTimeline = otioTimeline;
p.timelineChanges = observer::Value<bool>::create(false);
const auto i = otioTimeline->metadata().find("tlRender");
if (i != otioTimeline->metadata().end())
{
Expand All @@ -102,9 +106,8 @@ namespace tl
catch (const std::exception&)
{}
}
p.timelineChanges = observer::Value<bool>::create(false);
p.readCache = readCache ? readCache : ReadCache::create();
p.readCache->setMax(16);
p.options = options;
p.readCache.setMax(readCacheMax);

// Get information about the timeline.
p.timeRange = timeline::getTimeRange(p.otioTimeline.value);
Expand Down Expand Up @@ -324,7 +327,6 @@ namespace tl
{
request->promise.set_value(AudioData());
}
p.readCache->cancelRequests();
}

void Timeline::tick()
Expand Down
16 changes: 7 additions & 9 deletions lib/tlTimeline/Timeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
#pragma once

#include <tlTimeline/Audio.h>
#include <tlTimeline/ReadCache.h>
#include <tlTimeline/Video.h>

#include <tlCore/Context.h>
#include <tlCore/Path.h>
#include <tlCore/ValueObserver.h>

#include <opentimelineio/timeline.h>

#include <future>

namespace tl
{
//! Timelines.
Expand Down Expand Up @@ -56,8 +58,7 @@ namespace tl
otio::SerializableObject::Retainer<otio::Timeline> create(
const file::Path&,
const std::shared_ptr<system::Context>&,
const Options& = Options(),
const std::shared_ptr<ReadCache>& = nullptr);
const Options& = Options());

//! Create a new timeline from a path and audio path. The file name
//! can point to an .otio file, .otioz file, movie file, or image
Expand All @@ -66,8 +67,7 @@ namespace tl
const file::Path& path,
const file::Path& audioPath,
const std::shared_ptr<system::Context>&,
const Options& = Options(),
const std::shared_ptr<ReadCache>& = nullptr);
const Options& = Options());

//! Timeline.
class Timeline : public std::enable_shared_from_this<Timeline>
Expand All @@ -78,8 +78,7 @@ namespace tl
void _init(
const otio::SerializableObject::Retainer<otio::Timeline>&,
const std::shared_ptr<system::Context>&,
const Options&,
const std::shared_ptr<ReadCache>&);
const Options&);

Timeline();

Expand All @@ -90,8 +89,7 @@ namespace tl
static std::shared_ptr<Timeline> create(
const otio::SerializableObject::Retainer<otio::Timeline>&,
const std::shared_ptr<system::Context>&,
const Options& = Options(),
const std::shared_ptr<ReadCache>& = nullptr);
const Options& = Options());

//! Create a new timeline from a file name. The file name can point
//! to an .otio file, movie file, or image sequence.
Expand Down
50 changes: 13 additions & 37 deletions lib/tlTimeline/TimelineCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,18 +351,16 @@ namespace tl
otio::SerializableObject::Retainer<otio::Timeline> create(
const file::Path& path,
const std::shared_ptr<system::Context>& context,
const Options& options,
const std::shared_ptr<ReadCache>& readCache)
const Options& options)
{
return create(path, file::Path(), context, options, readCache);
return create(path, file::Path(), context, options);
}

otio::SerializableObject::Retainer<otio::Timeline> create(
const file::Path& inputPath,
const file::Path& inputAudioPath,
const std::shared_ptr<system::Context>& context,
const Options& options,
const std::shared_ptr<ReadCache>& readCache)
const Options& options)
{
otio::SerializableObject::Retainer<otio::Timeline> out;
std::string error;
Expand Down Expand Up @@ -415,13 +413,6 @@ namespace tl
if (auto read = ioSystem->read(path, options.ioOptions))
{
const auto info = read->getInfo().get();
if (readCache)
{
ReadCacheItem item;
item.read = read;
item.ioInfo = info;
readCache->add(item);
}

otime::RationalTime startTime = time::invalidTime;
otio::Track* videoTrack = nullptr;
Expand Down Expand Up @@ -469,13 +460,6 @@ namespace tl
if (auto audioRead = ioSystem->read(audioPath, options.ioOptions))
{
const auto audioInfo = audioRead->getInfo().get();
if (readCache)
{
ReadCacheItem item;
item.read = audioRead;
item.ioInfo = audioInfo;
readCache->add(item);
}

auto audioClip = new otio::Clip;
audioClip->set_source_range(audioInfo.audioTime);
Expand Down Expand Up @@ -586,11 +570,10 @@ namespace tl
std::shared_ptr<Timeline> Timeline::create(
const otio::SerializableObject::Retainer<otio::Timeline>& timeline,
const std::shared_ptr<system::Context>& context,
const Options& options,
const std::shared_ptr<ReadCache>& readCache)
const Options& options)
{
auto out = std::shared_ptr<Timeline>(new Timeline);
out->_init(timeline, context, options, readCache);
out->_init(timeline, context, options);
return out;
}

Expand All @@ -600,13 +583,11 @@ namespace tl
const Options& options)
{
auto out = std::shared_ptr<Timeline>(new Timeline);
auto readCache = ReadCache::create();
auto otioTimeline = timeline::create(
file::Path(fileName, options.pathOptions),
context,
options,
readCache);
out->_init(otioTimeline, context, options, readCache);
options);
out->_init(otioTimeline, context, options);
return out;
}

Expand All @@ -616,9 +597,8 @@ namespace tl
const Options& options)
{
auto out = std::shared_ptr<Timeline>(new Timeline);
auto readCache = ReadCache::create();
auto otioTimeline = timeline::create(path, context, options, readCache);
out->_init(otioTimeline, context, options, readCache);
auto otioTimeline = timeline::create(path, context, options);
out->_init(otioTimeline, context, options);
return out;
}

Expand All @@ -629,14 +609,12 @@ namespace tl
const Options& options)
{
auto out = std::shared_ptr<Timeline>(new Timeline);
auto readCache = ReadCache::create();
auto otioTimeline = timeline::create(
file::Path(fileName, options.pathOptions),
file::Path(audioFileName, options.pathOptions),
context,
options,
readCache);
out->_init(otioTimeline, context, options, readCache);
options);
out->_init(otioTimeline, context, options);
return out;
}

Expand All @@ -647,14 +625,12 @@ namespace tl
const Options& options)
{
auto out = std::shared_ptr<Timeline>(new Timeline);
auto readCache = ReadCache::create();
auto otioTimeline = timeline::create(
path,
audioPath,
context,
options,
readCache);
out->_init(otioTimeline, context, options, readCache);
options);
out->_init(otioTimeline, context, options);
return out;
}
}
Expand Down
Loading

0 comments on commit 6ef184f

Please sign in to comment.