Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mediastreamer2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BC
public
mediastreamer2
Commits
e41cfff7
Commit
e41cfff7
authored
Apr 18, 2016
by
François Grisez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add two fields to SoundDeviceAudioHacks structure to set general and equalizer gains of the speaker
parent
2a54c9f8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
15 deletions
+56
-15
devices.h
include/mediastreamer2/devices.h
+3
-1
mediastream.h
include/mediastreamer2/mediastream.h
+9
-2
devices.c
src/audiofilters/devices.c
+2
-2
audiostream.c
src/voip/audiostream.c
+42
-10
No files found.
include/mediastreamer2/devices.h
View file @
e41cfff7
...
...
@@ -34,8 +34,10 @@
#define DEVICE_HAS_CRAPPY_OPENGL (1<<7)
/*set when the opengl is crappy and our opengl surfaceview will crash */
struct
SoundDeviceAudioHacks
{
const
char
*
equalizer
;
const
char
*
mic_
equalizer
;
float
mic_gain
;
const
char
*
spk_equalizer
;
float
spk_gain
;
};
typedef
struct
SoundDeviceAudioHacks
SoundDeviceAudioHacks
;
...
...
include/mediastreamer2/mediastream.h
View file @
e41cfff7
...
...
@@ -613,7 +613,7 @@ static MS2_INLINE void audio_stream_enable_adaptive_jittcomp(AudioStream *stream
* use audio_stream_set_sound_card_input_gain() instead.
*
* @param stream The stream.
* @param gain Gain to apply in dB.
* @param gain
_db
Gain to apply in dB.
*/
MS2_PUBLIC
void
audio_stream_set_mic_gain_db
(
AudioStream
*
stream
,
float
gain_db
);
...
...
@@ -629,9 +629,16 @@ MS2_PUBLIC void audio_stream_set_mic_gain(AudioStream *stream, float gain);
/**
* enable/disable rtp stream
*
*
/
*/
MS2_PUBLIC
void
audio_stream_mute_rtp
(
AudioStream
*
stream
,
bool_t
val
);
/**
* Apply a gain on received RTP packets.
* @param stream An AudioStream.
* @param gain_db Gain to apply in dB.
*/
MS2_PUBLIC
void
audio_stream_set_spk_gain_db
(
AudioStream
*
stream
,
float
gain_db
);
/**
* Set microphone volume gain.
* If the sound backend supports it, the set volume gain will be synchronized
...
...
src/audiofilters/devices.c
View file @
e41cfff7
...
...
@@ -34,7 +34,7 @@
* 1st column: list of triplet frequency, gain, width
* 2nd column: mic gain in db
*/
static
SoundDeviceAudioHacks
SonySGP511Hacks
=
{
"50:0.01:100 600:0.2:100 1350:0.2:100 2000:0.2:100"
,
-
4
};
static
SoundDeviceAudioHacks
SonySGP511Hacks
=
{
"50:0.01:100 600:0.2:100 1350:0.2:100 2000:0.2:100"
,
-
4
,
NULL
,
0
};
/*
* 1st column: value of ro.product.manufacturer
...
...
@@ -410,4 +410,4 @@ SoundDeviceDescription* ms_devices_info_get_sound_device_description(MSDevicesIn
ms_message
(
"Sound device information for [%s/%s/%s] is: builtin=[%s], delay=[%i] ms"
,
manufacturer
,
model
,
platform
,
(
d
->
flags
&
DEVICE_HAS_BUILTIN_AEC
)
?
"yes"
:
"no"
,
d
->
delay
);
return
d
;
}
\ No newline at end of file
}
src/voip/audiostream.c
View file @
e41cfff7
...
...
@@ -1047,20 +1047,36 @@ int audio_stream_start_from_io(AudioStream *stream, RtpProfile *profile, const c
#ifdef ANDROID
/*configure equalizer if needed*/
audio_stream_set_mic_gain_db
(
stream
,
0
);
if
(
stream
->
mic_equalizer
)
{
SoundDeviceDescription
*
device
=
sound_device_description_get
();
if
(
device
&&
device
->
hacks
)
{
const
char
*
gains
=
device
->
hacks
->
equalizer
;
if
(
gains
)
{
MSList
*
gains_list
=
ms_parse_equalizer_string
(
gains
);
audio_stream_set_spk_gain_db
(
stream
,
0
);
SoundDeviceDescription
*
device
=
sound_device_description_get
();
if
(
device
&&
device
->
hacks
)
{
const
char
*
gains
;
gains
=
device
->
hacks
->
mic_equalizer
;
if
(
gains
)
{
MSList
*
gains_list
=
ms_parse_equalizer_string
(
gains
);
if
(
gains_list
)
{
MSList
*
it
;
ms_message
(
"Found equalizer configuration for the microphone in the devices table"
);
for
(
it
=
gains_list
;
it
;
it
++
)
{
MSEqualizerGain
*
g
=
(
MSEqualizerGain
*
)
it
->
data
;
ms_message
(
"Read equalizer gains: %f(~%f) --> %f"
,
g
->
frequency
,
g
->
width
,
g
->
gain
);
ms_filter_call_method
(
stream
->
mic_equalizer
,
MS_EQUALIZER_SET_GAIN
,
g
);
}
ms_list_free_with_data
(
gains_list
,
ms_free
);
}
}
gains
=
device
->
hacks
->
spk_equalizer
;
if
(
gains
)
{
MSList
*
gains_list
=
ms_parse_equalizer_string
(
gains
);
if
(
gains_list
)
{
MSList
*
it
;
ms_message
(
"Found equalizer configuration in the devices table"
);
for
(
it
=
gains_list
;
it
;
it
++
)
{
ms_message
(
"Found equalizer configuration
for the speakers
in the devices table"
);
for
(
it
=
gains_list
;
it
;
it
++
)
{
MSEqualizerGain
*
g
=
(
MSEqualizerGain
*
)
it
->
data
;
ms_message
(
"Read equalizer gains: %f(~%f) --> %f"
,
g
->
frequency
,
g
->
width
,
g
->
gain
);
ms_filter_call_method
(
stream
->
mic_equalizer
,
MS_EQUALIZER_SET_GAIN
,
g
);
}
if
(
gains_list
)
ms_list_free_with_data
(
gains_list
,
ms_free
);
ms_list_free_with_data
(
gains_list
,
ms_free
);
}
}
}
...
...
@@ -1746,7 +1762,7 @@ static void audio_stream_set_rtp_output_gain_db(AudioStream *stream, float gain_
if
(
stream
->
volsend
){
ms_filter_call_method
(
stream
->
volsend
,
MS_VOLUME_SET_DB_GAIN
,
&
gain
);
}
else
ms_warning
(
"Could not apply gain: gain control wasn't activated. "
}
else
ms_warning
(
"Could not apply gain
on sent RTP packets
: gain control wasn't activated. "
"Use audio_stream_enable_gain_control() before starting the stream."
);
}
...
...
@@ -1760,6 +1776,22 @@ void audio_stream_mute_rtp(AudioStream *stream, bool_t val)
}
}
void
audio_stream_set_spk_gain_db
(
AudioStream
*
stream
,
float
gain_db
)
{
float
gain
=
gain_db
;
#ifdef ANDROID
SoundDeviceDescription
*
device
=
sound_device_description_get
();
if
(
device
&&
device
->
hacks
)
{
gain
+=
device
->
hacks
->
spk_gain
;
ms_message
(
"Applying %f dB to speaker gain based on parameter and audio hack value in device table"
,
gain
);
}
#endif
if
(
stream
->
volrecv
){
ms_filter_call_method
(
stream
->
volsend
,
MS_VOLUME_SET_DB_GAIN
,
&
gain
);
}
else
ms_warning
(
"Could not apply gain on received RTP packet: gain control wasn't activated. "
"Use audio_stream_enable_gain_control() before starting the stream."
);
}
float
audio_stream_get_quality_rating
(
AudioStream
*
stream
){
return
media_stream_get_quality_rating
(
&
stream
->
ms
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment