mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 21:52:30 -04:00
feat(bindings): Expose video messages in matrix-sdk-ffi
This commit is contained in:
@@ -97,8 +97,8 @@ mod uniffi_types {
|
||||
EmoteMessageContent, EncryptedMessage, EventTimelineItem, FormattedBody, ImageInfo,
|
||||
ImageMessageContent, InsertAtData, Message, MessageFormat, MessageType,
|
||||
NoticeMessageContent, Reaction, TextMessageContent, ThumbnailInfo, TimelineChange,
|
||||
TimelineDiff, TimelineItem, TimelineItemContent, TimelineKey, UpdateAtData,
|
||||
VirtualTimelineItem,
|
||||
TimelineDiff, TimelineItem, TimelineItemContent, TimelineKey, UpdateAtData, VideoInfo,
|
||||
VideoMessageContent, VirtualTimelineItem,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -270,6 +270,13 @@ impl Message {
|
||||
info: c.info.as_deref().map(Into::into),
|
||||
},
|
||||
}),
|
||||
MTy::Video(c) => Some(MessageType::Video {
|
||||
content: VideoMessageContent {
|
||||
body: c.body.clone(),
|
||||
source: Arc::new(c.source.clone()),
|
||||
info: c.info.as_deref().map(Into::into),
|
||||
},
|
||||
}),
|
||||
MTy::Notice(c) => Some(MessageType::Notice {
|
||||
content: NoticeMessageContent {
|
||||
body: c.body.clone(),
|
||||
@@ -304,6 +311,7 @@ impl Message {
|
||||
pub enum MessageType {
|
||||
Emote { content: EmoteMessageContent },
|
||||
Image { content: ImageMessageContent },
|
||||
Video { content: VideoMessageContent },
|
||||
Notice { content: NoticeMessageContent },
|
||||
Text { content: TextMessageContent },
|
||||
}
|
||||
@@ -321,6 +329,13 @@ pub struct ImageMessageContent {
|
||||
pub info: Option<ImageInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct VideoMessageContent {
|
||||
pub body: String,
|
||||
pub source: Arc<MediaSource>,
|
||||
pub info: Option<VideoInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct ImageInfo {
|
||||
pub height: Option<u64>,
|
||||
@@ -332,6 +347,18 @@ pub struct ImageInfo {
|
||||
pub blurhash: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct VideoInfo {
|
||||
pub duration: Option<u64>,
|
||||
pub height: Option<u64>,
|
||||
pub width: Option<u64>,
|
||||
pub mimetype: Option<String>,
|
||||
pub size: Option<u64>,
|
||||
pub thumbnail_info: Option<ThumbnailInfo>,
|
||||
pub thumbnail_source: Option<Arc<MediaSource>>,
|
||||
pub blurhash: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Record)]
|
||||
pub struct ThumbnailInfo {
|
||||
pub height: Option<u64>,
|
||||
@@ -397,6 +424,28 @@ impl From<&matrix_sdk::ruma::events::room::ImageInfo> for ImageInfo {
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
height: info.height.map(Into::into),
|
||||
width: info.width.map(Into::into),
|
||||
mimetype: info.mimetype.clone(),
|
||||
size: info.size.map(Into::into),
|
||||
});
|
||||
|
||||
Self {
|
||||
duration: info.duration.map(|d| d.as_secs()),
|
||||
height: info.height.map(Into::into),
|
||||
width: info.width.map(Into::into),
|
||||
mimetype: info.mimetype.clone(),
|
||||
size: info.size.map(Into::into),
|
||||
thumbnail_info,
|
||||
thumbnail_source: info.thumbnail_source.clone().map(Arc::new),
|
||||
blurhash: info.blurhash.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Enum)]
|
||||
pub enum EncryptedMessage {
|
||||
OlmV1Curve25519AesSha2 {
|
||||
|
||||
Reference in New Issue
Block a user