#ifndef IMAGE_IO_H
#define IMAGE_IO_H
#include "libde265/image.h"
#include <deque>
class ImageSource
{
public:
LIBDE265_API ImageSource();
virtual LIBDE265_API ~ImageSource() { }
virtual LIBDE265_API de265_image* get_image(bool block=true) = 0;
virtual LIBDE265_API void skip_frames(int n) = 0;
virtual LIBDE265_API int get_width() const = 0;
virtual LIBDE265_API int get_height() const = 0;
};
class ImageSource_YUV : public ImageSource
{
public:
LIBDE265_API ImageSource_YUV();
virtual LIBDE265_API ~ImageSource_YUV();
bool LIBDE265_API set_input_file(const char* filename, int w,int h);
virtual LIBDE265_API de265_image* get_image(bool block=true);
virtual LIBDE265_API void skip_frames(int n);
virtual LIBDE265_API int get_width() const { return width; }
virtual LIBDE265_API int get_height() const { return height; }
private:
FILE* mFH;
bool mReachedEndOfFile;
int width,height;
de265_image* read_next_image();
};
class ImageSink
{
public:
virtual LIBDE265_API ~ImageSink() { }
virtual LIBDE265_API void send_image(const de265_image* img) = 0;
};
class ImageSink_YUV : public ImageSink
{
public:
LIBDE265_API ImageSink_YUV() : mFH(NULL) { }
LIBDE265_API ~ImageSink_YUV();
bool LIBDE265_API set_filename(const char* filename);
virtual LIBDE265_API void send_image(const de265_image* img);
private:
FILE* mFH;
};
class PacketSink
{
public:
virtual LIBDE265_API ~PacketSink() { }
virtual LIBDE265_API void send_packet(const uint8_t* data, int n) = 0;
};
class PacketSink_File : public PacketSink
{
public:
LIBDE265_API PacketSink_File();
virtual LIBDE265_API ~PacketSink_File();
LIBDE265_API void set_filename(const char* filename);
virtual LIBDE265_API void send_packet(const uint8_t* data, int n);
private:
FILE* mFH;
};
#endif