1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
#pragma once
/*
* Copyright (C) 2005-2008 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "StdString.h"
#include "system.h"
class CDVDInputStream;
#if (defined HAVE_CONFIG_H) && (!defined WIN32)
#include "config.h"
#endif
#ifndef _LINUX
enum CodecID;
#else
extern "C" {
#if (defined USE_EXTERNAL_FFMPEG)
#if (defined HAVE_LIBAVCODEC_AVCODEC_H)
#include <libavcodec/avcodec.h>
#elif (defined HAVE_FFMPEG_AVCODEC_H)
#include <ffmpeg/avcodec.h>
#endif
#else
#include "libavcodec/avcodec.h"
#endif
}
#endif
enum AVDiscard;
enum StreamType
{
STREAM_NONE, // if unknown
STREAM_AUDIO, // audio stream
STREAM_VIDEO, // video stream
STREAM_DATA, // data stream
STREAM_SUBTITLE,// subtitle stream
STREAM_TELETEXT // Teletext data stream
};
enum StreamSource {
STREAM_SOURCE_NONE = 0x000,
STREAM_SOURCE_DEMUX = 0x100,
STREAM_SOURCE_NAV = 0x200,
STREAM_SOURCE_DEMUX_SUB = 0x300,
STREAM_SOURCE_TEXT = 0x400
};
#define STREAM_SOURCE_MASK(a) ((a) & 0xf00)
/*
* CDemuxStream
* Base class for all demuxer streams
*/
class CDemuxStream
{
public:
CDemuxStream()
{
iId = 0;
iPhysicalId = 0;
codec = (CodecID)0; // CODEC_ID_NONE
codec_fourcc = 0;
type = STREAM_NONE;
source = STREAM_SOURCE_NONE;
iDuration = 0;
pPrivate = NULL;
ExtraData = NULL;
ExtraSize = 0;
language[0] = 0;
disabled = false;
}
virtual ~CDemuxStream() {}
virtual void GetStreamInfo(std::string& strInfo)
{
strInfo = "";
}
virtual void GetStreamName(std::string& strInfo);
virtual void SetDiscard(AVDiscard discard);
virtual AVDiscard GetDiscard();
int iId; // most of the time starting from 0
int iPhysicalId; // id
CodecID codec;
unsigned int codec_fourcc; // if available
StreamType type;
int source;
int iDuration; // in mseconds
void* pPrivate; // private pointer for the demuxer
void* ExtraData; // extra data for codec to use
unsigned int ExtraSize; // size of extra data
char language[4]; // ISO 639 3-letter language code (empty string if undefined)
bool disabled; // set when stream is disabled. (when no decoder exists)
};
class CDemuxStreamVideo : public CDemuxStream
{
public:
CDemuxStreamVideo() : CDemuxStream()
{
iFpsScale = 0;
iFpsRate = 0;
iHeight = 0;
iWidth = 0;
fAspect = 0.0;
bVFR = false;
type = STREAM_VIDEO;
}
virtual ~CDemuxStreamVideo() {}
int iFpsScale; // scale of 1000 and a rate of 29970 will result in 29.97 fps
int iFpsRate;
int iHeight; // height of the stream reported by the demuxer
int iWidth; // width of the stream reported by the demuxer
float fAspect; // display aspect of stream
bool bVFR; // variable framerate
};
class CDemuxStreamAudio : public CDemuxStream
{
public:
CDemuxStreamAudio() : CDemuxStream()
{
iChannels = 0;
iSampleRate = 0;
iBlockAlign = 0;
iBitRate = 0;
iBitsPerSample = 0;
type = STREAM_AUDIO;
}
virtual ~CDemuxStreamAudio() {}
void GetStreamType(std::string& strInfo);
int iChannels;
int iSampleRate;
int iBlockAlign;
int iBitRate;
int iBitsPerSample;
};
class CDemuxStreamSubtitle : public CDemuxStream
{
public:
CDemuxStreamSubtitle() : CDemuxStream()
{
identifier = 0;
type = STREAM_SUBTITLE;
}
int identifier;
};
class CDemuxStreamTeletext : public CDemuxStream
{
public:
CDemuxStreamTeletext() : CDemuxStream()
{
type = STREAM_TELETEXT;
}
virtual void GetStreamInfo(std::string& strInfo);
};
typedef struct DemuxPacket
{
BYTE* pData; // data
int iSize; // data size
int iStreamId; // integer representing the stream index
int iGroupId; // the group this data belongs to, used to group data from different streams together
double pts; // pts in DVD_TIME_BASE
double dts; // dts in DVD_TIME_BASE
double duration; // duration in DVD_TIME_BASE if available
} DemuxPacket;
class CDVDDemux
{
public:
CDVDDemux() {}
virtual ~CDVDDemux() {}
/*
* Reset the entire demuxer (same result as closing and opening it)
*/
virtual void Reset() = 0;
/*
* Aborts any internal reading that might be stalling main thread
* NOTICE - this can be called from another thread
*/
virtual void Abort() = 0;
/*
* Flush the demuxer, if any data is kept in buffers, this should be freed now
*/
virtual void Flush() = 0;
/*
* Read a packet, returns NULL on error
*
*/
virtual DemuxPacket* Read() = 0;
/*
* Seek, time in msec calculated from stream start
*/
virtual bool SeekTime(int time, bool backwords = false, double* startpts = NULL) = 0;
/*
* Seek to a specified chapter.
* startpts can be updated to the point where display should start
*/
virtual bool SeekChapter(int chapter, double* startpts = NULL) { return false; }
/*
* Get the number of chapters available
*/
virtual int GetChapterCount() { return 0; }
/*
* Get current chapter
*/
virtual int GetChapter() { return -1; }
/*
* Get the name of the current chapter
*/
virtual void GetChapterName(std::string& strChapterName) {}
/*
* Set the playspeed, if demuxer can handle different
* speeds of playback
*/
virtual void SetSpeed(int iSpeed) = 0;
/*
* returns the total time in msec
*/
virtual int GetStreamLength() = 0;
/*
* returns the stream or NULL on error, starting from 0
*/
virtual CDemuxStream* GetStream(int iStreamId) = 0;
/*
* return nr of streams, 0 if none
*/
virtual int GetNrOfStreams() = 0;
/*
* returns opened filename
*/
virtual std::string GetFileName() = 0;
/*
* return nr of audio streams, 0 if none
*/
int GetNrOfAudioStreams();
/*
* return nr of video streams, 0 if none
*/
int GetNrOfVideoStreams();
/*
* return nr of subtitle streams, 0 if none
*/
int GetNrOfSubtitleStreams();
/*
* return nr of teletext streams, 0 if none
*/
int GetNrOfTeletextStreams();
/*
* return the audio stream, or NULL if it does not exist
*/
CDemuxStreamAudio* GetStreamFromAudioId(int iAudioIndex);
/*
* return the video stream, or NULL if it does not exist
*/
CDemuxStreamVideo* GetStreamFromVideoId(int iVideoIndex);
/*
* return the subtitle stream, or NULL if it does not exist
*/
CDemuxStreamSubtitle* GetStreamFromSubtitleId(int iSubtitleIndex);
/*
* return the teletext stream, or NULL if it does not exist
*/
CDemuxStreamTeletext* GetStreamFromTeletextId(int iTeletextIndex);
/*
* return a user-presentable codec name of the given stream
*/
virtual void GetStreamCodecName(int iStreamId, CStdString &strName) {};
};
|