capturekit 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. capturekit/__init__.py +164 -0
  2. capturekit/_backends/__init__.py +0 -0
  3. capturekit/_backends/base.py +89 -0
  4. capturekit/_backends/linux/__init__.py +1 -0
  5. capturekit/_backends/linux/_xlib.py +655 -0
  6. capturekit/_backends/linux/api.py +160 -0
  7. capturekit/_backends/linux/pulse.py +464 -0
  8. capturekit/_backends/linux/x11.py +720 -0
  9. capturekit/_backends/windows/__init__.py +0 -0
  10. capturekit/_backends/windows/_com.py +350 -0
  11. capturekit/_backends/windows/_d3d11.py +307 -0
  12. capturekit/_backends/windows/_win32.py +420 -0
  13. capturekit/_backends/windows/_winrt.py +162 -0
  14. capturekit/_backends/windows/api.py +214 -0
  15. capturekit/_backends/windows/cursor.py +66 -0
  16. capturekit/_backends/windows/dxgi_duplication.py +310 -0
  17. capturekit/_backends/windows/wasapi.py +570 -0
  18. capturekit/_backends/windows/wgc.py +398 -0
  19. capturekit/_pipeline/__init__.py +1 -0
  20. capturekit/_pipeline/aligner.py +177 -0
  21. capturekit/_pipeline/clock.py +47 -0
  22. capturekit/_pipeline/frame_queue.py +120 -0
  23. capturekit/_pipeline/mixer.py +80 -0
  24. capturekit/_pipeline/timeline.py +133 -0
  25. capturekit/_platform.py +24 -0
  26. capturekit/_version.py +1 -0
  27. capturekit/_worker.py +100 -0
  28. capturekit/capabilities.py +79 -0
  29. capturekit/capture.py +141 -0
  30. capturekit/config.py +85 -0
  31. capturekit/encoding/__init__.py +5 -0
  32. capturekit/encoding/ffmpeg.py +356 -0
  33. capturekit/encoding/pipes.py +212 -0
  34. capturekit/errors.py +109 -0
  35. capturekit/py.typed +0 -0
  36. capturekit/recording.py +940 -0
  37. capturekit/sources.py +124 -0
  38. capturekit/types.py +211 -0
  39. capturekit-0.1.0.dist-info/METADATA +112 -0
  40. capturekit-0.1.0.dist-info/RECORD +41 -0
  41. capturekit-0.1.0.dist-info/WHEEL +4 -0
capturekit/errors.py ADDED
@@ -0,0 +1,109 @@
1
+ """Exception hierarchy.
2
+
3
+ Every error raised by capturekit derives from :class:`CaptureError` so callers
4
+ can catch library failures with one ``except`` clause while still being able
5
+ to distinguish specific conditions.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+
11
+ class CaptureError(Exception):
12
+ """Base class for all capturekit errors."""
13
+
14
+
15
+ class UnsupportedPlatformError(CaptureError):
16
+ """The operating system is not supported (e.g. macOS)."""
17
+
18
+
19
+ class UnsupportedDisplayServerError(CaptureError):
20
+ """The targeted display server is unsupported (e.g. a Wayland-only session)."""
21
+
22
+
23
+ class CapabilityUnavailableError(CaptureError):
24
+ """A capability exists in capturekit but is unavailable on this system.
25
+
26
+ Examples: process audio loopback on Windows builds older than 20348, or
27
+ XComposite missing on the targeted X server.
28
+ """
29
+
30
+
31
+ class TargetNotFoundError(CaptureError):
32
+ """A requested monitor, window, device or process does not exist."""
33
+
34
+
35
+ class TargetLostError(CaptureError):
36
+ """A capture target disappeared during capture."""
37
+
38
+
39
+ class WindowClosedError(TargetLostError):
40
+ """The captured window was closed or its handle became invalid."""
41
+
42
+
43
+ class InvalidRegionError(CaptureError, ValueError):
44
+ """A crop region is empty or lies outside the capture source."""
45
+
46
+
47
+ class CaptureTimeoutError(CaptureError, TimeoutError):
48
+ """No frame or audio data arrived within the requested time."""
49
+
50
+
51
+ class AccessDeniedError(CaptureError, PermissionError):
52
+ """The OS refused capture (secure desktop, protected content, policy)."""
53
+
54
+
55
+ class AudioDeviceError(CaptureError):
56
+ """Audio device failure."""
57
+
58
+
59
+ class AudioDeviceDisconnectedError(AudioDeviceError, TargetLostError):
60
+ """The audio device was removed or invalidated during capture."""
61
+
62
+
63
+ class EncoderError(CaptureError):
64
+ """FFmpeg/encoder failure. ``stderr_tail`` holds recent encoder output."""
65
+
66
+ def __init__(self, message: str, *, stderr_tail: str = "", returncode: int | None = None):
67
+ super().__init__(
68
+ message if not stderr_tail else f"{message}\n--- ffmpeg ---\n{stderr_tail}"
69
+ )
70
+ self.stderr_tail = stderr_tail
71
+ self.returncode = returncode
72
+
73
+
74
+ class EncoderNotAvailableError(EncoderError):
75
+ """No usable encoder/FFmpeg executable was found."""
76
+
77
+
78
+ class RecorderStateError(CaptureError, RuntimeError):
79
+ """An operation is invalid in the recorder's current state."""
80
+
81
+
82
+ class NativeError(CaptureError, OSError):
83
+ """A native API call failed. ``code`` holds the HRESULT/errno when known."""
84
+
85
+ def __init__(self, what: str, code: int | None = None):
86
+ self.what = what
87
+ self.code = code
88
+ text = what if code is None else f"{what} failed (0x{code & 0xFFFFFFFF:08X})"
89
+ super().__init__(text)
90
+
91
+
92
+ __all__ = [
93
+ "AccessDeniedError",
94
+ "AudioDeviceDisconnectedError",
95
+ "AudioDeviceError",
96
+ "CapabilityUnavailableError",
97
+ "CaptureError",
98
+ "CaptureTimeoutError",
99
+ "EncoderError",
100
+ "EncoderNotAvailableError",
101
+ "InvalidRegionError",
102
+ "NativeError",
103
+ "RecorderStateError",
104
+ "TargetLostError",
105
+ "TargetNotFoundError",
106
+ "UnsupportedDisplayServerError",
107
+ "UnsupportedPlatformError",
108
+ "WindowClosedError",
109
+ ]
capturekit/py.typed ADDED
File without changes