~vcs-imports/smpeg/trunk

« back to all changes in this revision

Viewing changes to MPEG.h

  • Committer: icculus
  • Date: 2021-08-20 16:53:24 UTC
  • Revision ID: svn-v4:d67a7ff0-0d32-0410-8e92-b5b47b70abfd:trunk:414
Moved to GitHub: https://github.com/icculus/smpeg

Show diffs side-by-side

added added

removed removed

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