removed very situational video_man from raii namespace
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
/**
|
||||
This file is a part of rexy's matrix bot
|
||||
Copyright (C) 2019 rexy712
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef RAII_VIDEO_MAN_HPP
|
||||
#define RAII_VIDEO_MAN_HPP
|
||||
|
||||
#include <memory> //unique_ptr
|
||||
#include "raii/string.hpp"
|
||||
|
||||
//needs to be extern C because quality library writing
|
||||
extern "C"{
|
||||
# include <libavcodec/avcodec.h> //AVCodecContext, AVCodec
|
||||
# include <libavformat/avformat.h> //AVFormatContext
|
||||
# include <libswscale/swscale.h> //sws_scale
|
||||
# include <libavutil/imgutils.h> //av_image_alloc
|
||||
}
|
||||
|
||||
namespace raii{
|
||||
|
||||
class video_man
|
||||
{
|
||||
public:
|
||||
using context_type = std::unique_ptr<AVCodecContext,void(&)(AVCodecContext*)>;
|
||||
using frame_type = std::unique_ptr<AVFrame,void(&)(AVFrame*)>;
|
||||
using packet_type = std::unique_ptr<AVPacket,void(&)(AVPacket*)>;
|
||||
|
||||
private:
|
||||
AVFormatContext* m_vid;
|
||||
AVCodec* m_codec;
|
||||
AVCodecContext* m_context;
|
||||
int m_stream_index = -1;
|
||||
|
||||
|
||||
public:
|
||||
video_man(const raii::string_base& filename);
|
||||
video_man(const video_man& v) = delete;
|
||||
video_man(video_man&& v);
|
||||
~video_man(void);
|
||||
|
||||
int height(void)const;
|
||||
int width(void)const;
|
||||
raii::string get_filetype(void)const;
|
||||
raii::string get_mimetype(void)const;
|
||||
packet_type create_jpg_thumbnail(void);
|
||||
|
||||
AVFormatContext* release(void);
|
||||
void reset(const raii::string_base& filename);
|
||||
void reset(void);
|
||||
|
||||
operator bool(void)const;
|
||||
private:
|
||||
void _init(const raii::string_base& filename);
|
||||
AVFormatContext* _open_video_file(const raii::string_base& filename);
|
||||
static AVFrame* _init_frame(int w, int h, int format);
|
||||
static void _change_color_range(SwsContext* sws_ctx);
|
||||
static context_type _get_jpeg_context(const AVCodecContext* decoder);
|
||||
static void _context_deleter(AVCodecContext* ptr);
|
||||
static void _frame_deleter(AVFrame* ptr);
|
||||
static void _packet_deleter(AVPacket* ptr);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user