Subversion Repositories Games.Descent

Rev

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 class used to parse and play MPEG streams */
23
 
24
#ifndef _MPEG_H_
25
#define _MPEG_H_
26
 
27
#include <stdlib.h>
28
#include <stdio.h>
29
#include <string.h>
30
 
31
#include "SDL.h"
32
 
33
#include "MPEGerror.h"
34
#include "MPEGstream.h"
35
#include "MPEGaction.h"
36
#include "MPEGaudio.h"
37
#include "MPEGvideo.h"
38
#include "MPEGsystem.h"
39
#include "MPEGfilter.h"
40
 
41
#define LENGTH_TO_CHECK_FOR_SYSTEM 0x50000      // Added by HanishKVC
42
 
43
/* The main MPEG class - parses system streams and creates other streams
44
 A few design notes:
45
   Making this derived from MPEGstream allows us to do system stream
46
   parsing.  We create an additional MPEG object for each type of
47
   stream in the MPEG file because each needs a separate pointer to
48
   the MPEG data.  The MPEG stream then creates an accessor object to
49
   do all the data parsing for that stream type.  It's a little odd,
50
   but seemed like the best way to implement stream parsing.
51
 */
52
class MPEG : public MPEGerror
53
{
54
public:
55
                /* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
56
    MPEG():MPEGerror(){}
57
        MPEG(bool Sdlaudio, char *addresse,char *asset,long buffersize){}
58
 
59
    MPEG(const char * name, bool SDLaudio = true);
60
    MPEG(int Mpeg_FD, bool SDLaudio = true);
61
    MPEG(void *data, int size, bool SDLaudio = true);
62
    MPEG(SDL_RWops *mpeg_source,bool SDLaudio = true);
63
    virtual ~MPEG();
64
 
65
    /* Initialize the MPEG */
66
    void Init(SDL_RWops *mpeg_source, bool SDLaudio);
67
    void InitErrorState();
68
 
69
    /* Enable/Disable audio and video */
70
    bool AudioEnabled(void);
71
    void EnableAudio(bool enabled);
72
    bool VideoEnabled(void);
73
    void EnableVideo(bool enabled);
74
 
75
    /* MPEG actions */
76
    void Loop(bool toggle);
77
                /* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
78
    virtual void Play(void);
79
    void Stop(void);
80
    void Rewind(void);
81
                /* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
82
    virtual void Pause(void);
83
    virtual void Seek(int bytes);
84
    void Skip(float seconds);
85
                /* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
86
    MPEGstatus GetStatus(void);
87
    void GetSystemInfo(MPEG_SystemInfo *info);
88
 
89
    /* MPEG audio actions */
90
    bool GetAudioInfo(MPEG_AudioInfo *info);
91
    void Volume(int vol);
92
    bool WantedSpec(SDL_AudioSpec *wanted);
93
    void ActualSpec(SDL_AudioSpec *actual);
94
    MPEGaudio *GetAudio(void);
95
 
96
    /* MPEG video actions */
97
    bool GetVideoInfo(MPEG_VideoInfo *info);
98
    bool SetDisplay(SDL_Surface *dst, SDL_mutex *lock,
99
                                 MPEG_DisplayCallback callback);
100
    void MoveDisplay(int x, int y);
101
    void ScaleDisplayXY(int w, int h);
102
    void SetDisplayRegion(int x, int y, int w, int h);
103
    void RenderFrame(int frame);
104
    void RenderFinal(SDL_Surface *dst, int x, int y);
105
    SMPEG_Filter * Filter(SMPEG_Filter * filter);
106
 
107
public:
108
    /* We need to have separate audio and video streams */
109
    MPEGstream * audiostream;
110
    MPEGstream * videostream;
111
 
112
    MPEGsystem * system;
113
 
114
protected:
115
    char *mpeg_mem;       // Used to copy MPEG passed in as memory
116
    SDL_RWops *source;
117
    MPEGaudioaction *audioaction;
118
    MPEGvideoaction *videoaction;
119
 
120
    MPEGaudio *audio;
121
    MPEGvideo *video;
122
 
123
    bool audioaction_enabled;
124
    bool videoaction_enabled;
125
 
126
    bool sdlaudio;
127
 
128
    bool loop;
129
    bool pause;
130
 
131
    void parse_stream_list();
132
    bool seekIntoStream(int position);
133
};
134
 
135
#endif /* _MPEG_H_ */