2 Copyright 2005-2006 Mark Calderbank
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP 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.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 Thanks goes to Jon Gettler of the MVPMC project and Stephen Rice for
24 the demuxer in mvpmc. It was used in the creation of this Demuxer,
25 however, no code was copied verbatim.
38 #include "draintarget.h"
40 #define PES_AUDIO_START 0xc0
41 #define PES_AUDIO_END 0xcf
50 void init(UCHAR type);
52 int write(UCHAR* buf, int len);
62 virtual void parseDetails();
63 UINT findPictureHeader();
65 static const ULLONG PTS_INVALID;
67 friend class PESPacket;
72 static Demuxer* getInstance();
73 int init(Callback* callback, DrainTarget* audio, DrainTarget* video, ULONG demuxMemoryV, ULONG demuxMemoryA);
78 void setVideoStream(int id);
79 void setAudioStream(int id);
83 virtual int scan(UCHAR* buf, int len) = 0;
84 virtual int findPTS(UCHAR* buf, int len, ULLONG* dest) = 0;
85 virtual int put(UCHAR* buf, int len) = 0;
86 virtual void setFrameNum(ULONG frame) {}
87 virtual void setPacketNum(ULONG packet) {}
88 virtual ULONG getFrameNumFromPTS(ULLONG pts) {return 0;}
89 virtual ULONG getPacketNum() {return 0;}
91 bool* getmpAudioChannels(); //Maybe virtual ?
92 int getselAudioChannel();
93 void setmpAudioChannel(int aud_channel);
95 int getHorizontalSize() { return horizontal_size; }
96 int getVerticalSize() { return vertical_size; }
97 int getAspectRatio() { return aspect_ratio; }
98 int getFrameRate() { return frame_rate; }
99 int getBitRate() { return bit_rate; }
100 ULLONG getVideoPTS() { return video_pts; }
101 ULLONG getAudioPTS() { return audio_pts; }
109 // Remove all data from a buffer apart from video PES packets.
110 // Returns the length of the reduced data.
112 static UINT stripAudio(UCHAR* buf, UINT len);
114 // Scan a buffer to see if video packets are present.
115 // Returns true if video exists; false if not.
117 static bool scanForVideo(UCHAR* buf, UINT len);
120 // General demuxer objects and status indicators
121 static Demuxer* instance;
128 int video_current, audio_current;
130 // Video stream information
131 void setAspectRatio(enum AspectRatio);
136 enum AspectRatio aspect_ratio;
141 ULLONG video_pts_seek;
145 static const int FrameRates[9];
149 PESTYPE_PRIVATE_1 = 0xBD,
152 PESTYPE_AUD1, PESTYPE_AUD2, PESTYPE_AUD3, PESTYPE_AUD4,
153 PESTYPE_AUD5, PESTYPE_AUD6, PESTYPE_AUD7, PESTYPE_AUD8,
154 PESTYPE_AUD9, PESTYPE_AUD10, PESTYPE_AUD11, PESTYPE_AUD12,
155 PESTYPE_AUD13, PESTYPE_AUD14, PESTYPE_AUD15, PESTYPE_AUD16,
156 PESTYPE_AUD17, PESTYPE_AUD18, PESTYPE_AUD19, PESTYPE_AUD20,
157 PESTYPE_AUD21, PESTYPE_AUD22, PESTYPE_AUD23, PESTYPE_AUD24,
158 PESTYPE_AUD25, PESTYPE_AUD26, PESTYPE_AUD27, PESTYPE_AUD28,
159 PESTYPE_AUD29, PESTYPE_AUD30, PESTYPE_AUD31,
160 PESTYPE_AUDMAX = PESTYPE_AUD31,
163 PESTYPE_VID1, PESTYPE_VID2, PESTYPE_VID3, PESTYPE_VID4,
164 PESTYPE_VID5, PESTYPE_VID6, PESTYPE_VID7, PESTYPE_VID8,
165 PESTYPE_VID9, PESTYPE_VID10, PESTYPE_VID11, PESTYPE_VID12,
166 PESTYPE_VID13, PESTYPE_VID14, PESTYPE_VID15,
167 PESTYPE_VIDMAX = PESTYPE_VID15
170 bool avail_mpaudchan[PESTYPE_AUDMAX-PESTYPE_AUD0+1];