Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

recording-media-slot handling: three defects when recording a call with explicit media slots (mix-method channels) - with patches

Closed
#2,208 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c

Research direction

The three defects sit in daemon/call.c (media_rec_slot assignment for OP_OFFER), daemon/recording.c (the metafile slot logic) and recording-daemon/mix.c (in_pts for a re-used mix input). Start by checking the proposed diffs against those spots and confirm the sender and receiver slots are swapped in call.c. Done means that with mix-method=channels, the caller lands on channel 1, the callee on channel 2, and a mid-call SSRC change adds no delay, verified with test tones as the reporter did.

Written by the indexing model from the issue text.

Description

Version: mr26.2.1.2 (same code on master)

Setup

Call recorded with output-mixed, mix-method=channels, mix-num-inputs=2, OpenSIPS passing recording-media-slot-offer=1 recording-media-slot-answer=2 recording-media-slots=2, plus a subscribe request (SIPREC copy) on the same call. Expected: caller on channel 1, callee on channel 2, in the right time position.

Observed and fixed (patches below, all verified with 440/880 Hz test tones, 5/5 calls each; the unpatched code fails all three):

1. daemon/call.c: both sides get the answer slot

 		if (flags->opmode == OP_OFFER) {
 			ilog(LOG_DEBUG, "Setting media recording slots to %u", flags->media_rec_slot_offer);
-			sender_media->media_rec_slot = receiver_media->media_rec_slot = flags->media_rec_slot_answer;
+			sender_media->media_rec_slot = flags->media_rec_slot_offer;
+			receiver_media->media_rec_slot = flags->media_rec_slot_answer;
 		}

Result without the fix: both parties are mixed into the same channel.

2. daemon/recording.c: a media without a slot (the subscription/SIPREC copy) resets the global slot count to 1 in the metafile

-	if(call->media_rec_slots < 1 || media->media_rec_slot < 1) {
+	if(call->media_rec_slots < 1) {
 		media_rec_slot = 1;
 		media_rec_slots = 1;
 	} else {
-		media_rec_slot = media->media_rec_slot;
+		media_rec_slot = media->media_rec_slot < 1 ? 1 : media->media_rec_slot;
 		media_rec_slots = call->media_rec_slots;
 	}

Result without the fix: as soon as a subscriber media (no slot) is written to the metafile, the recording daemon reads MEDIA_REC_SLOTS=1 and the mixer falls back to one channel.

3. recording-daemon/mix.c: a re-used mix input starts at pts 0, so audio after an SSRC change is shifted

 	ilog(LOG_DEBUG, "requested slot is %u, Re-using mix input index #%u", stream_channel_slot, next);
 	mix_input_reset(mix, next);
+	/* the recycled input already contributed up to the current output position:
+	 * continue from there instead of padding silence from 0, which delays all later audio */
+	mix->in_pts[next] = mix->out_pts;
 	mix->input_ref[next] = ptr;
 	mix->next_idx[stream_channel_slot] = next;

Result without the fix: when the caller changes SSRC mid-call (re-INVITE / media server switch), the audio after the switch is delayed in the mixed output by the time already elapsed.

Happy to open these as a PR if you prefer.

Dominant language
Perl
Stars
992
Forks
459
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sipwise/rtpengine

All issues in sipwise/rtpengine

Similar issues

More Perl issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.