логи поправил
This commit is contained in:
parent
323c7f4f96
commit
054f9949be
@ -66,7 +66,7 @@ def get_promise_cancel_command(promise_id):
|
||||
|
||||
|
||||
async def send_messages(websocket, message):
|
||||
logging.message(f">>> Отправка сообщения: {json.dumps(message, indent=4)}")
|
||||
print(f">>> Отправка сообщения: {json.dumps(message, indent=4)}")
|
||||
await websocket.send(json.dumps(message))
|
||||
await asyncio.sleep(0)
|
||||
|
||||
@ -80,11 +80,11 @@ async def receive_messages(websocket, auth_dict):
|
||||
message_from_json = json.loads(message)
|
||||
for message_item in message_from_json:
|
||||
voice_call = await get_voice_calls()
|
||||
logging.message(f"<<< Ответ получен: {message_item}")
|
||||
print(f"<<< Ответ получен: {message_item}")
|
||||
identifier = message_item.get("identifier")
|
||||
|
||||
if identifier == "core/connection_response":
|
||||
logging.message(f"Соединение установлено. Инициализация модулей...")
|
||||
print(f"Соединение установлено. Инициализация модулей...")
|
||||
await send_messages(websocket, get_call_initialize_command())
|
||||
await send_messages(websocket, get_location_initialize_command())
|
||||
|
||||
@ -97,11 +97,11 @@ async def receive_messages(websocket, auth_dict):
|
||||
identifier == "location:0/position_broadcast"
|
||||
and auth_dict["wlocationsystem"]
|
||||
):
|
||||
logging.message(message_item["payload"])
|
||||
print(message_item["payload"])
|
||||
await save_location(message_item["payload"])
|
||||
|
||||
elif call_mapi_initialized and voice_call and auth_dict["plasystem"]:
|
||||
logging.message(
|
||||
print(
|
||||
"Запрос на отправку аудио. Инициализация трансляции трансляцию..."
|
||||
)
|
||||
await set_voice_call_sent(voice_call)
|
||||
@ -109,7 +109,7 @@ async def receive_messages(websocket, auth_dict):
|
||||
websocket,
|
||||
get_transmit_command(promise_id, ssrc, auth_dict["raduisip_group"]),
|
||||
)
|
||||
logging.message("Начало трансляции файла.")
|
||||
print("Начало трансляции файла.")
|
||||
await start_audio_stream(
|
||||
voice_call.alarm_file.audio_file.path,
|
||||
auth_dict["radiusip_host_ws"],
|
||||
@ -118,7 +118,7 @@ async def receive_messages(websocket, auth_dict):
|
||||
)
|
||||
await send_messages(websocket, get_promise_cancel_command(promise_id))
|
||||
promise_id += 1
|
||||
logging.message("Трансляция завершена и вызов остановлен.")
|
||||
print("Трансляция завершена и вызов остановлен.")
|
||||
|
||||
|
||||
@sync_to_async
|
||||
@ -188,7 +188,7 @@ async def start_audio_stream(audio_path, dest_ip, dest_port, ssrc):
|
||||
sequence_number = 0
|
||||
timestamp = 0
|
||||
|
||||
logging.message("Начинаем отправку аудио по RTP...")
|
||||
print("Начинаем отправку аудио по RTP...")
|
||||
# Конвертируем аудио в G.711A
|
||||
audio_data = convert_audio_to_g711a(audio_path)
|
||||
|
||||
@ -200,7 +200,7 @@ async def start_audio_stream(audio_path, dest_ip, dest_port, ssrc):
|
||||
for i in range(0, len(audio_data), packet_size):
|
||||
frame_data = audio_data[i : i + packet_size]
|
||||
if not frame_data:
|
||||
logging.message("Достигнут конец файла аудио.")
|
||||
print("Достигнут конец файла аудио.")
|
||||
break
|
||||
|
||||
# Создаем RTP пакет с заголовком
|
||||
@ -222,7 +222,7 @@ async def start_audio_stream(audio_path, dest_ip, dest_port, ssrc):
|
||||
time.sleep(delay)
|
||||
|
||||
sock.close()
|
||||
logging.message("Передача аудиофайла завершена.")
|
||||
print("Передача аудиофайла завершена.")
|
||||
|
||||
|
||||
@sync_to_async
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user