Commit e8ca093c authored by Stefan Doehla's avatar Stefan Doehla
Browse files

[add] rtpdump_concat tool

parent 5169f5ae
Loading
Loading
Loading
Loading
Loading

scripts/rtp/Makefile

0 → 100644
+22 −0
Original line number Diff line number Diff line
# Makefile for RTP utilities (rtpdump_concat)

CC ?= gcc
CFLAGS ?= -Wall -Wextra -O2 -I../../lib_util -I../../lib_com
LDFLAGS ?=

# Source files
RTPDUMP_SRC = ../../lib_util/rtpdump.c
CONCAT_SRC = rtpdump_concat.c

# Output binary
TARGET ?= rtpdump_concat

all: $(TARGET)

$(TARGET): $(CONCAT_SRC) $(RTPDUMP_SRC)
	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)

clean:
	rm -f $(TARGET) *.o

.PHONY: all clean

scripts/rtp/README.md

0 → 100644
+107 −0
Original line number Diff line number Diff line
# RTP Utilities

## rtpdump_concat

Concatenates multiple RTPDUMP files with continuous sequence numbers and timestamps.

### Building

```bash
cd scripts/rtp
make
```

### Usage

```bash
./rtpdump_concat -o <outputfile> [options] <inputfile1> <inputfile2> [...]
```

### Options

**Required:**
- `-o <outputfile>` - Output RTPDUMP file

**RTP Header Overrides:**
- `-s <ssrc>` - Override SSRC (synchronization source identifier)
- `-p <pt>` - Override payload type (0-127)
- `-i <seq>` - Initial sequence number (default: from first packet)

**RTPDUMP Header:**
- `-a <address>` - Source IP address (default: from first file or 127.0.0.1)
- `-P <port>` - Source port (default: from first file or 5000)

**Timing:**
- `-t <interval_ms>` - Timestamp interval in milliseconds (default: auto-detect from packets, fallback 20ms)

**Limiting:**
- `-n <count>` - Maximum number of packets to read from each input file

**Other:**
- `-v` - Verbose output
- `-h, --help` - Show help message

### Examples

Basic concatenation:
```bash
./rtpdump_concat -o combined.rtp part1.rtp part2.rtp part3.rtp
```

Override RTP header fields for consistency:
```bash
./rtpdump_concat -o out.rtp -s 0xAABBCCDD -p 96 -i 1000 in1.rtp in2.rtp
```

Force 20ms frame spacing:
```bash
./rtpdump_concat -o out.rtp -t 20 in1.rtp in2.rtp in3.rtp
```

Set source IP address and port:
```bash
./rtpdump_concat -o out.rtp -a 192.168.1.100 -P 5004 in1.rtp in2.rtp
```

### Description

This tool reads multiple RTPDUMP files and concatenates them into a single output file. It ensures:

1. **Continuous sequence numbers**: The RTP sequence numbers are adjusted so they increment continuously across file boundaries
2. **Continuous timestamps**: The RTP timestamps are adjusted to maintain continuity
3. **Continuous time offsets**: The packet time offsets (in the RTPDUMP format) are adjusted for seamless concatenation

### RTP and RTPDUMP Header Overrides

When concatenating files from separate encoding sessions, each file may have different header values. The override options allow you to normalize these fields:

**RTP Packet Headers:**
- **SSRC override** (`-s`): Ensures all packets have the same synchronization source identifier, making the output appear as a single RTP stream
- **Payload type override** (`-p`): Normalizes the payload type field across all packets
- **Initial sequence number** (`-i`): Sets a specific starting sequence number instead of using the first packet's value
- **Timestamp interval** (`-t`): Forces a specific frame duration when the auto-detection might not work correctly

**RTPDUMP File Header:**
- **Source address** (`-a`): Sets the source IP address in the RTPDUMP file header (default: copied from first input file, or 127.0.0.1)
- **Source port** (`-P`): Sets the source port in the RTPDUMP file header (default: copied from first input file, or 5000)

The IP address MUST be IPv4 and can be specified in dotted notation (e.g., `192.168.1.100`) or hex format (e.g., `0xC0A80164`).

These options are primarily intended for testing format switching behavior by concatenating separately-encoded files with different IVAS formats while maintaining consistent RTP headers (similar to the previous separate encoder main program in `encoder_fmtsw.c`).

### Implementation Details

- Uses the RTPDUMP library from lib_util/rtpdump.c
- Supports up to 100 input files
- Assumes 20ms frame duration at 16kHz RTP clock rate for timestamp calculation

### Building the binaries on macOS

**macOS universal:**
`make CFLAGS="-Wall -Wextra -O2 -I../../lib_util -I../../lib_com -arch x86_64 -arch arm64"`

**Linux x86_64 static:**
`docker run --rm --platform linux/amd64 -v $(pwd)/../..:/src -w /src/scripts/rtp gcc:latest make clean all LDFLAGS="-static"`

**Windows 64-bit:**
`docker run --rm --platform linux/amd64 -v $(pwd)/../..:/src -w /src/scripts/rtp gcc:latest bash -c "apt-get update -qq && apt-get install -y -qq gcc-mingw-w64-x86-64 && x86_64-w64-mingw32-gcc --version && make clean all CC=x86_64-w64-mingw32-gcc LDFLAGS='-static'"`
+538 −0

File added.

Preview size limit exceeded, changes collapsed.

+66.2 KiB

File added.

No diff preview for this file type.

+1.06 MiB

File added.

No diff preview for this file type.

Loading