Skip to content

Commit

Permalink
Updated dependencies 🔥
Browse files Browse the repository at this point in the history
  • Loading branch information
NiiightmareXD committed Aug 5, 2024
1 parent fa261c7 commit de4165d
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 28 deletions.
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ parking_lot = "0.12.3"
rayon = "1.10.0"

# Error handling
thiserror = "1.0.61"
thiserror = "1.0.63"

[package.metadata.docs.rs]
default-target = "x86_64-pc-windows-msvc"
Expand Down
10 changes: 10 additions & 0 deletions src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl<T: GraphicsCaptureApiHandler + Send + 'static, E> CaptureControl<T, E> {
///
/// The newly created CaptureControl struct.
#[must_use]
#[inline]
pub fn new(
thread_handle: JoinHandle<Result<(), GraphicsCaptureApiError<E>>>,
halt_handle: Arc<AtomicBool>,
Expand All @@ -86,6 +87,7 @@ impl<T: GraphicsCaptureApiHandler + Send + 'static, E> CaptureControl<T, E> {
///
/// `true` if the capture thread is finished, `false` otherwise.
#[must_use]
#[inline]
pub fn is_finished(&self) -> bool {
self.thread_handle
.as_ref()
Expand All @@ -98,6 +100,7 @@ impl<T: GraphicsCaptureApiHandler + Send + 'static, E> CaptureControl<T, E> {
///
/// The join handle for the capture thread.
#[must_use]
#[inline]
pub fn into_thread_handle(self) -> JoinHandle<Result<(), GraphicsCaptureApiError<E>>> {
self.thread_handle.unwrap()
}
Expand All @@ -108,6 +111,7 @@ impl<T: GraphicsCaptureApiHandler + Send + 'static, E> CaptureControl<T, E> {
///
/// The halt handle used to pause the capture thread.
#[must_use]
#[inline]
pub fn halt_handle(&self) -> Arc<AtomicBool> {
self.halt_handle.clone()
}
Expand All @@ -118,6 +122,7 @@ impl<T: GraphicsCaptureApiHandler + Send + 'static, E> CaptureControl<T, E> {
///
/// The callback struct used to call struct methods directly.
#[must_use]
#[inline]
pub fn callback(&self) -> Arc<Mutex<T>> {
self.callback.clone()
}
Expand All @@ -127,6 +132,7 @@ impl<T: GraphicsCaptureApiHandler + Send + 'static, E> CaptureControl<T, E> {
/// # Returns
///
/// `Ok(())` if the capturing thread stops successfully, an error otherwise.
#[inline]
pub fn wait(mut self) -> Result<(), CaptureControlError<E>> {
if let Some(thread_handle) = self.thread_handle.take() {
match thread_handle.join() {
Expand All @@ -147,6 +153,7 @@ impl<T: GraphicsCaptureApiHandler + Send + 'static, E> CaptureControl<T, E> {
/// # Returns
///
/// `Ok(())` if the capture thread stops successfully, an error otherwise.
#[inline]
pub fn stop(mut self) -> Result<(), CaptureControlError<E>> {
self.halt_handle.store(true, atomic::Ordering::Relaxed);

Expand Down Expand Up @@ -226,6 +233,7 @@ pub trait GraphicsCaptureApiHandler: Sized {
/// # Returns
///
/// Returns `Ok(())` if the capture was successful, otherwise returns an error of type `GraphicsCaptureApiError`.
#[inline]
fn start<T: TryInto<GraphicsCaptureItem>>(
settings: Settings<Self::Flags, T>,
) -> Result<(), GraphicsCaptureApiError<Self::Error>>
Expand Down Expand Up @@ -332,6 +340,7 @@ pub trait GraphicsCaptureApiHandler: Sized {
/// # Returns
///
/// Returns `Ok(CaptureControl)` if the capture was successful, otherwise returns an error of type `GraphicsCaptureApiError`.
#[inline]
fn start_free_threaded<T: TryInto<GraphicsCaptureItem> + Send + 'static>(
settings: Settings<Self::Flags, T>,
) -> Result<CaptureControl<Self, Self::Error>, GraphicsCaptureApiError<Self::Error>>
Expand Down Expand Up @@ -499,6 +508,7 @@ pub trait GraphicsCaptureApiHandler: Sized {
/// # Returns
///
/// Returns `Ok(())` if the handler execution was successful, otherwise returns an error of type `Self::Error`.
#[inline]
fn on_closed(&mut self) -> Result<(), Self::Error> {
Ok(())
}
Expand Down
4 changes: 4 additions & 0 deletions src/d3d11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ impl<T> SendDirectX<T> {
/// # Returns
///
/// Returns A New `SendDirectX` Instance
#[must_use]
#[inline]
pub const fn new(device: T) -> Self {
Self(device)
}
Expand All @@ -48,6 +50,7 @@ impl<T> SendDirectX<T> {
unsafe impl<T> Send for SendDirectX<T> {}

/// Create `ID3D11Device` and `ID3D11DeviceContext`
#[inline]
pub fn create_d3d_device() -> Result<(ID3D11Device, ID3D11DeviceContext), Error> {
// Array of Direct3D feature levels.
// The feature levels are listed in descending order of capability.
Expand Down Expand Up @@ -88,6 +91,7 @@ pub fn create_d3d_device() -> Result<(ID3D11Device, ID3D11DeviceContext), Error>
}

/// Create `IDirect3DDevice` From `ID3D11Device`
#[inline]
pub fn create_direct3d_device(d3d_device: &ID3D11Device) -> Result<IDirect3DDevice, Error> {
let dxgi_device: IDXGIDevice = d3d_device.cast()?;
let inspectable = unsafe { CreateDirect3D11DeviceFromDXGIDevice(&dxgi_device)? };
Expand Down
19 changes: 12 additions & 7 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ impl ImageEncoder {
/// # Returns
///
/// A new `ImageEncoder` instance.
#[must_use]
#[inline]
pub const fn new(format: ImageFormat, color_format: ColorFormat) -> Self {
Self {
format,
Expand All @@ -90,6 +92,7 @@ impl ImageEncoder {
/// # Errors
///
/// Returns an `Error` if the encoding fails or if the color format is unsupported.
#[inline]
pub fn encode(
&self,
image_buffer: &[u8],
Expand Down Expand Up @@ -210,6 +213,7 @@ impl VideoEncoder {
///
/// Returns a `Result` containing the `VideoEncoder` instance if successful, or a
/// `VideoEncoderError` if an error occurs.
#[inline]
pub fn new<P: AsRef<Path>>(
encoder_type: VideoEncoderType,
encoder_quality: VideoEncoderQuality,
Expand Down Expand Up @@ -240,12 +244,8 @@ impl VideoEncoder {
MediaEncodingProfile::CreateVp9(VideoEncodingQuality(encoder_quality as i32))?
}
};
media_encoding_profile
.Video()?
.SetWidth(width)?;
media_encoding_profile
.Video()?
.SetHeight(height)?;
media_encoding_profile.Video()?.SetWidth(width)?;
media_encoding_profile.Video()?.SetHeight(height)?;
if fps.is_some() {
media_encoding_profile
.Video()?
Expand All @@ -256,7 +256,7 @@ impl VideoEncoder {
.FrameRate()?
.SetDenominator(1)?;
}

let video_encoding_properties = VideoEncodingProperties::CreateUncompressed(
&MediaEncodingSubtypes::Bgra8()?,
width,
Expand Down Expand Up @@ -402,6 +402,7 @@ impl VideoEncoder {
///
/// Returns a `Result` containing the `VideoEncoder` instance if successful, or a
/// `VideoEncoderError` if an error occurs.
#[inline]
pub fn new_from_stream<P: AsRef<Path>>(
encoder_type: VideoEncoderType,
encoder_quality: VideoEncoderQuality,
Expand Down Expand Up @@ -562,6 +563,7 @@ impl VideoEncoder {
///
/// Returns `Ok(())` if the frame is successfully sent for encoding, or a `VideoEncoderError`
/// if an error occurs.
#[inline]
pub fn send_frame(&mut self, frame: &mut Frame) -> Result<(), VideoEncoderError> {
let timespan = match self.first_timespan {
Some(timespan) => TimeSpan {
Expand Down Expand Up @@ -608,6 +610,7 @@ impl VideoEncoder {
///
/// Returns `Ok(())` if the frame is successfully sent for encoding, or a `VideoEncoderError`
/// if an error occurs.
#[inline]
pub fn send_frame_buffer(
&mut self,
buffer: &[u8],
Expand Down Expand Up @@ -655,6 +658,7 @@ impl VideoEncoder {
///
/// Returns `Ok(())` if the encoding is successfully finished, or a `VideoEncoderError` if an
/// error occurs.
#[inline]
pub fn finish(mut self) -> Result<(), VideoEncoderError> {
self.frame_sender.send(None)?;

Expand All @@ -673,6 +677,7 @@ impl VideoEncoder {
}

impl Drop for VideoEncoder {
#[inline]
fn drop(&mut self) {
let _ = self.frame_sender.send(None);

Expand Down
Loading

0 comments on commit de4165d

Please sign in to comment.