mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-27 04:20:28 +00:00
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:
parent
8cb328b6f2
commit
6fe806c2b5
10 changed files with 51 additions and 42 deletions
|
@ -13,15 +13,15 @@ rust-version = "1.66"
|
|||
[dependencies]
|
||||
async-stream = "0.3.4"
|
||||
base32 = "0.4"
|
||||
aws-config = "0.54.0"
|
||||
aws-sdk-s3 = "0.24.0"
|
||||
aws-sdk-transcribestreaming = "0.24.0"
|
||||
aws-sdk-translate = "0.24.0"
|
||||
aws-types = "0.54.0"
|
||||
aws-credential-types = "0.54.0"
|
||||
aws-sig-auth = "0.54.0"
|
||||
aws-smithy-http = { version = "0.54.0", features = [ "rt-tokio" ] }
|
||||
aws-smithy-types = "0.54.0"
|
||||
aws-config = "0.55.0"
|
||||
aws-sdk-s3 = "0.25.0"
|
||||
aws-sdk-transcribestreaming = "0.25.0"
|
||||
aws-sdk-translate = "0.25.0"
|
||||
aws-types = "0.55.0"
|
||||
aws-credential-types = "0.55.0"
|
||||
aws-sig-auth = "0.55.0"
|
||||
aws-smithy-http = { version = "0.55.0", features = [ "rt-tokio" ] }
|
||||
aws-smithy-types = "0.55.0"
|
||||
bytes = "1.0"
|
||||
futures = "0.3"
|
||||
gio = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gio" }
|
||||
|
|
|
@ -19,10 +19,12 @@ use std::time::Duration;
|
|||
|
||||
use gst::{element_imp_error, glib, prelude::*, subclass::prelude::*};
|
||||
|
||||
use aws_sdk_s3::config;
|
||||
use aws_sdk_s3::model::ObjectCannedAcl;
|
||||
use aws_sdk_s3::types::ByteStream;
|
||||
use aws_sdk_s3::{config::retry::RetryConfig, Client, Credentials, Region};
|
||||
use aws_sdk_s3::{
|
||||
config::{self, retry::RetryConfig, Credentials, Region},
|
||||
primitives::ByteStream,
|
||||
types::ObjectCannedAcl,
|
||||
Client,
|
||||
};
|
||||
use aws_types::sdk_config::SdkConfig;
|
||||
|
||||
use crate::s3utils;
|
||||
|
|
|
@ -11,13 +11,18 @@ use gst::prelude::*;
|
|||
use gst::subclass::prelude::*;
|
||||
use gst_base::subclass::prelude::*;
|
||||
|
||||
use aws_sdk_s3::client::fluent_builders::{
|
||||
AbortMultipartUpload, CompleteMultipartUpload, CreateMultipartUpload, UploadPart,
|
||||
use aws_sdk_s3::{
|
||||
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 once_cell::sync::Lazy;
|
||||
|
@ -236,7 +241,7 @@ impl S3Sink {
|
|||
}
|
||||
|
||||
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 state = match *state {
|
||||
|
@ -275,7 +280,7 @@ impl S3Sink {
|
|||
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 settings = self.settings.lock().unwrap();
|
||||
let mut state = self.state.lock().unwrap();
|
||||
|
@ -314,7 +319,7 @@ impl S3Sink {
|
|||
fn create_complete_multipart_upload_request(
|
||||
&self,
|
||||
started_state: &mut Started,
|
||||
) -> CompleteMultipartUpload {
|
||||
) -> CompleteMultipartUploadFluentBuilder {
|
||||
started_state
|
||||
.completed_parts
|
||||
.sort_by(|a, b| a.part_number.cmp(&b.part_number));
|
||||
|
@ -344,7 +349,7 @@ impl S3Sink {
|
|||
client: &Client,
|
||||
url: &GstS3Url,
|
||||
settings: &Settings,
|
||||
) -> CreateMultipartUpload {
|
||||
) -> CreateMultipartUploadFluentBuilder {
|
||||
let bucket = Some(url.bucket.clone());
|
||||
let key = Some(url.object.clone());
|
||||
let content_type = settings.content_type.clone();
|
||||
|
@ -365,7 +370,7 @@ impl S3Sink {
|
|||
client: &Client,
|
||||
url: &GstS3Url,
|
||||
started_state: &Started,
|
||||
) -> AbortMultipartUpload {
|
||||
) -> AbortMultipartUploadFluentBuilder {
|
||||
let bucket = Some(url.bucket.clone());
|
||||
let key = Some(url.object.clone());
|
||||
|
||||
|
|
|
@ -12,8 +12,10 @@ use once_cell::sync::Lazy;
|
|||
use std::sync::Mutex;
|
||||
use std::time::Duration;
|
||||
|
||||
use aws_sdk_s3::config;
|
||||
use aws_sdk_s3::{config::retry::RetryConfig, Client, Credentials};
|
||||
use aws_sdk_s3::{
|
||||
config::{self, retry::RetryConfig, Credentials},
|
||||
Client,
|
||||
};
|
||||
|
||||
use gst::glib;
|
||||
use gst::prelude::*;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//
|
||||
// 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 url::Url;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
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_smithy_http::byte_stream::{error::Error, ByteStream};
|
||||
|
|
|
@ -513,7 +513,7 @@ impl Transcriber {
|
|||
(Some(key), Some(secret_key)) => {
|
||||
gst::debug!(CAT, imp: self, "Using settings credentials");
|
||||
aws_config::ConfigLoader::default().credentials_provider(
|
||||
aws_transcribe::Credentials::new(
|
||||
aws_transcribe::config::Credentials::new(
|
||||
key,
|
||||
secret_key,
|
||||
session_token,
|
||||
|
|
|
@ -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)]
|
||||
#[repr(u32)]
|
||||
|
|
|
@ -11,7 +11,7 @@ use gst::subclass::prelude::*;
|
|||
use gst::{glib, prelude::*};
|
||||
|
||||
use aws_sdk_transcribestreaming as aws_transcribe;
|
||||
use aws_sdk_transcribestreaming::model;
|
||||
use aws_sdk_transcribestreaming::types;
|
||||
|
||||
use futures::channel::mpsc;
|
||||
use futures::prelude::*;
|
||||
|
@ -23,13 +23,13 @@ use super::CAT;
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct TranscriberSettings {
|
||||
lang_code: model::LanguageCode,
|
||||
lang_code: types::LanguageCode,
|
||||
sample_rate: i32,
|
||||
vocabulary: Option<String>,
|
||||
vocabulary_filter: Option<String>,
|
||||
vocabulary_filter_method: model::VocabularyFilterMethod,
|
||||
vocabulary_filter_method: types::VocabularyFilterMethod,
|
||||
session_id: Option<String>,
|
||||
results_stability: model::PartialResultsStability,
|
||||
results_stability: types::PartialResultsStability,
|
||||
}
|
||||
|
||||
impl TranscriberSettings {
|
||||
|
@ -55,7 +55,7 @@ pub struct 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 start_time = ((item.start_time * 1_000_000_000.0) as u64).nseconds() + lateness;
|
||||
|
@ -65,7 +65,7 @@ impl TranscriptItem {
|
|||
pts: start_time,
|
||||
duration: end_time - start_time,
|
||||
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 {
|
||||
imp: glib::subclass::ObjectImplRef<Transcriber>,
|
||||
output: aws_transcribe::output::StartStreamTranscriptionOutput,
|
||||
output: aws_transcribe::operation::start_stream_transcription::StartStreamTranscriptionOutput,
|
||||
lateness: gst::ClockTime,
|
||||
partial_index: usize,
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ impl TranscriberStream {
|
|||
let chunk_stream = buffer_rx.flat_map(move |buffer: gst::Buffer| {
|
||||
async_stream::stream! {
|
||||
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) {
|
||||
yield Ok(AudioStream::AudioEvent(AudioEvent::builder().audio_chunk(Blob::new(chunk)).build()));
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ impl TranscriberStream {
|
|||
.start_stream_transcription()
|
||||
.language_code(settings.lang_code)
|
||||
.media_sample_rate_hertz(settings.sample_rate)
|
||||
.media_encoding(model::MediaEncoding::Pcm)
|
||||
.media_encoding(types::MediaEncoding::Pcm)
|
||||
.enable_partial_results_stabilization(true)
|
||||
.partial_results_stability(settings.results_stability)
|
||||
.set_vocabulary_name(settings.vocabulary)
|
||||
|
@ -167,7 +167,7 @@ impl TranscriberStream {
|
|||
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;
|
||||
|
||||
if let Some(result) = transcript_evt
|
||||
|
@ -203,7 +203,7 @@ impl TranscriberStream {
|
|||
/// Builds a list from the provided stable items.
|
||||
fn get_ready_transcript_items(
|
||||
&mut self,
|
||||
mut items: Vec<model::Item>,
|
||||
mut items: Vec<types::Item>,
|
||||
partial: bool,
|
||||
) -> Option<Vec<TranscriptItem>> {
|
||||
if items.len() <= self.partial_index {
|
||||
|
|
|
@ -62,7 +62,7 @@ async fn test_s3() {
|
|||
);
|
||||
|
||||
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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue