pub struct ClientSession { /* private fields */ }Expand description
Sans-IO RTMP client publish session.
Implementations§
Source§impl ClientSession
impl ClientSession
Sourcepub fn new(config: RtmpClientConfig) -> Self
pub fn new(config: RtmpClientConfig) -> Self
Create a new client session.
Sourcepub fn start(&mut self) -> Vec<u8> ⓘ
pub fn start(&mut self) -> Vec<u8> ⓘ
Produce C0+C1 handshake bytes. Call once at session start.
Sourcepub fn handle_data(
&mut self,
input: &[u8],
) -> Result<(Vec<u8>, Vec<ClientEvent>), RtmpError>
pub fn handle_data( &mut self, input: &[u8], ) -> Result<(Vec<u8>, Vec<ClientEvent>), RtmpError>
Feed inbound bytes. Returns (outbound bytes, events).
Sourcepub fn pending_len(&self) -> usize
pub fn pending_len(&self) -> usize
Bytes buffered from the peer that have not yet formed a complete
message — a non-zero value at end of input means the stream was cut
mid-handshake or mid-message, which the session reports as
DamageKind::InputTruncated.
Sourcepub fn send_audio(
&mut self,
timestamp: Timestamp,
data: &[u8],
) -> Result<Vec<u8>, RtmpError>
pub fn send_audio( &mut self, timestamp: Timestamp, data: &[u8], ) -> Result<Vec<u8>, RtmpError>
Encode an audio message (type 8). Only valid in Publishing state.
timestamp is the media timestamp on the publisher’s own clock
(§5.1.3), carried on the wire as whole milliseconds.
Sourcepub fn send_video(
&mut self,
timestamp: Timestamp,
data: &[u8],
) -> Result<Vec<u8>, RtmpError>
pub fn send_video( &mut self, timestamp: Timestamp, data: &[u8], ) -> Result<Vec<u8>, RtmpError>
Encode a video message (type 9). Only valid in Publishing state.
timestamp is the media timestamp on the publisher’s own clock
(§5.1.3), carried on the wire as whole milliseconds.
Sourcepub fn send_metadata(
&mut self,
metadata: &[(String, Amf0Value)],
) -> Result<Vec<u8>, RtmpError>
pub fn send_metadata( &mut self, metadata: &[(String, Amf0Value)], ) -> Result<Vec<u8>, RtmpError>
Encode a metadata message (@setDataFrame/onMetaData, type 18).
Sourcepub fn send_publish_message(
&mut self,
message: &PublishMessage,
) -> Result<Vec<u8>, RtmpError>
pub fn send_publish_message( &mut self, message: &PublishMessage, ) -> Result<Vec<u8>, RtmpError>
Encode one message of a crate::flv::publish_open plan on this
session’s payload chunk stream and message stream, at timestamp 0.
Only valid in Publishing state.
Sourcepub fn is_publishing(&self) -> bool
pub fn is_publishing(&self) -> bool
Whether the session has reached Publishing state.