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

[addons][inputstream][videocodec] rework documentations, fix "C" ABI and fix memleaks #17438

Merged
merged 21 commits into from
Oct 29, 2020

Conversation

AlwinEsch
Copy link
Member

@AlwinEsch AlwinEsch commented Mar 4, 2020

Description

There are some changes that fix Memleaks that I noticed on the addons.

This is ensured by the fact that the "C" structures at the input stream are not transferred to the addon but are managed using C++ classes, which are then used by the addon.

In addition, some things are simplified because the data does not have to be used on the addon using "C".

The other, and most importantly with Memleaks, is that the interface to inputstream and videocodec is now 100% "C" and no "C++" stuff is given between Kodi and addon.

I will go through this change step by step on all addon types, on the one hand to make feature requests in this regard (where users also requested a usable "C") and to be really sure that there are no creeping errors in the "C" ABI.

In the end (other requests), a "C" ABI test system is brought to Kodi to ensure that nothing wrong gets into it.

Regarding documentation, you can see here how it looks:

There are certainly a lot of grammatical errors and also certainly wrong descriptions, if someone could look over it and my miserable English would be correct 😀.

Also added on first commit the support about BlockSize where on stream reads is required.

This is still WIP and certain things are not yet correct.

As a note: I have adapted the changes to our code guidelines.

EDIT
I forgot a part of the codec where the "C" structures are in their own memory (to simplify API changes, like on c162382)

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • My code follows the Code Guidelines of this project
  • My change requires a change to the documentation, either Doxygen or wiki
  • I have updated the documentation accordingly
  • I have read the Contributing document
  • I have added tests to cover my change
  • All new and existing tests passed

@AlwinEsch AlwinEsch added Type: Cleanup non-breaking change which removes non-working or unmaintained functionality Type: Improvement non-breaking change which improves existing functionality WIP PR that is still being worked on Component: Binary add-ons Component: Video rendering Documentation API change: Binary add-ons v19 Matrix labels Mar 4, 2020
@AlwinEsch AlwinEsch added this to the Matrix 19.0-alpha 1 milestone Mar 4, 2020
@AlwinEsch AlwinEsch requested a review from peak3d March 4, 2020 19:19
@AlwinEsch AlwinEsch requested a review from ksooo as a code owner March 6, 2020 22:22
@AlwinEsch AlwinEsch changed the title [addons][inputstream][videocodec] rework documentations and fix memleaks [addons][inputstream][videocodec] rework documentations, fix "C" ABI and fix memleaks Mar 6, 2020
@phunkyfish phunkyfish added the PR Cleanup: Recent Checked as part of PR cleanup. PR has been followed up on recently. label Mar 10, 2020
@jenkins4kodi jenkins4kodi added the Rebase needed PR that does not apply/merge cleanly to current base branch label Mar 10, 2020
@AlwinEsch AlwinEsch force-pushed the rework-inputstream branch 4 times, most recently from 4130195 to 60275e4 Compare March 14, 2020 19:02
@AlwinEsch
Copy link
Member Author

Is now cleaned up by add of code from other requests, further is on #17501 another separated part created.

After them is in I look to take some documentation parts where become no change from API here.

@AlwinEsch AlwinEsch removed the Rebase needed PR that does not apply/merge cleanly to current base branch label Mar 21, 2020
@jenkins4kodi jenkins4kodi added the Rebase needed PR that does not apply/merge cleanly to current base branch label Apr 2, 2020
Before it contains a C++ part where not match API.

Also id the C++ addon call changed to use std::vector
Before was there the complete structure has return value where makes
harder in unused cases and not match a correct "C" ABI.
…C" style

Before was a pure "C" compile not possible, which shows that this ABI is not set correctly.

The interface must be sure that it is only in pure "C"!

This change only in relation to inputstream, all other types and positions also require
some changes.
This is added to prevent memleaks and to use stack memory.

This becomes on next changes improved and done by a C++ structure
inside Headers.
This is done to confirm a pure "C" within interface and to allow
use for other languages where need a "C" as base.

This changes are the initial part, there still few included headers
where use C++!

This becomes improved on following changes, for here to have the
other commits more clean and see if relate to "C" between Kodi
or to "C++" on addon.
…TREAM_PROPERTY

This is added to translate the "C" structure INPUTSTREAM_PROPERTY to C++
class InputstreamProperty.

This added to make access easier and more secure against leaks.
…PUTSTREAM_CAPABILITIES

This is added to translate the "C" structure INPUTSTREAM_CAPABILITIES to C++
class InputstreamCapabilities.

This added to make access easier and more secure against leaks.
…M_INFO

This is added to translate the "C" structure INPUTSTREAM_INFO to C++
class InputstreamInfo.

This added to make access easier and more secure against leaks.
…A and INPUTSTREAM_CONTENTLIGHT_METADATA

This to have them more clean and to match more the interface.
…AM_TIMES

This is added to translate the "C" structure INPUTSTREAM_TIMES to C++
class InputstreamTimes.

This added to make access easier and more secure against leaks.
This separate the Kodi TimingConstants.h to use a own on addons
where his text begin with "STREAM_..." now and them with "DVD_..." stays
on Kodi itself.

There are few Pro's and Contra's about but for wanted API better to have.

+++: It stays in pure "C" for them and as base for other languages and the "C++" also on new header
+++: For the time where the headers comes into a own dev-kit and no more in Kodi source
+++: No file outside of the addon header placed in Kodi
---: On changed by them in Kodi must be them on addon headers also by value changes the header updated.
…ders dir

This add the header to the kodi-dev-kit folder to have them all
together and prepared for a independent dev kit, further to confirm
more the "C" use between Kodi and addon.
Further is his "C" code on "kodi/c-api/addon-instance/inputstream/stream_codec.h"
now. This to have them more clean as it only relate to inputstream and codec
addon instances and not to other addon types.
There is the "C" part about moved to "kodi/c-api/addon-instance/inputstream/stream_crypto.h"
and parts renamed to have more clean. Further is the C++ helper class
"kodi::addon::StreamCryptoSession" added to use C++ on addons about.
…ts to addon dev-kit

There becomes the parts where was previous on Kodi's videoplayer moved to
the addon dev kit and much cleaned to confirm the "C" ABI style.

This change is not nice but needed for this:
- The dev-kit should be soon independent of Kodi (trademark, other languages, smaller)
- Before was there some C++ parts inside where breaks a safe ABI use between addon and Kodi
- Have the header places for addons better sorted and more clean in view
Before was for streams always Kodi's C++ based structure
used where not match a "C" ABI for the addons.
This are no more used now by addons itself and only be used on
videoplayer itself.
This to cleanup and to confirm "C" safe ABI and base for other languages.
Also is on the C++ header a clang cleanup done.
Class to handle the "C" structure VIDEOCODEC_INITDATA in C++.
This makes the documentation about inputstream and videocodec to style
needed for binary addons and to show correct on Website.

There still some parts where need improved and a bit more detailed
text, but think to make indpendent then as it not touch API itself.
This increase all changed addon instance versions.
PVR included as it use a the new DEMUX_PACKET structure now.
@AlwinEsch AlwinEsch removed the Don't merge PR that should not be merged (yet) label Oct 28, 2020
@AlwinEsch AlwinEsch merged commit 56aa1f9 into xbmc:master Oct 29, 2020
@AlwinEsch AlwinEsch deleted the rework-inputstream branch October 29, 2020 12:01
@@ -0,0 +1,18 @@
--- a/xbmc/addons/kodi-dev-kit/include/kodi/c-api/addon-instance/inputstream/stream_constants.h
Copy link
Member

Choose a reason for hiding this comment

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

What's this file used for?

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems to come in on rebase, Sorry!

Becomes today kicked out and think to add also on .gitignore a /*.diff below of /*.patch to prevent it on base folder in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change: Binary add-ons API change: PVR Component: Binary add-ons Component: Video rendering Documentation PR Cleanup: Recent Checked as part of PR cleanup. PR has been followed up on recently. Type: Cleanup non-breaking change which removes non-working or unmaintained functionality Type: Improvement non-breaking change which improves existing functionality v19 Matrix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants