[FL-3152] Screen streaming improvements (#2498)
* Rpc: reserve some bandwidth when screen streaming * Move furi_hal_compress to toolbox/comporess * Lib: heatshrink as external submodule, compile warnings fixes, better buffer management * Lib: cleanup compressor definitions * Rpc: add canvas orientation support * Format Sources
This commit is contained in:
@@ -33,8 +33,18 @@ typedef struct {
|
||||
uint32_t input_counter;
|
||||
} RpcGuiSystem;
|
||||
|
||||
static void
|
||||
rpc_system_gui_screen_stream_frame_callback(uint8_t* data, size_t size, void* context) {
|
||||
static const PB_Gui_ScreenOrientation rpc_system_gui_screen_orientation_map[] = {
|
||||
[CanvasOrientationHorizontal] = PB_Gui_ScreenOrientation_HORIZONTAL,
|
||||
[CanvasOrientationHorizontalFlip] = PB_Gui_ScreenOrientation_HORIZONTAL_FLIP,
|
||||
[CanvasOrientationVertical] = PB_Gui_ScreenOrientation_VERTICAL,
|
||||
[CanvasOrientationVerticalFlip] = PB_Gui_ScreenOrientation_VERTICAL_FLIP,
|
||||
};
|
||||
|
||||
static void rpc_system_gui_screen_stream_frame_callback(
|
||||
uint8_t* data,
|
||||
size_t size,
|
||||
CanvasOrientation orientation,
|
||||
void* context) {
|
||||
furi_assert(data);
|
||||
furi_assert(context);
|
||||
|
||||
@@ -44,6 +54,8 @@ static void
|
||||
furi_assert(size == rpc_gui->transmit_frame->content.gui_screen_frame.data->size);
|
||||
|
||||
memcpy(buffer, data, size);
|
||||
rpc_gui->transmit_frame->content.gui_screen_frame.orientation =
|
||||
rpc_system_gui_screen_orientation_map[orientation];
|
||||
|
||||
furi_thread_flags_set(furi_thread_get_id(rpc_gui->transmit_thread), RpcGuiWorkerFlagTransmit);
|
||||
}
|
||||
@@ -53,12 +65,22 @@ static int32_t rpc_system_gui_screen_stream_frame_transmit_thread(void* context)
|
||||
|
||||
RpcGuiSystem* rpc_gui = (RpcGuiSystem*)context;
|
||||
|
||||
uint32_t transmit_time = 0;
|
||||
while(true) {
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(RpcGuiWorkerFlagAny, FuriFlagWaitAny, FuriWaitForever);
|
||||
|
||||
if(flags & RpcGuiWorkerFlagTransmit) {
|
||||
transmit_time = furi_get_tick();
|
||||
rpc_send(rpc_gui->session, rpc_gui->transmit_frame);
|
||||
transmit_time = furi_get_tick() - transmit_time;
|
||||
|
||||
// Guaranteed bandwidth reserve
|
||||
uint32_t extra_delay = transmit_time / 20;
|
||||
if(extra_delay > 500) extra_delay = 500;
|
||||
if(extra_delay) furi_delay_tick(extra_delay);
|
||||
}
|
||||
|
||||
if(flags & RpcGuiWorkerFlagExit) {
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user