mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-15 03:25:46 -04:00
feat(bindings): Add AudioInfo & AudioMessageContent to matrix-sdk-ffi
Signed-off-by: Matteo Ludwig <ludwig@silpion.de>
This commit is contained in:
@@ -93,13 +93,13 @@ mod uniffi_types {
|
||||
SlidingSyncViewBuilder, StoppableSpawn, UnreadNotificationsCount,
|
||||
},
|
||||
timeline::{
|
||||
EmoteMessageContent, EncryptedMessage, EventSendState, EventTimelineItem, FileInfo,
|
||||
FileMessageContent, FormattedBody, ImageInfo, ImageMessageContent, InsertAtData,
|
||||
MembershipChange, Message, MessageFormat, MessageType, NoticeMessageContent,
|
||||
OtherState, ProfileTimelineDetails, Reaction, TextMessageContent, ThumbnailInfo,
|
||||
TimelineChange, TimelineDiff, TimelineItem, TimelineItemContent,
|
||||
TimelineItemContentKind, UpdateAtData, VideoInfo, VideoMessageContent,
|
||||
VirtualTimelineItem,
|
||||
AudioInfo, AudioMessageContent, EmoteMessageContent, EncryptedMessage, EventSendState,
|
||||
EventTimelineItem, FileInfo, FileMessageContent, FormattedBody, ImageInfo,
|
||||
ImageMessageContent, InsertAtData, MembershipChange, Message, MessageFormat,
|
||||
MessageType, NoticeMessageContent, OtherState, ProfileTimelineDetails, Reaction,
|
||||
TextMessageContent, ThumbnailInfo, TimelineChange, TimelineDiff, TimelineItem,
|
||||
TimelineItemContent, TimelineItemContentKind, UpdateAtData, VideoInfo,
|
||||
VideoMessageContent, VirtualTimelineItem,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -434,6 +434,13 @@ impl Message {
|
||||
info: c.info.as_deref().map(Into::into),
|
||||
},
|
||||
}),
|
||||
MTy::Audio(c) => Some(MessageType::Audio {
|
||||
content: AudioMessageContent {
|
||||
body: c.body.clone(),
|
||||
source: Arc::new(c.source.clone()),
|
||||
info: c.info.as_deref().map(Into::into),
|
||||
},
|
||||
}),
|
||||
MTy::Video(c) => Some(MessageType::Video {
|
||||
content: VideoMessageContent {
|
||||
body: c.body.clone(),
|
||||
@@ -482,6 +489,7 @@ impl Message {
|
||||
pub enum MessageType {
|
||||
Emote { content: EmoteMessageContent },
|
||||
Image { content: ImageMessageContent },
|
||||
Audio { content: AudioMessageContent },
|
||||
Video { content: VideoMessageContent },
|
||||
File { content: FileMessageContent },
|
||||
Notice { content: NoticeMessageContent },
|
||||
@@ -501,6 +509,13 @@ pub struct ImageMessageContent {
|
||||
pub info: Option<ImageInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct AudioMessageContent {
|
||||
pub body: String,
|
||||
pub source: Arc<MediaSource>,
|
||||
pub info: Option<AudioInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct VideoMessageContent {
|
||||
pub body: String,
|
||||
@@ -526,6 +541,14 @@ pub struct ImageInfo {
|
||||
pub blurhash: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct AudioInfo {
|
||||
// FIXME: duration should be a std::time::Duration once the UniFFI proc-macro API adds support
|
||||
// for that
|
||||
pub duration: Option<u64>,
|
||||
pub size: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct VideoInfo {
|
||||
pub duration: Option<u64>,
|
||||
@@ -611,6 +634,15 @@ impl From<&matrix_sdk::ruma::events::room::ImageInfo> for ImageInfo {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&matrix_sdk::ruma::events::room::message::AudioInfo> for AudioInfo {
|
||||
fn from(info: &matrix_sdk::ruma::events::room::message::AudioInfo) -> Self {
|
||||
Self {
|
||||
duration: info.duration.map(|d| d.as_millis() as u64),
|
||||
size: info.size.map(Into::into),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&matrix_sdk::ruma::events::room::message::VideoInfo> for VideoInfo {
|
||||
fn from(info: &matrix_sdk::ruma::events::room::message::VideoInfo) -> Self {
|
||||
let thumbnail_info = info.thumbnail_info.as_ref().map(|info| ThumbnailInfo {
|
||||
|
||||
Reference in New Issue
Block a user