init
7
src-tauri/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Generated by Tauri
|
||||
# will have schema files for capabilities auto-completion
|
||||
/gen/schemas
|
||||
5166
src-tauri/Cargo.lock
generated
Normal file
25
src-tauri/Cargo.toml
Normal file
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "ox-speak"
|
||||
version = "0.1.0"
|
||||
description = "A Tauri App"
|
||||
authors = ["you"]
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
# The `_lib` suffix may seem redundant but it is necessary
|
||||
# to make the lib name unique and wouldn't conflict with the bin name.
|
||||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
||||
name = "ox_speak_lib"
|
||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||
|
||||
[build-dependencies]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
tauri = { version = "2", features = [] }
|
||||
tauri-plugin-opener = "2"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
opusic-sys = "0.5"
|
||||
3
src-tauri/build.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
10
src-tauri/capabilities/default.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "default",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": [
|
||||
"core:default",
|
||||
"opener:default"
|
||||
]
|
||||
}
|
||||
BIN
src-tauri/icons/128x128.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
src-tauri/icons/128x128@2x.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
src-tauri/icons/32x32.png
Normal file
|
After Width: | Height: | Size: 974 B |
BIN
src-tauri/icons/Square107x107Logo.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
src-tauri/icons/Square142x142Logo.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
src-tauri/icons/Square150x150Logo.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
src-tauri/icons/Square284x284Logo.png
Normal file
|
After Width: | Height: | Size: 7.6 KiB |
BIN
src-tauri/icons/Square30x30Logo.png
Normal file
|
After Width: | Height: | Size: 903 B |
BIN
src-tauri/icons/Square310x310Logo.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
src-tauri/icons/Square44x44Logo.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src-tauri/icons/Square71x71Logo.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
src-tauri/icons/Square89x89Logo.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
src-tauri/icons/StoreLogo.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
src-tauri/icons/icon.icns
Normal file
BIN
src-tauri/icons/icon.ico
Normal file
|
After Width: | Height: | Size: 85 KiB |
BIN
src-tauri/icons/icon.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
16
src-tauri/src/lib.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
#[tauri::command]
|
||||
fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.invoke_handler(tauri::generate_handler![greet])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
mod utils;
|
||||
16
src-tauri/src/main.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
// On désactive l'Explicit Sync qui pose problème avec NVIDIA/Wayland
|
||||
std::env::set_var("__NV_DISABLE_EXPLICIT_SYNC", "1");
|
||||
|
||||
// Optionnel : tu peux aussi forcer la désactivation du DMABUF ici
|
||||
// si tu remarques que certains utilisateurs ont encore des pages blanches.
|
||||
// std::env::set_var("WEBKIT_DISABLE_DMABUF_RENDERER", "1");
|
||||
}
|
||||
|
||||
ox_speak_lib::run()
|
||||
}
|
||||
1
src-tauri/src/utils/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
mod opus_codec;
|
||||
143
src-tauri/src/utils/opus_codec.rs
Normal file
@@ -0,0 +1,143 @@
|
||||
use std::ffi::c_int;
|
||||
use std::ptr::{self, NonNull};
|
||||
|
||||
use opusic_sys as sys;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Application {
|
||||
Voip,
|
||||
Audio,
|
||||
LowDelay,
|
||||
}
|
||||
|
||||
impl Application {
|
||||
fn to_sys(&self) -> c_int {
|
||||
match self {
|
||||
Application::Voip => sys::OPUS_APPLICATION_VOIP,
|
||||
Application::Audio => sys::OPUS_APPLICATION_AUDIO,
|
||||
Application::LowDelay => sys::OPUS_APPLICATION_RESTRICTED_LOWDELAY,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Channels {
|
||||
Mono = 1,
|
||||
Stereo = 2,
|
||||
}
|
||||
|
||||
impl Channels {
|
||||
fn as_i32(self) -> i32 {
|
||||
self as i32
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OpusEncoder{
|
||||
enc: NonNull<sys::OpusEncoder>,
|
||||
sample_rate: i32,
|
||||
channels: Channels,
|
||||
}
|
||||
|
||||
impl OpusEncoder {
|
||||
pub fn new(sample_rate: i32, channels: Channels, application: Application) -> Result<Self, i32> {
|
||||
let mut error = 0;
|
||||
let enc_ptr = unsafe {
|
||||
sys::opus_encoder_create(
|
||||
sample_rate,
|
||||
channels.as_i32(),
|
||||
application.to_sys(),
|
||||
&mut error
|
||||
)
|
||||
};
|
||||
|
||||
if error != sys::OPUS_OK || enc_ptr.is_null() {
|
||||
return Err(error)
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
enc: unsafe { NonNull::new_unchecked(enc_ptr)},
|
||||
sample_rate,
|
||||
channels,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn encode(&mut self, input: &[i16], output: &mut [u8]) -> Result<usize, i32> {
|
||||
let frame_size = (input.len() / self.channels.as_i32() as usize) as c_int;
|
||||
|
||||
let result = unsafe {
|
||||
sys::opus_encode(
|
||||
self.enc.as_ptr(),
|
||||
input.as_ptr(),
|
||||
frame_size,
|
||||
output.as_mut_ptr(),
|
||||
output.len() as c_int,
|
||||
)
|
||||
};
|
||||
|
||||
if result < 0 {
|
||||
Err(result)
|
||||
} else {
|
||||
Ok(result as usize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for OpusEncoder {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
sys::opus_encoder_destroy(self.enc.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OpusDecoder {
|
||||
dec: NonNull<sys::OpusDecoder>,
|
||||
channels: Channels,
|
||||
}
|
||||
|
||||
impl OpusDecoder {
|
||||
pub fn new(sample_rate: i32, channels: Channels) -> Result<Self, i32> {
|
||||
let mut error = 0;
|
||||
let dec_ptr = unsafe {
|
||||
sys::opus_decoder_create(sample_rate, channels.as_i32(), &mut error)
|
||||
};
|
||||
|
||||
if error != sys::OPUS_OK || dec_ptr.is_null() {
|
||||
return Err(error);
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
dec: unsafe { NonNull::new_unchecked(dec_ptr) },
|
||||
channels,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn decode(&mut self, packet: &[u8], output: &mut [i16], decode_fec: bool) -> Result<usize, i32> {
|
||||
let frame_size = (output.len() / self.channels.as_i32() as usize) as c_int;
|
||||
|
||||
let result = unsafe {
|
||||
sys::opus_decode(
|
||||
self.dec.as_ptr(),
|
||||
packet.as_ptr(),
|
||||
packet.len() as c_int,
|
||||
output.as_mut_ptr(),
|
||||
frame_size,
|
||||
if decode_fec { 1 } else { 0 },
|
||||
)
|
||||
};
|
||||
|
||||
if result < 0 {
|
||||
return Err(result);
|
||||
}
|
||||
|
||||
Ok(result as usize)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for OpusDecoder {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
sys::opus_decoder_destroy(self.dec.as_ptr());
|
||||
}
|
||||
}
|
||||
}
|
||||
35
src-tauri/tauri.conf.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"$schema": "https://schema.tauri.app/config/2",
|
||||
"productName": "ox-speak",
|
||||
"version": "0.1.0",
|
||||
"identifier": "com.ox-speak.app",
|
||||
"build": {
|
||||
"beforeDevCommand": "yarn dev",
|
||||
"devUrl": "http://localhost:1420",
|
||||
"beforeBuildCommand": "yarn build",
|
||||
"frontendDist": "../dist"
|
||||
},
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "ox-speak",
|
||||
"width": 1024,
|
||||
"height": 768
|
||||
}
|
||||
],
|
||||
"security": {
|
||||
"csp": null
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
}
|
||||