Subversion Repositories Games.Descent

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.     SMPEG - SDL MPEG Player Library
  3.     Copyright (C) 1999  Loki Entertainment Software
  4.    
  5.     - Modified by Michel Darricau from eProcess <mdarricau@eprocess.fr>  for popcorn -
  6.  
  7.     This library is free software; you can redistribute it and/or
  8.     modify it under the terms of the GNU Library General Public
  9.     License as published by the Free Software Foundation; either
  10.     version 2 of the License, or (at your option) any later version.
  11.  
  12.     This library is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.     Library General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU Library General Public
  18.     License along with this library; if not, write to the Free
  19.     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. /* A class based on the MPEG stream class, used to parse and play video */
  23.  
  24. #ifndef _MPEGVIDEO_H_
  25. #define _MPEGVIDEO_H_
  26.  
  27. #include "SDL.h"
  28. #include "SDL_thread.h"
  29. #include "MPEGerror.h"
  30. #include "MPEGaction.h"
  31.  
  32. class MPEGstream;
  33.  
  34. /* This is the MPEG video stream structure in the mpeg_play code */
  35. struct vid_stream;
  36. typedef struct vid_stream VidStream;
  37.  
  38. /* Temporary definition of time stamp structure. */
  39.  
  40. typedef double TimeStamp;
  41.  
  42. class MPEGvideo : public MPEGerror, public MPEGvideoaction {
  43.  
  44.     /* Thread to play the video asynchronously */
  45.     friend int Play_MPEGvideo(void *udata);
  46.  
  47.     /* Various mpeg_play functions that need our data */
  48.     friend VidStream* mpegVidRsrc( TimeStamp time_stamp, VidStream* vid_stream, int first );
  49.     friend int get_more_data( VidStream* vid_stream );
  50.  
  51. public:
  52.     MPEGvideo(MPEGstream *stream);
  53.     virtual ~MPEGvideo();
  54.  
  55.     /* MPEG actions */
  56.     void Play(void);
  57.     void Stop(void);
  58.     void Rewind(void);
  59.     void ResetSynchro(double time);
  60.      void Skip(float seconds);
  61.                 /* Michel Darricau from eProcess <mdarricau@eprocess.fr> conflict name in popcorn */
  62.     MPEGstatus GetStatus(void);
  63.  
  64.     /* MPEG video actions */
  65.     bool GetVideoInfo(MPEG_VideoInfo *info);
  66.     bool SetDisplay(SDL_Surface *dst, SDL_mutex *lock,
  67.                                             MPEG_DisplayCallback callback);
  68.     void MoveDisplay(int x, int y);
  69.     void ScaleDisplayXY(int w, int h);
  70.     void SetDisplayRegion(int x, int y, int w, int h);
  71.     void RenderFrame(int frame);
  72.     void RenderFinal(SDL_Surface *dst, int x, int y);
  73.     SMPEG_Filter * Filter(SMPEG_Filter * filter);
  74.  
  75.     /* Display and sync functions */
  76.     void DisplayFrame( VidStream* vid_stream );
  77.     void ExecuteDisplay( VidStream* vid_stream );
  78.     int timeSync( VidStream* vid_stream );
  79.  
  80.     /* Yes, it's a hack.. */
  81.     MPEGaudioaction *TimeSource(void ) {
  82.         return time_source;
  83.     }
  84.  
  85. protected:
  86.     MPEGstream *mpeg;
  87.  
  88.     VidStream* _stream;
  89.     SDL_Surface* _dst;
  90.     SDL_mutex* _mutex;
  91.     SDL_Thread* _thread;
  92.  
  93.     MPEG_DisplayCallback _callback;
  94.  
  95.     int _ow;            // original width of the movie
  96.     int _oh;            // original height of the movie
  97.     int _w;             // mb aligned width of the movie
  98.     int _h;             // mb aligned height of the movie
  99.     SDL_Rect _srcrect;  // source area
  100.     SDL_Rect _dstrect;  // display area
  101.     SDL_Overlay *_image;// source image
  102.     float _fps;         // frames per second
  103.     SMPEG_Filter * _filter; // pointer to the current filter used
  104.     SDL_mutex* _filter_mutex; // make sure the filter is not changed while being used
  105.  
  106.     void RewindStream(void);
  107. };
  108.  
  109. #endif /* _MPEGVIDEO_H_ */
  110.