LiveKit C++ SDK
Real-time audio/video SDK for C++
Loading...
Searching...
No Matches
livekit::BaseStreamWriter Class Reference

#include <data_stream.h>

Inheritance diagram for livekit::BaseStreamWriter:
Collaboration diagram for livekit::BaseStreamWriter:

Public Member Functions

const std::string & streamId () const noexcept
 Stream id assigned to this writer.
 
const std::string & topic () const noexcept
 Topic of this stream.
 
const std::string & mimeType () const noexcept
 MIME type for this stream.
 
std::int64_t timestampMs () const noexcept
 Timestamp (ms) when the stream was created.
 
bool isClosed () const noexcept
 Whether the stream has been closed.
 
void close (const std::string &reason="", const std::map< std::string, std::string > &attributes={})
 

Protected Types

enum class  StreamKind { kUnknown , kText , kByte }
 

Protected Member Functions

 BaseStreamWriter (LocalParticipant &local_participant, const std::string &topic="", const std::map< std::string, std::string > &attributes={}, const std::string &stream_id="", std::optional< std::size_t > total_size=std::nullopt, const std::string &mime_type="", const std::vector< std::string > &destination_identities={}, const std::string &sender_identity="")
 
void ensureHeaderSent ()
 
void sendChunk (const std::vector< std::uint8_t > &content)
 
void sendTrailer (const std::string &reason, const std::map< std::string, std::string > &attributes)
 

Protected Attributes

LocalParticipantlocal_participant_
 
std::string stream_id_
 
std::string mime_type_
 
std::string topic_
 
std::int64_t timestamp_ms_ = 0
 
std::optional< std::size_t > total_size_
 
std::map< std::string, std::string > attributes_
 
std::vector< std::string > destination_identities_
 
std::string sender_identity_
 
bool closed_ = false
 
bool header_sent_ = false
 
std::uint64_t next_chunk_index_ = 0
 
StreamKind kind_ = StreamKind::kUnknown
 
std::string reply_to_id_
 
std::string byte_name_
 

Detailed Description

Base class for sending data streams. Concrete subclasses are TextStreamWriter and ByteStreamWriter.

Member Function Documentation

◆ close()

void livekit::BaseStreamWriter::close ( const std::string &  reason = "",
const std::map< std::string, std::string > &  attributes = {} 
)

Close the stream with optional reason and attributes. Throws on FFI error or if already closed.

◆ ensureHeaderSent()

void livekit::BaseStreamWriter::ensureHeaderSent ( )
protected

Ensure the header has been sent once. Throws on error.

◆ sendChunk()

void livekit::BaseStreamWriter::sendChunk ( const std::vector< std::uint8_t > &  content)
protected

Send a raw chunk of bytes. Throws on error or if stream is closed.

◆ sendTrailer()

void livekit::BaseStreamWriter::sendTrailer ( const std::string &  reason,
const std::map< std::string, std::string > &  attributes 
)
protected

Send the trailer with given reason and attributes. Throws on error.


The documentation for this class was generated from the following file: