Metadata-Version: 2.4
Name: cast_sender
Version: 1.0.3
Summary: Python bindings for the Open Screen Cast Sender library
Author-email: Google LLC <opensource@google.com>
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: THIRD_PARTY_NOTICES.txt
Dynamic: license-file

# Open Screen Cast Sender

This package provides Python bindings for the Google Open Screen Sender library.
It allows you to cast media files to a Chromecast device natively from Python.

## Installation

```bash
pip install cast_sender
```

## Usage and Settings

### 1. Initialize the Environment

The `CastRuntime` handles the underlying C++ TaskRunner and event loop.

```python
import cast_sender
env = cast_sender.CastRuntime()
```

### 2. Initialize the Sender

Create a `CastSender` instance by providing the target receiver's IP address and
port.

```python
# ip_address: Target Cast Receiver's IP (e.g., "192.168.1.50")
# port: Cast V2 connection port (typically 8009)
# cert_path: (Optional) Path to a PEM developer root CA certificate.
sender = cast_sender.CastSender(env=env, ip_address="192.168.1.50", port=8009, cert_path="")
```

### 3. Configure the Stream Settings

The `StreamConfig` object allows you to customize the streaming session:

```python
config = cast_sender.StreamConfig()

# (Required)
# file_path: Absolute local path to the video container.
config.file_path = "/path/to/video.mp4"

# (Optional)
# remote_transport_id: Destination receiver transport ID. Bypasses receiver app LAUNCH if provided.
# session_id: Pre-launched receiver app session ID. Used for a clean STOP.
# codec_name: Supported video encoder codec string (e.g., "vp8", "vp9", "av1"). Default is "vp8".
# max_bitrate: Peak aggregate bitrate (audio + video) in bps. Default is 5242880 (5 Mbps).
# should_include_audio: If False, negotiates a video-only mirroring session. Default is True.
config.remote_transport_id = ""
config.session_id = ""
config.codec_name = "vp8"
config.max_bitrate = 5242880
config.should_include_audio = True
```

### 4. Start Streaming

Initiates the Cast session connection, media negotiation, and streaming over
UDP.

```python
# is_debug: (Optional) If True, sets the internal log level to INFO. Default is False.
sender.stream_video(config=config, is_debug=True)
```

### 5. Teardown

Gracefully stop active streaming and shut down network sockets:

```python
sender.teardown()
```
