Files
dragonpilot/tools/clib/FrameReader.hpp
iejMac 19d962cdf3 qt replay (#20602)
* initial commit, works

* remove nui

* working again

* visionipc

* cleanup

* cleanup

* moving VisionIpcServer to Unlogger class

* works

* tab cleanup

* headless mode

* headless mode works

* working headless mode

* gitignore update

* small unlogger refactor

* refactor param in UIState

* works, very slow, hacks

* cleanup

* works

* cleanup

* cleanup

* unused

* works for whole route

* nicer

* a little nicer

* different threshold

* maintains 1 segment window

* works with public api

* comments

* networkTimer works

* cleanup

* unified HttpRequest

* tabs

* tabs

* comments'

* gitignore

* gitignore

* only on PC

* same line else

* no changes in home.cc

* scons

* update scons

* works

* revert mainc.c

* revert home

* else

* just api + problem with api send

* works

* include cleanup

* general json fail

* whitespace

* remove active

* adding request repeater

* removing comments

* tabs

* update comment

* cereal

* fix

* trailing new lines

* grammar

* if whitespace

* indentation

* Update selfdrive/ui/SConscript

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* Update selfdrive/ui/qt/request_repeater.cc

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>

* works

* sort by dir

* no blockSignal

* replay is now QOBject

* cant take const char

* rename inner it

* get width and height from frame readeR

* resolve TODO

* seek in next pr

* spaces

* ui stuff

* fix CI

* remove comments

* no repalce

* trim segment fix

* remove seek from stream

* no cache key

* final changes'

* fix

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
2021-04-24 00:59:09 -07:00

61 lines
1.0 KiB
C++

#ifndef FRAMEREADER_HPP
#define FRAMEREADER_HPP
#include <unistd.h>
#include <vector>
#include <map>
#include <thread>
#include <mutex>
#include <list>
#include <condition_variable>
#include "channel.hpp"
// independent of QT, needs ffmpeg
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
class FrameReader {
public:
FrameReader(const char *fn);
uint8_t *get(int idx);
AVFrame *toRGB(AVFrame *);
void waitForReady() {
while (!joined) usleep(10*1000);
}
int getRGBSize() { return width*height*3; }
void loaderThread();
void cacherThread();
//TODO: get this from the actual frame
int width = 1164;
int height = 874;
private:
AVFormatContext *pFormatCtx = NULL;
AVCodecContext *pCodecCtx = NULL;
struct SwsContext *sws_ctx = NULL;
std::vector<AVPacket *> pkts;
std::thread *t;
bool joined = false;
std::map<int, uint8_t *> cache;
std::mutex mcache;
void GOPCache(int idx);
channel<int> to_cache;
bool valid = true;
char url[0x400];
};
#endif