Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GFX: add config which to prefer H264 vs RFX #3218

Merged
merged 5 commits into from
Aug 29, 2024

Conversation

metalefty
Copy link
Member

Not implemented to use loaded config yet.

I'd like to get reviewed whether the structure to save codec priority is appropriate.

@metalefty metalefty force-pushed the gfx_codec_order branch 4 times, most recently from d3e7b25 to 90716ff Compare August 24, 2024 13:44
Copy link
Member

@matt335672 matt335672 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor comments.

tests/xrdp/gfx/gfx.toml Outdated Show resolved Hide resolved
xrdp/xrdp_tconfig.c Outdated Show resolved Hide resolved
xrdp/xrdp_tconfig.c Outdated Show resolved Hide resolved
xrdp/xrdp_tconfig.c Outdated Show resolved Hide resolved
tests/xrdp/test_tconfig.c Outdated Show resolved Hide resolved
xrdp/xrdp_mm.c Outdated
if (best_pro_index >= 0)
#if defined(XRDP_H264)
struct xrdp_tconfig_gfx_codec_order co = self->wm->gfx_config->codec;
bool_t use_h264 = (best_h264_index >= 0 && (best_pro_index < 0 || (co.h264_idx >= 0 && co.h264_idx < co.rfx_idx)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have 2 codecs for GFX now. It might be more complex when we support a third codec.

@metalefty
Copy link
Member Author

@matt335672 Added to use codec order. Can you have a look at the part?

Commits will be squashed into 2 parts later, adding configuration and using configuration.

@metalefty metalefty marked this pull request as ready for review August 27, 2024 05:06
@matt335672
Copy link
Member

@metalefty - sorry it's taken me a while to get to this, but I wanted to review it properly.

I share your concern about working out the codec order, particularly if we add another codec.

I think there's a better way to do this by replacing the _idx values in xrdp_tconfig.h with an array which just contains the order of the codecs entered by the user, like this:-

--- a/xrdp/xrdp_tconfig.h
+++ b/xrdp/xrdp_tconfig.h
@@ -42,10 +42,17 @@ struct xrdp_tconfig_gfx_x264_param
     int fps_den;
 };
 
+enum xrdp_tconfig_codecs
+{
+    XTC_H264,
+    XTC_RFX
+};
+
 struct xrdp_tconfig_gfx_codec_order
 {
-    int h264_idx;
-    int rfx_idx;
+
+    enum xrdp_tconfig_codecs codecs[2];
+    unsigned int codec_count;
 };
 
 struct xrdp_tconfig_gfx

Then in xrdp_mm.c we can just iterate over the list and find the first match, ignoring any unsupported codecs. This scales for any number of codecs.

I've put together a complete patch (including tests) which illustrates this approach:-

patch.txt

Some of the variable names could maybe do with changing.

What do you think?

@metalefty
Copy link
Member Author

I like that idea. Could you attach a patch git format-patch when you have changed variable names? Then I'll add your changes to this pull request.

@matt335672
Copy link
Member

Will do.

I’ve also just realised the code I added to xrdp_mm.c is complete rubbish! I’ll fix that too, and test it. That will be tomorrow now.

@matt335672
Copy link
Member

matt335672 commented Aug 28, 2024

How's this?

0001-Rework-codec-order-in-tconfig.patch

After testing, it occurs to me that for some error conditions (e.g. missing file, badly formatted file) we can default to just "RFX" rather than nothing at all. Then at least we get a match on the codecs. What do you think?

@metalefty
Copy link
Member Author

Agreed.

Replaced codec idx values with a list of codecs from the
config file.

Added some logging for debugging
@matt335672
Copy link
Member

Away from my PC ATM. I’ll fix the build errors and add a patch (and test) to default to RFX tomorrow, time permitting

@matt335672
Copy link
Member

Try this one:-

0001-Further-changes-to-selectable-H.264-support.patch.txt

Two tests added:-

  1. If the user tries to load a missing file, an RFX-only config is returned
  2. If the config specified H.264, but there are no default for H.264, an RFX-only config is returned

CI should be fine now.

@matt335672
Copy link
Member

PS: Feel free to edit/squash as appropriate.

- Fix CI errors
- tconfig_load_gfx() removes H.264 from the supported codec list
  if significant errors are found loading the H.264 configuration
- tconfig_load_gfx() always produces a usable config, even if the
  specified file can't be loaded
@metalefty
Copy link
Member Author

Thanks, wonderful! LGTM.

@metalefty metalefty merged commit 27f0feb into neutrinolabs:devel Aug 29, 2024
14 checks passed
@metalefty metalefty deleted the gfx_codec_order branch August 29, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants