comparison libervia/backend/plugins/plugin_xep_0167/__init__.py @ 4277:b4b4ea8c5c87

plugin XEP-0167: Let use a `call_setup_cb` method in session: when set, the `call_setup_cb` method will be used instead of calling the `call_setup` bridge signal. This will be useful to incoming `Conferences` component to handle the signaling internally. rel 445
author Goffi <goffi@goffi.org>
date Fri, 05 Jul 2024 17:18:37 +0200
parents 0d7bb4df2343
children 96fdf4891747
comparison
equal deleted inserted replaced
4276:00a9316547ed 4277:b4b4ea8c5c87
49 49
50 PLUGIN_INFO = { 50 PLUGIN_INFO = {
51 C.PI_NAME: "Jingle RTP Sessions", 51 C.PI_NAME: "Jingle RTP Sessions",
52 C.PI_IMPORT_NAME: "XEP-0167", 52 C.PI_IMPORT_NAME: "XEP-0167",
53 C.PI_TYPE: "XEP", 53 C.PI_TYPE: "XEP",
54 C.PI_MODES: C.PLUG_MODE_BOTH,
54 C.PI_PROTOCOLS: ["XEP-0167"], 55 C.PI_PROTOCOLS: ["XEP-0167"],
55 C.PI_DEPENDENCIES: ["XEP-0166"], 56 C.PI_DEPENDENCIES: ["XEP-0166"],
56 C.PI_MAIN: "XEP_0167", 57 C.PI_MAIN: "XEP_0167",
57 C.PI_HANDLER: "yes", 58 C.PI_HANDLER: "yes",
58 C.PI_DESCRIPTION: _("""Real-time Transport Protocol (RTP) is used for A/V calls"""), 59 C.PI_DESCRIPTION: _("""Real-time Transport Protocol (RTP) is used for A/V calls"""),
500 sdp = mapping.generate_sdp_from_session(session) 501 sdp = mapping.generate_sdp_from_session(session)
501 session["answer_sdp_d"] = answer_sdp_d = defer.Deferred() 502 session["answer_sdp_d"] = answer_sdp_d = defer.Deferred()
502 # we should have the answer long before 2 min 503 # we should have the answer long before 2 min
503 answer_sdp_d.addTimeout(2 * 60, reactor) 504 answer_sdp_d.addTimeout(2 * 60, reactor)
504 505
505 self.host.bridge.call_setup( 506 call_setup = session.get("call_setup_cb")
506 session["id"], 507
507 data_format.serialise( 508 if call_setup is None:
509 self.host.bridge.call_setup(
510 session["id"],
511 data_format.serialise(
512 {
513 "role": session["role"],
514 "sdp": sdp,
515 }
516 ),
517 client.profile,
518 )
519 else:
520 await call_setup(
521 client,
522 session,
508 { 523 {
509 "role": session["role"], 524 "role": session["role"],
510 "sdp": sdp, 525 "sdp": sdp,
511 } 526 },
512 ), 527 )
513 client.profile,
514 )
515 528
516 answer_sdp = await answer_sdp_d 529 answer_sdp = await answer_sdp_d
517
518 parsed_answer = mapping.parse_sdp(answer_sdp, session["role"]) 530 parsed_answer = mapping.parse_sdp(answer_sdp, session["role"])
519 session["metadata"].update(parsed_answer["metadata"]) 531 session["metadata"].update(parsed_answer["metadata"])
520 self.propagate_data(session, parsed_answer) 532 self.propagate_data(session, parsed_answer)
521 533
522 return True 534 return True
581 elif action == self._j.A_SESSION_ACCEPT: 593 elif action == self._j.A_SESSION_ACCEPT:
582 self.send_answer_sdp(client, session) 594 self.send_answer_sdp(client, session)
583 else: 595 else:
584 log.warning(f"FIXME: unmanaged action {action}") 596 log.warning(f"FIXME: unmanaged action {action}")
585 597
586 self.host.trigger.point( 598 await self.host.trigger.async_point(
587 "XEP-0167_jingle_handler", 599 "XEP-0167_jingle_handler",
588 client, 600 client,
589 action, 601 action,
590 session, 602 session,
591 content_name, 603 content_name,