multimedia/client/qt_gl_render/yuvgl/media/H264Docoder.h

59 lines
1.2 KiB
C++

#pragma once
#include <ctype.h>
#include <vector>
#include <list>
#include <iostream>
#include <time.h>
#include "RtmpPuller.h"
#include "RtmpPuller2.h"
using namespace std;
extern "C" {
#include "libavutil/pixfmt.h"
#include "libavcodec/avcodec.h"
#include "sdl/SDL.h"
}
#define INBUF_SIZE 4096
typedef vector<char> VData;
class Decoder {
private:
list<VData> mDecodeData;
public:
virtual int Decode(VData &dat) { return -1; };
};
typedef class H264decoder :public Decoder, public RtmpPuller2::RtmpPullObserver {
public:
class H264DecodeObserver {
public:
virtual int OnRecieveData(AVFrame *frame) { return 0; };
};
enum CAP_STATUS {
RUNNING = 1,
STOP = 2,
PAUSE = 3,
FAIL = 4,
};
H264decoder();
~H264decoder();
VData *Decodes(void *dat, uint32_t len);
void OnRtmpFrame(void * dat, uint32_t size);
int SetObserver(H264DecodeObserver *);
private:
AVCodec *mCodec;
AVCodecContext *mCtx = NULL;
int frame, got_picture, len;
AVFrame *picture;
AVPacket avpkt;
H264DecodeObserver *mObserver;
//SDL---------------------------
int screen_w = 0, screen_h = 0;
SDL_Window *screen;
SDL_Renderer* sdlRenderer;
SDL_Texture* sdlTexture;
SDL_Rect sdlRect;
}CH264Decoder;