rocket-welder-sdk 1.0.5__py3-none-any.whl → 1.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.
@@ -0,0 +1,496 @@
1
+ Metadata-Version: 2.4
2
+ Name: rocket-welder-sdk
3
+ Version: 1.1.0
4
+ Summary: High-performance video streaming SDK for RocketWelder services using ZeroBuffer IPC
5
+ Home-page: https://github.com/modelingevolution/rocket-welder-sdk
6
+ Author: ModelingEvolution
7
+ Author-email: ModelingEvolution <info@modelingevolution.com>
8
+ Maintainer-email: ModelingEvolution <info@modelingevolution.com>
9
+ License: MIT
10
+ Project-URL: Homepage, https://github.com/modelingevolution/rocket-welder-sdk
11
+ Project-URL: Repository, https://github.com/modelingevolution/rocket-welder-sdk.git
12
+ Project-URL: Issues, https://github.com/modelingevolution/rocket-welder-sdk/issues
13
+ Keywords: video,streaming,gstreamer,ipc,shared-memory,zerobuffer,computer-vision
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Topic :: Multimedia :: Video
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Operating System :: OS Independent
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ Requires-Dist: numpy>=1.20.0
29
+ Requires-Dist: opencv-python>=4.5.0
30
+ Requires-Dist: zerobuffer-ipc>=1.1.10
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=7.0; extra == "dev"
33
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
34
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
35
+ Requires-Dist: black>=22.0; extra == "dev"
36
+ Requires-Dist: mypy>=1.0; extra == "dev"
37
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
38
+ Requires-Dist: types-setuptools; extra == "dev"
39
+ Dynamic: author
40
+ Dynamic: home-page
41
+ Dynamic: requires-python
42
+
43
+ # Rocket Welder SDK
44
+
45
+ [![NuGet](https://img.shields.io/nuget/v/RocketWelder.SDK.svg)](https://www.nuget.org/packages/RocketWelder.SDK/)
46
+ [![PyPI](https://img.shields.io/pypi/v/rocket-welder-sdk.svg)](https://pypi.org/project/rocket-welder-sdk/)
47
+ [![vcpkg](https://img.shields.io/badge/vcpkg-rocket--welder--sdk-blue)](https://github.com/modelingevolution/rocket-welder-sdk-vcpkg-registry)
48
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
49
+
50
+ Multi-language client libraries for interacting with RocketWelder video streaming services.
51
+
52
+ ## Overview
53
+
54
+ The Rocket Welder SDK provides high-performance video streaming capabilities for containerized applications. It offers native client libraries in C++, C#, and Python, enabling seamless integration with RocketWelder video streaming pipelines.
55
+
56
+ ## Features
57
+
58
+ - **High Performance**: Optimized for minimal latency and maximum throughput
59
+ - **Multi-Language Support**: Native libraries for C++, C#, and Python
60
+ - **Protocol Flexibility**: Support for multiple streaming protocols via connection strings
61
+ - **Container-Ready**: Designed for Docker/Kubernetes deployments
62
+ - **Simple Integration**: Easy-to-use API with minimal configuration
63
+
64
+ ## Client Libraries
65
+
66
+ | Language | Package Manager | Package Name |
67
+ |----------|----------------|--------------|
68
+ | C++ | vcpkg | rocket-welder-sdk |
69
+ | C# | NuGet | RocketWelder.SDK |
70
+ | Python | pip | rocket-welder-sdk |
71
+
72
+ ## Connection String Format
73
+
74
+ The SDK uses URI-style connection strings to specify data sources and protocols:
75
+
76
+ ```
77
+ protocol://[host[:port]]/[path][?param1=value1&param2=value2]
78
+ ```
79
+
80
+ ### Supported Protocols
81
+
82
+ #### Shared Memory (High-Performance Local)
83
+ ```
84
+ shm://<buffer_name>
85
+ shm://<buffer_name>?buffer_size=10MB&metadata_size=1024KB
86
+ shm://<buffer_name>?mode=duplex&buffer_size=10MB
87
+ ```
88
+
89
+ **Optional Parameters:**
90
+ - `mode`: Communication mode (`duplex` for bidirectional/mutable, `oneway` for one-way communication; default: `duplex`)
91
+ - `buffer_size`: Size of the data buffer (default: 20MB, supports units: B, KB, MB, GB)
92
+ - `metadata_size`: Size of the metadata buffer (default: 4KB, supports units: B, KB, MB)
93
+
94
+ #### MJPEG over HTTP
95
+ ```
96
+ mjpeg+http://192.168.1.100:8080
97
+ mjpeg+http://camera.local:8080
98
+ ```
99
+
100
+ #### MJPEG over TCP
101
+ ```
102
+ mjpeg+tcp://192.168.1.100:5000
103
+ mjpeg+tcp://camera.local:5000
104
+ ```
105
+
106
+ ### Environment Variable
107
+
108
+ When deployed in a Rocket Welder container, the connection string is provided via:
109
+ ```bash
110
+ CONNECTION_STRING=shm://camera_feed?buffer_size=20MB&metadata_size=4KB
111
+ ```
112
+
113
+ ## Installation
114
+
115
+ ### C++ with vcpkg
116
+
117
+ Configure the custom registry in your `vcpkg-configuration.json`:
118
+ ```json
119
+ {
120
+ "registries": [
121
+ {
122
+ "kind": "git",
123
+ "repository": "https://github.com/modelingevolution/rocket-welder-sdk-vcpkg-registry",
124
+ "baseline": "YOUR_BASELINE_HERE",
125
+ "packages": ["rocket-welder-sdk"]
126
+ }
127
+ ]
128
+ }
129
+ ```
130
+
131
+ Then install:
132
+ ```bash
133
+ # Install via vcpkg
134
+ vcpkg install rocket-welder-sdk
135
+
136
+ # Or integrate with CMake
137
+ find_package(rocket-welder-sdk CONFIG REQUIRED)
138
+ target_link_libraries(your_app PRIVATE rocket-welder-sdk::rocket-welder-sdk)
139
+ ```
140
+
141
+ ### C# with NuGet
142
+
143
+ [![NuGet Downloads](https://img.shields.io/nuget/dt/RocketWelder.SDK.svg)](https://www.nuget.org/packages/RocketWelder.SDK/)
144
+
145
+ ```bash
146
+ # Package Manager Console
147
+ Install-Package RocketWelder.SDK
148
+
149
+ # .NET CLI
150
+ dotnet add package RocketWelder.SDK
151
+
152
+ # PackageReference in .csproj
153
+ <PackageReference Include="RocketWelder.SDK" Version="1.0.*" />
154
+ ```
155
+
156
+ ### Python with pip
157
+
158
+ [![PyPI Downloads](https://img.shields.io/pypi/dm/rocket-welder-sdk.svg)](https://pypi.org/project/rocket-welder-sdk/)
159
+
160
+ ```bash
161
+ # Install from PyPI
162
+ pip install rocket-welder-sdk
163
+
164
+ # Install with optional dependencies
165
+ pip install rocket-welder-sdk[opencv] # Includes OpenCV
166
+ pip install rocket-welder-sdk[all] # All optional dependencies
167
+
168
+ # Install specific version
169
+ pip install rocket-welder-sdk==1.0.0
170
+ ```
171
+
172
+ ## Quick Start
173
+
174
+ ### C++ Quick Start
175
+ ```cpp
176
+ #include <rocket_welder/client.hpp>
177
+
178
+ auto client = rocket_welder::Client::from_connection_string("shm://my-buffer");
179
+ client.on_frame([](cv::Mat& frame) {
180
+ // Process frame
181
+ });
182
+ client.start();
183
+ ```
184
+
185
+ ### C# Quick Start
186
+ ```csharp
187
+ using RocketWelder.SDK;
188
+
189
+ var client = RocketWelderClient.FromConnectionString("shm://my-buffer");
190
+ client.Start(frame => {
191
+ // Process frame
192
+ });
193
+ ```
194
+
195
+ ### Python Quick Start
196
+ ```python
197
+ import rocket_welder_sdk as rw
198
+
199
+ client = rw.Client.from_connection_string("shm://my-buffer")
200
+
201
+ @client.on_frame
202
+ def process(frame):
203
+ # Process frame
204
+ pass
205
+
206
+ client.start()
207
+ ```
208
+
209
+ ## Usage Examples
210
+
211
+ ### C++
212
+
213
+ ```cpp
214
+ #include <rocket_welder/client.hpp>
215
+ #include <opencv2/opencv.hpp>
216
+
217
+ int main(int argc, char* argv[]) {
218
+ // Best practice: use from() which:
219
+ // 1. Checks environment variable (CONNECTION_STRING)
220
+ // 2. Overrides with command line args if provided
221
+ auto client = rocket_welder::Client::from(argc, argv);
222
+
223
+ // Or specify connection string directly
224
+ auto client = rocket_welder::Client::from_connection_string(
225
+ "shm://camera_feed?buffer_size=20MB&metadata_size=4KB"
226
+ );
227
+
228
+ // Process frames as OpenCV Mat (mutable by default)
229
+ client.on_frame([](cv::Mat& frame) {
230
+ // Add overlay text - zero copy!
231
+ cv::putText(frame, "Processing", cv::Point(10, 30),
232
+ cv::FONT_HERSHEY_SIMPLEX, 1.0, cv::Scalar(0, 255, 0), 2);
233
+
234
+ // Add timestamp overlay
235
+ auto now = std::chrono::system_clock::now();
236
+ auto time_t = std::chrono::system_clock::to_time_t(now);
237
+ cv::putText(frame, std::ctime(&time_t), cv::Point(10, 60),
238
+ cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(255, 255, 255), 1);
239
+ });
240
+
241
+ client.start();
242
+ return 0;
243
+ }
244
+ ```
245
+
246
+ ### C#
247
+
248
+ ```csharp
249
+ using RocketWelder.SDK;
250
+ using OpenCvSharp;
251
+
252
+ class Program
253
+ {
254
+ static void Main(string[] args)
255
+ {
256
+ // Best practice: use From() which:
257
+ // 1. Checks environment variable (CONNECTION_STRING)
258
+ // 2. Overrides with command line args if provided
259
+ var client = RocketWelderClient.From(args);
260
+
261
+ // Or specify connection string directly
262
+ var client = RocketWelderClient.FromConnectionString(
263
+ "shm://camera_feed?buffer_size=20MB&metadata_size=4KB"
264
+ );
265
+
266
+ int frameCount = 0;
267
+
268
+ // Process frames as OpenCV Mat
269
+ client.Start((Mat frame) =>
270
+ {
271
+ // Add overlay text
272
+ Cv2.PutText(frame, "Processing", new Point(10, 30),
273
+ HersheyFonts.HersheySimplex, 1.0, new Scalar(0, 255, 0), 2);
274
+
275
+ // Add frame counter overlay
276
+ Cv2.PutText(frame, $"Frame: {frameCount++}", new Point(10, 60),
277
+ HersheyFonts.HersheySimplex, 0.5, new Scalar(255, 255, 255), 1);
278
+ });
279
+ }
280
+ }
281
+ ```
282
+
283
+ ### Python
284
+
285
+ ```python
286
+ import rocket_welder_sdk as rw
287
+ import cv2
288
+ import sys
289
+
290
+ # Best practice: use from_args() which:
291
+ # 1. Checks environment variable (CONNECTION_STRING)
292
+ # 2. Overrides with command line args if provided
293
+ client = rw.Client.from_args(sys.argv)
294
+
295
+ # Or specify connection string directly
296
+ client = rw.Client.from_connection_string("shm://camera_feed?buffer_size=20MB&metadata_size=4KB")
297
+
298
+ # Process frames as numpy arrays (OpenCV compatible)
299
+ @client.on_frame
300
+ def process_frame(frame: np.ndarray):
301
+ # Add overlay text - zero copy!
302
+ cv2.putText(frame, "Processing", (10, 30),
303
+ cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 0), 2)
304
+
305
+ # Add timestamp overlay
306
+ from datetime import datetime
307
+ timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
308
+ cv2.putText(frame, timestamp, (10, 60),
309
+ cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
310
+
311
+ client.start()
312
+
313
+ # Or use iterator pattern
314
+ for frame in client.frames():
315
+ # Each frame is a numpy array
316
+ print(f"Received frame: {frame.shape}")
317
+ ```
318
+
319
+ ## Docker Integration
320
+
321
+ ### C++ Dockerfile
322
+
323
+ ```dockerfile
324
+ FROM ubuntu:22.04 AS builder
325
+
326
+ # Install build tools and OpenCV
327
+ RUN apt-get update && apt-get install -y \
328
+ build-essential \
329
+ cmake \
330
+ libopencv-dev
331
+
332
+ # Install Rocket Welder SDK via vcpkg
333
+ RUN vcpkg install rocket-welder-sdk
334
+
335
+ # Build your application
336
+ WORKDIR /app
337
+ COPY . .
338
+ RUN cmake . && make
339
+
340
+ FROM ubuntu:22.04
341
+ RUN apt-get update && apt-get install -y libopencv-dev
342
+ COPY --from=builder /app/my_app /usr/local/bin/
343
+ CMD ["my_app"]
344
+ ```
345
+
346
+ ### C# Dockerfile
347
+
348
+ ```dockerfile
349
+ FROM mcr.microsoft.com/dotnet/sdk:8.0 AS builder
350
+
351
+ WORKDIR /app
352
+ COPY *.csproj ./
353
+ RUN dotnet restore
354
+
355
+ COPY . ./
356
+ RUN dotnet publish -c Release -o out
357
+
358
+ FROM mcr.microsoft.com/dotnet/runtime:8.0
359
+ WORKDIR /app
360
+ COPY --from=builder /app/out .
361
+ CMD ["dotnet", "MyApp.dll"]
362
+ ```
363
+
364
+ ### Python Dockerfile
365
+
366
+ ```dockerfile
367
+ FROM python:3.11-slim
368
+
369
+ # Install OpenCV and other dependencies
370
+ RUN apt-get update && apt-get install -y \
371
+ python3-opencv \
372
+ && rm -rf /var/lib/apt/lists/*
373
+
374
+ # Install Rocket Welder SDK and ML frameworks
375
+ RUN pip install --no-cache-dir \
376
+ rocket-welder-sdk \
377
+ numpy \
378
+ ultralytics # Example: YOLO
379
+
380
+ WORKDIR /app
381
+ COPY . .
382
+
383
+ CMD ["python", "app.py"]
384
+ ```
385
+
386
+ ## Protocol Details
387
+
388
+ ### Shared Memory Protocol (shm://)
389
+
390
+ High-performance local data transfer between processes:
391
+
392
+ - **Performance**: Minimal latency, maximum throughput
393
+ - **Use Cases**: Local processing, multi-container applications on same host
394
+
395
+ ### MJPEG over HTTP (mjpeg+http://)
396
+
397
+ Motion JPEG streaming over HTTP:
398
+
399
+ - **Performance**: Good balance of quality and bandwidth
400
+ - **Advantages**: Wide compatibility, firewall-friendly, browser support
401
+ - **Use Cases**: Network streaming, web applications, remote monitoring
402
+
403
+ ### MJPEG over TCP (mjpeg+tcp://)
404
+
405
+ Motion JPEG streaming over raw TCP socket:
406
+
407
+ - **Performance**: Lower latency than HTTP, less protocol overhead
408
+ - **Advantages**: Direct socket connection, minimal overhead, suitable for local networks
409
+ - **Use Cases**: Low-latency streaming, embedded systems, industrial applications
410
+
411
+ ## Building from Source
412
+
413
+ ### Prerequisites
414
+
415
+ - CMake 3.20+
416
+ - C++20 compiler
417
+ - Python 3.8+ (for Python bindings)
418
+ - .NET 6.0+ SDK (for C# bindings)
419
+ - OpenCV 4.0+ (optional, for image processing)
420
+
421
+ ### Build Instructions
422
+
423
+ ```bash
424
+ git clone https://github.com/modelingevolution/rocket-welder-sdk.git
425
+ cd rocket-welder-sdk
426
+
427
+ # Build all libraries
428
+ mkdir build && cd build
429
+ cmake ..
430
+ make -j$(nproc)
431
+
432
+ # Run tests
433
+ ctest
434
+
435
+ # Install
436
+ sudo make install
437
+ ```
438
+
439
+ ## API Reference
440
+
441
+ Detailed API documentation for each language:
442
+
443
+ - [C++ API Reference](docs/cpp-api.md)
444
+ - [C# API Reference](docs/csharp-api.md)
445
+ - [Python API Reference](docs/python-api.md)
446
+
447
+ ## Examples
448
+
449
+ See the [examples](examples/) directory for complete working examples:
450
+
451
+ - [Simple Frame Reader](examples/simple-reader/)
452
+ - [Frame Processor](examples/frame-processor/)
453
+ - [Multi-Stream Handler](examples/multi-stream/)
454
+ - [Performance Benchmark](examples/benchmark/)
455
+
456
+ ## Contributing
457
+
458
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
459
+
460
+ ## License
461
+
462
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
463
+
464
+ ## Support
465
+
466
+ - **Issues**: [GitHub Issues](https://github.com/modelingevolution/rocket-welder-sdk/issues)
467
+ - **Discussions**: [GitHub Discussions](https://github.com/modelingevolution/rocket-welder-sdk/discussions)
468
+ - **Documentation**: [https://docs.rocket-welder.io](https://docs.rocket-welder.io)
469
+
470
+ ## Technical Details
471
+
472
+ ### GStreamer Integration
473
+
474
+ The SDK integrates with GStreamer pipelines through specialized elements:
475
+ - **zerosink**: Simple sink element for writing video frames
476
+ - **zerobuffer**: Processing element with bidirectional communication using DuplexChannel
477
+
478
+ ### Zero-Copy Buffer Technology
479
+
480
+ For shared memory protocol, the SDK uses:
481
+ - **C++**: Zero-Copy-Buffer (via vcpkg) - Returns cv::Mat with zero-copy access
482
+ - **C#**: ZeroBuffer (via NuGet) - Returns OpenCvSharp.Mat with zero-copy access
483
+ - **Python**: zero-buffer (via pip) - Returns numpy arrays compatible with OpenCV
484
+
485
+ The SDK leverages DuplexChannel for bidirectional communication, enabling:
486
+ - Zero-copy frame access as OpenCV Mat objects
487
+ - In-place frame processing without memory allocation
488
+ - Direct memory mapping between producer and consumer
489
+ - Efficient metadata passing alongside frame data
490
+
491
+ This technology enables direct memory access without data duplication, providing maximum performance for local processing scenarios.
492
+
493
+ ## Acknowledgments
494
+
495
+ - GStreamer Project for the multimedia framework
496
+ - ZeroBuffer contributors for the zero-copy buffer implementation
@@ -0,0 +1,11 @@
1
+ rocket_welder_sdk/__init__.py,sha256=6lQUKg8w-qK_5DRFOiydCdirGAj9t-dcCBmDyuW9GNc,909
2
+ rocket_welder_sdk/bytes_size.py,sha256=Myl29-wyWCIYdbMmgaxXebT8Dz8_Fwcr3fnfaNW81P0,7463
3
+ rocket_welder_sdk/connection_string.py,sha256=msDgHD7525UXvrNPqKGpYgQJJtmOfS_XEnX3JA8LIz0,7731
4
+ rocket_welder_sdk/controllers.py,sha256=acrGGBrFvHO2NUIwaj1wsX7bef0Pn3bgYJlcJJUn3bE,24032
5
+ rocket_welder_sdk/gst_metadata.py,sha256=K0FByW-BiRPPmveTPLKl1G3A_f9Tog0i8wukiaaXnig,7201
6
+ rocket_welder_sdk/py.typed,sha256=0cXFZXmes4Y-vnl4lO3HtyyyWaFNw85B7tJdFeCtHDc,67
7
+ rocket_welder_sdk/rocket_welder_client.py,sha256=1-W1ofdMof9njmLOx4eV8vgxtU2xgk96h8V01Yey9wE,5547
8
+ rocket_welder_sdk-1.1.0.dist-info/METADATA,sha256=3g0N-hAnSmhEddO1fl8ox3KkiRL9V6gyOL90Zqr9JAg,14330
9
+ rocket_welder_sdk-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ rocket_welder_sdk-1.1.0.dist-info/top_level.txt,sha256=2iZvBjnwVCUW-uDE23-eJld5PZ9-mlPI69QiXM5IrTA,18
11
+ rocket_welder_sdk-1.1.0.dist-info/RECORD,,
@@ -1,183 +0,0 @@
1
- """
2
- RocketWelder client implementation.
3
- """
4
-
5
- import os
6
- import sys
7
- import time
8
- import threading
9
- from typing import Optional, Callable, Dict, Any, Iterator
10
- import numpy as np
11
- import cv2
12
-
13
-
14
- class Client:
15
- """Client for RocketWelder video streaming services."""
16
-
17
- def __init__(self, connection_string: str):
18
- """
19
- Initialize client with connection string.
20
-
21
- Args:
22
- connection_string: Connection string (e.g., "shm://buffer_name")
23
- """
24
- self.connection_string = connection_string
25
- self._callback: Optional[Callable[[np.ndarray], None]] = None
26
- self._callback_with_metadata: Optional[Callable[[np.ndarray, Dict[str, Any]], None]] = None
27
- self._running = False
28
- self._thread: Optional[threading.Thread] = None
29
-
30
- # TODO: Parse connection string
31
- # TODO: Initialize based on protocol (shm://, mjpeg+http://, etc.)
32
-
33
- @classmethod
34
- def from_args(cls, argv: list) -> 'Client':
35
- """
36
- Create client from command line arguments and environment variables.
37
- Environment variable CONNECTION_STRING is checked first, then overridden by args.
38
-
39
- Args:
40
- argv: Command line arguments (typically sys.argv)
41
-
42
- Returns:
43
- Client instance
44
- """
45
- # Check environment variable first
46
- connection_string = os.environ.get('CONNECTION_STRING')
47
-
48
- # Override with command line args if present
49
- if argv:
50
- for arg in argv[1:]: # Skip program name
51
- if (arg.startswith('shm://') or
52
- arg.startswith('mjpeg+http://') or
53
- arg.startswith('mjpeg+tcp://')):
54
- connection_string = arg
55
- break
56
-
57
- return cls(connection_string or 'shm://default')
58
-
59
- @classmethod
60
- def from_env(cls) -> 'Client':
61
- """
62
- Create client from environment variable CONNECTION_STRING.
63
-
64
- Returns:
65
- Client instance
66
- """
67
- connection_string = os.environ.get('CONNECTION_STRING', 'shm://default')
68
- return cls(connection_string)
69
-
70
- @classmethod
71
- def from_connection_string(cls, connection_string: str) -> 'Client':
72
- """
73
- Create client from a specific connection string.
74
-
75
- Args:
76
- connection_string: Connection string
77
-
78
- Returns:
79
- Client instance
80
- """
81
- return cls(connection_string)
82
-
83
- def on_frame(self, callback: Callable) -> Callable:
84
- """
85
- Decorator/method to set frame processing callback.
86
-
87
- The callback can have one of these signatures:
88
- - callback(frame: np.ndarray) -> None
89
- - callback(frame: np.ndarray, metadata: dict) -> None
90
-
91
- Args:
92
- callback: Function to process frames
93
-
94
- Returns:
95
- The callback function (for decorator usage)
96
- """
97
- import inspect
98
- sig = inspect.signature(callback)
99
- param_count = len(sig.parameters)
100
-
101
- if param_count == 1:
102
- self._callback = callback
103
- elif param_count == 2:
104
- self._callback_with_metadata = callback
105
- else:
106
- raise ValueError(f"Callback must have 1 or 2 parameters, got {param_count}")
107
-
108
- return callback
109
-
110
- def start(self):
111
- """Start frame processing."""
112
- if self._running:
113
- return
114
-
115
- if not self._callback and not self._callback_with_metadata:
116
- raise RuntimeError("Frame callback must be set before starting")
117
-
118
- self._running = True
119
- self._thread = threading.Thread(target=self._process_frames)
120
- self._thread.daemon = True
121
- self._thread.start()
122
-
123
- def stop(self):
124
- """Stop frame processing."""
125
- if not self._running:
126
- return
127
-
128
- self._running = False
129
- if self._thread:
130
- self._thread.join(timeout=5.0)
131
- self._thread = None
132
-
133
- def is_running(self) -> bool:
134
- """Check if client is running."""
135
- return self._running
136
-
137
- def frames(self) -> Iterator[np.ndarray]:
138
- """
139
- Iterator interface for frame processing.
140
-
141
- Yields:
142
- Frame as numpy array
143
- """
144
- # TODO: Implement actual frame reading
145
- # For now, generate dummy frames for testing
146
- while True:
147
- # Create dummy frame
148
- frame = np.zeros((480, 640, 3), dtype=np.uint8)
149
- yield frame
150
- time.sleep(0.033) # ~30 FPS
151
-
152
- def _process_frames(self):
153
- """Internal method to process frames in thread."""
154
- # TODO: Implement actual frame processing
155
- # For now, generate dummy frames for testing
156
- while self._running:
157
- # Create dummy frame
158
- frame = np.zeros((480, 640, 3), dtype=np.uint8)
159
-
160
- # Create dummy metadata
161
- metadata = {
162
- 'timestamp': time.time(),
163
- 'format': 'BGR',
164
- 'width': 640,
165
- 'height': 480
166
- }
167
-
168
- # Call appropriate callback
169
- if self._callback:
170
- self._callback(frame)
171
- elif self._callback_with_metadata:
172
- self._callback_with_metadata(frame, metadata)
173
-
174
- time.sleep(0.033) # ~30 FPS
175
-
176
- def __enter__(self):
177
- """Context manager entry."""
178
- self.start()
179
- return self
180
-
181
- def __exit__(self, exc_type, exc_val, exc_tb):
182
- """Context manager exit."""
183
- self.stop()
@@ -1,20 +0,0 @@
1
- """
2
- Rocket Welder SDK - Python client for RocketWelder video streaming services
3
-
4
- Zero-copy video streaming and processing with shared memory buffers.
5
- """
6
-
7
- __version__ = "1.0.0"
8
-
9
- from .connection_string import ConnectionString, Protocol
10
- from .gst_caps import GstCaps
11
- from .client import RocketWelderClient
12
- from .exceptions import RocketWelderException
13
-
14
- __all__ = [
15
- "ConnectionString",
16
- "Protocol",
17
- "GstCaps",
18
- "RocketWelderClient",
19
- "RocketWelderException",
20
- ]