2 * Copyright 2000-2004 Ingo Weinhold <ingo_weinhold@gmx.de>
3 * Copyright 2006-2008 Stephan Aßmus <superstippi@gmx.de>
4 * All rights reserved. Distributed under the terms of the MIT License.
6 #ifndef MEDIA_TRACK_AUDIO_SUPPLIER_H
7 #define MEDIA_TRACK_AUDIO_SUPPLIER_H
12 #include "AudioTrackSupplier.h"
16 struct media_codec_info
;
20 class MediaTrackAudioSupplier
: public AudioTrackSupplier
{
22 MediaTrackAudioSupplier(BMediaTrack
* track
,
24 virtual ~MediaTrackAudioSupplier();
26 virtual const media_format
& Format() const;
27 virtual status_t
GetEncodedFormat(media_format
* format
) const;
28 virtual status_t
GetCodecInfo(media_codec_info
* info
) const;
29 virtual bigtime_t
Duration() const;
31 // AudioReader interface
32 // (needed to reuse the class as AudioResampler input)
33 virtual bigtime_t
InitialLatency() const;
34 virtual status_t
Read(void* buffer
, int64 pos
, int64 frames
);
36 virtual status_t
InitCheck() const;
38 virtual int32
TrackIndex() const
39 { return fTrackIndex
; }
43 void _InitFromTrack();
45 int64
_FramesPerBuffer() const;
47 void _CopyFrames(void* source
, int64 sourceOffset
,
48 void* target
, int64 targetOffset
,
49 int64 position
, int64 frames
) const;
50 void _CopyFrames(Buffer
* buffer
, void* target
,
51 int64 targetOffset
, int64 position
,
54 void _AllocateBuffers();
56 Buffer
* _BufferAt(int32 index
) const;
57 Buffer
* _FindBufferAtFrame(int64 frame
) const;
58 Buffer
* _FindUnusedBuffer() const;
59 Buffer
* _FindUsableBuffer() const;
60 Buffer
* _FindUsableBufferFor(int64 position
) const;
61 void _GetBuffersFor(BList
& buffers
, int64 position
,
63 void _TouchBuffer(Buffer
* buffer
);
65 status_t
_ReadBuffer(Buffer
* buffer
, int64 position
);
66 status_t
_ReadBuffer(Buffer
* buffer
, int64 position
,
69 void _ReadCachedFrames(void*& buffer
,
70 int64
& position
, int64
& frames
,
73 status_t
_ReadUncachedFrames(void* buffer
,
74 int64 position
, int64 frames
,
77 status_t
_FindKeyFrameForward(int64
& position
);
78 status_t
_FindKeyFrameBackward(int64
& position
);
80 // status_t _SeekToKeyFrameForward(int64& position);
81 status_t
_SeekToKeyFrameBackward(int64
& position
);
84 BMediaTrack
* fMediaTrack
;
91 bool fReportSeekError
;
95 #endif // MEDIA_TRACK_AUDIO_SUPPLIER_H