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
60
61
62
63
64
65
66
// SPDX-License-Identifier: Apache-2.0
//
//! The `MediaTransport` trait — Flowcat's transport-agnostic *media* seam.
//!
//! Where [`MediaSocket`](crate::transport::MediaSocket) is a raw WS frame pipe,
//! `MediaTransport` is one level up: it speaks **decoded audio + lifecycle
//! events**, so the [S2S pipeline](crate::pipeline::build_s2s_task) does not care
//! whether the audio arrived as carrier WebSocket frames (Plivo) or RTP (native
//! SIP). See
//! SIP-DESIGN.md §1 "The transport seam".
//!
//! Two implementations plug in here:
//! - [`WsCarrierTransport`](crate::transport::WsCarrierTransport) adapts the WS
//! path (`MediaSocket` + `MediaSerializer`) — used for Plivo.
//! - the native-SIP `SipTransport` (separate module, not yet built) will decode
//! RTP into the same `MediaIn` shape.
use async_trait;
use crateFlowcatError;
use crateAudioChunk;
/// An inbound media-lifecycle event, normalized across every transport.
///
/// The carrier-/protocol-specific framing (Plivo `start`/`media`/`stop`, an SDP
/// answer, an RTP packet, a BYE) is collapsed into these three cases by the
/// concrete [`MediaTransport`].
/// A transport-agnostic bidirectional media channel for one call.
///
/// Driven by the [S2S pipeline](crate::pipeline::build_s2s_task): `recv` yields the
/// next inbound [`MediaIn`]; `send_audio` plays bot audio back to the caller; `send_clear`
/// flushes buffered playback on barge-in; `carrier_rate` is the sample rate that
/// inbound audio arrives at and outbound audio must be supplied at.