Ticket #504 (closed defect: fixed)

Opened 10 years ago

Last modified 10 years ago

Fixed support for stereo audio all the way in pjmedia

Reported by: nanang Owned by: nanang
Priority: normal Milestone: release-0.9.0
Component: pjmedia Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description (last modified by bennylp) (diff)

Identified issues:

  1. The PA callbacks implementations contains wrong assertion, because of samples_per_frame misinterpretation (thanks Rodrigo Vega, http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2008-March/001974.html):
    • Soundport's samples_per_frame is total samples number per frame of ALL channels.
    • While PA's frameCount refers to number of samples for EACH channel.
  2. Lack of channel_count multiplication in samples_per_frame calculation in some parts of stream causing silence in stereo audio call.
  3. STEREO_DEMO in pjsua causing crash in PortAudio without call (perhaps because of some pointer to PA buffer get overwritten)
  4. Add channel_count field in pjsua_media_config to configure number of channels for both sound device and conference bridge. Add --stereo option in pjsua to change set this channel_count field to 2.
  5. Create two utility functions to:
    1. convert one mono channel audio frame to N-channel audio frame. Just duplicate the sample to all channels.
    2. convert N-channel audio from to mono audio frame. The function should have an option to either mix sample from all the channels into one channel, or to just take audio samples from one of the channel. To make the implementation simpler, we can just implement these two functions as inline functions in a new header file (e.g., stereo.h) rather than a media port.
  6. Use these channel conversion functions in the conference bridge, to convert audio samples from media ports when the media port has different channel number with the conference bridge.

Attachments

ticket504.patch (1.3 KB) - added by nanang 10 years ago.
Fixed assertion param in PortAudio?'s callback implementation
ticket504.2.patch (528 bytes) - added by nanang 10 years ago.
Fixed calculation of samples_per_frame in stream port
ticket504.3.patch (1.3 KB) - added by nanang 10 years ago.
- fixed calculation of samples_per_frame of conference bridge in pjsua_media - fixed number of samples supplied to store_mono_frame() in splitcomb
ticket504.4.patch (37.9 KB) - added by nanang 10 years ago.
Fix issue number 4 to 6

Change History

Changed 10 years ago by nanang

Fixed assertion param in PortAudio?'s callback implementation

comment:1 Changed 10 years ago by bennylp

Patch ticket504.patch committed in r1848, thanks.

comment:2 Changed 10 years ago by nanang

  • Description modified (diff)
  • Summary changed from Wrong assertion param in portaudio callbacks (thanks Rodrigo Vega) to Problem in multichannel audio

Changed 10 years ago by nanang

Fixed calculation of samples_per_frame in stream port

comment:3 Changed 10 years ago by bennylp

  • Summary changed from Problem in multichannel audio to Fixed support for stereo audio all the way in pjmedia

Committed 'ticket504.2.patch' as is in r1861, thanks.

comment:4 Changed 10 years ago by bennylp

  • Owner changed from nanang to bennylp
  • Status changed from new to assigned
  • Description modified (diff)

comment:5 Changed 10 years ago by bennylp

  • Owner changed from bennylp to nanang
  • Status changed from assigned to new

Changed 10 years ago by nanang

  • fixed calculation of samples_per_frame of conference bridge in pjsua_media - fixed number of samples supplied to store_mono_frame() in splitcomb

comment:6 Changed 10 years ago by bennylp

Ticket ticket504.3.patch committed in r1866, thanks.

Changed 10 years ago by nanang

Fix issue number 4 to 6

comment:7 Changed 10 years ago by bennylp

  • Status changed from new to closed
  • Resolution set to fixed

Committed ticket504.4.patch in r1898 with the following modifications:

  • renamed function names in stereo.h:
    • pjmedia_stereo_convert_from_mono() --> pjmedia_convert_channel_1ton()
    • pjmedia_stereo_convert_to_mono() --> pjmedia_convert_channel_nto1()
  • changed the "options" argument to "mix" (boolean) since the existing enum is not a bitmask, and in nto1(), allow caller to specify which channel to be retrieved if mixing is disabled.
  • changed channel conversion algorithm to avoid multiplication in the loop
  • changed default conversion mode to mixed in conference
  • added stereo_port.c to makefiles, EVC4, and Symbian projects
  • fix channel_count field in pjmedia_conf_port_info
  • display channel count in "cl" command output in pjsua

Also committed in this revision changes to conference.c unrelated to stereo:

  • removed unnecessary vad
  • moved the conditional "if" checking outside the loop in level calculation/adjustment in get_frame() and write_port() functions.

This closes the ticket.

comment:8 Changed 10 years ago by bennylp

In r1901:

  • added missing new files!!
Note: See TracTickets for help on using tickets.