private void checkHardwareAcceleration_CheckedChanged(object sender, EventArgs e) { bool succeeded = false; if (checkHardwareAcceleration.Checked) { if (HardwareAcceleration.CanEnable) { succeeded = HardwareAcceleration.Enable(); } else { MessageBox.Show("Cannot enable hardware acceleration, the libraries libEGL.dll and libGLESv2.dll could not be restored.", Program.BrandName + " Settings", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { succeeded = HardwareAcceleration.Disable(); } if (succeeded) { PromptRestart(); } else { checkHardwareAcceleration.CheckedChanged -= checkHardwareAcceleration_CheckedChanged; checkHardwareAcceleration.Checked = HardwareAcceleration.IsEnabled; checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged; } }
/// <summary> /// Initializes a video encoder resource asynchronously. This should be called after /// GetSupportedProfiles() and before any functions below. /// </summary> /// <param name="inputFormat">The <code>VideoFrame_Format</code> of the /// frames which will be encoded.</param> /// <param name="inputVisibleSize">A <code>Size</code> specifying the /// dimensions of the visible part of the input frames.</param> /// <param name="outputProfile">A <code>VideoProfile</code> specifying the /// codec profile of the encoded output stream.</param> /// <param name="initialBitrate">The initial bitrate of the encoded output stream</param> /// <param name="acceleration">A <code>HardwareAcceleration</code> specifying /// whether to use a hardware accelerated or a software implementation.</param> /// <param name="messageLoop">Optional MessageLoop instance that can be used to post the command to</param> /// <returns>Error code. Returns NotSupported if video encoding is not available, or the /// requested codec profile is not supported. /// Returns NoMemory if frame and bitstream buffers can't be created.</returns> public Task <PPError> InitializeAsync(VideoFrameFormat inputFormat, PPSize inputVisibleSize, VideoProfile outputProfile, uint initialBitrate, HardwareAcceleration acceleration, MessageLoop messageLoop = null) => InitializeAsyncCore(inputFormat, inputVisibleSize, outputProfile, initialBitrate, acceleration, messageLoop);
public VideoOption(VideoOption videoOption) { this.rotation = videoOption.rotation; this.width = videoOption.width; this.height = videoOption.height; this.hardwareAcceleration = videoOption.hardwareAcceleration; }
internal VideoProfileDescription(PPVideoProfileDescription01 profileDescription) { Profile = (VideoProfile)profileDescription.profile; MaxResolution = profileDescription.max_resolution; MaxFramerateNumerator = profileDescription.max_framerate_numerator; MaxFramerateDenominator = profileDescription.max_framerate_denominator; HardwareAcceleration = (HardwareAcceleration)profileDescription.acceleration; }
/// <summary> /// Initializes a video encoder resource. This should be called after /// GetSupportedProfiles() and before any functions below. /// </summary> /// <param name="inputFormat">The <code>VideoFrame_Format</code> of the /// frames which will be encoded.</param> /// <param name="inputVisibleSize">A <code>Size</code> specifying the /// dimensions of the visible part of the input frames.</param> /// <param name="outputProfile">A <code>VideoProfile</code> specifying the /// codec profile of the encoded output stream.</param> /// <param name="initialBitrate">The initial bitrate of the encoded output stream</param> /// <param name="acceleration">A <code>HardwareAcceleration</code> specifying /// whether to use a hardware accelerated or a software implementation.</param> /// <returns>Error code. Returns NotSupported if video encoding is not available, or the /// requested codec profile is not supported. /// Returns NoMemory if frame and bitstream buffers can't be created.</returns> public PPError Initialize(VideoFrameFormat inputFormat, PPSize inputVisibleSize, VideoProfile outputProfile, uint initialBitrate, HardwareAcceleration acceleration) => (PPError)PPBVideoEncoder.Initialize(this, (PPVideoFrameFormat)inputFormat, inputVisibleSize, (PPVideoProfile)outputProfile, initialBitrate, (PPHardwareAcceleration)acceleration, new CompletionCallback(OnInitialize));
private async Task <PPError> InitializeAsyncCore(VideoFrameFormat inputFormat, PPSize inputVisibleSize, VideoProfile outputProfile, uint initialBitrate, HardwareAcceleration acceleration, MessageLoop messageLoop = null) { var tcs = new TaskCompletionSource <PPError>(); EventHandler <PPError> handler = (s, e) => { tcs.TrySetResult(e); }; try { HandleInitialize += handler; if (MessageLoop == null && messageLoop == null) { Initialize(inputFormat, inputVisibleSize, outputProfile, initialBitrate, acceleration); } else { Action <PPError> action = new Action <PPError>((e) => { var result = (PPError)PPBVideoEncoder.Initialize(this, (PPVideoFrameFormat)inputFormat, inputVisibleSize, (PPVideoProfile)outputProfile, initialBitrate, (PPHardwareAcceleration)acceleration, new BlockUntilComplete() ); tcs.TrySetResult(result); } ); InvokeHelper(action, messageLoop); } return(await tcs.Task); } catch (Exception exc) { Console.WriteLine(exc.Message); tcs.SetException(exc); return(PPError.Aborted); } finally { HandleInitialize -= handler; } }