-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtest_echotest.py
More file actions
59 lines (42 loc) · 1.5 KB
/
test_echotest.py
File metadata and controls
59 lines (42 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import asyncio
import logging
import os
from urllib.parse import urljoin
from dotenv import load_dotenv
load_dotenv()
# from janus_client.transport import JanusTransportHTTP
from janus_client import JanusSession, JanusEchoTestPlugin
format = "%(asctime)s: %(message)s"
logging.basicConfig(format=format, level=logging.INFO, datefmt="%H:%M:%S")
logger = logging.getLogger()
async def main():
# transport = JanusTransportHTTP(
# uri="https://janusmy.josephgetmyip.com/janusbase/janus"
# )
# session = JanusSession(base_url="wss://janusmy.josephgetmyip.com/janusbasews/janus")
session = JanusSession(
base_url=urljoin(
os.getenv("JANUS_HTTP_URL", ""),
os.getenv("JANUS_HTTP_BASE_PATH", ""),
),
api_secret=os.getenv("JANUS_API_SECRET", ""),
)
plugin_handle = JanusEchoTestPlugin()
await plugin_handle.attach(session=session)
if os.path.exists("./asdasd.mp4"):
os.remove("./asdasd.mp4")
await plugin_handle.start(
play_from="./Into.the.Wild.2007.mp4", record_to="./asdasd.mp4"
)
response = await session.transport.ping()
logger.info(response)
await asyncio.sleep(15)
await plugin_handle.close_stream()
await plugin_handle.destroy()
await session.destroy()
if __name__ == "__main__":
try:
# asyncio.run(main=main())
asyncio.get_event_loop().run_until_complete(main())
except KeyboardInterrupt:
pass