Preferences/Config changes for image-surface settings
[ardour.git] / gtk2_ardour / video_image_frame.h
1 /*
2  * Copyright (C) 2013-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2013-2017 Robin Gareus <robin@gareus.org>
4  *
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.
9  *
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.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 #ifndef __ardour_video_image_frame_h__
20 #define __ardour_video_image_frame_h__
21
22 #include <string>
23 #include <glib.h>
24
25 #include <sigc++/signal.h>
26 #include <pthread.h>
27
28 #include "ardour/ardour.h"
29 #include "pbd/signals.h"
30
31 #include "canvas/container.h"
32 #include "canvas/pixbuf.h"
33 #include "canvas/image.h"
34
35 namespace ARDOUR {
36         class TempoSection;
37         class MeterSection;
38 }
39
40 class PublicEditor;
41
42 /** @class VideoImageFrame
43  *  @brief a single video-frame to be displayed in the video timeline
44  */
45 class VideoImageFrame : public sigc::trackable
46 {
47         public:
48         VideoImageFrame (PublicEditor&, ArdourCanvas::Container&, int, int, std::string, std::string);
49         virtual ~VideoImageFrame ();
50
51         void set_position (samplepos_t);
52         void set_videoframe (samplepos_t, int rightend = -1);
53         samplepos_t get_video_frame_number() {return video_frame_number;}
54
55         int get_height () {return clip_height;}
56         int get_width ()  {return clip_width;}
57         int get_rightend() { return rightend;}
58         samplepos_t get_req_frame () {return req_video_frame_number;}
59         std::string get_video_server_url () {return video_server_url;}
60         std::string get_video_filename ()   {return video_filename;}
61
62         void http_download_done (char *);
63         PBD::Signal0<void> ImgChanged;
64
65         protected:
66
67         PublicEditor& editor;
68         ArdourCanvas::Container *_parent;
69         ArdourCanvas::Image *image;
70         boost::shared_ptr<ArdourCanvas::Image::Data> img;
71
72         int clip_width;
73         int clip_height;
74         int rightend;
75
76         std::string video_server_url;
77         std::string video_filename;
78
79         double        unit_position;
80         samplepos_t   sample_position;
81         samplepos_t   video_frame_number;
82
83         void reposition ();
84         void exposeimg ();
85
86         void fill_frame (const uint8_t r, const uint8_t g, const uint8_t b);
87         void draw_line ();
88         void draw_x ();
89         void cut_rightend ();
90
91
92         void http_get (samplepos_t fn);
93         void http_get_again (samplepos_t fn);
94
95         samplepos_t req_video_frame_number;
96         samplepos_t want_video_frame_number;
97         bool        queued_request;
98
99         pthread_mutex_t request_lock;
100         pthread_mutex_t queue_lock;
101
102         pthread_t      thread_id_tt;
103         bool           thread_active;
104
105 };
106
107 #endif /* __ardour_video_image_frame_h__ */