2 Copyright (C) 2010 Paul Davis
3 Author: Robin Gareus <robin@gareus.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifdef WITH_VIDEOTIMELINE
23 #include <sigc++/bind.h>
24 #include "ardour/tempo.h"
26 #include "pbd/file_utils.h"
27 #include "ardour/session_directory.h"
29 #include "ardour_ui.h"
30 #include "public_editor.h"
31 #include "gui_thread.h"
33 #include "canvas_impl.h"
34 #include "simpleline.h"
35 #include "utils_videotl.h"
36 #include "rgb_macros.h"
37 #include "video_timeline.h"
39 #include <gtkmm2ext/utils.h>
41 #include <curl/curl.h>
46 using namespace ARDOUR;
48 using namespace Timecode;
50 VideoTimeLine::VideoTimeLine (PublicEditor *ed, ArdourCanvas::Group *vbg, int initial_height)
52 , videotl_bar_group(vbg)
53 , bar_height(initial_height)
55 video_start_offset = 0L;
59 auto_set_session_fps = false;
60 video_offset_lock = false;
61 video_aspect_ratio = 4.0/3.0;
62 open_video_monitor_dialog = 0;
63 Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context());
64 video_server_url = video_get_server_url(Config);
65 server_docroot = video_get_docroot(Config);
68 video_file_fps = 25.0;
71 reopen_vmonitor=false;
74 VtlUpdate.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context());
75 GuiUpdate.connect (*this, invalidator (*this), boost::bind (&VideoTimeLine::gui_update, this, _1), gui_context());
78 VideoTimeLine::~VideoTimeLine ()
83 /* close and save settings */
85 VideoTimeLine::save_session ()
91 LocaleGuard lg (X_("POSIX"));
93 bool is_dirty = false;
95 XMLNode* prev = _session->extra_xml (X_("Videomonitor"));
97 /* remember if vmonitor was open.. */
98 XMLNode* node = new XMLNode(X_("Videomonitor"));
100 node->add_property (X_("active"), (vmonitor && vmonitor->is_started())?"yes":"no");
101 if (!prev || !(prev->property (X_("active")) && prev->property (X_("active"))->value() == node->property(X_("active"))->value()) ){
102 _session->add_extra_xml (*node);
103 is_dirty=true; // TODO not if !prev && value==default
107 node = _session->extra_xml (X_("Videotimeline"));
110 if (!(node->property(X_("id")) && node->property(X_("id"))->value() == id().to_s())) {
111 node->add_property (X_("id"), id().to_s());
116 /* remember timeline height.. */
118 int h = editor->get_videotl_bar_height();
119 if (!(node->property(X_("Height")) && atoi(node->property(X_("Height"))->value().c_str())==h)) {
120 node->add_property (X_("Height"), h);
125 /* save video-offset-lock */
127 if (!(node->property(X_("VideoOffsetLock")) && atoi(node->property(X_("VideoOffsetLock"))->value().c_str())==video_offset_lock)) {
128 node->add_property (X_("VideoOffsetLock"), video_offset_lock?X_("1"):X_("0"));
132 /* save video-offset */
134 if (!(node->property(X_("VideoOffset")) && atoll(node->property(X_("VideoOffset"))->value().c_str())==video_offset)) {
135 node->add_property (X_("VideoOffset"), video_offset);
140 /* save 'auto_set_session_fps' */
142 if (!(node->property(X_("AutoFPS")) && atoi(node->property(X_("AutoFPS"))->value().c_str())==auto_set_session_fps)) {
143 node->add_property (X_("AutoFPS"), auto_set_session_fps?X_("1"):X_("0"));
148 _session->set_dirty ();
152 /* close and save settings */
154 VideoTimeLine::close_session ()
156 if (video_duration == 0) {
159 close_video_monitor();
165 GuiUpdate("set-xjadeo-sensitive-off");
166 if (open_video_monitor_dialog) {
167 delete open_video_monitor_dialog;
169 open_video_monitor_dialog = 0;
172 /** load settings from session */
174 VideoTimeLine::set_session (ARDOUR::Session *s)
176 SessionHandlePtr::set_session (s);
177 if (!_session) { return ; }
179 LocaleGuard lg (X_("POSIX"));
181 XMLNode* node = _session->extra_xml (X_("Videotimeline"));
183 if (!node || !node->property (X_("Filename"))) {
188 ARDOUR_UI::instance()->start_video_server((Gtk::Window*)0, false);
192 const XMLProperty* proph = node->property (X_("Height"));
194 editor->set_video_timeline_height(atoi(proph->value().c_str()));
196 #if 0 /* TODO THINK: set FPS first time only ?! */
197 const XMLProperty* propasfps = node->property (X_("AutoFPS"));
199 auto_set_session_fps = atoi(propasfps->value().c_str())?true:false;
203 const XMLProperty* propoffset = node->property (X_("VideoOffset"));
205 video_offset = atoll(propoffset->value().c_str());
206 video_offset_p = video_offset;
209 const XMLProperty* proplock = node->property (X_("VideoOffsetLock"));
211 video_offset_lock = atoi(proplock->value().c_str())?true:false;
214 const XMLProperty* localfile = node->property (X_("LocalFile"));
216 local_file = atoi(localfile->value().c_str())?true:false;
219 const XMLProperty* propf = node->property (X_("Filename"));
220 video_file_info(propf->value(), local_file);
223 if (open_video_monitor_dialog) {
224 delete open_video_monitor_dialog;
226 open_video_monitor_dialog = 0;
228 node = _session->extra_xml (X_("Videomonitor"));
230 const XMLProperty* prop = node->property (X_("active"));
231 if (prop && prop->value() == "yes" && found_xjadeo() && !video_filename.empty() && local_file) {
232 open_video_monitor(false);
236 _session->register_with_memento_command_factory(id(), this);
237 _session->config.ParameterChanged.connect (*this, invalidator (*this), ui_bind (&VideoTimeLine::parameter_changed, this, _1), gui_context());
241 VideoTimeLine::save_undo ()
243 video_offset_p = video_offset;
247 VideoTimeLine::set_state (const XMLNode& node, int /*version*/)
249 LocaleGuard lg (X_("POSIX"));
250 const XMLProperty* propoffset = node.property (X_("VideoOffset"));
252 video_offset = atoll(propoffset->value().c_str());
254 ARDOUR_UI::instance()->flush_videotimeline_cache(true);
259 VideoTimeLine::get_state ()
261 XMLNode* node = new XMLNode (X_("Videotimeline"));
262 LocaleGuard lg (X_("POSIX"));
263 node->add_property (X_("VideoOffset"), video_offset_p);
268 VideoTimeLine::remove_frames ()
270 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i ) {
271 VideoImageFrame *frame = (*i);
275 video_frames.clear();
279 VideoTimeLine::get_video_frame (framepos_t vfn, int cut, int rightend)
282 for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i) {
283 VideoImageFrame *frame = (*i);
284 if (abs(frame->get_video_frame_number()-vfn)<=cut
285 && frame->get_rightend() == rightend) { return frame; }
291 VideoTimeLine::get_apv()
293 // XXX: dup code - TODO use this fn in update_video_timeline()
294 float apv = -1; /* audio frames per video frame; */
295 if (!_session) return apv;
297 if (_session->config.get_use_video_file_fps()) {
298 if (video_file_fps == 0 ) return apv;
300 if (_session->timecode_frames_per_second() == 0 ) return apv;
303 if (_session->config.get_videotimeline_pullup()) {
304 apv = _session->frame_rate();
306 apv = _session->nominal_frame_rate();
308 if (_session->config.get_use_video_file_fps()) {
309 apv /= video_file_fps;
311 apv /= _session->timecode_frames_per_second();
317 VideoTimeLine::update_video_timeline()
319 if (!_session) return;
321 if (_session->config.get_use_video_file_fps()) {
322 if (video_file_fps == 0 ) return;
324 if (_session->timecode_frames_per_second() == 0 ) return;
327 double frames_per_unit = editor->unit_to_frame(1.0);
328 framepos_t leftmost_frame = editor->leftmost_position();
331 * 1) calculate how many frames there should be in current zoom (plus 1 page on each side)
332 * 2) calculate first frame and distance between video-frames (according to zoom)
333 * 3) destroy/add frames
334 * 4) reposition existing frames
335 * 5) assign framenumber to frames -> request/decode video.
338 /* video-file and session properties */
339 double display_vframe_width; /* unit: pixels ; width of one thumbnail in the timeline */
340 float apv; /* audio frames per video frame; */
341 framepos_t leftmost_video_frame; /* unit: video-frame number ; temporary var -> vtl_start */
343 /* variables needed to render videotimeline -- what needs to computed first */
344 framepos_t vtl_start; /* unit: audio-frames ; first displayed video-frame */
345 framepos_t vtl_dist; /* unit: audio-frames ; distance between displayed video-frames */
346 unsigned int visible_video_frames; /* number of frames that fit on current canvas */
348 if (_session->config.get_videotimeline_pullup()) {
349 apv = _session->frame_rate();
351 apv = _session->nominal_frame_rate();
353 if (_session->config.get_use_video_file_fps()) {
354 apv /= video_file_fps;
356 apv /= _session->timecode_frames_per_second();
359 display_vframe_width = bar_height * video_aspect_ratio;
361 if (apv > frames_per_unit * display_vframe_width) {
362 /* high-zoom: need space between successive video-frames */
363 vtl_dist = rint(apv);
365 /* continous timeline: skip video-frames */
366 vtl_dist = ceil(display_vframe_width * frames_per_unit / apv) * apv;
369 assert (vtl_dist > 0);
372 #define GOFFSET (video_offset)
374 leftmost_video_frame = floor (floor((leftmost_frame - video_start_offset - GOFFSET ) / vtl_dist) * vtl_dist / apv);
376 vtl_start = rint (GOFFSET + video_start_offset + leftmost_video_frame * apv);
377 visible_video_frames = 2 + ceil(editor->current_page_frames() / vtl_dist); /* +2 left+right partial frames */
379 /* expand timeline (cache next/prev page images) */
380 vtl_start -= visible_video_frames * vtl_dist;
381 visible_video_frames *=3;
383 if (vtl_start < GOFFSET ) {
384 visible_video_frames += ceil(vtl_start/vtl_dist);
388 /* apply video-file constraints */
389 if (vtl_start > video_start_offset + video_duration + GOFFSET ) {
390 visible_video_frames = 0;
392 /* TODO optimize: compute rather than iterate */
393 while (visible_video_frames > 0 && vtl_start + (visible_video_frames-1) * vtl_dist >= video_start_offset + video_duration + GOFFSET) {
394 --visible_video_frames;
402 while (video_frames.size() < visible_video_frames) {
403 VideoImageFrame *frame;
404 frame = new VideoImageFrame(*editor, *videotl_bar_group, display_vframe_width, bar_height, video_server_url, translated_filename());
405 frame->ImgChanged.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context());
406 video_frames.push_back(frame);
409 VideoFrames outdated_video_frames;
410 std::list<int> remaining;
412 outdated_video_frames = video_frames;
415 /* when zoomed out, ignore shifts by +-1 frame
416 * which can occur due to rounding errors when
417 * scrolling to a new leftmost-audio frame.
420 if (vtl_dist/apv < 3.0) cut =0;
425 for (unsigned int vfcount=0; vfcount < visible_video_frames; ++vfcount){
426 framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
427 framepos_t vframeno = rint ( (vfpos - GOFFSET) / apv); /* unit: video-frames */
428 vfpos = (vframeno * apv ) + GOFFSET; /* audio-frame corresponding to /rounded/ video-frame */
430 int rightend = -1; /* unit: pixels */
431 if (vfpos + vtl_dist > video_start_offset + video_duration + GOFFSET) {
432 rightend = display_vframe_width * (video_start_offset + video_duration + GOFFSET - vfpos) / vtl_dist;
433 //printf("lf(e): %lu\n", vframeno); // XXX
435 VideoImageFrame * frame = get_video_frame(vframeno, cut, rightend);
437 frame->set_position(vfpos-leftmost_frame);
438 outdated_video_frames.remove(frame);
440 remaining.push_back(vfcount);
444 for (VideoFrames::iterator i = outdated_video_frames.begin(); i != outdated_video_frames.end(); ++i ) {
445 VideoImageFrame *frame = (*i);
446 if (remaining.empty()) {
447 frame->set_position(-2 * vtl_dist); /* move off screen */
449 int vfcount=remaining.front();
450 remaining.pop_front();
451 framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
452 framepos_t vframeno = rint ((vfpos - GOFFSET) / apv); /* unit: video-frames */
453 int rightend = -1; /* unit: pixels */
454 if (vfpos + vtl_dist > video_start_offset + video_duration + GOFFSET) {
455 rightend = display_vframe_width * (video_start_offset + video_duration + GOFFSET - vfpos) / vtl_dist;
456 //printf("lf(n): %lu\n", vframeno); // XXX
458 frame->set_position(vfpos-leftmost_frame);
459 frame->set_videoframe(vframeno, rightend);
465 VideoTimeLine::translated_filename ()
468 return video_filename;
470 return video_map_path(server_docroot, video_filename);
475 VideoTimeLine::video_file_info (std::string filename, bool local)
479 if (filename.at(0) == G_DIR_SEPARATOR || !local_file) {
480 video_filename = filename;
482 video_filename = Glib::build_filename (_session->session_directory().video_path(), filename);
485 long long int _duration;
486 double _start_offset;
488 if (!video_query_info(
489 video_server_url, translated_filename(),
490 video_file_fps, _duration, _start_offset, video_aspect_ratio)) {
491 warning << _("Parsing video file info failed. Is the Video Server running? Is the file readable by the Video Server? Does the docroot match? Is it a video file?") << endmsg;
494 video_duration = _duration * _session->nominal_frame_rate() / video_file_fps;
495 video_start_offset = _start_offset * _session->nominal_frame_rate();
497 if (auto_set_session_fps && video_file_fps != _session->timecode_frames_per_second()) {
498 switch ((int)floorf(video_file_fps*1000.0)) {
500 _session->config.set_timecode_format(timecode_23976);
503 _session->config.set_timecode_format(timecode_24);
507 _session->config.set_timecode_format(timecode_24976);
510 _session->config.set_timecode_format(timecode_25);
513 _session->config.set_timecode_format(timecode_2997drop);
516 _session->config.set_timecode_format(timecode_30);
519 _session->config.set_timecode_format(timecode_5994);
522 _session->config.set_timecode_format(timecode_60);
525 warning << _("Failed to set session-framerate: ") << video_file_fps << _(" does not have a corresponding option setting in Ardour.") << endmsg; /* TODO: gettext arg */
528 _session->config.set_video_pullup(0); /* TODO only set if set_timecode_format() was successful ?!*/
530 if (video_file_fps != _session->timecode_frames_per_second()) {
531 warning << _("Video file's framerate is not equal to Ardour session timecode's framerate: ")
532 << video_file_fps << _(" vs ") << _session->timecode_frames_per_second() << endmsg;
534 flush_local_cache ();
536 _session->maybe_update_session_range(
537 std::max(get_offset(), (ARDOUR::frameoffset_t) 0),
538 std::max(get_offset() + get_duration(), (ARDOUR::frameoffset_t) 0)
541 if (found_xjadeo() && local_file) {
542 GuiUpdate("set-xjadeo-sensitive-on");
543 if (vmonitor && vmonitor->is_started()) {
545 /* xjadeo <= 0.6.4 has a bug where changing the video-file may segfauls
546 * if the geometry changes to a different line-size alignment
548 reopen_vmonitor = true;
551 vmonitor->set_fps(video_file_fps);
552 vmonitor->open(video_filename);
555 } else if (!local_file) {
556 #if 1 /* temp debug/devel message */
557 // TODO - call xjremote remotely.
558 printf("the given video file can not be accessed on localhost, video monitoring is not currently supported for this case\n");
559 GuiUpdate("set-xjadeo-sensitive-off");
567 VideoTimeLine::check_server ()
571 snprintf(url, sizeof(url), "%s%sstatus"
572 , video_server_url.c_str()
573 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
575 char *res=curl_http_get(url, NULL);
577 if (strstr(res, "status: ok, online.")) { ok = true; }
584 VideoTimeLine::gui_update(std::string const & t) {
585 /* this is to be called via GuiUpdate() only. */
586 ENSURE_GUI_THREAD (*this, &VideoTimeLine::queue_visual_videotimeline_update)
587 if (t == "videotimeline-update") {
588 editor->queue_visual_videotimeline_update();
589 } else if (t == "set-xjadeo-active-off") {
590 editor->toggle_xjadeo_proc(0);
591 } else if (t == "set-xjadeo-active-on") {
592 editor->toggle_xjadeo_proc(1);
593 } else if (t == "set-xjadeo-sensitive-on") {
594 editor->set_xjadeo_sensitive(true);
595 } else if (t == "set-xjadeo-sensitive-off") {
596 editor->toggle_xjadeo_proc(0);
597 //close_video_monitor();
598 editor->set_xjadeo_sensitive(false);
603 VideoTimeLine::set_height (int height) {
609 VideoTimeLine::vmon_update () {
610 if (vmonitor && vmonitor->is_started()) {
611 vmonitor->set_offset( GOFFSET); // TODO proper re-init xjadeo w/o restart not just offset.
616 VideoTimeLine::flush_local_cache () {
622 VideoTimeLine::flush_cache () {
625 snprintf(url, sizeof(url), "%s%sadmin/flush_cache"
626 , video_server_url.c_str()
627 , (video_server_url.length()>0 && video_server_url.at(video_server_url.length()-1) == '/')?"":"/"
629 char *res=curl_http_get(url, NULL);
633 if (vmonitor && vmonitor->is_started()) {
634 reopen_vmonitor=true;
637 video_file_info(video_filename, local_file);
642 VideoTimeLine::parameter_changed (std::string const & p)
644 if (p == "video-server-url") {
645 set_video_server_url (video_get_server_url(Config));
646 } else if (p == "video-server-docroot") {
647 set_video_server_docroot (video_get_docroot(Config));
648 } else if (p == "video-advanced-setup") {
649 set_video_server_url (video_get_server_url(Config));
650 set_video_server_docroot (video_get_docroot(Config));
652 if (p == "use-video-file-fps" || p == "videotimeline-pullup" ) { /* session->config parameter */
658 VideoTimeLine::set_video_server_url(std::string vsu) {
659 flush_local_cache ();
660 video_server_url = vsu;
665 VideoTimeLine::set_video_server_docroot(std::string vsr) {
666 flush_local_cache ();
667 server_docroot = vsr;
671 /* video-monitor for this timeline */
673 VideoTimeLine::find_xjadeo () {
674 std::string xjadeo_file_path;
675 if (getenv("XJREMOTE")) {
676 _xjadeo_bin = strdup(getenv("XJREMOTE")); // XXX TODO: free it?!
677 } else if (find_file_in_search_path (SearchPath(Glib::getenv("PATH")), X_("xjremote"), xjadeo_file_path)) {
678 _xjadeo_bin = xjadeo_file_path;
680 else if (Glib::file_test(X_("/Applications/Jadeo.app/Contents/MacOS/xjremote"), Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_EXECUTABLE)) {
681 _xjadeo_bin = X_("/Applications/Jadeo.app/Contents/MacOS/xjremote");
683 /* TODO: win32: allow to configure PATH to xjremote */
684 else if (Glib::file_test(X_("C:\\Program Files\\xjadeo\\xjremote.exe"), Glib::FILE_TEST_EXISTS)) {
685 _xjadeo_bin = X_("C:\\Program Files\\xjadeo\\xjremote.exe");
687 else if (Glib::file_test(X_("C:\\Program Files\\xjadeo\\xjremote.bat"), Glib::FILE_TEST_EXISTS)) {
688 _xjadeo_bin = X_("C:\\Program Files\\xjadeo\\xjremote.bat");
691 _xjadeo_bin = X_("");
692 warning << _("Video-monitor 'xjadeo' was not found. Please install http://xjadeo.sf.net/ "
693 "(a custom path to xjadeo can be specified by setting the XJREMOTE environment variable. "
694 "It should point to an application compatible with xjadeo's remote-control interface 'xjremote').")
700 VideoTimeLine::open_video_monitor(bool interactive) {
701 if (!found_xjadeo()) return;
703 vmonitor = new VideoMonitor(editor, _xjadeo_bin);
704 vmonitor->set_session(_session);
705 vmonitor->Terminated.connect (sigc::mem_fun (*this, &VideoTimeLine::terminated_video_monitor));
706 } else if (vmonitor->is_started()) {
710 int xj_settings_mask = vmonitor->restore_settings_mask();
712 /* load mask from Session */
713 XMLNode* node = _session->extra_xml (X_("XJRestoreSettings"));
715 const XMLProperty* prop = node->property (X_("mask"));
717 xj_settings_mask = atoi(prop->value().c_str());
722 if (interactive && Config->get_video_monitor_setup_dialog()) {
723 if (open_video_monitor_dialog == 0) {
724 open_video_monitor_dialog = new OpenVideoMonitorDialog(_session);
726 if (open_video_monitor_dialog->is_visible()) {
729 open_video_monitor_dialog->setup_settings_mask(xj_settings_mask);
730 open_video_monitor_dialog->set_filename(video_filename);
731 Gtk::ResponseType r = (Gtk::ResponseType) open_video_monitor_dialog->run ();
732 open_video_monitor_dialog->hide();
733 if (r != Gtk::RESPONSE_ACCEPT) {
734 GuiUpdate("set-xjadeo-active-off");
738 if (_session && (xj_settings_mask != open_video_monitor_dialog->xj_settings_mask()) ) {
739 /* save mask to Session */
740 XMLNode* node = new XMLNode(X_("XJRestoreSettings"));
741 node->add_property (X_("mask"), (const long) open_video_monitor_dialog->xj_settings_mask() );
742 _session->add_extra_xml (*node);
743 _session->set_dirty ();
746 if (open_video_monitor_dialog->show_again()) {
747 Config->set_video_monitor_setup_dialog(false);
750 vmonitor->set_debug(open_video_monitor_dialog->enable_debug());
752 vmonitor->restore_settings_mask(open_video_monitor_dialog->xj_settings_mask());
754 vmonitor->restore_settings_mask(xj_settings_mask);
758 if (!vmonitor->start()) {
759 warning << "launching xjadeo failed.." << endmsg;
760 close_video_monitor();
762 GuiUpdate("set-xjadeo-active-on");
763 vmonitor->set_fps(video_file_fps);
764 vmonitor->open(video_filename);
769 VideoTimeLine::close_video_monitor() {
770 if (vmonitor && vmonitor->is_started()) {
776 VideoTimeLine::terminated_video_monitor () {
780 GuiUpdate("set-xjadeo-active-off");
782 if (reopen_vmonitor) {
783 reopen_vmonitor=false;
784 open_video_monitor(false);
790 VideoTimeLine::clear_video_monitor_session_state ()
793 vmonitor->clear_session_state();
795 if (!_session) { return; }
796 XMLNode* node = new XMLNode(X_("XJSettings"));
797 _session->add_extra_xml (*node);
798 _session->set_dirty ();
804 VideoTimeLine::manual_seek_video_monitor (framepos_t pos)
806 if (!vmonitor) { return; }
807 if (!vmonitor->is_started()) { return; }
808 if (!vmonitor->synced_by_manual_seeks()) { return; }
809 vmonitor->manual_seek(pos, false, GOFFSET); // XXX -> set offset in xjadeo
812 #endif /* WITH_VIDEOTIMELINE */