recording-media-slot handling: three defects when recording a call with explicit media slots (mix-method channels) - with patches
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
- Domain
- audio-video-rtc
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sipwise/rtpengine
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
HTTP/WS worker threads spin forever in `__websocket_write_done()` (`sched_yield` loop) — 100% CPU with `--listen-http`Possibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 15/100
sipwise/rtpengine#2197 · 1 comment ·
Maintainers usually reply within 1 day
-
Kernel NULL pointer dereference in target_put() during target deletionPossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 4/5 3-5 days Newbie friendliness 38/100
sipwise/rtpengine#2190 · 1 comment ·
Maintainers usually reply within 1 day
-
Calls using a third logical interface are silently never written to Redis (breaks keyspace-notification HA)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sipwise/rtpengine#2181 · 4 comments ·
Maintainers usually reply within 1 day
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 45/100
sipwise/rtpengine#2162 · 1 comment ·
Maintainers usually reply within 1 day
All issues in sipwise/rtpengine
Similar issues
-
Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
inverse-inc/packetfence#9549 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
jimsalterjrs/sanoid#1116 · 1 reaction ·
-
Add .gitattributes so share/skel keeps LF on a Windows git checkoutPossibly taken @sadhana-s-codez claimed this 4 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
PerlDancer/Dancer2#1854 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
major/MySQLTuner-perl#1007 ·
Maintainers usually reply within 1 day