Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
mediastreamer2
Commits
a8538b58
Commit
a8538b58
authored
Feb 20, 2013
by
Simon Morlat
Browse files
first increment ptime, then decrease quality
parent
674c20e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
25 deletions
+26
-25
src/voip/bitratedriver.c
src/voip/bitratedriver.c
+26
-25
No files found.
src/voip/bitratedriver.c
View file @
a8538b58
...
...
@@ -88,32 +88,33 @@ static int audio_bitrate_driver_execute_action(MSBitrateDriver *objbase, const M
if
(
action
->
type
==
MSRateControlActionDecreaseBitrate
){
/*reducing bitrate of the codec isn't sufficient. Increasing ptime is much more efficient*/
inc_ptime
(
obj
);
if
(
obj
->
nom_bitrate
>
0
){
int
cur_br
=
0
;
int
new_br
;
if
(
ms_filter_call_method
(
obj
->
encoder
,
MS_FILTER_GET_BITRATE
,
&
obj
->
cur_bitrate
)
!=
0
){
ms_message
(
"MSAudioBitrateDriver: Encoder has current bitrate %i"
,
obj
->
cur_bitrate
);
}
/*if max ptime is reached, then try to reduce the codec bitrate if possible */
if
(
ms_filter_call_method
(
obj
->
encoder
,
MS_FILTER_GET_BITRATE
,
&
cur_br
)
!=
0
){
ms_message
(
"MSAudioBitrateDriver: GET_BITRATE failed"
);
return
0
;
}
new_br
=
cur_br
-
((
cur_br
*
action
->
value
)
/
100
);
ms_message
(
"MSAudioBitrateDriver: Attempting to reduce audio bitrate to %i"
,
new_br
);
if
(
ms_filter_call_method
(
obj
->
encoder
,
MS_FILTER_SET_BITRATE
,
&
new_br
)
!=
0
){
ms_message
(
"MSAudioBitrateDriver: SET_BITRATE failed, incrementing ptime"
);
inc_ptime
(
obj
);
return
0
;
if
(
inc_ptime
(
obj
)
==-
1
){
if
(
obj
->
nom_bitrate
>
0
){
int
cur_br
=
0
;
int
new_br
;
if
(
ms_filter_call_method
(
obj
->
encoder
,
MS_FILTER_GET_BITRATE
,
&
obj
->
cur_bitrate
)
!=
0
){
ms_message
(
"MSAudioBitrateDriver: Encoder has current bitrate %i"
,
obj
->
cur_bitrate
);
}
/*if max ptime is reached, then try to reduce the codec bitrate if possible */
if
(
ms_filter_call_method
(
obj
->
encoder
,
MS_FILTER_GET_BITRATE
,
&
cur_br
)
!=
0
){
ms_message
(
"MSAudioBitrateDriver: GET_BITRATE failed"
);
return
0
;
}
new_br
=
cur_br
-
((
cur_br
*
action
->
value
)
/
100
);
ms_message
(
"MSAudioBitrateDriver: Attempting to reduce audio bitrate to %i"
,
new_br
);
if
(
ms_filter_call_method
(
obj
->
encoder
,
MS_FILTER_SET_BITRATE
,
&
new_br
)
!=
0
){
ms_message
(
"MSAudioBitrateDriver: SET_BITRATE failed, incrementing ptime"
);
inc_ptime
(
obj
);
return
0
;
}
new_br
=
0
;
ms_filter_call_method
(
obj
->
encoder
,
MS_FILTER_GET_BITRATE
,
&
new_br
);
ms_message
(
"MSAudioBitrateDriver: bitrate actually set to %i"
,
new_br
);
obj
->
cur_bitrate
=
new_br
;
}
new_br
=
0
;
ms_filter_call_method
(
obj
->
encoder
,
MS_FILTER_GET_BITRATE
,
&
new_br
);
ms_message
(
"MSAudioBitrateDriver: bitrate actually set to %i"
,
new_br
);
obj
->
cur_bitrate
=
new_br
;
}
}
else
if
(
action
->
type
==
MSRateControlActionDecreasePacketRate
){
inc_ptime
(
obj
);
...
...
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