File: pix_recordQT.h

package info (click to toggle)
gem 1%3A0.93.3-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 28,524 kB
  • sloc: cpp: 134,188; sh: 11,215; makefile: 2,853; ansic: 84
file content (277 lines) | stat: -rw-r--r-- 6,048 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/*
 *  pix_recordQT.h
 *  GEM_darwin
 *
 *  Created by chris clepper on 7/18/05.
 *  Copyright 2005. All rights reserved.
 *
 */
 
 //this will record QT movies
#ifndef _INCLUDE__GEM_PIXES_PIX_RECORDQT_H_
#define _INCLUDE__GEM_PIXES_PIX_RECORDQT_H_

#if 1
#include "Base/GemBase.h"
#include "Gem/Image.h"

#ifdef _WIN32
#include <io.h>
#include <stdio.h>
#include <QTML.h>
#include <Movies.h>
#include <QuicktimeComponents.h>
#include <Files.h>
#endif

#ifdef __APPLE__
#include <Quicktime/QuickTime.h>
#include <Carbon/Carbon.h>

#include <unistd.h> //needed for Unix file open() type functions
#include <stdio.h>
#include <string.h>
#include <fcntl.h> 

#endif


/*-----------------------------------------------------------------
-------------------------------------------------------------------
CLASS
    pix_recordQT
    
    Writes a pix of the render buffer
    
KEYWORDS
    pix
    
DESCRIPTION

    Inlet for a list - "vert_size"
    Inlet for a list - "vert_pos"

    "file" - filename to write to
    "bang" - do write now
    "auto 0/1" - stop/start writing automatically

    "vert_size" - Set the size of the pix
    "vert_pos" - Set the position of the pix
    
-----------------------------------------------------------------*/
class GEM_EXTERN pix_recordQT : public GemBase
{
    CPPEXTERN_HEADER(pix_recordQT, GemBase);

    public:

        //////////
        // Constructor
    	pix_recordQT(int argc, t_atom *argv);
    	
    protected:
    	
    	//////////
    	// Destructor
    	virtual ~pix_recordQT();
		
		virtual void	setupQT();
		
		virtual void	compressFrame();
		
		//virtual void	startRecording();
		
		virtual void	stopRecording();
    	
    	//////////
    	// Do the rendering
    	virtual void 	render(GemState *state);

    	//////////
    	// Clear the dirty flag on the pixBlock
    	virtual void 	postrender(GemState *state) {};

    	//////////
    	// Set the filename and filetype
    	virtual void	fileMess(int argc, t_atom *argv);
 
    	//////////
    	// When a size message is received
    	virtual void	sizeMess(int width, int height);
    	
    	//////////
    	// When a position message is received
    	virtual void	posMess(int x, int y);
		
		/////////
		// call up compression dialog
		virtual void	dialogMess();
		
		virtual void	getCodecList();
		
		virtual void	codecMess(int argc, t_atom *argv);
		
		virtual void	csMess(int format);
		
		
    	
    	//////////
    	// Clean up the image
   // 	void	    	cleanImage();
    	
    	//////////
    	// The original pix_recordQT
    //	imageStruct 	*m_originalImage;


	//////////
	// Manual writing
	bool            m_banged;
    	
	//////////
	// Automatic writing
	bool            m_automatic;

	//////////
	// Counter for automatic writing
	int             m_autocount;
	
	/////////
	// recording start
	bool			m_recordStart;
	
	/////////
	// recording start
	bool			m_recordStop;
	
	//////
	// is recording setup and ready to go?
	bool			m_recordSetup;
	
	bool			m_dialog;
    	
    	//////////
	// path to write to
    	char	    	m_pathname[80];
    	//////////
	// current file to write to
    	char	    	m_filename[80];

    	//////////
	// current file to write to
    	int	    	m_filetype; // 0=tiff, [1..6=jpeg]

    	//////////
    	// The x position
    	int     	m_xoff;
    	
    	//////////
    	// The y position
    	int     	m_yoff;
    	
    	//////////
    	// The width
    	int     	m_width;
    	
    	//////////
    	// The height
    	int     	m_height;
		
		//////////
		// previous dimensions to check
		int			m_prevHeight;
		
		int			m_prevWidth;
		
		pixBlock	*m_pixBlock;
		
		imageStruct	m_compressImage;
		
		//////////
		// a outlet for information like #frames
		t_outlet     *m_outNumFrames;
		
		int				m_currentFrame; //keep track of the number of frames
		
		///////////
		/// QT stuff
		
		GWorldPtr				m_srcGWorld;
		Rect					m_srcRect;
		int						m_rowBytes;
		Movie					m_movie;
		Track					track;
		Media					media;
		ComponentInstance		stdComponent;
		SCTemporalSettings		TemporalSettings;
		SCSpatialSettings		SpatialSettings;
		SCDataRateSettings		DataRateSetting;
		SCDataRateSettings		datarate;
		long					dataSize;
    	ImageDescriptionHandle	hImageDesc;
		
		//these are for the programmatic setting of the compressor
		CodecType				m_codecType;
		CodecComponent			m_codec;
		short					m_depth;
		CodecQ					m_spatialQuality;
		//set these to reflect if the codec settings are good or not
		bool				m_codecSet;
		bool				m_codecQualitySet;

		
		short		nFileRefNum;
		short		nResID;
		
		//this will hold the ctype value of the codecs listed by getCodecList()
		typedef struct codecListStorage{
			int		position;
			int		ctype;
			CodecComponent		codec;
		};

		codecListStorage	codecContainer[64];//anyone with more than 64 codecs can change this
		
		
				
		int					m_fps;
		
		//duration of frames in ms
		int					m_frameDuration;
		
		//number of QT ticks for a frame 600/frameDuration (used by AddMediaSample)
		int					m_ticks;
		
		bool	m_firstRun;
#ifdef __APPLE__
		UnsignedWide startTime, endTime;
#endif
#ifdef _WIN32
		LARGE_INTEGER freq, startTime, endTime;
#endif
		float seconds;
		
		Component			aComponent;
		ComponentInstance	aClock;
		TimeRecord			aTime;
	
		int		m_colorspace;
		
		
    private:
    	
    	//////////
    	// static member functions
    	static void 	fileMessCallback(void *data, t_symbol *s, int argc, t_atom *argv);
    	static void 	autoMessCallback(void *data, t_floatarg on);
    	static void 	bangMessCallback(void *data);
    	static void 	sizeMessCallback(void *data, t_floatarg width, t_floatarg height );
    	static void 	posMessCallback(void *data, t_floatarg x, t_floatarg y);
		static void 	recordMessCallback(void *data, t_floatarg on);
		static void 	dialogMessCallback(void *data);
		static void 	codeclistMessCallback(void *data);
		static void 	codecMessCallback(void *data, t_symbol *s, int argc, t_atom *argv);
		static void		colorspaceCallback(void *data, t_symbol *state);
};
#endif //for __APPLE__
#endif	// for header file