Skip to content

Commit

Permalink
WIP A/B playback sync
Browse files Browse the repository at this point in the history
  • Loading branch information
darbyjohnston committed Feb 26, 2024
1 parent 4d0f016 commit 890b36e
Show file tree
Hide file tree
Showing 17 changed files with 262 additions and 435 deletions.
28 changes: 14 additions & 14 deletions examples/panorama-qtwidget/PanoramaTimelineViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,32 @@ namespace tl
update();
}

void PanoramaTimelineViewport::setTimelinePlayer(qt::TimelinePlayer* timelinePlayer)
void PanoramaTimelineViewport::setPlayer(const QSharedPointer<qt::TimelinePlayer>& player)
{
_videoData = timeline::VideoData();
if (_timelinePlayer)
if (_player)
{
disconnect(
_timelinePlayer,
SIGNAL(currentVideoChanged(const tl::timeline::VideoData&)),
_player.get(),
SIGNAL(currentVideoChanged(const std::vector<tl::timeline::VideoData>&)),
this,
SLOT(_currentVideoCallback(const tl::timeline::VideoData&)));
SLOT(_currentVideoCallback(const std::vector<tl::timeline::VideoData>&)));
}
_timelinePlayer = timelinePlayer;
if (_timelinePlayer)
_player = player;
_videoData.clear();
if (_player)
{
const auto& ioInfo = _timelinePlayer->ioInfo();
const auto& ioInfo = _player->ioInfo();
_videoSize = !ioInfo.video.empty() ? ioInfo.video[0].size : image::Size();
_videoData = _timelinePlayer->currentVideo();
_videoData = _player->currentVideo();
connect(
_timelinePlayer,
SIGNAL(currentVideoChanged(const tl::timeline::VideoData&)),
SLOT(_currentVideoCallback(const tl::timeline::VideoData&)));
_player.get(),
SIGNAL(currentVideoChanged(const std::vector<tl::timeline::VideoData>&)),
SLOT(_currentVideoCallback(const std::vector<tl::timeline::VideoData>&)));
}
update();
}

void PanoramaTimelineViewport::_currentVideoCallback(const timeline::VideoData& value)
void PanoramaTimelineViewport::_currentVideoCallback(const std::vector<timeline::VideoData>& value)
{
_videoData = value;
update();
Expand Down
8 changes: 4 additions & 4 deletions examples/panorama-qtwidget/PanoramaTimelineViewport.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ namespace tl
void setImageOptions(const timeline::ImageOptions&);

//! Set the timeline player.
void setTimelinePlayer(qt::TimelinePlayer*);
void setPlayer(const QSharedPointer<qt::TimelinePlayer>&);

private Q_SLOTS:
void _currentVideoCallback(const tl::timeline::VideoData&);
void _currentVideoCallback(const std::vector<tl::timeline::VideoData>&);

protected:
void initializeGL() override;
Expand All @@ -63,9 +63,9 @@ namespace tl
timeline::OCIOOptions _ocioOptions;
timeline::LUTOptions _lutOptions;
timeline::ImageOptions _imageOptions;
qt::TimelinePlayer* _timelinePlayer = nullptr;
QSharedPointer<qt::TimelinePlayer> _player;
image::Size _videoSize;
timeline::VideoData _videoData;
std::vector<timeline::VideoData> _videoData;
math::Vector2f _cameraRotation;
float _cameraFOV = 45.F;
geom::TriangleMesh3 _sphereMesh;
Expand Down
6 changes: 3 additions & 3 deletions examples/panorama-qtwidget/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ int main(int argc, char* argv[])
auto timeline = tl::timeline::Timeline::create(argv[1], context);

// Create the timeline player.
QScopedPointer<tl::qt::TimelinePlayer> timelinePlayer(
QSharedPointer<tl::qt::TimelinePlayer> player(
new tl::qt::TimelinePlayer(
tl::timeline::Player::create(timeline, context),
context));

// Create the panorama timeline viewport.
auto timelineViewport = new tl::examples::panorama_qtwidget::PanoramaTimelineViewport(context);
timelineViewport->setTimelinePlayer(timelinePlayer.get());
timelineViewport->setPlayer(player);
timelineViewport->setAttribute(Qt::WA_DeleteOnClose);
timelineViewport->show();

// Start playback.
timelinePlayer->setPlayback(tl::timeline::Playback::Forward);
player->setPlayback(tl::timeline::Playback::Forward);

// Start the application.
r = app.exec();
Expand Down
6 changes: 3 additions & 3 deletions examples/player-qtwidget/player-qtwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ int main(int argc, char* argv[])
auto timeline = tl::timeline::Timeline::create(argv[1], context);

// Create the timeline player.
QSharedPointer<tl::qt::TimelinePlayer> timelinePlayer(
QSharedPointer<tl::qt::TimelinePlayer> player(
new tl::qt::TimelinePlayer(
tl::timeline::Player::create(timeline, context),
context));

// Create the timeline viewport.
auto timelineViewport = new tl::qtwidget::TimelineViewport(context);
timelineViewport->setTimelinePlayers({ timelinePlayer });
timelineViewport->setPlayer(player);
timelineViewport->setAttribute(Qt::WA_DeleteOnClose);
timelineViewport->show();

// Start playback.
timelinePlayer->setPlayback(tl::timeline::Playback::Forward);
player->setPlayback(tl::timeline::Playback::Forward);

// Start the application.
r = app.exec();
Expand Down
Loading

0 comments on commit 890b36e

Please sign in to comment.