Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 3 | pmbaty | 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 virtual class to provide basic MPEG playback actions */ |
||
| 23 | |||
| 24 | #ifndef _MPEGACTION_H_ |
||
| 25 | #define _MPEGACTION_H_ |
||
| 26 | |||
| 27 | #include "SDL.h" |
||
| 28 | #include "MPEGfilter.h" |
||
| 29 | |||
| 30 | typedef enum { |
||
| 31 | MPEG_ERROR = -1, |
||
| 32 | MPEG_STOPPED, |
||
| 33 | MPEG_PLAYING |
||
| 34 | } MPEGstatus; |
||
| 35 | |||
| 36 | class MPEGaction { |
||
| 37 | public: |
||
| 38 | MPEGaction() { |
||
| 39 | playing = false; |
||
| 40 | paused = false; |
||
| 41 | looping = false; |
||
| 42 | play_time = 0.0; |
||
| 43 | } |
||
| 44 | virtual void Loop(bool toggle) { |
||
| 45 | looping = toggle; |
||
| 46 | } |
||
| 47 | virtual double Time(void) { /* Returns the time in seconds since start */ |
||
| 48 | return play_time; |
||
| 49 | } |
||
| 50 | virtual void Play(void) = 0; |
||
| 51 | virtual void Stop(void) = 0; |
||
| 52 | virtual void Rewind(void) = 0; |
||
| 53 | virtual void ResetSynchro(double) = 0; |
||
| 54 | virtual void Skip(float seconds) = 0; |
||
| 55 | virtual void Pause(void) { /* A toggle action */ |
||
| 56 | if ( paused ) { |
||
| 57 | paused = false; |
||
| 58 | Play(); |
||
| 59 | } else { |
||
| 60 | Stop(); |
||
| 61 | paused = true; |
||
| 62 | } |
||
| 63 | } |
||
| 64 | /* Michel Darricau from eProcess <mdarricau@eprocess.fr> conflict name in popcorn */ |
||
| 65 | virtual MPEGstatus GetStatus(void) = 0; |
||
| 66 | |||
| 67 | protected: |
||
| 68 | bool playing; |
||
| 69 | bool paused; |
||
| 70 | bool looping; |
||
| 71 | double play_time; |
||
| 72 | |||
| 73 | bool force_exit; |
||
| 74 | |||
| 75 | void ResetPause(void) { |
||
| 76 | paused = false; |
||
| 77 | } |
||
| 78 | }; |
||
| 79 | |||
| 80 | /* For getting info about the audio portion of the stream */ |
||
| 81 | typedef struct MPEG_AudioInfo { |
||
| 82 | int mpegversion; |
||
| 83 | int mode; |
||
| 84 | int frequency; |
||
| 85 | int layer; |
||
| 86 | int bitrate; |
||
| 87 | int current_frame; |
||
| 88 | } MPEG_AudioInfo; |
||
| 89 | |||
| 90 | /* Audio action class */ |
||
| 91 | class MPEGaudioaction : public MPEGaction { |
||
| 92 | public: |
||
| 93 | virtual bool GetAudioInfo(MPEG_AudioInfo *info) { |
||
| 94 | return(true); |
||
| 95 | } |
||
| 96 | virtual void Volume(int vol) = 0; |
||
| 97 | }; |
||
| 98 | |||
| 99 | /* Matches the declaration of SDL_UpdateRect() */ |
||
| 100 | typedef void(*MPEG_DisplayCallback)(SDL_Surface* dst, int x, int y, |
||
| 101 | unsigned int w, unsigned int h); |
||
| 102 | |||
| 103 | /* For getting info about the video portion of the stream */ |
||
| 104 | typedef struct MPEG_VideoInfo { |
||
| 105 | int width; |
||
| 106 | int height; |
||
| 107 | int current_frame; |
||
| 108 | double current_fps; |
||
| 109 | } MPEG_VideoInfo; |
||
| 110 | |||
| 111 | /* Video action class */ |
||
| 112 | class MPEGvideoaction : public MPEGaction { |
||
| 113 | public: |
||
| 114 | virtual void SetTimeSource(MPEGaudioaction *source) { |
||
| 115 | time_source = source; |
||
| 116 | } |
||
| 117 | virtual bool GetVideoInfo(MPEG_VideoInfo *info) { |
||
| 118 | return(false); |
||
| 119 | } |
||
| 120 | virtual bool SetDisplay(SDL_Surface *dst, SDL_mutex *lock, |
||
| 121 | MPEG_DisplayCallback callback) = 0; |
||
| 122 | virtual void MoveDisplay(int x, int y) = 0; |
||
| 123 | virtual void ScaleDisplayXY(int w, int h) = 0; |
||
| 124 | virtual void SetDisplayRegion(int x, int y, int w, int h) = 0; |
||
| 125 | virtual void RenderFrame(int frame) = 0; |
||
| 126 | virtual void RenderFinal(SDL_Surface *dst, int x, int y) = 0; |
||
| 127 | virtual SMPEG_Filter * Filter(SMPEG_Filter * filter) = 0; |
||
| 128 | protected: |
||
| 129 | MPEGaudioaction *time_source; |
||
| 130 | }; |
||
| 131 | |||
| 132 | |||
| 133 | /* For getting info about the system portion of the stream */ |
||
| 134 | typedef struct MPEG_SystemInfo { |
||
| 135 | int total_size; |
||
| 136 | int current_offset; |
||
| 137 | double total_time; |
||
| 138 | double current_time; |
||
| 139 | } MPEG_SystemInfo; |
||
| 140 | |||
| 141 | #endif /* _MPEGACTION_H_ */ |