mirror of
https://github.com/TakeV-Lambda/dino.git
synced 2024-11-22 15:04:37 +00:00
Resample audio data for common 48k sample rate
This commit is contained in:
parent
c8a37c0246
commit
b01f6f9ef7
2 changed files with 16 additions and 10 deletions
|
@ -202,7 +202,8 @@ public class Dino.Plugins.Rtp.CodecUtil {
|
|||
string decode = element_name ?? get_decode_element_name(media, codec);
|
||||
if (depay == null || decode == null) return null;
|
||||
string decode_prefix = get_decode_prefix(media, codec, decode) ?? "";
|
||||
return @"$depay name=$base_name-rtp-depay ! $decode_prefix$decode name=$base_name-decode ! $(media)convert name=$base_name-convert";
|
||||
string resample = media == "audio" ? @" ! audioresample name=$base_name-resample" : "";
|
||||
return @"$depay name=$base_name-rtp-depay ! $decode_prefix$decode name=$base_name-decode ! $(media)convert name=$base_name-convert$resample";
|
||||
}
|
||||
|
||||
public Gst.Element? get_decode_bin(string media, JingleRtp.PayloadType payload_type, string? name = null) {
|
||||
|
@ -224,11 +225,8 @@ public class Dino.Plugins.Rtp.CodecUtil {
|
|||
if (pay == null || encode == null) return null;
|
||||
string encode_prefix = get_encode_prefix(media, codec, encode) ?? "";
|
||||
string encode_suffix = get_encode_suffix(media, codec, encode) ?? "";
|
||||
if (media == "audio") {
|
||||
return @"audioconvert name=$base_name-convert ! audioresample name=$base_name-resample ! $encode_prefix$encode$encode_suffix ! $pay pt=$pt name=$base_name-rtp-pay";
|
||||
} else {
|
||||
return @"$(media)convert name=$base_name-convert ! $encode_prefix$encode$encode_suffix ! $pay pt=$pt name=$base_name-rtp-pay";
|
||||
}
|
||||
string resample = media == "audio" ? @" ! audioresample name=$base_name-resample" : "";
|
||||
return @"$(media)convert name=$base_name-convert$resample ! $encode_prefix$encode$encode_suffix ! $pay pt=$pt name=$base_name-rtp-pay";
|
||||
}
|
||||
|
||||
public Gst.Element? get_encode_bin(string media, JingleRtp.PayloadType payload_type, string? name = null) {
|
||||
|
|
|
@ -59,7 +59,7 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object {
|
|||
if (element == null) create();
|
||||
links++;
|
||||
if (mixer != null) return mixer;
|
||||
if (is_sink && media == "audio") return plugin.echoprobe;
|
||||
if (is_sink && media == "audio") return filter;
|
||||
return element;
|
||||
}
|
||||
|
||||
|
@ -146,9 +146,10 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object {
|
|||
element.@set("sync", false);
|
||||
}
|
||||
if (is_sink && media == "audio") {
|
||||
// mixer = Gst.ElementFactory.make("audiomixer", @"$id-mixer");
|
||||
// pipe.add(mixer);
|
||||
// mixer.link(plugin.echoprobe);
|
||||
filter = Gst.ElementFactory.make("capsfilter", @"$id-caps-filter");
|
||||
filter.@set("caps", get_best_caps());
|
||||
pipe.add(filter);
|
||||
filter.link(plugin.echoprobe);
|
||||
plugin.echoprobe.link(element);
|
||||
}
|
||||
plugin.unpause();
|
||||
|
@ -173,6 +174,13 @@ public class Dino.Plugins.Rtp.Device : MediaDevice, Object {
|
|||
pipe.remove(mixer);
|
||||
mixer = null;
|
||||
} else if (is_sink && media == "audio") {
|
||||
if (filter != null) {
|
||||
filter.set_locked_state(true);
|
||||
filter.set_state(Gst.State.NULL);
|
||||
filter.unlink(plugin.echoprobe);
|
||||
pipe.remove(filter);
|
||||
filter = null;
|
||||
}
|
||||
plugin.echoprobe.unlink(element);
|
||||
}
|
||||
element.set_locked_state(true);
|
||||
|
|
Loading…
Reference in a new issue