Skip to content

Commit 5a83949

Browse files
Additional fixes
1 parent b7776e0 commit 5a83949

2 files changed

Lines changed: 16 additions & 25 deletions

File tree

src/ffi_client.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -676,21 +676,13 @@ FfiClient::publishDataTrackAsync(std::uint64_t local_participant_handle,
676676
"FfiResponse missing publish_data_track"}));
677677
return pr.get_future();
678678
}
679-
} catch (...) {
679+
} catch (const std::exception &e) {
680680
cancelPendingByAsyncId(async_id);
681681
std::promise<Result<proto::OwnedLocalDataTrack, PublishDataTrackError>> pr;
682-
try {
683-
throw;
684-
} catch (const std::exception &e) {
685-
pr.set_value(
686-
Result<proto::OwnedLocalDataTrack, PublishDataTrackError>::failure(
687-
PublishDataTrackError{PublishDataTrackErrorCode::INTERNAL,
688-
e.what()}));
689-
} catch(...) {
690-
pr.set_value(
691-
Result<proto::OwnedLocalDataTrack, PublishDataTrackError>::failure(
692-
PublishDataTrackError{PublishDataTrackErrorCode::INTERNAL, "unknown exception"}));
693-
}
682+
pr.set_value(
683+
Result<proto::OwnedLocalDataTrack, PublishDataTrackError>::failure(
684+
PublishDataTrackError{PublishDataTrackErrorCode::INTERNAL,
685+
e.what()}));
694686
return pr.get_future();
695687
}
696688

src/video_frame.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,20 @@ std::size_t computeBufferSize(int width, int height, VideoBufferType type) {
5454
return w * h * 3;
5555

5656
case VideoBufferType::I420:
57-
case VideoBufferType::NV12:
57+
// Y (1 byte) + U (1 byte) + V (1 byte)
58+
case VideoBufferType::NV12: {
59+
// Y (1 byte) + UV interleaved (2 bytes per chroma sample)
60+
const std::size_t chroma_w = (w + 1) / 2;
61+
const std::size_t chroma_h = (h + 1) / 2;
62+
return w * h + chroma_w * chroma_h * 2;
63+
}
64+
5865
case VideoBufferType::I010: {
59-
// Y full, U and V subsampled 2x2
66+
// 16 bits per sample in memory
67+
// Y: 2 bytes per sample, U & V: 2 bytes per sample
6068
const std::size_t chroma_w = (w + 1) / 2;
6169
const std::size_t chroma_h = (h + 1) / 2;
62-
if (type == VideoBufferType::I420) {
63-
// Y (1 byte) + U (1 byte) + V (1 byte)
64-
return w * h + chroma_w * chroma_h * 2;
65-
} else if (type == VideoBufferType::NV12) {
66-
// Y (1 byte), UV interleaved (2 bytes per chroma sample)
67-
return w * h + chroma_w * chroma_h * 2;
68-
} else { // I010, 16 bits per sample in memory
69-
// Y: 2 bytes per sample, U & V: 2 bytes per sample
70-
return w * h * 2 + chroma_w * chroma_h * 4;
71-
}
70+
return w * h * 2 + chroma_w * chroma_h * 4;
7271
}
7372

7473
case VideoBufferType::I420A: {

0 commit comments

Comments
 (0)