home *** CD-ROM | disk | FTP | other *** search
/ Altsys Virtuoso 2.0K / virtuoso_20k.iso / DemoApps / Graphics / Viewers / Movie / Source / MovieView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-08  |  3.5 KB  |  160 lines

  1. #include <stdio.h>
  2. #include <libc.h>
  3. #include <math.h>
  4. #include <sys/file.h> /* access() */
  5. #include <string.h> /* strfoo() */
  6. #include <sys/dir.h> /* getdirentries */
  7. #include <sys/stat.h>
  8. #include <sys/file.h>
  9.  
  10. #import <objc/List.h>
  11. #import <appkit/Application.h>   /* NX_BASETHRESHOLD */
  12. #import <appkit/View.h>
  13. #import <appkit/Pasteboard.h>
  14. #import <appkit/NXBitmapImageRep.h>
  15. #import <appkit/NXImage.h>
  16. #import <appkit/nextstd.h>
  17. #import <dpsclient/wraps.h>
  18. #import <appkit/Slider.h>
  19. #import <appkit/Button.h>
  20. #import <appkit/Matrix.h>
  21. #import <appkit/Text.h>
  22. #import <appkit/Panel.h>
  23. #import <appkit/OpenPanel.h>
  24. #import <appkit/SavePanel.h>
  25. #import <defaults/defaults.h>
  26. #import <streams/streams.h>
  27.  
  28.  
  29. #import "Animator.h"
  30.  
  31. typedef enum { REVERSE = -1, STOPPED = 0, FORWARD = 1, LOADING = 2 } runState;
  32. typedef enum { LOOP = 0, BOUNCE=1, ONCE=2} runMode;
  33. typedef enum { D_DEF=0, D_2=1, D_8=2, D_12=3, D_24=4} depthMode;
  34.  
  35. #define VERSION __DATE__
  36.  
  37. #define REVSTEP 0
  38. #define REV 1
  39. #define STOP 2
  40. #define FWD 3
  41. #define FWDSTEP 4
  42.  
  43. typedef struct _mpeg_info
  44. {
  45. // window settings
  46.     int    colorSpace,
  47.         zoom,
  48.         backing;
  49.     BOOL sync,
  50.         drop;
  51.     float fps;
  52. // stream attributes
  53.     unsigned int h_size;
  54.     unsigned int v_size;
  55.     unsigned char aspect_ratio;        // Code for aspect ratio.
  56.     unsigned char picture_rate;        // Code for picture rate.
  57.     unsigned long bit_rate;            // Bit rate.
  58.     unsigned int vbv_buffer_size;    // Minimum buffer size.
  59.     BOOL const_param_flag;            // Contrained parameter flag.
  60. // measured statistics
  61.     int    totalFrames,
  62.         frameCount;
  63.     double    elapsedTime;
  64. } mpegInfo;
  65.  
  66. /* a single frame of the movie */
  67. typedef struct {
  68.   NXBitmapImageRep *original;
  69.   NXImage *image;
  70.   } movieFrameStruct;
  71.  
  72. @interface MovieView : View
  73. {
  74.   char moviePath[MAXPATHLEN];
  75.   movieFrameStruct *movieFrame;
  76.   int numFrames;
  77.   int currentFrameIndex;
  78.   int frameCount;
  79.   NXSize maxSize; /* size of biggest frame (for restore: method) */
  80.   float frameRate;
  81.   
  82.   runState state; /* fwd, back, stopped */
  83.   runMode mode; /* once, loop, bounce */
  84.   depthMode dmode; /* depth on-screen */
  85.   BOOL updateControls, showFrameNumber;
  86.   BOOL noOriginals, fromStream;
  87.  
  88.   id panel; /* control panel */
  89.  
  90.   id fpsSlider;  /* things in the control panel */
  91.   id fNumSlider;
  92.   id fpsText;
  93.   id actualFpsText;
  94.   id nFramesText;
  95.   id fNumText;
  96.   id modeButtons;
  97.   id stateButtons;
  98.   id depthButtons;
  99.   id statusText;
  100.   double oldt;
  101.  
  102.   BOOL pingDuringDisplay;
  103.   Animator *anim;
  104. }
  105.  
  106. - initFrame:(const NXRect *) frameRect;
  107. - drawSelf:(const NXRect *) rects :(int)count;
  108.  
  109. - makeWindow;
  110. - makePanel:(char *)filename;
  111. - setFps:(float)fps;
  112. - setNoOriginals;
  113.  
  114. - (BOOL)open:sender;
  115. - (BOOL)play:sender;
  116. - (BOOL)openFile:(char *)filename;
  117. - (List *)openAnimDirectory:(char *)filenameRoot;
  118. - openMPEGfile:(char *)filename;
  119.  
  120. - addBitmap:bm;
  121. - allocateFrames:(List *)frames;
  122.  
  123. - superviewSizeChanged:(NXSize *)old;
  124. - renderFrames;
  125. - recache;
  126.  
  127. - save:sender;
  128. - (BOOL) panelValidateFilenames:sender; // SavePanel's delegate
  129.  
  130. - freeCaches;
  131. - freeOriginals;
  132. - free;
  133. - copy:sender;
  134. - fwd:sender;
  135. - rev:sender;
  136. - move:sender;
  137. - stop:sender;
  138. - fwdStep:sender;
  139. - revStep:sender;
  140. - step:(int) direction;
  141. - reSize:(NXSize *)s;
  142. - expand2x:sender;
  143. - reduce50pct:sender;
  144. - restore:sender;
  145. - modeButtonsChanged:sender;
  146. - fNumSliderChanged:sender;
  147. - fpsSliderChanged:sender;
  148. - pingButtonChanged:sender;
  149. - selectStateButton:(runState)b;
  150. - depthButtonsChanged:sender;
  151. - updateCheckBoxChanged:sender;
  152. - frameCheckBoxChanged:sender;
  153.  
  154. // Window's delegate
  155. - windowWillClose:sender;
  156. - windowDidMiniaturize:sender;
  157. - windowDidDeminiaturize:sender;
  158.  
  159. @end
  160.