|
1 /* |
|
2 * MP3/MPlayer plugin to VDR (C++) |
|
3 * |
|
4 * (C) 2001-2005 Stefan Huelswitt <s.huelswitt@gmx.de> |
|
5 * |
|
6 * This code is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU General Public License |
|
8 * as published by the Free Software Foundation; either version 2 |
|
9 * of the License, or (at your option) any later version. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 * GNU General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU General Public License |
|
17 * along with this program; if not, write to the Free Software |
|
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
19 * Or, point your browser to http://www.gnu.org/copyleft/gpl.html |
|
20 */ |
|
21 |
|
22 #ifndef ___DVB_MP3_H |
|
23 #define ___DVB_MP3_H |
|
24 |
|
25 #include <vdr/thread.h> |
|
26 #include <vdr/player.h> |
|
27 |
|
28 // ------------------------------------------------------------------- |
|
29 |
|
30 class cRingBufferFrame; |
|
31 class cFrame; |
|
32 |
|
33 class cPlayList; |
|
34 class cSong; |
|
35 class cSongInfo; |
|
36 class cBackgroundScan; |
|
37 class cDecoder; |
|
38 class cOutput; |
|
39 class cOutputDvb; |
|
40 class cShuffle; |
|
41 |
|
42 // ------------------------------------------------------------------- |
|
43 |
|
44 class cMP3PlayInfo { |
|
45 public: |
|
46 char Title[64], Artist[64], Album[64], SMode[32], Filename[256]; |
|
47 int Year, SampleFreq, Bitrate, MaxBitrate; |
|
48 int Num, MaxNum; |
|
49 // not in hash |
|
50 bool Loop, Shuffle; |
|
51 int Hash; |
|
52 }; |
|
53 |
|
54 // ------------------------------------------------------------------- |
|
55 |
|
56 class cPlayManager : public cThread { |
|
57 private: |
|
58 cMutex listMutex; |
|
59 cCondVar fgCond, bgCond; |
|
60 cList<cSong> list; |
|
61 cSong *curr; |
|
62 int currIndex, maxIndex; |
|
63 // |
|
64 cSong *play; |
|
65 bool playNew, eol; |
|
66 // |
|
67 cShuffle *shuffle; |
|
68 bool shuffleMode, loopMode; |
|
69 // |
|
70 cSong *scan; |
|
71 bool stopscan, throttle, pass2, release; |
|
72 // |
|
73 virtual void Action(void); |
|
74 void NoScan(cSong *nono); |
|
75 void NoPlay(cSong *nono); |
|
76 void ThrottleWait(void); |
|
77 public: |
|
78 cPlayManager(void); |
|
79 ~cPlayManager(); |
|
80 // Control interface (to be called from frontend thread only!) |
|
81 void Flush(void); |
|
82 void Add(cPlayList *pl); |
|
83 bool Next(void); |
|
84 bool Prev(void); |
|
85 void Goto(int num); |
|
86 void ToggleShuffle(void); |
|
87 void ToggleLoop(void); |
|
88 bool Info(int num, cMP3PlayInfo *info); |
|
89 void Halt(void); |
|
90 // Player interface (to be called from player thread only!) |
|
91 cSong *Current(void); |
|
92 bool NewCurrent(void); |
|
93 bool NextCurrent(void); |
|
94 void Release(void); |
|
95 void Throttle(bool thr); |
|
96 }; |
|
97 |
|
98 extern cPlayManager *mgr; |
|
99 |
|
100 // ------------------------------------------------------------------- |
|
101 |
|
102 class cMP3Player : public cPlayer, cThread { |
|
103 friend class cOutputDvb; |
|
104 private: |
|
105 bool active, started; |
|
106 cRingBufferFrame *ringBuffer; |
|
107 cMutex playModeMutex; |
|
108 cCondVar playModeCond; |
|
109 // |
|
110 int playindex, total; |
|
111 cDecoder *decoder; |
|
112 cOutput *output; |
|
113 cFrame *rframe, *pframe; |
|
114 enum ePlayMode { pmPlay, pmStopped, pmPaused, pmStartup }; |
|
115 ePlayMode playMode; |
|
116 enum eState { msStart, msStop, msDecode, msNormalize, msResample, msOutput, msError, msEof, msWait, msRestart }; |
|
117 eState state; |
|
118 bool levelgood, isStream; |
|
119 unsigned int dvbSampleRate; |
|
120 // |
|
121 void Empty(void); |
|
122 void StopPlay(void); |
|
123 void SetPlayMode(ePlayMode mode); |
|
124 void WaitPlayMode(ePlayMode mode, bool inv); |
|
125 protected: |
|
126 virtual void Activate(bool On); |
|
127 virtual void Action(void); |
|
128 public: |
|
129 cMP3Player(void); |
|
130 virtual ~cMP3Player(); |
|
131 void Pause(void); |
|
132 void Play(void); |
|
133 bool PrevCheck(void); |
|
134 void SkipSeconds(int secs); |
|
135 virtual bool GetIndex(int &Current, int &Total, bool SnapToIFrame=false); |
|
136 virtual bool GetReplayMode(bool &Play, bool &Forward, int &Speed); |
|
137 bool Active(void) { return active; } |
|
138 bool IsStream(void) { return isStream; } |
|
139 }; |
|
140 |
|
141 #endif //___DVB_MP3_H |