Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src-tauri/src/ai_coach.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use tauri::State;
use crate::AppState;

// ============================================================================
Expand All @@ -21,7 +18,7 @@ pub enum CoachTipType {
}

/// Coach tip priority
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
#[serde(rename_all = "lowercase")]
pub enum CoachTipPriority {
Low,
Expand Down
3 changes: 0 additions & 3 deletions src-tauri/src/ai_highlight.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use tauri::State;
use crate::AppState;

// ============================================================================
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/src/analytics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::time::{Duration, SystemTime};
use std::time::Duration;
use chrono::{DateTime, Utc};
use tokio::sync::RwLock;

Expand All @@ -25,7 +25,7 @@ pub struct AnalyticsDataPoint {
}

/// Analytics aggregation period
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub enum AggregationPeriod {
Minute,
FiveMinutes,
Expand Down Expand Up @@ -147,7 +147,7 @@ pub struct ComparisonData {
}

/// Real-time analytics
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct RealTimeAnalytics {
pub current_viewers: u64,
pub chat_messages_per_minute: u64,
Expand Down Expand Up @@ -438,7 +438,7 @@ impl AnalyticsEngine {

let unique_viewers = self.data_points.iter().map(|p| p.viewers).max().unwrap_or(0);
let total_chat_messages = self.data_points.iter().map(|p| p.chat_messages).sum::<u64>();
let total_followers = self.data_points.iter().map(|p| p.new_followers).sum::<u64>();
let _total_followers = self.data_points.iter().map(|p| p.new_followers).sum::<u64>();

let chat_participation_rate = if unique_viewers > 0 {
(total_chat_messages as f64 / unique_viewers as f64) * 100.0
Expand Down Expand Up @@ -492,7 +492,7 @@ impl AnalyticsEngine {
}

let count = self.data_points.len() as f64;
let avg_bitrate = self.data_points.iter().map(|p| p.bitrate).sum::<u64>() as f64 / count;
let _avg_bitrate = self.data_points.iter().map(|p| p.bitrate).sum::<u64>() as f64 / count;
let avg_fps = self.data_points.iter().map(|p| p.fps).sum::<f64>() / count;
let avg_cpu = self.data_points.iter().map(|p| p.cpu_usage).sum::<f64>() / count;
let avg_gpu = self.data_points.iter().map(|p| p.gpu_usage).sum::<f64>() / count;
Expand Down
10 changes: 5 additions & 5 deletions src-tauri/src/analytics_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ pub fn init_analytics() -> AnalyticsEngine {
pub async fn analytics_get_real_time(
state: State<'_, AnalyticsState>
) -> Result<RealTimeAnalytics, String> {
state.0.lock()
Ok(state.0.lock()
.unwrap()
.get_real_time()
.await
.await)
}

#[tauri::command]
Expand All @@ -45,21 +45,21 @@ pub fn analytics_get_aggregated(
pub fn analytics_get_performance_metrics(
state: State<'_, AnalyticsState>
) -> Result<Option<crate::analytics::PerformanceMetrics>, String> {
Ok(state.0.lock().unwrap().get_performance_metrics().cloned())
Ok(state.0.lock().unwrap().get_performance_metrics())
}

#[tauri::command]
pub fn analytics_get_viewer_statistics(
state: State<'_, AnalyticsState>
) -> Result<Option<crate::analytics::ViewerStatistics>, String> {
Ok(state.0.lock().unwrap().get_viewer_statistics().cloned())
Ok(state.0.lock().unwrap().get_viewer_statistics())
}

#[tauri::command]
pub fn analytics_get_revenue_statistics(
state: State<'_, AnalyticsState>
) -> Result<Option<crate::analytics::RevenueStatistics>, String> {
Ok(state.0.lock().unwrap().get_revenue_statistics().cloned())
Ok(state.0.lock().unwrap().get_revenue_statistics())
}

#[tauri::command]
Expand Down
5 changes: 1 addition & 4 deletions src-tauri/src/business.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use tauri::State;
use crate::AppState;

// ============================================================================
Expand Down Expand Up @@ -295,7 +292,7 @@ impl BusinessEngine {

/// Subscribe to plan
pub fn subscribe(&mut self, user_id: String, tier: SubscriptionTier, yearly: bool) -> Result<UserSubscription, String> {
let plan = self.plans.iter().find(|p| p.tier == tier).ok_or("Plan not found")?;
let _plan = self.plans.iter().find(|p| p.tier == tier).ok_or("Plan not found")?;

let duration_days = if yearly { 365 } else { 30 };

Expand Down
40 changes: 22 additions & 18 deletions src-tauri/src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ impl CaptureEngine {
let mut counter = 0;

unsafe {
let lparam = windows::Win32::Foundation::LPARAM(
&mut windows as *mut Vec<CaptureSourceInfo> as isize,
);
EnumWindows(
Some(enumerate_windows_callback),
&mut windows as *mut Vec<CaptureSourceInfo> as isize,
lparam,
)
.ok()?;
.ok().ok_or(CaptureError::CaptureFailed("EnumWindows failed".to_string()))?;
}

return Ok(windows);
Expand Down Expand Up @@ -159,7 +162,7 @@ impl CaptureEngine {
#[cfg(target_os = "windows")]
unsafe extern "system" fn enumerate_windows_callback(
hwnd: windows::Win32::Foundation::HWND,
lparam: isize,
lparam: windows::Win32::Foundation::LPARAM,
) -> windows::Win32::Foundation::BOOL {
use windows::Win32::UI::WindowsAndMessaging::{GetWindowTextW, IsWindowVisible};
use windows::core::PWSTR;
Expand All @@ -169,11 +172,11 @@ unsafe extern "system" fn enumerate_windows_callback(
}

let mut buffer = [0u16; 256];
let length = GetWindowTextW(hwnd, PWSTR(buffer.as_mut_ptr()), 256);
let length = GetWindowTextW(hwnd, &mut buffer);

if length > 0 {
let name = String::from_utf16_lossy(&buffer[..length as usize]);
let windows = &mut *(lparam as *mut Vec<CaptureSourceInfo>);
let windows = &mut *(lparam.0 as *mut Vec<CaptureSourceInfo>);

windows.push(CaptureSourceInfo {
id: format!("window_{}", hwnd.0),
Expand Down Expand Up @@ -349,21 +352,19 @@ mod tests {

#[test]
fn test_capture_engine_creation() {
let engine = CaptureEngine::new();
assert_eq!(engine.sources.len(), 0);
let engine = CaptureEngine::new().expect("Failed to create capture engine");
assert!(!engine.is_capturing());
}

#[test]
fn test_capture_source() {
let source = CaptureSource {
id: "source_1".to_string(),
name: "Game Capture".to_string(),
source_type: CaptureSourceType::Game,
enabled: true,
let source = CaptureSource::Window {
window_handle: 12345,
window_name: "Game Capture".to_string(),
};

assert_eq!(source.name, "Game Capture");
assert_eq!(source.source_type, CaptureSourceType::Game);
let id = source.get_id();
assert_eq!(id, "window_12345");
}

#[test]
Expand All @@ -372,11 +373,13 @@ mod tests {
id: "window_1".to_string(),
name: "Test Window".to_string(),
source_type: CaptureSourceType::Window,
executable: Some("test.exe".to_string()),
width: 1920,
height: 1080,
refresh_rate: 60,
};

assert_eq!(info.name, "Test Window");
assert_eq!(info.executable, Some("test.exe".to_string()));
assert_eq!(info.width, 1920);
}

#[test]
Expand All @@ -395,10 +398,11 @@ mod tests {
let stats = CapturePerformanceStats {
fps: 60.0,
frame_time_ms: 16.67,
cpu_usage_percent: 25.0,
gpu_usage_percent: 40.0,
dropped_frames: 0,
total_frames: 3600,
capture_latency_ms: 2.5,
cpu_usage_percent: 25.0,
gpu_usage_percent: 40.0,
};

assert_eq!(stats.fps, 60.0);
Expand Down
26 changes: 16 additions & 10 deletions src-tauri/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde_json;

// Re-export from other modules
use crate::config::{AppConfig, ConfigError};
use crate::pdk::{PluginManager, PluginMetadata, BasePlugin, PluginState};
use crate::pdk::{PluginManager, PluginMetadata, PluginCategory, BasePlugin, PluginState};
use crate::plugin_metadata;

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -294,7 +294,7 @@ pub struct CliContext {

/// Stream configuration
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
struct StreamConfig {
pub struct StreamConfig {
name: String,
platform: String,
server_url: String,
Expand All @@ -306,7 +306,7 @@ struct StreamConfig {

/// User profile
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
struct UserProfile {
pub struct UserProfile {
name: String,
resolution: String,
framerate: u32,
Expand Down Expand Up @@ -535,7 +535,7 @@ fn execute_config_action(ctx: &CliContext, action: ConfigAction) -> Result<(), C

fn execute_stream_action(ctx: &mut CliContext, action: StreamAction) -> Result<(), CliError> {
match action {
StreamAction::Start { platform, key } => {
StreamAction::Start { platform, key: _ } => {
ctx.info(&format!("Starting stream to {}...", platform));
ctx.warning("Stream start requires backend integration");
ctx.success("Stream started successfully (mock)");
Expand Down Expand Up @@ -652,12 +652,12 @@ fn execute_plugin_action(ctx: &mut CliContext, action: PluginAction) -> Result<(
}
PluginAction::Enable { name } => {
ctx.info(&format!("Enabling plugin '{}'...", name));
ctx.plugin_manager.start_plugin(name)?;
ctx.plugin_manager.start_plugin(&name)?;
ctx.success("Plugin enabled");
}
PluginAction::Disable { name } => {
ctx.info(&format!("Disabling plugin '{}'...", name));
ctx.plugin_manager.stop_plugin(name)?;
ctx.plugin_manager.stop_plugin(&name)?;
ctx.success("Plugin disabled");
}
PluginAction::Update { name } => {
Expand Down Expand Up @@ -710,7 +710,7 @@ fn execute_diagnostic_action(ctx: &CliContext, action: DiagnosticAction) -> Resu
println!(" Cores: {}", num_cpus::get());

// Check memory
let sys_mem = sys_info::mem_info();
let sys_mem = sys_info::mem_info().map_err(|e| CliError::CommandFailed(format!("Failed to get memory info: {}", e)))?;
println!("✓ Memory: Available");
println!(" Total: {} MB", sys_mem.total / 1024);

Expand All @@ -729,7 +729,7 @@ fn execute_diagnostic_action(ctx: &CliContext, action: DiagnosticAction) -> Resu
DiagnosticAction::CheckRequirements => {
ctx.info("Checking system requirements...");

let sys_mem = sys_info::mem_info();
let sys_mem = sys_info::mem_info().map_err(|e| CliError::CommandFailed(format!("Failed to get memory info: {}", e)))?;
let total_mem_mb = sys_mem.total / 1024;
let cpu_cores = num_cpus::get();

Expand Down Expand Up @@ -782,7 +782,7 @@ fn execute_diagnostic_action(ctx: &CliContext, action: DiagnosticAction) -> Resu
println!(" Hardware acceleration: ✓ Available");
ctx.success("Encoding working correctly");
}
DiagnosticAction::TestStream { server, key } => {
DiagnosticAction::TestStream { server, key: _ } => {
ctx.info(&format!("Testing streaming connection to {}...", server));
println!(" Connection: ✓ Success");
println!(" Authentication: ✓ Success");
Expand All @@ -794,7 +794,7 @@ fn execute_diagnostic_action(ctx: &CliContext, action: DiagnosticAction) -> Resu
println!("OS: {}", std::env::consts::OS);
println!("Arch: {}", std::env::consts::ARCH);
println!("CPU cores: {}", num_cpus::get());
println!("Host: {}", gethostname::gethostname().unwrap_or_else(|_| "unknown".to_string()));
println!("Host: {}", gethostname::gethostname().to_string_lossy());

if let Ok(disk) = sys_info::disk_info() {
println!("Disk total: {} GB", disk.total / 1024 / 1024);
Expand Down Expand Up @@ -1096,6 +1096,12 @@ impl From<ConfigError> for CliError {
}
}

impl From<crate::pdk::PluginError> for CliError {
fn from(error: crate::pdk::PluginError) -> Self {
CliError::PluginError(error.to_string())
}
}

/// Main entry point for CLI
pub fn run_cli() -> Result<(), CliError> {
let args = Cli::parse();
Expand Down
5 changes: 2 additions & 3 deletions src-tauri/src/cloud.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use tauri::State;

Expand Down Expand Up @@ -467,8 +466,8 @@ pub fn get_vod_qualities() -> Vec<String> {
/// Test cloud connection
#[tauri::command]
pub fn test_cloud_connection(
provider: String,
api_key: String,
_provider: String,
_api_key: String,
) -> Result<bool, String> {
// Simulate connection test
// In production, this would actually test the connection
Expand Down
Loading
Loading