mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 04:39:06 +00:00
api: implement first server API + tests
This commit is contained in:
@@ -3,7 +3,6 @@ import time
|
||||
import uuid
|
||||
|
||||
import httpx
|
||||
import pyaudio
|
||||
import stamina
|
||||
from aiortc import RTCPeerConnection, RTCSessionDescription
|
||||
from aiortc.contrib.media import MediaPlayer, MediaRelay
|
||||
@@ -24,7 +23,6 @@ class StreamClient:
|
||||
self.server_url = url
|
||||
self.play_from = play_from
|
||||
self.ping_pong = ping_pong
|
||||
self.paudio = pyaudio.PyAudio()
|
||||
|
||||
self.pc = RTCPeerConnection()
|
||||
|
||||
@@ -87,6 +85,7 @@ class StreamClient:
|
||||
self.logger.info(f"Track {track.kind} ended")
|
||||
|
||||
self.pc.addTrack(audio)
|
||||
self.track_audio = audio
|
||||
|
||||
channel = pc.createDataChannel("data-channel")
|
||||
self.logger = self.logger.bind(channel=channel.label)
|
||||
@@ -142,3 +141,6 @@ class StreamClient:
|
||||
coro = self.run_offer(self.pc, self.signaling)
|
||||
task = asyncio.create_task(coro)
|
||||
await task
|
||||
|
||||
def is_ended(self):
|
||||
return self.track_audio is None or self.track_audio.readyState == "ended"
|
||||
|
||||
Reference in New Issue
Block a user