update smallWebRTC screen support to support the utils format for listening to screenshares
This commit is contained in:
committed by
Mattie Ruth
parent
40f1f4ff11
commit
b987579d54
@@ -233,12 +233,15 @@ async def maybe_capture_participant_camera(
|
||||
framerate: Video capture framerate. Defaults to 0 (auto).
|
||||
"""
|
||||
try:
|
||||
from pipecat.transports.network.small_webrtc import SmallWebRTCTransport
|
||||
from pipecat.transports.services.daily import DailyTransport
|
||||
|
||||
if isinstance(transport, DailyTransport):
|
||||
await transport.capture_participant_video(
|
||||
client["id"], framerate=framerate, video_source="camera"
|
||||
)
|
||||
elif isinstance(transport, SmallWebRTCTransport):
|
||||
await transport.capture_participant_video(video_source="camera")
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -254,12 +257,16 @@ async def maybe_capture_participant_screen(
|
||||
framerate: Video capture framerate. Defaults to 0 (auto).
|
||||
"""
|
||||
try:
|
||||
from pipecat.transports.network.small_webrtc import SmallWebRTCTransport
|
||||
from pipecat.transports.services.daily import DailyTransport
|
||||
|
||||
if isinstance(transport, DailyTransport):
|
||||
await transport.capture_participant_video(
|
||||
client["id"], framerate=framerate, video_source="screenVideo"
|
||||
)
|
||||
elif isinstance(transport, SmallWebRTCTransport):
|
||||
await transport.capture_participant_video(video_source="screenVideo")
|
||||
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
@@ -679,25 +679,28 @@ class SmallWebRTCInputTransport(BaseInputTransport):
|
||||
# Start screen video reception if it's not already running
|
||||
self._receive_screen_video_task = self.create_task(self._receive_video("screenVideo"))
|
||||
|
||||
async def capture_participant_video(
|
||||
async def capture_participant_media(
|
||||
self,
|
||||
video_source: str = "camera",
|
||||
source: str = "camera",
|
||||
):
|
||||
"""Capture video from a specific participant.
|
||||
"""Capture media from a specific participant.
|
||||
|
||||
Args:
|
||||
video_source: Video source to capture from.
|
||||
source: Media source to capture from. ("camera", "microphone", or "screenVideo")
|
||||
"""
|
||||
# If we're not already receiving video, try to get a frame now
|
||||
if (
|
||||
video_source == "camera"
|
||||
and not self._receive_video_task
|
||||
and self._params.video_in_enabled
|
||||
source == "microphone"
|
||||
and not self._receive_audio_task
|
||||
and self._params.audio_in_enabled
|
||||
):
|
||||
# Start audio reception if it's not already running
|
||||
self._receive_audio_task = self.create_task(self._receive_audio())
|
||||
elif source == "camera" and not self._receive_video_task and self._params.video_in_enabled:
|
||||
# Start video reception if it's not already running
|
||||
self._receive_video_task = self.create_task(self._receive_video("camera"))
|
||||
elif (
|
||||
video_source == "screenVideo"
|
||||
source == "screenVideo"
|
||||
and not self._receive_screen_video_task
|
||||
and self._params.video_in_enabled
|
||||
):
|
||||
@@ -892,15 +895,34 @@ class SmallWebRTCTransport(BaseTransport):
|
||||
|
||||
async def capture_participant_video(
|
||||
self,
|
||||
participant_id: str = None,
|
||||
framerate: int = 30,
|
||||
video_source: str = "camera",
|
||||
color_format: str = "RGB",
|
||||
):
|
||||
"""Capture video from a specific participant.
|
||||
|
||||
Args:
|
||||
participant_id: ID of the participant to capture video from.
|
||||
framerate: Desired framerate for video capture.
|
||||
participant_id: Unused parameter, kept for compatibility.
|
||||
framerate: Unused parameter, kept for compatibility.
|
||||
video_source: Video source to capture from.
|
||||
color_format: Color format for video frames.
|
||||
color_format: Unused parameter, kept for compatibility.
|
||||
"""
|
||||
if self._input:
|
||||
await self._input.capture_participant_video(video_source)
|
||||
await self._input.capture_participant_media(source=video_source)
|
||||
|
||||
async def capture_participant_audio(
|
||||
self,
|
||||
participant_id: str = None,
|
||||
audio_source: str = "microphone",
|
||||
sample_rate: int = 16000,
|
||||
):
|
||||
"""Capture audio from a specific participant.
|
||||
|
||||
Args:
|
||||
participant_id: Unused parameter, kept for compatibility.
|
||||
audio_source: Audio source to capture from. (currently, "microphone" is the only supported option)
|
||||
sample_rate: Unused parameter, kept for compatibility.
|
||||
"""
|
||||
if self._input:
|
||||
await self._input.capture_participant_media(source=audio_source)
|
||||
|
||||
@@ -542,7 +542,7 @@ class SmallWebRTCConnection(BaseObject):
|
||||
# For support 3 receivers in the following order:
|
||||
# audio, video, screenVideo
|
||||
transceivers = self._pc.getTransceivers()
|
||||
if len(transceivers) <= 1 or not transceivers[SCREEN_VIDEO_TRANSCEIVER_INDEX].receiver:
|
||||
if len(transceivers) <= 2 or not transceivers[SCREEN_VIDEO_TRANSCEIVER_INDEX].receiver:
|
||||
logger.warning("No screen video transceiver is available")
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user