Convenience method that configures video/audio and starts the WebRTC server. This is equivalent to calling configure_video(), configure_audio(), and serve() with the appropriate parameters. Args: device: Video device identifier (default:
(
self,
# Video configuration
device=None,
format=None,
size="640x480",
fps=30,
stereo_video=False,
# Audio configuration
audio_device=None,
audio_format=None,
audio_sample_rate=None,
stereo_audio=False,
# Network configuration
port=9999,
)
| 4947 | info_thread.start() |
| 4948 | |
| 4949 | def start_streaming( |
| 4950 | self, |
| 4951 | # Video configuration |
| 4952 | device=None, |
| 4953 | format=None, |
| 4954 | size="640x480", |
| 4955 | fps=30, |
| 4956 | stereo_video=False, |
| 4957 | # Audio configuration |
| 4958 | audio_device=None, |
| 4959 | audio_format=None, |
| 4960 | audio_sample_rate=None, |
| 4961 | stereo_audio=False, |
| 4962 | # Network configuration |
| 4963 | port=9999, |
| 4964 | ): |
| 4965 | """ |
| 4966 | Convenience method that configures video/audio and starts the WebRTC server. |
| 4967 | |
| 4968 | This is equivalent to calling configure_video(), configure_audio(), and serve() |
| 4969 | with the appropriate parameters. |
| 4970 | |
| 4971 | Args: |
| 4972 | device: Video device identifier (default: None for synthetic frames). |
| 4973 | Set to None to generate frames programmatically without a camera. |
| 4974 | format: Video format (default: "avfoundation" for macOS). |
| 4975 | Ignored if device=None. |
| 4976 | fps: Frame rate (default: 30) |
| 4977 | size: Frame size as "WIDTHxHEIGHT" string (default: "640x480") |
| 4978 | port: Port to run WebRTC server on (default: 9999) |
| 4979 | stereo_video: If True, stream side-by-side stereo video (default: False) |
| 4980 | stereo_audio: If True, stream stereo audio (2 channels), otherwise mono (default: False) |
| 4981 | audio_device: Audio device identifier (default: None, no audio). |
| 4982 | Example: ":0" for default microphone on macOS. |
| 4983 | audio_format: Audio input format (default: None, auto-detect). |
| 4984 | Use "avfoundation" for macOS audio input. |
| 4985 | audio_sample_rate: Optional sample rate (Hz) for synthetic audio frames. |
| 4986 | Defaults to 48000 when not specified. |
| 4987 | |
| 4988 | Note: |
| 4989 | - Use register_frame_callback() to add custom frame processing before calling this |
| 4990 | - Use register_audio_callback() to add custom audio processing before calling this |
| 4991 | - If device=None, the callback MUST generate frames (not just modify them) |
| 4992 | - Without device, callback receives a blank frame to populate |
| 4993 | |
| 4994 | Example:: |
| 4995 | |
| 4996 | # Simple usage (equivalent to configure_video + serve) |
| 4997 | streamer.start_streaming(device="0:none", format="avfoundation") |
| 4998 | |
| 4999 | # With callbacks |
| 5000 | streamer.register_frame_callback(my_frame_processor) |
| 5001 | streamer.start_streaming(device=None, size="1280x720", fps=60) |
| 5002 | """ |
| 5003 | # Always configure video (start_streaming implies video streaming) |
| 5004 | self.configure_video( |
| 5005 | device=device, |
| 5006 | format=format, |