Merge branch 'cairocanvas' of git.ardour.org:ardour/ardour into cairocanvas
[ardour.git] / gtk2_ardour / video_image_frame.h
1 /*
2     Copyright (C) 2010 Paul Davis
3     Author: 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
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20 #ifdef WITH_VIDEOTIMELINE
21
22 #ifndef __ardour_video_image_frame_h__
23 #define __ardour_video_image_frame_h__
24
25 #define ARDOUR_USER_AGENT (PROGRAM_NAME VERSIONSTRING)
26 #define ARDOUR_CURL_TIMEOUT (60)
27
28 #include <string>
29 #include <glib.h>
30
31 #include <sigc++/signal.h>
32 #include <pthread.h>
33
34 #include "ardour/ardour.h"
35 #include "pbd/signals.h"
36
37 #include "canvas/group.h"
38 #include "canvas/pixbuf.h"
39
40 namespace ARDOUR {
41         class TempoSection;
42         class MeterSection;
43 }
44
45 class PublicEditor;
46
47 /** @class VideoImageFrame
48  *  @brief a single video-frame to be displayed in the video timeline
49  */
50 class VideoImageFrame : public sigc::trackable
51 {
52         public:
53         VideoImageFrame (PublicEditor&, ArdourCanvas::Group&, int, int, std::string, std::string);
54         virtual ~VideoImageFrame ();
55
56         void set_position (framepos_t);
57         void set_videoframe (framepos_t, int rightend = -1);
58         framepos_t get_video_frame_number() {return video_frame_number;}
59
60         int get_height () {return clip_height;}
61         int get_width ()  {return clip_width;}
62         int get_rightend() { return rightend;}
63         framepos_t get_req_frame () {return req_video_frame_number;}
64         std::string get_video_server_url () {return video_server_url;}
65         std::string get_video_filename ()   {return video_filename;}
66
67         void http_download_done (char *);
68         PBD::Signal0<void> ImgChanged;
69
70         protected:
71
72         PublicEditor& editor;
73         ArdourCanvas::Group *_parent;
74         ArdourCanvas::Group *group;
75         ArdourCanvas::Pixbuf *img_pixbuf;
76
77         int clip_width;
78         int clip_height;
79         int rightend;
80
81         std::string video_server_url;
82         std::string video_filename;
83
84         double        unit_position;
85         framepos_t   frame_position;
86         framepos_t   video_frame_number;
87
88         void reposition ();
89         void exposeimg ();
90
91         void draw_line ();
92         void cut_rightend ();
93
94
95         void http_get(framepos_t fn);
96         void http_get_again(framepos_t fn);
97
98         framepos_t req_video_frame_number;
99         framepos_t want_video_frame_number;
100         bool        queued_request;
101
102         pthread_mutex_t request_lock;
103         pthread_mutex_t queue_lock;
104
105         pthread_t      thread_id_tt;
106         bool           thread_active;
107
108 };
109
110 extern "C" {
111         char *curl_http_get (const char *u, int *status);
112 }
113
114 #endif /* __ardour_video_image_frame_h__ */
115
116 #endif /* WITH_VIDEOTIMELINE */