58 lines
1.4 KiB
C++
58 lines
1.4 KiB
C++
#ifndef VP9_DECODER_H
|
|
#define VP9_DECODER_H
|
|
|
|
#include "../../shared/interface/vp9_interface.h"
|
|
#include <media/NdkMediaCodec.h>
|
|
#include <media/NdkMediaFormat.h>
|
|
#include <android/native_window.h>
|
|
#include <EGL/egl.h>
|
|
#include <GLES2/gl2.h>
|
|
#include <GLES2/gl2ext.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// Android-specific VP9 decoder implementation using MediaCodec
|
|
class AndroidVP9Decoder {
|
|
private:
|
|
struct DecoderStream {
|
|
AMediaCodec* codec;
|
|
ANativeWindow* surface;
|
|
GLuint texture_id;
|
|
bool initialized;
|
|
int width;
|
|
int height;
|
|
};
|
|
|
|
DecoderStream streams[MAX_VP9_STREAMS];
|
|
bool global_initialized;
|
|
EGLDisplay egl_display;
|
|
EGLContext egl_context;
|
|
|
|
// Helper methods
|
|
bool initializeMediaCodec(int stream_id, int width, int height);
|
|
bool createSurfaceTexture(int stream_id);
|
|
void releaseSurfaceTexture(int stream_id);
|
|
bool isHardwareDecodingSupported();
|
|
|
|
public:
|
|
AndroidVP9Decoder();
|
|
~AndroidVP9Decoder();
|
|
|
|
bool initialize(int width, int height);
|
|
bool decodeFrame(const uint8_t* data, size_t data_size, int stream_id);
|
|
uint32_t getTextureId(int stream_id);
|
|
bool isHardwareSupported();
|
|
vp9_status_t getStatus();
|
|
void release();
|
|
};
|
|
|
|
// Global decoder instance
|
|
extern AndroidVP9Decoder* g_decoder;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // VP9_DECODER_H
|