matrice-streaming 0.1.66__py3-none-any.whl → 0.1.68__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.
@@ -17,9 +17,11 @@ try:
17
17
  from .gstreamer_worker_manager import GStreamerWorkerManager
18
18
 
19
19
  GSTREAMER_AVAILABLE = is_gstreamer_available()
20
- except (ImportError, ValueError):
20
+ except (ImportError, ValueError, AttributeError, RuntimeError, TypeError):
21
21
  # ImportError: gi module not available
22
22
  # ValueError: gi.require_version fails when GStreamer not installed
23
+ # AttributeError/RuntimeError/TypeError: other initialization errors
24
+ # Suppress warnings - these are optional dependencies
23
25
  GSTREAMER_AVAILABLE = False
24
26
  GStreamerCameraStreamer = None
25
27
  GStreamerConfig = None
@@ -38,10 +40,9 @@ try:
38
40
  get_available_gpu_count,
39
41
  )
40
42
  NVDEC_AVAILABLE = is_nvdec_available()
41
- print(f"NVDEC_AVAILABLE: {NVDEC_AVAILABLE}")
42
- except Exception as e:
43
- print(f"Error importing NVDEC: {e}")
44
- # NVDEC not available (requires CuPy, PyNvVideoCodec)
43
+ except (ImportError, AttributeError, RuntimeError, TypeError, ValueError) as e:
44
+ # NVDEC not available (requires CuPy, PyNvVideoCodec, cuda_shm_ring_buffer)
45
+ # Suppress warnings - these are optional dependencies
45
46
  NVDEC_AVAILABLE = False
46
47
  NVDECWorkerManager = None
47
48
 
@@ -88,8 +88,13 @@ except ImportError:
88
88
  try:
89
89
  from matrice_common.stream.cuda_shm_ring_buffer import CudaIpcRingBuffer, GlobalFrameCounter
90
90
  RING_BUFFER_AVAILABLE = True
91
- except ImportError:
91
+ except (ImportError, AttributeError, RuntimeError, TypeError):
92
+ # ImportError: module not found
93
+ # AttributeError: cp.ndarray is None (cupy not available)
94
+ # RuntimeError/TypeError: other initialization errors
92
95
  RING_BUFFER_AVAILABLE = False
96
+ CudaIpcRingBuffer = None
97
+ GlobalFrameCounter = None
93
98
 
94
99
  logger = logging.getLogger(__name__)
95
100
 
@@ -415,8 +420,8 @@ def _get_nv12_resize_kernel():
415
420
  """Get or compile the NV12 resize kernel.
416
421
 
417
422
  This kernel resizes NV12 directly (no color conversion).
418
- Output: concatenated Y (H×W) + UV ((H/2)×W) = H×W×1.5 bytes
419
- This is 50% smaller than RGB (H×W×3 bytes).
423
+ Output: concatenated Y (H*W) + UV ((H/2)*W) = H*W*1.5 bytes
424
+ This is 50% smaller than RGB (H*W*3 bytes).
420
425
 
421
426
  Consumer will do: NV12→RGB→CHW→FP16 in one fused kernel.
422
427
  """
@@ -424,9 +429,9 @@ def _get_nv12_resize_kernel():
424
429
  if _nv12_resize_kernel is None and CUPY_AVAILABLE:
425
430
  _nv12_resize_kernel = cp.RawKernel(r'''
426
431
  extern "C" __global__ void nv12_resize(
427
- const unsigned char* src_y, // Source Y plane
428
- const unsigned char* src_uv, // Source UV plane (interleaved)
429
- unsigned char* dst, // Output: Y (H×W) followed by UV ((H/2)×W)
432
+ const unsigned char* src_y,
433
+ const unsigned char* src_uv,
434
+ unsigned char* dst,
430
435
  int src_h, int src_w,
431
436
  int dst_h, int dst_w,
432
437
  int y_stride, int uv_stride
@@ -472,8 +477,8 @@ def nv12_resize(y_plane: cp.ndarray, uv_plane: cp.ndarray,
472
477
  dst_h: int = 640, dst_w: int = 640) -> cp.ndarray:
473
478
  """Resize NV12 without color conversion.
474
479
 
475
- Output: concatenated Y (H×W) + UV ((H/2)×W) as single buffer.
476
- Total size: H×W + (H/2)×W = H×W×1.5 bytes (50% of RGB).
480
+ Output: concatenated Y (H*W) + UV ((H/2)*W) as single buffer.
481
+ Total size: H*W + (H/2)*W = H*W*1.5 bytes (50% of RGB).
477
482
  """
478
483
  kernel = _get_nv12_resize_kernel()
479
484
  if kernel is None:
@@ -499,7 +504,7 @@ def surface_to_nv12(frame, target_h: int = 640, target_w: int = 640) -> Optional
499
504
  """Convert NVDEC surface to resized NV12 (50% smaller than RGB).
500
505
 
501
506
  Output: (H + H/2, W) uint8 - concatenated Y + UV planes.
502
- Total size: H×W×1.5 bytes (vs H×W×3 for RGB).
507
+ Total size: H*W*1.5 bytes (vs H*W*3 for RGB).
503
508
  """
504
509
  if not CUPY_AVAILABLE or frame is None:
505
510
  return None
@@ -547,11 +552,14 @@ def surface_to_nv12(frame, target_h: int = 640, target_w: int = 640) -> Optional
547
552
  return nv12_frame[:, :, cp.newaxis] if nv12_frame is not None else None
548
553
 
549
554
  except Exception as e:
550
- # Safely encode error message (some CUDA errors contain non-ASCII chars like '×')
555
+ # Safely handle any characters in error message (CUDA errors may contain Unicode like ×)
551
556
  try:
552
557
  err_msg = str(e).encode('ascii', errors='replace').decode('ascii')
553
558
  except Exception:
554
- err_msg = "unknown error"
559
+ try:
560
+ err_msg = repr(str(e))[:200]
561
+ except Exception:
562
+ err_msg = "failed to format error message"
555
563
  logger.warning(f"surface_to_nv12 failed: {err_msg}")
556
564
  return None
557
565
 
@@ -564,7 +572,7 @@ class NVDECDecoderPool:
564
572
  """Pool of NVDEC decoders that time-multiplex streams.
565
573
 
566
574
  Each decoder is exclusively owned by one worker thread.
567
- Outputs NV12: 1.5×H×W bytes (50% smaller than RGB).
575
+ Outputs NV12: 1.5*H*W bytes (50% smaller than RGB).
568
576
  """
569
577
 
570
578
  def __init__(self, pool_size: int, gpu_id: int = 0):
@@ -803,8 +811,14 @@ def nvdec_pool_worker(
803
811
  if local_errors <= 3:
804
812
  logger.error(f"Worker {worker_id} write error: {e}")
805
813
 
806
- if decoded_frames and len(ring_buffers) > 0:
807
- next(iter(ring_buffers.values())).sync_writes()
814
+ if decoded_frames:
815
+ # Sync all buffers that received frames in this round
816
+ # Critical for cross-container IPC - ensures GPU writes are visible
817
+ synced_cams = set()
818
+ for cam_id, _ in decoded_frames:
819
+ if cam_id in ring_buffers and cam_id not in synced_cams:
820
+ ring_buffers[cam_id].sync_writes()
821
+ synced_cams.add(cam_id)
808
822
 
809
823
  if num_frames == 0:
810
824
  time.sleep(0.0001)
@@ -50,8 +50,9 @@ NVDEC_AVAILABLE = False
50
50
  try:
51
51
  from .camera_streamer.nvdec_worker_manager import NVDECWorkerManager, is_nvdec_available
52
52
  NVDEC_AVAILABLE = is_nvdec_available()
53
- except ImportError:
54
- # NVDEC not available (requires CuPy, PyNvVideoCodec)
53
+ except (ImportError, AttributeError, RuntimeError, TypeError, ValueError):
54
+ # NVDEC not available (requires CuPy, PyNvVideoCodec, cuda_shm_ring_buffer)
55
+ # Suppress warnings - these are optional dependencies
55
56
  pass
56
57
 
57
58
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice_streaming
3
- Version: 0.1.66
3
+ Version: 0.1.68
4
4
  Summary: Common server utilities for Matrice.ai services
5
5
  Author-email: "Matrice.ai" <dipendra@matrice.ai>
6
6
  License-Expression: MIT
@@ -14,11 +14,11 @@ matrice_streaming/streaming_gateway/dynamic_camera_manager.py,sha256=DCXyufxK_z4
14
14
  matrice_streaming/streaming_gateway/event_listener.py,sha256=7x-TKjsAsSFXlGq88bfGB1IR8A5rJTrAotJEBklyofk,3084
15
15
  matrice_streaming/streaming_gateway/metrics_reporter.py,sha256=N9At7kEvY6mkMzibdcSzyo4JJYhBiy9Kxqtd0AfuGCY,46670
16
16
  matrice_streaming/streaming_gateway/streaming_action.py,sha256=o6favSDGY0wTMBCsx1lai8x7aBSDyGswAvDFIvsPYgA,30189
17
- matrice_streaming/streaming_gateway/streaming_gateway.py,sha256=fxKsR0QkQGyncEkpg-ZtEqTFenlFOD8BlC1baK98a7o,61124
17
+ matrice_streaming/streaming_gateway/streaming_gateway.py,sha256=Bh2pYcB-sovK7MJNp7AxaT4iGUf46pA2UKx4s2OmLOo,61259
18
18
  matrice_streaming/streaming_gateway/streaming_gateway_utils.py,sha256=6kNYgl3f7HmeKFKYUW1IncNv8zT6rqpQxh_FDWEbKow,25271
19
19
  matrice_streaming/streaming_gateway/streaming_status_listener.py,sha256=RgbW0xYbbpmO6ZjkVlh6fg8iqkpRaIShR2dQ3SMVFUw,3161
20
20
  matrice_streaming/streaming_gateway/camera_streamer/ARCHITECTURE.md,sha256=kngsqiS1PdNYhihBoMtoiIf3THJ4OM33E_hxExqzKqY,9980
21
- matrice_streaming/streaming_gateway/camera_streamer/__init__.py,sha256=yW3dwpNw9GbrIDjl1ugKyPsvJ-pWo8TVmqRtEvtJaJE,2000
21
+ matrice_streaming/streaming_gateway/camera_streamer/__init__.py,sha256=nwVY-ySnKvOedeDXakyR_6KPHSz3yzSeaO_4IFMMP4I,2219
22
22
  matrice_streaming/streaming_gateway/camera_streamer/async_camera_worker.py,sha256=Bg7yfkCn2RofLqviq22eKRhdxMYtqaeTFJC2no94_lI,59278
23
23
  matrice_streaming/streaming_gateway/camera_streamer/async_ffmpeg_worker.py,sha256=isBYJnnbdxefkRrV2BsizCSZe1ZDPn5wfoTSOTtObsU,37007
24
24
  matrice_streaming/streaming_gateway/camera_streamer/camera_streamer.py,sha256=1BzWnwfPEWPVQ6gBW7uZFvykq2zEvygd5LWE6uqVRhY,39085
@@ -33,7 +33,7 @@ matrice_streaming/streaming_gateway/camera_streamer/gstreamer_camera_streamer.py
33
33
  matrice_streaming/streaming_gateway/camera_streamer/gstreamer_worker.py,sha256=AqKNJ6q_BxFphOlJ2GaS4WpoLCHXLEu5JVvoKQNrGV0,42822
34
34
  matrice_streaming/streaming_gateway/camera_streamer/gstreamer_worker_manager.py,sha256=jlKwIWWMXpztdyKiyremGmkVyw9mf2AxEmT7154xnrc,22002
35
35
  matrice_streaming/streaming_gateway/camera_streamer/message_builder.py,sha256=W295q6cIm05ReF1ooQus3rsKgZOG3EldZplbQco-OyM,10231
36
- matrice_streaming/streaming_gateway/camera_streamer/nvdec.py,sha256=-vm0wncirN0S8OJu6flwzNxfePFIG4JjAj7GdbQBqzc,52495
36
+ matrice_streaming/streaming_gateway/camera_streamer/nvdec.py,sha256=Y3zhycfTpZ_bF5-Ef55J0iFi9wTLTv4Xxmw-woV1occ,53118
37
37
  matrice_streaming/streaming_gateway/camera_streamer/nvdec_worker_manager.py,sha256=KlcwKFUPVZTQ3J1VIuhPev8Xv9BNw4dj2iLGHrREQCQ,16035
38
38
  matrice_streaming/streaming_gateway/camera_streamer/platform_pipelines.py,sha256=UNjsYYWbUJteOq2tzxISFAbWMa2e9GUExSS6fWc2Aow,27303
39
39
  matrice_streaming/streaming_gateway/camera_streamer/retry_manager.py,sha256=d8tlGoWoeSlgpCgXbUHTM61ekCQZki7TO1HzL2yPVzk,3607
@@ -49,8 +49,8 @@ matrice_streaming/streaming_gateway/debug/debug_streaming_gateway.py,sha256=ZiDg
49
49
  matrice_streaming/streaming_gateway/debug/debug_utils.py,sha256=jWcSBgrk_YVt1QzSyw6geX17YBnTvgVdA5ubqO531a0,10477
50
50
  matrice_streaming/streaming_gateway/debug/example_debug_streaming.py,sha256=-gS8zNDswAoj6oss66QQWYZhY24usfLiMH0FFK06vV0,7994
51
51
  matrice_streaming/streaming_gateway/debug/test_videoplayback.py,sha256=s_dgWkoESiuJHlUAf_iv4d7OGmAhwocwDZmIcFUZzvo,11093
52
- matrice_streaming-0.1.66.dist-info/licenses/LICENSE.txt,sha256=_uQUZpgO0mRYL5-fPoEvLSbNnLPv6OmbeEDCHXhK6Qc,1066
53
- matrice_streaming-0.1.66.dist-info/METADATA,sha256=_xJDV0qoP7stxJsBdOSA2URbHcO6oVq9jT2_swH9vBU,2477
54
- matrice_streaming-0.1.66.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
55
- matrice_streaming-0.1.66.dist-info/top_level.txt,sha256=PM_trIe8f4JLc90J871rNMYGVM3Po9Inx4As5LrCFUU,18
56
- matrice_streaming-0.1.66.dist-info/RECORD,,
52
+ matrice_streaming-0.1.68.dist-info/licenses/LICENSE.txt,sha256=_uQUZpgO0mRYL5-fPoEvLSbNnLPv6OmbeEDCHXhK6Qc,1066
53
+ matrice_streaming-0.1.68.dist-info/METADATA,sha256=vSC8p6EEAKwozRFvArLlVcJoipCaAe9KX7S_H9vyJ8I,2477
54
+ matrice_streaming-0.1.68.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
55
+ matrice_streaming-0.1.68.dist-info/top_level.txt,sha256=PM_trIe8f4JLc90J871rNMYGVM3Po9Inx4As5LrCFUU,18
56
+ matrice_streaming-0.1.68.dist-info/RECORD,,