-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[v0.10] add OpenH264 support #3324
Merged
metalefty
merged 11 commits into
neutrinolabs:v0.10-h264
from
metalefty:v0.10-h264-openh264
Dec 2, 2024
Merged
[v0.10] add OpenH264 support #3324
metalefty
merged 11 commits into
neutrinolabs:v0.10-h264
from
metalefty:v0.10-h264-openh264
Dec 2, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Out of time today, but here's a suggested fix for the CI fail:- --- a/xrdp/xrdp_encoder_openh264.c
+++ b/xrdp/xrdp_encoder_openh264.c
@@ -53,6 +53,20 @@ struct openh264_global
openh264_param[NUM_CONNECTION_TYPES];
};
+// The method invocations on ISVCEncoder are different for C and C++, as
+// ISVCEncoder is a true class in C++, but an emulated one in C
+#ifdef __cplusplus
+#define ENC_GET_DEFAULT_PARAMS(obj,pParam) (obj)->GetDefaultParams(pParam)
+#define ENC_INITIALIZE_EXT(obj,pParam) (obj)->InitializeExt(pParam)
+#define ENC_ENCODE_FRAME(obj,kpSrcPic,pBsInfo) \
+ (obj)->EncodeFrame(kpSrcPic, pBsInfo)
+#else
+#define ENC_GET_DEFAULT_PARAMS(obj,pParam) (*obj)->GetDefaultParams(obj, pParam)
+#define ENC_INITIALIZE_EXT(obj,pParam) (*obj)->InitializeExt(obj, pParam)
+#define ENC_ENCODE_FRAME(obj,kpSrcPic,pBsInfo) \
+ (*obj)->EncodeFrame(obj, kpSrcPic, pBsInfo)
+#endif
+
/*****************************************************************************/
void *
xrdp_encoder_openh264_create(void)
@@ -167,7 +181,7 @@ xrdp_encoder_openh264_encode(void *handle, int session, int left, int top,
LOG(LOG_LEVEL_INFO, "xrdp_encoder_openh264_encode: "
"WelsCreateSVCEncoder rv %p for width %d height %d",
oe->openh264_enc_han, width, height);
- status = (*oe->openh264_enc_han)->GetDefaultParams(
+ status = ENC_GET_DEFAULT_PARAMS(
oe->openh264_enc_han, &encParamExt);
LOG(LOG_LEVEL_INFO, "xrdp_encoder_openh264_encode: "
"GetDefaultParams rv %d", status);
@@ -191,7 +205,7 @@ xrdp_encoder_openh264_encode(void *handle, int session, int left, int top,
slc->iVideoHeight = encParamExt.iPicHeight;
slc->iSpatialBitrate = encParamExt.iTargetBitrate;
slc->iMaxSpatialBitrate = encParamExt.iMaxBitrate;
- status = (*oe->openh264_enc_han)->InitializeExt(
+ status = ENC_INITIALIZE_EXT(
oe->openh264_enc_han, &encParamExt);
LOG(LOG_LEVEL_INFO, "xrdp_encoder_openh264_encode: "
"InitializeExt rv %d", status);
@@ -270,8 +284,7 @@ xrdp_encoder_openh264_encode(void *handle, int session, int left, int top,
}
}
g_memset(&info, 0, sizeof(info));
- status = (*oe->openh264_enc_han)->EncodeFrame(oe->openh264_enc_han,
- &pic1, &info);
+ status = ENC_ENCODE_FRAME(oe->openh264_enc_han, &pic1, &info);
if (status != 0)
{
LOG(LOG_LEVEL_TRACE, "OpenH264: Failed to encode frame"); |
I had no idea about the CI failure, thanks! |
matt335672
approved these changes
Dec 2, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks fine to me. I had a couple of thoughts about the design:-
- I was wondering whether we could fold the x264 and Openh264 parameter sets together in
gfx.toml
, but on reflection I think they're better left as separate sets, in case we need to add something else to one of them. - I was also wondering about
h264_encoder
and whether this could be better folded into theorder
parameter. Again, on reflection, I think it's better this way, as it's easier for different distros to edit this setting (if they need to) using a singlesed
command.
Thanks for the comments.
|
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
gfx.toml
gfx.toml
--enable-openh264
to CI@matt335672 Could you review this?
This works very well on my side. Comparing x264 and OpenH264 is easy. Just edit
h264_encoder
ingfx.conf
and reconnect. It looks x264 is smoother and faster but OpenH264 can control bitrate stricter than x264 because OpenH264 can skip frames so as not to exceed the max bitrate.BTW, we forgot to add gfx_missing_h264.toml to
EXTRA_DIST
before. The test passed. The result is the same as expected, but the process is not what we expect.