00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CHOP_Realtime_h__
00021 #define __CHOP_Realtime_h__
00022
00023 #include "CHOP_API.h"
00024 #include "CHOP_Node.h"
00025
00026 #define REALTIME_MODE_TRIM 0
00027 #define REALTIME_MODE_ACCUM 1
00028 #define REALTIME_MODE_CONTINUOUS 2
00029 #define REALTIME_MODE_CURRENT_FRAME 3
00030 #define REALTIME_MODE_FRAME_ONE 4
00031
00032 #define REALTIME_INPUT_INTEREST_NONE (-1)
00033 #define REALTIME_INPUT_INTEREST_ALL (-2)
00034
00035 #define DEF_REALTIME_SETTLING_TIME 3
00036
00037 class CL_Filter;
00038 class chop_RealtimeData;
00039
00040
00041 class CHOP_API ut_RealtimeData
00042 {
00043 public:
00044 ut_RealtimeData(const char *name, int input = -1);
00045 virtual ~ut_RealtimeData();
00046
00047 const UT_String & tag() { return myTag; }
00048 int inputNum() { return myInputNum; }
00049 void setInput(int n) { myInputNum = n; }
00050
00051 virtual bool loadStates(UT_IStream &is, int version);
00052 virtual int saveStates(ostream &os, int binary);
00053
00054 private:
00055 UT_String myTag;
00056 int myInputNum;
00057 };
00058
00059
00060 class CHOP_API ut_FilterData : public ut_RealtimeData
00061 {
00062 public:
00063 ut_FilterData(const char *name, int filter_size, int overlap);
00064 virtual ~ut_FilterData();
00065
00066 virtual bool loadStates(UT_IStream &is, int version);
00067 virtual int saveStates(ostream &os, int binary);
00068
00069 CL_Filter *myFilter;
00070 };
00071
00072 class CHOP_API CHOP_Realtime : public CHOP_Node
00073 {
00074 protected:
00075
00076 CHOP_Realtime(OP_Network *parent,
00077 const char *name,
00078 OP_Operator *entry);
00079 virtual ~CHOP_Realtime();
00080
00081 virtual OP_ERROR cookMySlice(OP_Context &, int start, int end) =0;
00082 virtual const char *getTimeSliceExtension() = 0;
00083 virtual int getSaveVersion() { return 1; }
00084
00085
00086
00087 virtual void realtimeInit(float t);
00088 virtual void realtimeCleanup();
00089
00090
00091 virtual void realtimeStart(float t);
00092 virtual void realtimeStop();
00093
00094
00095
00096
00097 virtual ut_RealtimeData * newRealtimeDataBlock(const char *name,
00098 const CL_Track *track,
00099 float t);
00100
00101
00102 virtual int usesRealtime() { return 1; }
00103 virtual int isRealtimeCook() { return REALTIME(); }
00104 virtual int isRealtimeActive(OP_Context &) { return 1; }
00105
00106
00107 virtual int isTimeDependent();
00108 virtual int isSteady() const;
00109 virtual int getSettlingTime() const
00110 { return DEF_REALTIME_SETTLING_TIME; }
00111 virtual int allowDoubleCooking() const { return 0; }
00112
00113 int isFirstRealtimeCook() const;
00114 void setFirstRealtimeCook(bool first);
00115
00116
00117 virtual int realtimeMode() { return REALTIME_MODE_TRIM; }
00118
00119
00120
00121 virtual int adjustClip() { return 1; }
00122
00123
00124 virtual OP_ERROR doCookRealtime(OP_Context &context);
00125
00126
00127
00128 virtual int getInputInterest() { return 0; }
00129
00130
00131
00132 virtual float getRealtimeFrameAdjustment(float ) { return 0.0F; }
00133
00134
00135 virtual float getRealtimeSampleRate() { return getSampleRate(); }
00136
00137
00138 virtual int getModifiedRange(int &first,int &last,int clear=1);
00139
00140
00141 int isWraparound() const;
00142
00143 int getNumDataBlocks() const;
00144 ut_RealtimeData * getDataBlock(int n);
00145 ut_RealtimeData * getDataBlock(const char *tag);
00146
00147 void getFrameRange(int &start, int &end);
00148 unsigned int getAbsoluteFrame();
00149
00150
00151
00152 virtual void cacheChannelData(float t);
00153 virtual void resetDataCache();
00154
00155 void setPreviousCookTime(float t);
00156
00157 void getCurrentRange(int &start, int &end) const;
00158 void setCurrentRange(int start, int end);
00159
00160
00161 ut_RealtimeData *addDataBlock(const char *name,
00162 const CL_Track *track =0,
00163 float t = 0.0F);
00164 ut_RealtimeData *insertDataBlock(int index,
00165 const char *name,
00166 const CL_Track *track =0,
00167 float t = 0.0F);
00168 void removeDataBlock(const char *name);
00169 void removeDataBlock(int index);
00170
00171 void updateDataBlocks();
00172
00173 void copyRealtimeInput(const CL_Clip *clip,
00174 int start, int end);
00175
00176 virtual OP_ERROR save(ostream &os, const OP_SaveFlags &flags,
00177 const char *pathPrefix);
00178
00179 virtual bool load(UT_IStream &is, const char *extension,
00180 const char *path);
00181
00182 virtual OP_ERROR saveStates(ostream &os, int binary);
00183 virtual bool loadStates(UT_IStream &is, int version);
00184
00185 protected:
00186
00187 chop_RealtimeData *newRealtimeBlock();
00188
00189 chop_RealtimeData *myRealtimeData;
00190
00191 private:
00192 void getParentTimeSlice(int &start,int &end);
00193
00194 public:
00195 chop_RealtimeData *getRealtimeData() { return myRealtimeData; }
00196 void setRealtimeData(chop_RealtimeData *d)
00197 { myRealtimeData = d; }
00198 static void deleteRealtimeData(chop_RealtimeData *data);
00199
00200 };
00201
00202 #endif