public SdlProducer( NanoClient client, AudioFormat audioFormat, VideoFormat videoFormat, bool fullscreen = false, bool useController = true ) { _cancellationTokenSource = new CancellationTokenSource(); _client = client; _audioRenderer = new SdlAudio((int)audioFormat.SampleRate, (int)audioFormat.Channels); _videoRenderer = new SdlVideo((int)videoFormat.Width, (int)videoFormat.Height, fullscreen); Decoder = new FFmpegDecoder(client, audioFormat, videoFormat); string baseDir = AppDomain.CurrentDomain.BaseDirectory; _useController = useController; if (_useController) { Input = new SdlInput($"{baseDir}/gamecontrollerdb.txt"); HandleInputEvent += Input.HandleInput; } }
public Xstream() { InitializeComponent(); // Start Nano (gamestreaming) _cancellationTokenSource = new CancellationTokenSource(); _audioRenderer = new FormAudio( (int)Program.AudioFormat.SampleRate, (int)Program.AudioFormat.Channels); // FormVideo this.ClientSize = new Size((int)Program.VideoFormat.Width, (int)Program.VideoFormat.Height); _fontSourceRegular = $"{AppDomain.CurrentDomain.BaseDirectory}Fonts/Xolonium-Regular.ttf"; _fontSourceBold = $"{AppDomain.CurrentDomain.BaseDirectory}Fonts/Xolonium-Bold.ttf"; Decoder = new FFmpegDecoder(Program.Nano, Program.AudioFormat, Program.VideoFormat); }
Rectangle _windowed;// Stored position and size for windowed mode public Xstream() { InitializeComponent(); VideoDisplay display = _displays[GetWindowDisplayIndex()]; Rectangle bounds = GetDisplayBounds(display); _windowed.Width = Program.Nano.Configuration.VideoMaximumWidth; _windowed.Height = Program.Nano.Configuration.VideoMaximumHeight; _windowed.X = bounds.X + (bounds.Width - _windowed.Width) / 2; _windowed.Y = bounds.Y + (bounds.Height - _windowed.Height) / 2; if (Config.Fullscreen) { //if (Config.Borderless) //{ // FormBorderStyle = FormBorderStyle.None; // WindowState = FormWindowState.Maximized; //} UpdateFullscreenMode(true); } else { ClientSize = new Size(_windowed.Width, _windowed.Height); } // If the window was created fullscreen, make sure the mode code matches UpdateFullscreenMode(Config.Fullscreen); string baseDir = AppDomain.CurrentDomain.BaseDirectory; Bitmap map = new Bitmap($"{baseDir}/Images/icon.png"); Icon = Icon.FromHandle(map.GetHicon()); FormClosed += (object sender, FormClosedEventArgs e) => { Native.DestroyIcon(Icon.Handle); }; Text = Config.CurrentMapping.TokenFilePath; KeyPreview = Config.KeyPreview; KeyDown += (sender, e) => { if (!KeyPreview) { return; } e.SuppressKeyPress = true; switch (e.KeyCode) { default: MessageBox.Show("Form.KeyPress: '" + e.KeyCode + "' consumed."); break; } }; // DirectX / FFMPEG setup _cancellationTokenSource = new CancellationTokenSource(); _audioRenderer = new DxAudio( (int)Program.AudioFormat.SampleRate, (int)Program.AudioFormat.Channels); _videoRenderer = new DxVideo( (int)Program.VideoFormat.Width, (int)Program.VideoFormat.Height); _decoder = new FFmpegDecoder(Program.Nano, Program.AudioFormat, Program.VideoFormat); Program.Nano.AudioFrameAvailable += _decoder.ConsumeAudioData; Program.Nano.VideoFrameAvailable += _decoder.ConsumeVideoData; if (Config.UseController) { _input = new DxInput($"{baseDir}/gamecontrollerdb.txt"); _handleInputEvent += _input.HandleInput; } Shown += (object sender, EventArgs e) => { _thread = new Thread(MainLoop); _thread.Start(); }; }
private void ReplaceAudioButton_Click(object sender, EventArgs e) { OpenDialog.Multiselect = true; OpenDialog.Title = "Select audio files"; OpenDialog.Filter = "Common Audio Files|*.ogg;*.wav;*.flac;*.mp3;*.aiff;*.ac3|All Files|*"; if (OpenDialog.ShowDialog(this) == DialogResult.Cancel) { return; } bool allogg = true; using (DelayedStreamCache cache = new DelayedStreamCache()) { FormatData data = new TemporaryFormatData(); AudioFormat format = new AudioFormat(); List <string> names = new List <string>(); Stream[] streams = new Stream[OpenDialog.FileNames.Length]; for (int i = 0; i < streams.Length; i++) { string filename = OpenDialog.FileNames[i]; streams[i] = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); cache.AddStream(streams[i]); IDecoder decoder; if (new EndianReader(streams[i], Endianness.BigEndian).ReadUInt32() != OggMagic) { allogg = false; streams[i].Position = 0; decoder = new FFmpegDecoder(streams[i]); } else { decoder = new RawkAudio.Decoder(streams[i], RawkAudio.Decoder.AudioFormat.VorbisOgg); } for (int k = 0; k < decoder.Channels; k++) { names.Add(Path.GetFileName(filename) + " [Channel #" + (k + 1).ToString("0") + "]"); float balance = 0; if (decoder.Channels == 2) { balance = k == 0 ? -1 : 1; } format.Mappings.Add(new AudioFormat.Mapping(0, balance, Platform.InstrumentFromString(Path.GetFileNameWithoutExtension(filename)))); } decoder.Dispose(); streams[i].Position = 0; } if (AudioForm.Show(format, names.ToArray(), this) == DialogResult.Cancel) { return; } foreach (IFormat audioformat in Data.GetFormats(FormatType.Audio)) { foreach (string audiostream in Data.GetStreamNames(audioformat)) { Data.DeleteStream(audiostream); } } if (allogg) { AudioFormatOgg.Instance.Create(data, streams, format); } else { AudioFormatFFmpeg.Instance.Create(data, streams, format); } data.SaveTo(Data); } UpdateAudioSizes(); }
public DecoderTests() { _decoder = new FFmpegDecoder(); }