2013-03-12 17:00:09 -04:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2013-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2013-2017 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2013 John Emmas <john@creativepost.co.uk>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2013-03-12 17:00:09 -04:00
|
|
|
|
2015-10-05 16:10:58 -04:00
|
|
|
#include "pbd/gstdio_compat.h"
|
2013-07-15 14:29:00 -04:00
|
|
|
|
2013-03-12 17:00:09 -04:00
|
|
|
#include "ardour/profile.h"
|
|
|
|
#include "ardour/rc_configuration.h"
|
2013-04-05 17:16:33 -04:00
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/audioregion.h"
|
2013-03-12 17:00:09 -04:00
|
|
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "editor.h"
|
2013-04-05 22:09:58 -04:00
|
|
|
#include "canvas/rectangle.h"
|
2013-03-12 17:00:09 -04:00
|
|
|
#include "editing.h"
|
|
|
|
#include "audio_time_axis.h"
|
|
|
|
#include "video_image_frame.h"
|
|
|
|
#include "export_video_dialog.h"
|
2013-04-05 17:16:33 -04:00
|
|
|
#include "interthread_progress_window.h"
|
2013-03-12 17:00:09 -04:00
|
|
|
|
2013-06-19 14:26:53 -04:00
|
|
|
#include "pbd/openuri.h"
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2013-03-12 17:00:09 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_video_timeline_height (const int h)
|
|
|
|
{
|
|
|
|
if (videotl_bar_height == h) { return; }
|
|
|
|
if (h < 2 || h > 8) { return; }
|
|
|
|
videotl_bar_height = h;
|
|
|
|
videotl_label.set_size_request (-1, (int)timebar_height * videotl_bar_height);
|
|
|
|
ARDOUR_UI::instance()->video_timeline->set_height(videotl_bar_height * timebar_height);
|
|
|
|
update_ruler_visibility();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::update_video_timeline (bool flush)
|
|
|
|
{
|
2020-05-21 19:39:43 -04:00
|
|
|
if (!ARDOUR_UI::instance()->video_timeline) {
|
|
|
|
return;
|
|
|
|
}
|
2017-07-03 08:03:10 -04:00
|
|
|
|
2013-03-12 17:00:09 -04:00
|
|
|
if (flush) {
|
|
|
|
ARDOUR_UI::instance()->video_timeline->flush_local_cache();
|
|
|
|
}
|
|
|
|
if (!ruler_video_action->get_active()) return;
|
|
|
|
ARDOUR_UI::instance()->video_timeline->update_video_timeline();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Editor::is_video_timeline_locked ()
|
|
|
|
{
|
|
|
|
return ARDOUR_UI::instance()->video_timeline->is_offset_locked();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::set_video_timeline_locked (const bool l)
|
|
|
|
{
|
|
|
|
ARDOUR_UI::instance()->video_timeline->set_offset_locked(l);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Editor::toggle_video_timeline_locked ()
|
|
|
|
{
|
|
|
|
ARDOUR_UI::instance()->video_timeline->toggle_offset_locked();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-09-18 12:39:17 -04:00
|
|
|
Editor::embed_audio_from_video (std::string path, samplepos_t n, bool lock_position_to_video)
|
2013-03-12 17:00:09 -04:00
|
|
|
{
|
|
|
|
vector<std::string> paths;
|
|
|
|
paths.push_back(path);
|
2013-04-05 17:16:33 -04:00
|
|
|
current_interthread_info = &import_status;
|
|
|
|
import_status.current = 1;
|
|
|
|
import_status.total = paths.size ();
|
|
|
|
import_status.all_done = false;
|
|
|
|
|
|
|
|
ImportProgressWindow ipw (&import_status, _("Import"), _("Cancel Import"));
|
|
|
|
ipw.show ();
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Track> track;
|
2021-07-07 23:24:02 -04:00
|
|
|
std::string const& gid = ARDOUR::Playlist::generate_pgroup_id ();
|
2020-10-19 14:37:54 -04:00
|
|
|
Temporal::timepos_t pos (n);
|
|
|
|
|
2022-11-21 19:45:42 -05:00
|
|
|
bool ok = import_sndfiles (paths, Editing::ImportDistinctFiles, Editing::ImportAsTrack, ARDOUR::SrcBest, pos, 1, 1, track, gid, false, false) == 0;
|
2022-02-07 16:46:23 -05:00
|
|
|
import_status.clear();
|
2020-10-19 14:37:54 -04:00
|
|
|
|
2013-04-05 17:16:33 -04:00
|
|
|
if (ok && track) {
|
2013-12-23 04:28:32 -05:00
|
|
|
if (lock_position_to_video) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Playlist> pl = track->playlist();
|
2020-10-19 14:37:54 -04:00
|
|
|
pl->find_next_region (pos, ARDOUR::End, 0)->set_video_locked (true);
|
2013-12-23 04:28:32 -05:00
|
|
|
}
|
2020-08-30 20:35:37 -04:00
|
|
|
_session->save_state ("", true);
|
2013-04-05 17:16:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
import_status.all_done = true;
|
2022-02-07 16:46:23 -05:00
|
|
|
::g_unlink (path.c_str());
|
2013-03-12 17:00:09 -04:00
|
|
|
}
|