Skip to content

Commit 494df3e

Browse files
steel-bucketmrswastik-robotprateekmedia
authored
[FEAT] added demuxer and file_functions module (#1662)
* feat: added demuxer module * Cargo Lock Update * Completed file_functions and demuxer * Completed file_functions and demuxer * written extern functions for demuxer * Removed libc completely, added tests for gxf and ported gxf to C * Hardsubx error fixed * Fixing format issues * clippy errors fixed * fixing format issues * fixing format issues * Windows failing tests * Windows failing tests * demuxer: added demuxer data transfer functions and removed some structs * made Demuxer and File Functions * Minor formatting changes * Minor Rebasing changes * demuxer: format rust and unit test rust checks * C formatting * Windows Failing test * Windows Failing test * Update CHANGES.TXT * Update CHANGES.TXT * Windows Failing Tests * Windows Failing Tests * Problem in Copy to Rust and some typos that copilot review suggested * Minor Formatting Error * Windows Failing Regressions * Windows Failing Regressions * Minor Comment Change * Data transfer module for DemuxerData added and more rustlike syntax to ctorust.rs * Minor Formatting Changes * demuxer: Rebase and a few tweaks to file_functions * demuxer: Minor Formatting Error * [FIX] 134 Codes in XDS and General Tests (#1708) * Made pointers valid in Unit Tests of Decoder * fix: test_do_cb * Copilot Suggestions * Suggestions about Redundancy * Suggestions about Redundancy * [FEAT] Add `bitstream` module in `lib_ccxr` (#1649) * feat: Add bitstream module * run code formatters * Run cargo clippy --fix * Run cargo fmt --all * refactor: remove rust pointer from C struct * feat: Add bitstream module * run code formatters * Run cargo clippy --fix * Run cargo fmt --all * refactor: remove rust pointer from C struct * Added Bitstream to libccxr_exports * Minor Formatting Issue * Bitstream: Removed redundant CType * bitstream: recommended changes for is_byte_aligned * bitstream: recommended changes for long comments * bitstream: comment fix * bitstream: removed redundant comparism comments --------- Co-authored-by: Deepnarayan Sett <depnra1@gmail.com> Co-authored-by: Deepnarayan Sett <71217129+steel-bucket@users.noreply.github.com> * demuxer: minor formatting changes * Demuxer: Changes to mistakes in CHANGES.txt * Demuxer: Removed extra newline in ccextractor.c * Demuxer: Changes to Encoding resolved * Demuxer: Moved CCX_NOPTS to common structs and some changes to Demuxer Data regd. MPEG_CLOCK_FREQ * some refactoring to CCX_NOPTS * Demuxer: Minor Mistake regarding CHANGES.txt * Demuxer: Unit test rust failing because of CCX_NOPTS * Demuxer: changed common_structs to common_types * Demuxer: Removed redundant libraries from Cargo.toml and moved tempfile to dev-dependencies * Demuxer: Removed to_vec function and renamed PSIBuffer/PMTEntry from_ctype functions * Demuxer: Renamed Stream_Type, improved Time complexity of the default() function and removed redundant comments * Demuxer: Removed two repeated code blocks and removed redundant comments * Demuxer: Removed two code blocks * Demuxer: Review Changes * Demuxer: Removed redundant tests * Update src/rust/src/demuxer/demux.rs Co-authored-by: Prateek Sunal <prtksunal@gmail.com> * Demuxer: Errors due to Rebase * Demuxer: Removed get_stream_mode * Demuxer: Errors due to rebasing and removing redundant CType Functions * Demuxer: Failing ES regressions * Demuxer: MythTV failing regression * Demuxer: Removed redundant comments * Demuxer: Unplugged ES for now * Demuxer: Replugged in ES * Demuxer: Formatting error * Demuxer: Windows failing CI * Demuxer: Windows failing CI * Demuxer: Windows failing Regressions * Demuxer: Formatting * Demuxer: Minor Cargo Clippy change * Demuxer: running regressions again * Demuxer: Cargo Lockfile Change * Demuxer: running regressions again * Demuxer: running regressions again --------- Co-authored-by: Swastik Patel <swastikpatel29@gmail.com> Co-authored-by: Prateek Sunal <prtksunal@gmail.com>
1 parent 810e02f commit 494df3e

35 files changed

+7885
-808
lines changed

docs/CHANGES.TXT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Fix: Segmentation faults on XDS files
1212
- Fix: Clippy Errors Based on Rust 1.88
1313
- IMPROVEMENT: Refactor and optimize Dockerfile
14+
- New: Add demuxer and file_functions module in lib_ccxr (#1662)
1415
- Fix: Improved handling of IETF language tags in Matroska files (#1665)
1516
- New: Create unit test for rust code (#1615)
1617
- Breaking: Major argument flags revamp for CCExtractor (#1564 & #1619)

src/lib_ccx/ccx_demuxer.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@
33
#include "lib_ccx.h"
44
#include "utility.h"
55
#include "ffmpeg_intgr.h"
6+
#ifndef DISABLE_RUST
7+
void ccxr_demuxer_reset(struct ccx_demuxer *ctx);
8+
void ccxr_demuxer_close(struct ccx_demuxer *ctx);
9+
int ccxr_demuxer_isopen(const struct ccx_demuxer *ctx);
10+
int ccxr_demuxer_open(struct ccx_demuxer *ctx, const char *file);
11+
LLONG ccxr_demuxer_get_file_size(struct ccx_demuxer *ctx);
12+
void ccxr_demuxer_print_cfg(const struct ccx_demuxer *ctx);
13+
#endif
614

715
static void ccx_demuxer_reset(struct ccx_demuxer *ctx)
816
{
17+
#ifndef DISABLE_RUST
18+
ccxr_demuxer_reset(ctx);
19+
#else
920
ctx->startbytes_pos = 0;
1021
ctx->startbytes_avail = 0;
1122
ctx->num_of_PIDs = 0;
@@ -17,25 +28,38 @@ static void ccx_demuxer_reset(struct ccx_demuxer *ctx)
1728
}
1829
memset(ctx->stream_id_of_each_pid, 0, (MAX_PSI_PID + 1) * sizeof(uint8_t));
1930
memset(ctx->PIDs_programs, 0, 65536 * sizeof(struct PMT_entry *));
31+
#endif
2032
}
2133

2234
static void ccx_demuxer_close(struct ccx_demuxer *ctx)
2335
{
36+
#ifndef DISABLE_RUST
37+
ccxr_demuxer_close(ctx);
38+
#else
2439
ctx->past = 0;
2540
if (ctx->infd != -1 && ccx_options.input_source == CCX_DS_FILE)
2641
{
2742
close(ctx->infd);
2843
ctx->infd = -1;
2944
activity_input_file_closed();
3045
}
46+
#endif
3147
}
3248

3349
static int ccx_demuxer_isopen(struct ccx_demuxer *ctx)
3450
{
51+
#ifndef DISABLE_RUST
52+
return ccxr_demuxer_isopen(ctx);
53+
#else
3554
return ctx->infd != -1;
55+
#endif
3656
}
57+
3758
static int ccx_demuxer_open(struct ccx_demuxer *ctx, const char *file)
3859
{
60+
#ifndef DISABLE_RUST
61+
return ccxr_demuxer_open(ctx, file);
62+
#else
3963
ctx->past = 0;
4064
ctx->min_global_timestamp = 0;
4165
ctx->global_timestamp_inited = 0;
@@ -193,9 +217,14 @@ static int ccx_demuxer_open(struct ccx_demuxer *ctx, const char *file)
193217
}
194218

195219
return 0;
220+
#endif
196221
}
222+
197223
LLONG ccx_demuxer_get_file_size(struct ccx_demuxer *ctx)
198224
{
225+
#ifndef DISABLE_RUST
226+
return ccxr_demuxer_get_file_size(ctx);
227+
#else
199228
LLONG ret = 0;
200229
int in = ctx->infd;
201230
LLONG current = LSEEK(in, 0, SEEK_CUR);
@@ -208,6 +237,7 @@ LLONG ccx_demuxer_get_file_size(struct ccx_demuxer *ctx)
208237
return -1;
209238

210239
return length;
240+
#endif
211241
}
212242

213243
static int ccx_demuxer_get_stream_mode(struct ccx_demuxer *ctx)
@@ -217,6 +247,9 @@ static int ccx_demuxer_get_stream_mode(struct ccx_demuxer *ctx)
217247

218248
static void ccx_demuxer_print_cfg(struct ccx_demuxer *ctx)
219249
{
250+
#ifndef DISABLE_RUST
251+
ccxr_demuxer_print_cfg(ctx);
252+
#else
220253
switch (ctx->auto_stream)
221254
{
222255
case CCX_SM_ELEMENTARY_OR_NOT_FOUND:
@@ -261,6 +294,7 @@ static void ccx_demuxer_print_cfg(struct ccx_demuxer *ctx)
261294
fatal(CCX_COMMON_EXIT_BUG_BUG, "BUG: Unknown stream mode. Please file a bug report on Github.\n");
262295
break;
263296
}
297+
#endif
264298
}
265299

266300
void ccx_demuxer_delete(struct ccx_demuxer **ctx)
@@ -407,4 +441,4 @@ struct demuxer_data *alloc_demuxer_data(void)
407441
data->next_stream = 0;
408442
data->next_program = 0;
409443
return data;
410-
}
444+
}

src/lib_ccx/ccx_demuxer_mxf.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414
#define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
1515
#define IS_KLV_KEY_ANY_VERSION(x, y) (!memcmp(x, y, 7) && !memcmp(x + 8, y + 8, sizeof(y) - 8))
1616

17-
enum MXFCaptionType
18-
{
19-
MXF_CT_VBI,
20-
MXF_CT_ANC,
21-
};
22-
23-
typedef uint8_t UID[16];
2417
typedef struct KLVPacket
2518
{
2619
UID key;
@@ -35,29 +28,12 @@ typedef struct MXFCodecUL
3528

3629
typedef int ReadFunc(struct ccx_demuxer *ctx, uint64_t size);
3730

38-
typedef struct
39-
{
40-
int track_id;
41-
uint8_t track_number[4];
42-
} MXFTrack;
43-
4431
typedef struct MXFReadTableEntry
4532
{
4633
const UID key;
4734
ReadFunc *read;
4835
} MXFReadTableEntry;
4936

50-
typedef struct MXFContext
51-
{
52-
enum MXFCaptionType type;
53-
int cap_track_id;
54-
UID cap_essence_key;
55-
MXFTrack tracks[32];
56-
int nb_tracks;
57-
int cap_count;
58-
struct ccx_rational edit_rate;
59-
} MXFContext;
60-
6137
typedef struct MXFLocalTAGS
6238
{
6339
uint16_t tag;

src/lib_ccx/ccx_demuxer_mxf.h

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@
33

44
#include "ccx_demuxer.h"
55

6-
int ccx_probe_mxf(struct ccx_demuxer *ctx);
7-
struct MXFContext *ccx_mxf_init(struct ccx_demuxer *demux);
6+
typedef uint8_t UID[16];
7+
8+
enum MXFCaptionType
9+
{
10+
MXF_CT_VBI,
11+
MXF_CT_ANC,
12+
};
13+
14+
typedef struct
15+
{
16+
int track_id;
17+
uint8_t track_number[4];
18+
} MXFTrack;
19+
20+
typedef struct MXFContext
21+
{
22+
enum MXFCaptionType type;
23+
int cap_track_id;
24+
UID cap_essence_key;
25+
MXFTrack tracks[32];
26+
int nb_tracks;
27+
int cap_count;
28+
struct ccx_rational edit_rate;
29+
} MXFContext;
30+
31+
int ccx_probe_mxf(struct ccx_demuxer* ctx);
32+
struct MXFContext* ccx_mxf_init(struct ccx_demuxer* demux);
833
#endif

0 commit comments

Comments
 (0)