Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serialize VideoBufferType using human-readable str #392

Merged
merged 2 commits into from
Mar 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions livekit-rtc/livekit/rtc/video_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def convert(
return VideoFrame._from_owned_info(resp.video_convert.buffer)

def __repr__(self) -> str:
return f"rtc.VideoFrame(width={self.width}, height={self.height}, type={self.type})"
return f"rtc.VideoFrame(width={self.width}, height={self.height}, type={proto_video.VideoBufferType.Name(self.type)})"

@classmethod
def __get_pydantic_core_schema__(cls, *_: Any):
Expand All @@ -217,7 +217,7 @@ def validate_video_frame(value: Any) -> "VideoFrame":
return VideoFrame(
width=value["width"],
height=value["height"],
type=proto_video.VideoBufferType.ValueType(value["type"]),
type=proto_video.VideoBufferType.Value(value["type"]),
data=base64.b64decode(value["data"]),
)

Expand All @@ -230,7 +230,7 @@ def validate_video_frame(value: Any) -> "VideoFrame":
{
"width": core_schema.model_field(core_schema.int_schema()),
"height": core_schema.model_field(core_schema.int_schema()),
"type": core_schema.model_field(core_schema.int_schema()),
"type": core_schema.model_field(core_schema.str_schema()),
"data": core_schema.model_field(core_schema.str_schema()),
},
),
Expand All @@ -242,7 +242,7 @@ def validate_video_frame(value: Any) -> "VideoFrame":
lambda instance: {
"width": instance.width,
"height": instance.height,
"type": instance.type,
"type": proto_video.VideoBufferType.Name(instance.type),
"data": base64.b64encode(instance.data).decode("utf-8"),
}
),
Expand Down
Loading