Port to AWS SDK 0.57/0.35

Co-authored-by: Sebastian Dröge <sebastian@centricular.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1379>
This commit is contained in:
Mathieu Duponchelle 2023-11-03 10:31:10 +02:00 committed by GStreamer Marge Bot
parent f7745a336f
commit 5371eb52ad
5 changed files with 76 additions and 94 deletions

View file

@ -13,15 +13,14 @@ rust-version = "1.70"
[dependencies] [dependencies]
async-stream = "0.3.4" async-stream = "0.3.4"
base32 = "0.4" base32 = "0.4"
aws-config = "0.56.0" aws-config = "0.57.0"
aws-sdk-s3 = "0.34.0" aws-sdk-s3 = "0.35.0"
aws-sdk-transcribestreaming = "0.34.0" aws-sdk-transcribestreaming = "0.35.0"
aws-sdk-translate = "0.34.0" aws-sdk-translate = "0.35.0"
aws-types = "0.56.0" aws-types = "0.57.0"
aws-credential-types = "0.56.0" aws-credential-types = "0.57.0"
aws-sig-auth = "0.56.0" aws-smithy-http = { version = "0.57.0", features = [ "rt-tokio" ] }
aws-smithy-http = { version = "0.56.0", features = [ "rt-tokio" ] } aws-smithy-types = "0.57.0"
aws-smithy-types = "0.56.0"
bytes = "1.0" bytes = "1.0"
futures = "0.3" futures = "0.3"
gio = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gio" } gio = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gio" }

View file

@ -10,10 +10,9 @@ use aws_config::meta::region::RegionProviderChain;
use aws_sdk_s3::config::{timeout::TimeoutConfig, Credentials, Region}; use aws_sdk_s3::config::{timeout::TimeoutConfig, Credentials, Region};
use aws_types::sdk_config::SdkConfig; use aws_types::sdk_config::SdkConfig;
use aws_smithy_http::byte_stream::{error::Error, ByteStream}; use aws_smithy_types::byte_stream::{error::Error, ByteStream};
use bytes::{buf::BufMut, Bytes, BytesMut}; use bytes::{buf::BufMut, Bytes, BytesMut};
use futures::stream::TryStreamExt;
use futures::{future, Future}; use futures::{future, Future};
use gst::glib::once_cell::sync::Lazy; use gst::glib::once_cell::sync::Lazy;
use std::sync::Mutex; use std::sync::Mutex;

View file

@ -85,12 +85,8 @@ impl TranslateLoop {
let found_output_lang = language_list let found_output_lang = language_list
.languages() .languages()
.and_then(|langs| {
langs
.iter() .iter()
.find(|lang| lang.language_code() == Some(&self.output_lang)) .any(|lang| lang.language_code() == self.output_lang);
})
.is_some();
if !found_output_lang { if !found_output_lang {
let err = format!("Unknown output languages: {}", self.output_lang); let err = format!("Unknown output languages: {}", self.output_lang);
@ -151,8 +147,7 @@ impl TranslateLoop {
gst::info!(CAT, imp: self.pad, "{err}"); gst::info!(CAT, imp: self.pad, "{err}");
gst::error_msg!(gst::LibraryError::Failed, ["{err}"]) gst::error_msg!(gst::LibraryError::Failed, ["{err}"])
})? })?
.translated_text .translated_text;
.unwrap_or_default();
gst::debug!(CAT, imp: self.pad, "Got translation {translated_text}"); gst::debug!(CAT, imp: self.pad, "Got translation {translated_text}");

View file

@ -33,14 +33,14 @@ gst_plugin_webrtc_protocol = { path="protocol", package = "gst-plugin-webrtc-sig
human_bytes = "0.4" human_bytes = "0.4"
url = "2" url = "2"
aws-config = "0.56.0" aws-config = "0.57.0"
aws-types = "0.56.0" aws-types = "0.57.0"
aws-credential-types = "0.56.0" aws-credential-types = "0.57.0"
aws-sig-auth = "0.56.0" aws-sigv4 = "0.57.0"
aws-smithy-http = { version = "0.56.0", features = [ "rt-tokio" ] } aws-smithy-http = { version = "0.57.0", features = [ "rt-tokio" ] }
aws-smithy-types = "0.56.0" aws-smithy-types = "0.57.0"
aws-sdk-kinesisvideo = "0.34.0" aws-sdk-kinesisvideo = "0.35.0"
aws-sdk-kinesisvideosignaling = "0.34.0" aws-sdk-kinesisvideosignaling = "0.35.0"
http = "0.2.7" http = "0.2.7"
chrono = "0.4" chrono = "0.4"
data-encoding = "2.3.3" data-encoding = "2.3.3"

View file

@ -22,10 +22,10 @@ use aws_sdk_kinesisvideo::{
Client, Client,
}; };
use aws_sdk_kinesisvideosignaling::Client as SignalingClient; use aws_sdk_kinesisvideosignaling::Client as SignalingClient;
use aws_sig_auth::signer::{self, HttpSignatureType, OperationSigningConfig, RequestConfig}; use aws_sigv4::http_request::{
use aws_smithy_http::body::SdkBody; sign, SignableBody, SignableRequest, SignatureLocation, SigningSettings,
use aws_types::{region::SigningRegion, SigningService}; };
use chrono::prelude::*; use aws_sigv4::sign::v4;
use data_encoding::BASE64; use data_encoding::BASE64;
use http::Uri; use http::Uri;
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
@ -269,12 +269,7 @@ impl Signaller {
gst::debug!(CAT, "Endpoints: {:?}", resp.resource_endpoint_list()); gst::debug!(CAT, "Endpoints: {:?}", resp.resource_endpoint_list());
let endpoint_wss_uri = let endpoint_wss_uri = match resp.resource_endpoint_list().iter().find_map(|endpoint| {
match resp
.resource_endpoint_list()
.unwrap()
.iter()
.find_map(|endpoint| {
if endpoint.protocol == Some(ChannelProtocol::Wss) { if endpoint.protocol == Some(ChannelProtocol::Wss) {
Some(endpoint.resource_endpoint().unwrap().to_owned()) Some(endpoint.resource_endpoint().unwrap().to_owned())
} else { } else {
@ -287,12 +282,7 @@ impl Signaller {
} }
}; };
let endpoint_https_uri = let endpoint_https_uri = match resp.resource_endpoint_list().iter().find_map(|endpoint| {
match resp
.resource_endpoint_list()
.unwrap()
.iter()
.find_map(|endpoint| {
if endpoint.protocol == Some(ChannelProtocol::Https) { if endpoint.protocol == Some(ChannelProtocol::Https) {
Some(endpoint.resource_endpoint().unwrap().to_owned()) Some(endpoint.resource_endpoint().unwrap().to_owned())
} else { } else {
@ -331,7 +321,6 @@ impl Signaller {
let ice_servers: Vec<String> = resp let ice_servers: Vec<String> = resp
.ice_server_list() .ice_server_list()
.unwrap()
.iter() .iter()
.filter_map(|server| { .filter_map(|server| {
Option::zip(server.username(), server.password()) Option::zip(server.username(), server.password())
@ -340,7 +329,6 @@ impl Signaller {
.flat_map(|(username, password, server)| { .flat_map(|(username, password, server)| {
server server
.uris() .uris()
.unwrap()
.iter() .iter()
.filter_map(move |uri| { .filter_map(move |uri| {
uri.split_once(':').map(|(protocol, host)| { uri.split_once(':').map(|(protocol, host)| {
@ -373,20 +361,20 @@ impl Signaller {
}), }),
); );
let current_time = Utc::now(); let mut signing_settings = SigningSettings::default();
signing_settings.signature_location = SignatureLocation::QueryParams;
let signer = signer::SigV4Signer::new(); signing_settings.expires_in = Some(Duration::from_secs(5 * 60));
let mut operation_config = OperationSigningConfig::default_config(); let identity = credentials.clone().into();
operation_config.signature_type = HttpSignatureType::HttpRequestQueryParams; let region_string = region.to_string();
operation_config.expires_in = Some(Duration::from_secs(5 * 60)); // See commit a3db85d. let signing_params = v4::SigningParams::builder()
.identity(&identity)
let request_config = RequestConfig { .region(&region_string)
request_ts: SystemTime::from(current_time), .name("kinesisvideo")
region: &SigningRegion::from(region), .time(SystemTime::now())
service: &SigningService::from_static("kinesisvideo"), .settings(signing_settings)
payload_override: None, .build()
}; .unwrap()
.into();
let transcribe_uri = Uri::builder() let transcribe_uri = Uri::builder()
.scheme("wss") .scheme("wss")
.authority(endpoint_wss_uri.authority().unwrap().to_owned()) .authority(endpoint_wss_uri.authority().unwrap().to_owned())
@ -399,22 +387,23 @@ impl Signaller {
gst::error!(CAT, imp: self, "Failed to build HTTP request URI: {err}"); gst::error!(CAT, imp: self, "Failed to build HTTP request URI: {err}");
anyhow!("Failed to build HTTP request URI: {err}") anyhow!("Failed to build HTTP request URI: {err}")
})?; })?;
// Convert the HTTP request into a signable request
let signable_request = SignableRequest::new(
"GET",
transcribe_uri.to_string(),
std::iter::empty(),
SignableBody::Bytes(&[]),
)
.expect("signable request");
let mut request = http::Request::builder() let mut request = http::Request::builder()
.uri(transcribe_uri) .uri(transcribe_uri)
.body(SdkBody::empty()) .body(aws_smithy_types::body::SdkBody::empty())
.expect("Failed to build valid request"); .expect("Failed to build valid request");
let (signing_instructions, _signature) =
let _signature = signer sign(signable_request, &signing_params)?.into_parts();
.sign( signing_instructions.apply_to_request(&mut request);
&operation_config,
&request_config,
&credentials,
&mut request,
)
.map_err(|err| {
gst::error!(CAT, imp: self, "Failed to sign HTTP request: {err}");
anyhow!("Failed to sign HTTP request: {err}")
})?;
let url = request.uri().to_string(); let url = request.uri().to_string();