Skip to content

Commit

Permalink
add decoder interface which must all decoders inherit
Browse files Browse the repository at this point in the history
  • Loading branch information
havlenapetr committed Jul 30, 2010
1 parent 69d00b3 commit 4479902
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
30 changes: 30 additions & 0 deletions jni/libmediaplayer/decoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef FFMPEG_DECODER_H
#define FFMPEG_DECODER_H

#include <pthread.h>

// map system drivers methods
#include <drivers_map.h>

#include "packetqueue.h"

class IDecoder
{
public:
virtual bool start(const char* err);
virtual bool startAsync(const char* err);
virtual int wait();
virtual void stop();

protected:
PacketQueue* mQueue;
AVCodecContext* mCodecCtx;
bool mDecoding;
pthread_t mThread;

virtual bool prepare(const char *err);
virtual bool decode(void* ptr);
virtual bool process(AVPacket *packet);
};

#endif //FFMPEG_DECODER_H
4 changes: 2 additions & 2 deletions jni/libmediaplayer/decoder_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ static DecoderAudio* sInstance;

DecoderAudio::DecoderAudio(PacketQueue* queue,
AVCodecContext* codec_ctx,
struct DecoderAudioConfig* config)
struct DecoderAudioConfig* config)
{
mQueue = queue;
mCodecCtx = codec_ctx;
mCodecCtx = codec_ctx;
mConfig = config;
sInstance = this;
}
Expand Down
7 changes: 2 additions & 5 deletions jni/libmediaplayer/decoder_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// map system drivers methods
#include <drivers_map.h>

#include "decoder.h"
#include "packetqueue.h"

struct DecoderAudioConfig
Expand All @@ -16,7 +17,7 @@ struct DecoderAudioConfig
int channels;
};

class DecoderAudio
class DecoderAudio : public IDecoder
{
public:
DecoderAudio(PacketQueue* queue,
Expand All @@ -31,11 +32,7 @@ class DecoderAudio
void stop();

private:
PacketQueue* mQueue;
AVCodecContext* mCodecCtx;
struct DecoderAudioConfig* mConfig;
bool mDecoding;
pthread_t mThread;
int16_t* mSamples;
int mSamplesSize;

Expand Down

0 comments on commit 4479902

Please sign in to comment.