2 * Copyright (c) 2005, David McPaul
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
23 * OF THE POSSIBILITY OF SUCH DAMAGE.
25 #ifndef _ASF_FILE_READER_H
26 #define _ASF_FILE_READER_H
29 #include <MediaDefs.h>
30 #include <MediaFormats.h>
31 #include <SupportDefs.h>
36 #include "libasf/asf.h"
40 struct ASFAudioFormat
{
44 uint32 AvgBytesPerSec
;
51 struct ASFVideoFormat
{
68 BPositionIO
*theStream
;
71 std::vector
<StreamEntry
> streams
;
76 ASFFileReader(BPositionIO
*pStream
);
77 virtual ~ASFFileReader();
81 bool IsEndOfFile(off_t pPosition
);
83 bool IsEndOfData(off_t pPosition
);
86 static bool IsSupported(BPositionIO
*source
);
88 // How many tracks in file
89 uint32
getStreamCount();
91 // the Stream duration indexed by streamIndex
92 bigtime_t
getStreamDuration(uint32 streamIndex
);
94 bool getAudioFormat(uint32 streamIndex
, ASFAudioFormat
*format
);
95 bool getVideoFormat(uint32 streamIndex
, ASFVideoFormat
*format
);
97 // The no of frames in the Stream indexed by streamIndex
98 uint32
getFrameCount(uint32 streamIndex
);
100 // Is stream (track) a video track
101 bool IsVideo(uint32 streamIndex
);
102 // Is stream (track) a audio track
103 bool IsAudio(uint32 streamIndex
);
105 BPositionIO
*Source() {return theStream
;};
107 IndexEntry
GetIndex(uint32 streamIndex
, uint32 frameNo
);
108 bool HasIndex(uint32 streamIndex
, uint32 frameNo
);
110 uint32
GetFrameForTime(uint32 streamIndex
, bigtime_t time
);
112 bool GetNextChunkInfo(uint32 streamIndex
, uint32 pFrameNo
, char **buffer
, uint32
*size
, bool *keyframe
, bigtime_t
*pts
);
114 static int32_t read(void *opaque
, void *buffer
, int32_t size
);
115 static int32_t write(void *opaque
, void *buffer
, int32_t size
);
116 static int64_t seek(void *opaque
, int64_t offset
);