update display

This commit is contained in:
pigeatgarlic 2023-12-15 11:50:43 +07:00
parent 710a2b9d63
commit 3164a3201f
4 changed files with 36 additions and 13 deletions

View File

@ -26,11 +26,7 @@ struct _VideoPipeline
safe::mail_t mail;
};
extern VideoPipeline *__cdecl StartQueue(int video_width,
int video_height,
int video_bitrate,
int video_framerate,
int video_codec,
extern VideoPipeline *__cdecl StartQueue(int video_codec,
char* display_name)
{
static bool init = false;
@ -53,7 +49,7 @@ extern VideoPipeline *__cdecl StartQueue(int video_width,
static VideoPipeline pipeline = {};
pipeline.mail = std::make_shared<safe::mail_raw_t>();
pipeline.monitor = {video_width, video_height, video_framerate, video_bitrate, 1, 0, 1, 0, 0};
pipeline.monitor = {1920, 1080, 120, 6000, 1, 0, 1, 0, 0};
pipeline.start = std::chrono::steady_clock::now();
switch (video_codec)
@ -111,6 +107,20 @@ PopFromQueue(VideoPipeline *pipeline,
return size;
}
void __cdecl
RaiseEventS(VideoPipeline *pipeline,
EventType event,
char* value)
{
switch (event)
{
case CHANGE_DISPLAY: // IDR FRAME
pipeline->mail->event<std::string>(mail::switch_display)->raise(std::string(value));
break;
default:
break;
}
}
void __cdecl
RaiseEvent(VideoPipeline *pipeline,
EventType event,

View File

@ -10,6 +10,7 @@ typedef struct _VideoPipeline VideoPipeline;
typedef enum _EventType {
POINTER_VISIBLE,
CHANGE_BITRATE,
CHANGE_DISPLAY,
IDR_FRAME,
STOP
@ -21,11 +22,7 @@ typedef enum _Codec {
AV1,
}Codec;
__declspec(dllexport) VideoPipeline* __cdecl StartQueue( int video_width,
int video_height,
int video_bitrate,
int video_framerate,
int video_codec,
__declspec(dllexport) VideoPipeline* __cdecl StartQueue(int video_codec,
char* display_name);
__declspec(dllexport) int __cdecl PopFromQueue(VideoPipeline* pipeline,
@ -36,6 +33,10 @@ __declspec(dllexport) void __cdecl RaiseEvent(VideoPipeline* pipeline,
EventType event,
int value);
__declspec(dllexport) void __cdecl RaiseEventS(VideoPipeline* pipeline,
EventType event,
char* value);
__declspec(dllexport) void __cdecl WaitEvent(VideoPipeline* pipeline,
EventType event);
@ -58,6 +59,10 @@ typedef void (*RAISEEVENT) (VideoPipeline* pipeline,
EventType event,
int value);
typedef void (*RAISEEVENTS) (VideoPipeline* pipeline,
EventType event,
char* value);
typedef void (*WAITEVENT) (VideoPipeline* pipeline,
EventType event);

View File

@ -17,6 +17,7 @@ static STARTQUEUE callstart;
static POPFROMQUEUE callpop;
static WAITEVENT callwait;
static RAISEEVENT callraise;
static RAISEEVENTS callraiseS;
static PEEKEVENT callpeek;
int
@ -31,6 +32,7 @@ initlibrary() {
callstart = (STARTQUEUE) GetProcAddress( hModule,"StartQueue");
callpop = (POPFROMQUEUE) GetProcAddress( hModule,"PopFromQueue");
callraise = (RAISEEVENT) GetProcAddress( hModule,"RaiseEvent");
callraiseS = (RAISEEVENTS) GetProcAddress( hModule,"RaiseEventS");
callwait = (WAITEVENT) GetProcAddress( hModule,"WaitEvent");
callpeek = (PEEKEVENT) GetProcAddress( hModule,"PeekEvent");
@ -59,8 +61,12 @@ int main(int argc, char *argv[])
int count = 0;
while (true) {
int size = callpop(pipeline, data, &duration);
if (callpeek(pipeline,STOP) || count == 10000) {
if (callpeek(pipeline,STOP) || count == 1000) {
break;
} else if (count % 100 == 0) {
callraise(pipeline,CHANGE_BITRATE,2000);
} else if (count % 100 == 50) {
callraiseS(pipeline,CHANGE_DISPLAY,"\\\\.\\DISPLAY1");
}
printf("received packet with size %d\n", size);

View File

@ -1021,7 +1021,7 @@ namespace video {
bool last_encoder_probe_supported_ref_frames_invalidation = false;
void
reset_display(std::shared_ptr<platf::display_t> &disp, const platf::mem_type_e &type, const std::string &display_name, const config_t &config) {
reset_display(std::shared_ptr<platf::display_t> &disp, const platf::mem_type_e &type, const std::string &display_name, config_t config) {
// We try this twice, in case we still get an error on reinitialization
for (int x = 0; x < 2; ++x) {
disp.reset();
@ -1030,6 +1030,8 @@ namespace video {
break;
}
config.width = disp->width;
config.height = disp->height;
// The capture code depends on us to sleep between failures
std::this_thread::sleep_for(200ms);
}