Skip to content

Commit 5f34d8c

Browse files
committed
Define VideoCodec and add video_encoder publish option
1 parent 04ecb45 commit 5f34d8c

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

‎include/livekit/room_event_types.h‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,37 @@ class LocalTrackPublication;
3434
class RemoteTrackPublication;
3535
class TrackPublication;
3636

37-
enum class VideoCodec;
37+
/// Video codec used when publishing a track.
38+
///
39+
/// Values mirror proto_room.VideoCodec.
40+
enum class VideoCodec {
41+
VP8 = 0,
42+
H264 = 1,
43+
AV1 = 2,
44+
VP9 = 3,
45+
H265 = 4,
46+
};
47+
48+
/// Preferred encoder backend when publishing a video track.
49+
///
50+
/// Values mirror proto_room.VideoEncoderBackend.
51+
enum class VideoEncoderBackend {
52+
/// Pick the best available backend.
53+
Auto = 0,
54+
/// Software encoder.
55+
Software = 1,
56+
/// Any hardware encoder.
57+
Hardware = 2,
58+
/// NVIDIA NVENC hardware encoder.
59+
Nvenc = 3,
60+
/// VA-API hardware encoder.
61+
Vaapi = 4,
62+
/// Apple VideoToolbox hardware encoder.
63+
VideoToolbox = 5,
64+
/// Pre-encoded passthrough: the application supplies encoded frames.
65+
PreEncoded = 6,
66+
};
67+
3868
enum class TrackSource;
3969

4070
/// Overall quality of a participant's connection.
@@ -359,6 +389,9 @@ struct TrackPublishOptions {
359389
/// Controls how the encoder trades off between resolution and framerate
360390
/// when bandwidth is constrained. If not set, the server defaults apply.
361391
std::optional<DegradationPreference> degradation_preference;
392+
393+
/// Preferred encoder backend for published video.
394+
std::optional<VideoEncoderBackend> video_encoder;
362395
};
363396

364397
// ---------------------------------------------------------

‎src/room_proto_converter.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ proto::TrackPublishOptions toProto(const TrackPublishOptions& in) {
533533
if (in.degradation_preference) {
534534
msg.set_degradation_preference(static_cast<proto::DegradationPreference>(*in.degradation_preference));
535535
}
536+
if (in.video_encoder) {
537+
msg.set_video_encoder(static_cast<proto::VideoEncoderBackend>(*in.video_encoder));
538+
}
536539
return msg;
537540
}
538541

@@ -573,6 +576,9 @@ TrackPublishOptions fromProto(const proto::TrackPublishOptions& in) {
573576
if (in.has_degradation_preference()) {
574577
out.degradation_preference = static_cast<DegradationPreference>(in.degradation_preference());
575578
}
579+
if (in.has_video_encoder()) {
580+
out.video_encoder = static_cast<VideoEncoderBackend>(in.video_encoder());
581+
}
576582
return out;
577583
}
578584

0 commit comments

Comments
 (0)