private async void ButtonConnect_Click(object sender, RoutedEventArgs e) { string connectAddr = InputIP.Text + ":" + InputPort.Text; string connectPSK = InputPSK.Text; ButtonConnect.IsEnabled = false; Debug.WriteLine("Connect to " + connectAddr); var myStatus = new CMsgRemoteClientBroadcastStatus() { Version = 8, MinVersion = 6, ConnectPort = SteamDiscoveryTransport.STEAM_DISCOVERY_PORT, Hostname = "my-fake-name", EnabledServices = (uint)ERemoteClientService.KEremoteClientServiceGameStreaming, Ostype = (int)EOSType.Windows10, Is64Bit = true, Euniverse = (int)EUniverse.Public, GamesRunning = false, }; myStatus.Users.Add(new CMsgRemoteClientBroadcastStatus.Types.User() { Steamid = 76561198009414634, // adjust to yours AuthKeyId = 00000000 // removed }); byte[] psk = Hexlify.StringToByteArray(connectPSK); // you can get this (and the AuthKeyId above) in C:\Program Files (x86)\Steam\userdata\[your user id]\config\localconfig.vdf under the SharedAuth section TlsPskClient tlsClient = new TlsPskClient(); tlsClient.Connect(connectAddr, "steam", psk); SteamRemote steamRemote = new SteamRemote(tlsClient, false, 1337, new Random().NextLong(), myStatus); steamRemote.MyApps.Add(new CMsgRemoteClientAppStatus.Types.AppStatus() { AppId = 391540, AppState = 4 }); await steamRemote.Start(); CMsgRemoteClientStartStreamResponse startResponse = await steamRemote.StartStream(new CMsgRemoteClientStartStream() { AppId = 391540, LaunchOption = -1, MaximumResolutionX = 1920, MaximumResolutionY = 1080, AudioChannelCount = 2 }); SteamStreamClient stream = new SteamStreamClient(new IPEndPoint(IPAddress.Parse(InputIP.Text), (int)startResponse.StreamPort), startResponse.AuthToken.ToByteArray(), this); stream.Connect(); unsafe { ffmpeg.av_log_set_level(ffmpeg.AV_LOG_VERBOSE); //ffmpeg.av_log_set_level(ffmpeg.AV_LOG_DEBUG); cb = libav_log; ffmpeg.av_log_set_callback(new av_log_set_callback_callback_func() { Pointer = Marshal.GetFunctionPointerForDelegate(cb) }); AVCodec *codec = ffmpeg.avcodec_find_decoder(AVCodecID.AV_CODEC_ID_H264); if (codec == null) { throw new InvalidOperationException("Unsupported codec"); } avparser = ffmpeg.av_parser_init((int)codec->id); avparser->flags |= ffmpeg.PARSER_FLAG_COMPLETE_FRAMES; avctx = ffmpeg.avcodec_alloc_context3(codec); if (ffmpeg.avcodec_open2(avctx, codec, null) < 0) { throw new Exception("Could not open codec"); } } }
private async void MainWindow_Loaded(object sender, RoutedEventArgs e) { var myStatus = new CMsgRemoteClientBroadcastStatus() { Version = 8, MinVersion = 6, ConnectPort = SteamDiscoveryTransport.STEAM_DISCOVERY_PORT, Hostname = "my-fake-name", EnabledServices = (uint)ERemoteClientService.KEremoteClientServiceGameStreaming, Ostype = (int)EOSType.Windows10, Is64Bit = true, Euniverse = (int)EUniverse.Public, GamesRunning = false, }; myStatus.Users.Add(new CMsgRemoteClientBroadcastStatus.Types.User() { Steamid = 76561198009414634, AuthKeyId = 00000000 // removed }); byte[] psk = Hexlify.StringToByteArray("0000000000000000000000000000000000000000000000000000000000000000"); // removed TlsPskClient tlsClient = new TlsPskClient(); tlsClient.Connect("127.0.0.1:27036", "steam", psk); SteamRemote steamRemote = new SteamRemote(tlsClient, false, 1337, new Random().NextLong(), myStatus); steamRemote.MyApps.Add(new CMsgRemoteClientAppStatus.Types.AppStatus() { AppId = 391540, AppState = 4 }); await steamRemote.Start(); CMsgRemoteClientStartStreamResponse startResponse = await steamRemote.StartStream(new CMsgRemoteClientStartStream() { AppId = 391540, LaunchOption = -1, MaximumResolutionX = 1920, MaximumResolutionY = 1080, AudioChannelCount = 2 }); /*Process process = new Process(); * process.StartInfo.FileName = @"C:\Program Files (x86)\Steam\streaming_client.exe"; * process.StartInfo.WorkingDirectory = @"C:\Program Files (x86)\Steam"; * process.StartInfo.Arguments = "--gameid " + 391540 + " --server 127.0.0.1:" + startResponse.StreamPort + " --quality 2 " + Hexlify.ByteArrayToString(startResponse.AuthToken.ToByteArray()); * Console.WriteLine(process.StartInfo.Arguments); * process.Start();*/ SteamStreamClient stream = new SteamStreamClient(new IPEndPoint(IPAddress.Parse("127.0.0.1"), (int)startResponse.StreamPort), startResponse.AuthToken.ToByteArray(), this); stream.Connect(); unsafe { ffmpeg.av_log_set_level(ffmpeg.AV_LOG_INFO); AVCodec *codec = ffmpeg.avcodec_find_decoder(AVCodecID.AV_CODEC_ID_H264); if (codec == null) { throw new InvalidOperationException("Unsupported codec"); } avctx = ffmpeg.avcodec_alloc_context3(codec); avctx->width = 1920; avctx->height = 1080; if (ffmpeg.avcodec_open2(avctx, codec, null) < 0) { throw new Exception("Could not open codec"); } } }