From 3164a3201fb0fcea3be8a9cdc90131bc24170c8c Mon Sep 17 00:00:00 2001 From: pigeatgarlic Date: Fri, 15 Dec 2023 11:50:43 +0700 Subject: [PATCH] update display --- src/dll.cpp | 22 ++++++++++++++++------ src/dll.h | 15 ++++++++++----- src/main.cpp | 8 +++++++- src/video.cpp | 4 +++- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/dll.cpp b/src/dll.cpp index f6fecef0..3dfc34da 100644 --- a/src/dll.cpp +++ b/src/dll.cpp @@ -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(); - 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(mail::switch_display)->raise(std::string(value)); + break; + default: + break; + } +} void __cdecl RaiseEvent(VideoPipeline *pipeline, EventType event, diff --git a/src/dll.h b/src/dll.h index 91abacd7..8523b520 100644 --- a/src/dll.h +++ b/src/dll.h @@ -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); diff --git a/src/main.cpp b/src/main.cpp index 7a749816..9fe8e9cb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); diff --git a/src/video.cpp b/src/video.cpp index eab68ed9..a0ada49b 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -1021,7 +1021,7 @@ namespace video { bool last_encoder_probe_supported_ref_frames_invalidation = false; void - reset_display(std::shared_ptr &disp, const platf::mem_type_e &type, const std::string &display_name, const config_t &config) { + reset_display(std::shared_ptr &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); }