|
LiveKit C++ SDK
Real-time audio/video SDK for C++
|
#include <local_data_track.h>
Public Member Functions | |
| LocalDataTrack (const LocalDataTrack &)=delete | |
| LocalDataTrack & | operator= (const LocalDataTrack &)=delete |
| const DataTrackInfo & | info () const noexcept |
| Metadata about this data track. | |
| Result< void, LocalDataTrackTryPushError > | tryPush (const DataTrackFrame &frame) |
| Result< void, LocalDataTrackTryPushError > | tryPush (std::vector< std::uint8_t > &&payload, std::optional< std::uint64_t > user_timestamp=std::nullopt) |
| bool | isPublished () const |
| Whether the track is still published in the room. | |
| void | unpublishDataTrack () |
Friends | |
| class | LocalParticipant |
Represents a locally published data track.
Unlike audio/video tracks, data tracks do not extend the Track base class. They use a separate publish/unpublish lifecycle and carry arbitrary binary frames instead of media.
Created via LocalParticipant::publishDataTrack().
Typical usage:
auto lp = room->localParticipant(); auto result = lp->publishDataTrack("sensor-data"); if (result) { auto dt = result.value(); DataTrackFrame frame; frame.payload = {0x01, 0x02, 0x03}; (void)dt->tryPush(frame); dt->unpublishDataTrack(); }
| Result< void, LocalDataTrackTryPushError > livekit::LocalDataTrack::tryPush | ( | const DataTrackFrame & | frame | ) |
Try to push a frame to all subscribers of this track.
| Result< void, LocalDataTrackTryPushError > livekit::LocalDataTrack::tryPush | ( | std::vector< std::uint8_t > && | payload, |
| std::optional< std::uint64_t > | user_timestamp = std::nullopt |
||
| ) |
Try to push a frame to all subscribers of this track.
| void livekit::LocalDataTrack::unpublishDataTrack | ( | ) |
Unpublish this data track from the room.
After this call, tryPush() fails and the track cannot be re-published.