53 lines
1.3 KiB
C#
53 lines
1.3 KiB
C#
namespace AZKiServer.RPC;
|
|
|
|
public static class ConversionExtensions
|
|
{
|
|
public static Models.MediaType FromRpc(this MediaType type)
|
|
{
|
|
return type switch
|
|
{
|
|
MediaType.None => Models.MediaType.None,
|
|
MediaType.Image => Models.MediaType.Image,
|
|
MediaType.Video => Models.MediaType.Video,
|
|
MediaType.All => Models.MediaType.All,
|
|
_ => throw new NotSupportedException()
|
|
};
|
|
}
|
|
|
|
public static MediaType ToRpc(this Models.MediaType type)
|
|
{
|
|
return type switch
|
|
{
|
|
Models.MediaType.None => MediaType.None,
|
|
Models.MediaType.Image => MediaType.Image,
|
|
Models.MediaType.Video => MediaType.Video,
|
|
Models.MediaType.All => MediaType.All,
|
|
_ => throw new NotSupportedException()
|
|
};
|
|
}
|
|
|
|
public static MediaEntry ToRpc(this Models.MediaEntry entry)
|
|
{
|
|
return new MediaEntry
|
|
{
|
|
Version = entry.Version,
|
|
CameraId = entry.CameraId,
|
|
Date = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(entry.Date),
|
|
Metadata = entry.Metadata.ToRpc(),
|
|
FilePath = entry.Filepath,
|
|
Id = entry.Id.ToString(),
|
|
Type = entry.Type.ToRpc()
|
|
};
|
|
}
|
|
|
|
public static MediaMetadata ToRpc(this Models.MediaMetadata metadata)
|
|
{
|
|
return new MediaMetadata
|
|
{
|
|
Duration = metadata.Duration,
|
|
Height = metadata.Height,
|
|
Width = metadata.Width
|
|
};
|
|
}
|
|
}
|