aws: Update to AWS SDK 0.55/0.25

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1152>
This commit is contained in:
Sebastian Dröge 2023-03-31 11:43:36 +03:00 committed by GStreamer Marge Bot
parent 8cb328b6f2
commit 6fe806c2b5
10 changed files with 51 additions and 42 deletions

View file

@ -13,15 +13,15 @@ rust-version = "1.66"
[dependencies] [dependencies]
async-stream = "0.3.4" async-stream = "0.3.4"
base32 = "0.4" base32 = "0.4"
aws-config = "0.54.0" aws-config = "0.55.0"
aws-sdk-s3 = "0.24.0" aws-sdk-s3 = "0.25.0"
aws-sdk-transcribestreaming = "0.24.0" aws-sdk-transcribestreaming = "0.25.0"
aws-sdk-translate = "0.24.0" aws-sdk-translate = "0.25.0"
aws-types = "0.54.0" aws-types = "0.55.0"
aws-credential-types = "0.54.0" aws-credential-types = "0.55.0"
aws-sig-auth = "0.54.0" aws-sig-auth = "0.55.0"
aws-smithy-http = { version = "0.54.0", features = [ "rt-tokio" ] } aws-smithy-http = { version = "0.55.0", features = [ "rt-tokio" ] }
aws-smithy-types = "0.54.0" aws-smithy-types = "0.55.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

@ -19,10 +19,12 @@ use std::time::Duration;
use gst::{element_imp_error, glib, prelude::*, subclass::prelude::*}; use gst::{element_imp_error, glib, prelude::*, subclass::prelude::*};
use aws_sdk_s3::config; use aws_sdk_s3::{
use aws_sdk_s3::model::ObjectCannedAcl; config::{self, retry::RetryConfig, Credentials, Region},
use aws_sdk_s3::types::ByteStream; primitives::ByteStream,
use aws_sdk_s3::{config::retry::RetryConfig, Client, Credentials, Region}; types::ObjectCannedAcl,
Client,
};
use aws_types::sdk_config::SdkConfig; use aws_types::sdk_config::SdkConfig;
use crate::s3utils; use crate::s3utils;

View file

@ -11,13 +11,18 @@ use gst::prelude::*;
use gst::subclass::prelude::*; use gst::subclass::prelude::*;
use gst_base::subclass::prelude::*; use gst_base::subclass::prelude::*;
use aws_sdk_s3::client::fluent_builders::{ use aws_sdk_s3::{
AbortMultipartUpload, CompleteMultipartUpload, CreateMultipartUpload, UploadPart, config::{self, retry::RetryConfig, Credentials, Region},
operation::{
abort_multipart_upload::builders::AbortMultipartUploadFluentBuilder,
complete_multipart_upload::builders::CompleteMultipartUploadFluentBuilder,
create_multipart_upload::builders::CreateMultipartUploadFluentBuilder,
upload_part::builders::UploadPartFluentBuilder,
},
primitives::ByteStream,
types::{CompletedMultipartUpload, CompletedPart},
Client,
}; };
use aws_sdk_s3::config;
use aws_sdk_s3::model::{CompletedMultipartUpload, CompletedPart};
use aws_sdk_s3::types::ByteStream;
use aws_sdk_s3::{config::retry::RetryConfig, Client, Credentials, Region};
use futures::future; use futures::future;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
@ -236,7 +241,7 @@ impl S3Sink {
} }
fn flush_current_buffer(&self) -> Result<(), Option<gst::ErrorMessage>> { fn flush_current_buffer(&self) -> Result<(), Option<gst::ErrorMessage>> {
let upload_part_req: UploadPart = self.create_upload_part_request()?; let upload_part_req = self.create_upload_part_request()?;
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
let state = match *state { let state = match *state {
@ -275,7 +280,7 @@ impl S3Sink {
Ok(()) Ok(())
} }
fn create_upload_part_request(&self) -> Result<UploadPart, gst::ErrorMessage> { fn create_upload_part_request(&self) -> Result<UploadPartFluentBuilder, gst::ErrorMessage> {
let url = self.url.lock().unwrap(); let url = self.url.lock().unwrap();
let settings = self.settings.lock().unwrap(); let settings = self.settings.lock().unwrap();
let mut state = self.state.lock().unwrap(); let mut state = self.state.lock().unwrap();
@ -314,7 +319,7 @@ impl S3Sink {
fn create_complete_multipart_upload_request( fn create_complete_multipart_upload_request(
&self, &self,
started_state: &mut Started, started_state: &mut Started,
) -> CompleteMultipartUpload { ) -> CompleteMultipartUploadFluentBuilder {
started_state started_state
.completed_parts .completed_parts
.sort_by(|a, b| a.part_number.cmp(&b.part_number)); .sort_by(|a, b| a.part_number.cmp(&b.part_number));
@ -344,7 +349,7 @@ impl S3Sink {
client: &Client, client: &Client,
url: &GstS3Url, url: &GstS3Url,
settings: &Settings, settings: &Settings,
) -> CreateMultipartUpload { ) -> CreateMultipartUploadFluentBuilder {
let bucket = Some(url.bucket.clone()); let bucket = Some(url.bucket.clone());
let key = Some(url.object.clone()); let key = Some(url.object.clone());
let content_type = settings.content_type.clone(); let content_type = settings.content_type.clone();
@ -365,7 +370,7 @@ impl S3Sink {
client: &Client, client: &Client,
url: &GstS3Url, url: &GstS3Url,
started_state: &Started, started_state: &Started,
) -> AbortMultipartUpload { ) -> AbortMultipartUploadFluentBuilder {
let bucket = Some(url.bucket.clone()); let bucket = Some(url.bucket.clone());
let key = Some(url.object.clone()); let key = Some(url.object.clone());

View file

@ -12,8 +12,10 @@ use once_cell::sync::Lazy;
use std::sync::Mutex; use std::sync::Mutex;
use std::time::Duration; use std::time::Duration;
use aws_sdk_s3::config; use aws_sdk_s3::{
use aws_sdk_s3::{config::retry::RetryConfig, Client, Credentials}; config::{self, retry::RetryConfig, Credentials},
Client,
};
use gst::glib; use gst::glib;
use gst::prelude::*; use gst::prelude::*;

View file

@ -6,7 +6,7 @@
// //
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use aws_sdk_s3::Region; use aws_sdk_s3::config::Region;
use percent_encoding::{percent_decode, percent_encode, AsciiSet, CONTROLS}; use percent_encoding::{percent_decode, percent_encode, AsciiSet, CONTROLS};
use url::Url; use url::Url;

View file

@ -7,7 +7,7 @@
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
use aws_config::meta::region::RegionProviderChain; 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_http::byte_stream::{error::Error, ByteStream};

View file

@ -513,7 +513,7 @@ impl Transcriber {
(Some(key), Some(secret_key)) => { (Some(key), Some(secret_key)) => {
gst::debug!(CAT, imp: self, "Using settings credentials"); gst::debug!(CAT, imp: self, "Using settings credentials");
aws_config::ConfigLoader::default().credentials_provider( aws_config::ConfigLoader::default().credentials_provider(
aws_transcribe::Credentials::new( aws_transcribe::config::Credentials::new(
key, key,
secret_key, secret_key,
session_token, session_token,

View file

@ -23,7 +23,7 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
) )
}); });
use aws_sdk_transcribestreaming::model::{PartialResultsStability, VocabularyFilterMethod}; use aws_sdk_transcribestreaming::types::{PartialResultsStability, VocabularyFilterMethod};
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::Enum)]
#[repr(u32)] #[repr(u32)]

View file

@ -11,7 +11,7 @@ use gst::subclass::prelude::*;
use gst::{glib, prelude::*}; use gst::{glib, prelude::*};
use aws_sdk_transcribestreaming as aws_transcribe; use aws_sdk_transcribestreaming as aws_transcribe;
use aws_sdk_transcribestreaming::model; use aws_sdk_transcribestreaming::types;
use futures::channel::mpsc; use futures::channel::mpsc;
use futures::prelude::*; use futures::prelude::*;
@ -23,13 +23,13 @@ use super::CAT;
#[derive(Debug)] #[derive(Debug)]
pub struct TranscriberSettings { pub struct TranscriberSettings {
lang_code: model::LanguageCode, lang_code: types::LanguageCode,
sample_rate: i32, sample_rate: i32,
vocabulary: Option<String>, vocabulary: Option<String>,
vocabulary_filter: Option<String>, vocabulary_filter: Option<String>,
vocabulary_filter_method: model::VocabularyFilterMethod, vocabulary_filter_method: types::VocabularyFilterMethod,
session_id: Option<String>, session_id: Option<String>,
results_stability: model::PartialResultsStability, results_stability: types::PartialResultsStability,
} }
impl TranscriberSettings { impl TranscriberSettings {
@ -55,7 +55,7 @@ pub struct TranscriptItem {
} }
impl TranscriptItem { impl TranscriptItem {
pub fn from(item: model::Item, lateness: gst::ClockTime) -> Option<TranscriptItem> { pub fn from(item: types::Item, lateness: gst::ClockTime) -> Option<TranscriptItem> {
let content = item.content?; let content = item.content?;
let start_time = ((item.start_time * 1_000_000_000.0) as u64).nseconds() + lateness; let start_time = ((item.start_time * 1_000_000_000.0) as u64).nseconds() + lateness;
@ -65,7 +65,7 @@ impl TranscriptItem {
pts: start_time, pts: start_time,
duration: end_time - start_time, duration: end_time - start_time,
content, content,
is_punctuation: matches!(item.r#type, Some(model::ItemType::Punctuation)), is_punctuation: matches!(item.r#type, Some(types::ItemType::Punctuation)),
}) })
} }
} }
@ -84,7 +84,7 @@ impl From<Vec<TranscriptItem>> for TranscriptEvent {
pub struct TranscriberStream { pub struct TranscriberStream {
imp: glib::subclass::ObjectImplRef<Transcriber>, imp: glib::subclass::ObjectImplRef<Transcriber>,
output: aws_transcribe::output::StartStreamTranscriptionOutput, output: aws_transcribe::operation::start_stream_transcription::StartStreamTranscriptionOutput,
lateness: gst::ClockTime, lateness: gst::ClockTime,
partial_index: usize, partial_index: usize,
} }
@ -108,7 +108,7 @@ impl TranscriberStream {
let chunk_stream = buffer_rx.flat_map(move |buffer: gst::Buffer| { let chunk_stream = buffer_rx.flat_map(move |buffer: gst::Buffer| {
async_stream::stream! { async_stream::stream! {
let data = buffer.map_readable().unwrap(); let data = buffer.map_readable().unwrap();
use aws_transcribe::{model::{AudioEvent, AudioStream}, types::Blob}; use aws_transcribe::{types::{AudioEvent, AudioStream}, primitives::Blob};
for chunk in data.chunks(8192) { for chunk in data.chunks(8192) {
yield Ok(AudioStream::AudioEvent(AudioEvent::builder().audio_chunk(Blob::new(chunk)).build())); yield Ok(AudioStream::AudioEvent(AudioEvent::builder().audio_chunk(Blob::new(chunk)).build()));
} }
@ -119,7 +119,7 @@ impl TranscriberStream {
.start_stream_transcription() .start_stream_transcription()
.language_code(settings.lang_code) .language_code(settings.lang_code)
.media_sample_rate_hertz(settings.sample_rate) .media_sample_rate_hertz(settings.sample_rate)
.media_encoding(model::MediaEncoding::Pcm) .media_encoding(types::MediaEncoding::Pcm)
.enable_partial_results_stabilization(true) .enable_partial_results_stabilization(true)
.partial_results_stability(settings.results_stability) .partial_results_stability(settings.results_stability)
.set_vocabulary_name(settings.vocabulary) .set_vocabulary_name(settings.vocabulary)
@ -167,7 +167,7 @@ impl TranscriberStream {
return Ok(TranscriptEvent::Eos); return Ok(TranscriptEvent::Eos);
}; };
if let model::TranscriptResultStream::TranscriptEvent(transcript_evt) = event { if let types::TranscriptResultStream::TranscriptEvent(transcript_evt) = event {
let mut ready_items = None; let mut ready_items = None;
if let Some(result) = transcript_evt if let Some(result) = transcript_evt
@ -203,7 +203,7 @@ impl TranscriberStream {
/// Builds a list from the provided stable items. /// Builds a list from the provided stable items.
fn get_ready_transcript_items( fn get_ready_transcript_items(
&mut self, &mut self,
mut items: Vec<model::Item>, mut items: Vec<types::Item>,
partial: bool, partial: bool,
) -> Option<Vec<TranscriptItem>> { ) -> Option<Vec<TranscriptItem>> {
if items.len() <= self.partial_index { if items.len() <= self.partial_index {

View file

@ -62,7 +62,7 @@ async fn test_s3() {
); );
let region_provider = aws_config::meta::region::RegionProviderChain::first_try( let region_provider = aws_config::meta::region::RegionProviderChain::first_try(
aws_sdk_s3::Region::new(region.clone()), aws_sdk_s3::config::Region::new(region.clone()),
) )
.or_default_provider(); .or_default_provider();