ccextractor icon indicating copy to clipboard operation
ccextractor copied to clipboard

[FEAT] Port all the `common_*` files, teletext and networking portions of `libccx` to rust

Open elbertronnie opened this issue 1 year ago • 5 comments

In raising this pull request, I confirm the following (please check boxes):

  • [x] I have read and understood the contributors guide.
  • [x] I have checked that another pull request for this purpose does not exist.
  • [x] I have considered, and confirmed that this submission will be valuable to others.
  • [x] I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • [x] I give this submission freely, and claim no ownership to its content.
  • [ ] I have mentioned this change in the changelog.

My familiarity with the project is as follows (check one):

  • [ ] I have never used CCExtractor.
  • [ ] I have used CCExtractor just a couple of times.
  • [ ] I absolutely love CCExtractor, but have not contributed previously.
  • [x] I am an active contributor to CCExtractor.

This PR aims to port most of the functions in files common_* , teletext.h, telxcc.c, networking.c and certain parts of utility.c (such as logging) to rust. Certain parts of the codebase is left blank if they are dependant on some code which this PR has not aimed to convert. Such parts will have to be revisited once their dependencies are also converted to rust.

I have placed the new rust code inside a new crate named as lib_ccxr, which is a normal rust library crate. This was because a static library crate does not allow doctests. This would also help in seperating ffi code to idiomatic Rust code. Since the Rust approach and C approach to solve a problem are very different, there are 3 layers of indirection I have used for porting:

1. The C-FFI layer

This layers will have function names same as defined in C but with the prefix of ccxr_. These functions will handle the conversion between C-native types and Rust-native types and then pass it on to the C-like Rust layer. These are the functions defined in the ccx_rust crate under libccxr_exports module.

2. The C-like Rust layer

This layer will have function names same as defined in C but work with Rust-native types. The code written using these functions would still be procedural but in Rust, hence the name C-like Rust. The entire task of these functions will be to translate the procedural code to idiomatic Rust code. These are the functions defined in the c_functions.rs file in appropriate modules inside the lib_ccxr crate.

3. The Idiomatic Rust layer

This layer will be the code written as one is supposed to write in idiomatic Rust. It will have complete documentation and tests. This code will will be situated in the lib_ccxr crate.

elbertronnie avatar Mar 12 '23 08:03 elbertronnie

@PunitLodha Can you review this PR? I have split the PR into multiple meaningful commits, so that atleast each individual commit is easy to review.

elbertronnie avatar Aug 26 '23 10:08 elbertronnie

@PunitLodha Can you review this PR? I have split the PR into multiple meaningful commits, so that atleast each individual commit is easy to review.

Could you make each commit a separate PR? If you can't, that means each change is not correctly isolated from the rest.

We need each commit to be self-contained (at least don't break anything) and be reversible by itself - we don't want to merge a huge PR with lots of commits that must exist together.

(we're still paying for playing fast-and-loose in the past)

cfsmp3 avatar Aug 26 '23 19:08 cfsmp3

CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results:

Report Name Tests Passed
Broken 13/13
CEA-708 2/14
DVB 2/7
DVD 3/3
DVR-MS 2/2
General 22/27
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 81/87
Teletext 7/21
WTV 13/13
XDS 31/34

It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Your PR breaks these cases:


Check the result page for more info.

ccextractor-bot avatar Aug 26 '23 21:08 ccextractor-bot

CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results:

Report Name Tests Passed
Broken 13/13
CEA-708 2/14
DVB 4/7
DVD 3/3
DVR-MS 2/2
General 24/27
Hauppage 3/3
MP4 2/3
NoCC 10/10
Options 79/87
Teletext 21/21
WTV 1/13
XDS 26/34

It seems that not all tests were passed completely. This is an indication that the output of some files is not as expected (but might be according to you).

Your PR breaks these cases:


Check the result page for more info.

ccextractor-bot avatar Aug 27 '23 09:08 ccextractor-bot

@PunitLodha @cfsmp3 I have tried to split this into multiple PRs: #1551, #1552, #1553, #1554, #1555, #1556, #1557, #1558, #1559, #1560.

elbertronnie avatar Aug 27 '23 20:08 elbertronnie