Skip to content

Commit

Permalink
VIDEO: Add StreamFileAudioTrack wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hoops committed Jul 21, 2012
1 parent 144b9ce commit 067e02e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions video/video_decoder.cpp
Expand Up @@ -486,6 +486,21 @@ bool AdvancedVideoDecoder::SeekableAudioTrack::seek(const Audio::Timestamp &time
return stream->seek(time);
}

AdvancedVideoDecoder::StreamFileAudioTrack::StreamFileAudioTrack() {
_stream = 0;
}

AdvancedVideoDecoder::StreamFileAudioTrack::~StreamFileAudioTrack() {
delete _stream;
}

bool AdvancedVideoDecoder::StreamFileAudioTrack::loadFromFile(const Common::String &baseName) {
// TODO: Make sure the stream isn't being played
delete _stream;
_stream = Audio::SeekableAudioStream::openStreamFile(baseName);
return _stream != 0;
}

void AdvancedVideoDecoder::addTrack(Track *track) {
_tracks.push_back(track);

Expand Down
21 changes: 21 additions & 0 deletions video/video_decoder.h
Expand Up @@ -609,6 +609,27 @@ class AdvancedVideoDecoder : public VideoDecoder {
virtual Audio::SeekableAudioStream *getSeekableAudioStream() const = 0;
};

/**
* A SeekableAudioTrack that constructs its SeekableAudioStream using
* SeekableAudioStream::openStreamFile()
*/
class StreamFileAudioTrack : public SeekableAudioTrack {
public:
StreamFileAudioTrack();
~StreamFileAudioTrack();

/**
* Load the track from a file with the given base name.
*
* @return true on success, false otherwise
*/
bool loadFromFile(const Common::String &baseName);

protected:
Audio::SeekableAudioStream *_stream;
Audio::SeekableAudioStream *getSeekableAudioStream() const { return _stream; }
};

/**
* Decode enough data for the next frame and enough audio to last that long.
*
Expand Down

0 comments on commit 067e02e

Please sign in to comment.