Fixing the examples to use the new IceServer structure.
This commit is contained in:
@@ -20,7 +20,7 @@ from fastapi.responses import RedirectResponse
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pipecat_ai_small_webrtc_prebuilt.frontend import SmallWebRTCPrebuiltUI
|
from pipecat_ai_small_webrtc_prebuilt.frontend import SmallWebRTCPrebuiltUI
|
||||||
|
|
||||||
from pipecat.transports.network.webrtc_connection import SmallWebRTCConnection
|
from pipecat.transports.network.webrtc_connection import IceServer, SmallWebRTCConnection
|
||||||
|
|
||||||
# Load environment variables
|
# Load environment variables
|
||||||
load_dotenv(override=True)
|
load_dotenv(override=True)
|
||||||
@@ -30,7 +30,11 @@ app = FastAPI()
|
|||||||
# Store connections by pc_id
|
# Store connections by pc_id
|
||||||
pcs_map: Dict[str, SmallWebRTCConnection] = {}
|
pcs_map: Dict[str, SmallWebRTCConnection] = {}
|
||||||
|
|
||||||
ice_servers = ["stun:stun.l.google.com:19302"]
|
ice_servers = [
|
||||||
|
IceServer(
|
||||||
|
urls="stun:stun.l.google.com:19302",
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
# Mount the frontend at /
|
# Mount the frontend at /
|
||||||
app.mount("/client", SmallWebRTCPrebuiltUI)
|
app.mount("/client", SmallWebRTCPrebuiltUI)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from fastapi.responses import RedirectResponse
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pipecat_ai_small_webrtc_prebuilt.frontend import SmallWebRTCPrebuiltUI
|
from pipecat_ai_small_webrtc_prebuilt.frontend import SmallWebRTCPrebuiltUI
|
||||||
|
|
||||||
from pipecat.transports.network.webrtc_connection import SmallWebRTCConnection
|
from pipecat.transports.network.webrtc_connection import IceServer, SmallWebRTCConnection
|
||||||
|
|
||||||
# Load environment variables
|
# Load environment variables
|
||||||
load_dotenv(override=True)
|
load_dotenv(override=True)
|
||||||
@@ -28,7 +28,11 @@ app = FastAPI()
|
|||||||
# Store connections by pc_id
|
# Store connections by pc_id
|
||||||
pcs_map: Dict[str, SmallWebRTCConnection] = {}
|
pcs_map: Dict[str, SmallWebRTCConnection] = {}
|
||||||
|
|
||||||
ice_servers = ["stun:stun.l.google.com:19302"]
|
ice_servers = [
|
||||||
|
IceServer(
|
||||||
|
urls="stun:stun.l.google.com:19302",
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
# Mount the frontend at /
|
# Mount the frontend at /
|
||||||
app.mount("/prebuilt", SmallWebRTCPrebuiltUI)
|
app.mount("/prebuilt", SmallWebRTCPrebuiltUI)
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ from fastapi.responses import RedirectResponse
|
|||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pipecat_ai_small_webrtc_prebuilt.frontend import SmallWebRTCPrebuiltUI
|
from pipecat_ai_small_webrtc_prebuilt.frontend import SmallWebRTCPrebuiltUI
|
||||||
|
|
||||||
from pipecat.transports.network.webrtc_connection import SmallWebRTCConnection
|
from pipecat.transports.network.webrtc_connection import IceServer, SmallWebRTCConnection
|
||||||
|
|
||||||
# Load environment variables
|
# Load environment variables
|
||||||
load_dotenv(override=True)
|
load_dotenv(override=True)
|
||||||
@@ -28,7 +28,11 @@ app = FastAPI()
|
|||||||
# Store connections by pc_id
|
# Store connections by pc_id
|
||||||
pcs_map: Dict[str, SmallWebRTCConnection] = {}
|
pcs_map: Dict[str, SmallWebRTCConnection] = {}
|
||||||
|
|
||||||
ice_servers = ["stun:stun.l.google.com:19302"]
|
ice_servers = [
|
||||||
|
IceServer(
|
||||||
|
urls="stun:stun.l.google.com:19302",
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
# Mount the frontend at /
|
# Mount the frontend at /
|
||||||
app.mount("/prebuilt", SmallWebRTCPrebuiltUI)
|
app.mount("/prebuilt", SmallWebRTCPrebuiltUI)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from fastapi import BackgroundTasks, FastAPI
|
|||||||
from fastapi.responses import FileResponse
|
from fastapi.responses import FileResponse
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from pipecat.transports.network.webrtc_connection import SmallWebRTCConnection
|
from pipecat.transports.network.webrtc_connection import IceServer, SmallWebRTCConnection
|
||||||
|
|
||||||
# Load environment variables
|
# Load environment variables
|
||||||
load_dotenv(override=True)
|
load_dotenv(override=True)
|
||||||
@@ -28,6 +28,13 @@ app = FastAPI()
|
|||||||
pcs_map: Dict[str, SmallWebRTCConnection] = {}
|
pcs_map: Dict[str, SmallWebRTCConnection] = {}
|
||||||
|
|
||||||
|
|
||||||
|
ice_servers = [
|
||||||
|
IceServer(
|
||||||
|
urls="stun:stun.l.google.com:19302",
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@app.post("/api/offer")
|
@app.post("/api/offer")
|
||||||
async def offer(request: dict, background_tasks: BackgroundTasks):
|
async def offer(request: dict, background_tasks: BackgroundTasks):
|
||||||
pc_id = request.get("pc_id")
|
pc_id = request.get("pc_id")
|
||||||
@@ -37,7 +44,7 @@ async def offer(request: dict, background_tasks: BackgroundTasks):
|
|||||||
logger.info(f"Reusing existing connection for pc_id: {pc_id}")
|
logger.info(f"Reusing existing connection for pc_id: {pc_id}")
|
||||||
await pipecat_connection.renegotiate(sdp=request["sdp"], type=request["type"])
|
await pipecat_connection.renegotiate(sdp=request["sdp"], type=request["type"])
|
||||||
else:
|
else:
|
||||||
pipecat_connection = SmallWebRTCConnection()
|
pipecat_connection = SmallWebRTCConnection(ice_servers)
|
||||||
await pipecat_connection.initialize(sdp=request["sdp"], type=request["type"])
|
await pipecat_connection.initialize(sdp=request["sdp"], type=request["type"])
|
||||||
|
|
||||||
@pipecat_connection.event_handler("closed")
|
@pipecat_connection.event_handler("closed")
|
||||||
|
|||||||
Reference in New Issue
Block a user