9
9
#include < sstream>
10
10
11
11
// WebRTC
12
+ #include < api/video/nv12_buffer.h>
12
13
#include < rtc_base/logging.h>
13
14
#include < third_party/libyuv/include/libyuv.h>
14
15
@@ -70,7 +71,7 @@ void FakeVideoCapturer::CaptureThread() {
70
71
// 画像を更新
71
72
UpdateImage (now);
72
73
73
- // Blend2D イメージから I420 バッファへ変換
74
+ // Blend2D イメージから VideoFrameBuffer へ変換
74
75
BLImageData data;
75
76
BLResult result = image_.get_data (&data);
76
77
if (result != BL_SUCCESS) {
@@ -79,14 +80,25 @@ void FakeVideoCapturer::CaptureThread() {
79
80
break ;
80
81
}
81
82
82
- webrtc::scoped_refptr<webrtc::I420Buffer> buffer =
83
- webrtc::I420Buffer::Create (config_.width , config_.height );
84
-
85
- libyuv::ABGRToI420 ((const uint8_t *)data.pixel_data , data.stride ,
86
- buffer->MutableDataY (), buffer->StrideY (),
87
- buffer->MutableDataU (), buffer->StrideU (),
88
- buffer->MutableDataV (), buffer->StrideV (), config_.width ,
89
- config_.height );
83
+ // 出力フォーマットを選択
84
+ webrtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer;
85
+ if (config_.force_nv12 ) {
86
+ // NV12 へ変換
87
+ auto nv12 = webrtc::NV12Buffer::Create (config_.width , config_.height );
88
+ libyuv::ABGRToNV12 ((const uint8_t *)data.pixel_data , data.stride ,
89
+ nv12->MutableDataY (), nv12->StrideY (),
90
+ nv12->MutableDataUV (), nv12->StrideUV (), config_.width ,
91
+ config_.height );
92
+ buffer = nv12;
93
+ } else {
94
+ // 既定は I420
95
+ auto i420 = webrtc::I420Buffer::Create (config_.width , config_.height );
96
+ libyuv::ABGRToI420 (
97
+ (const uint8_t *)data.pixel_data , data.stride , i420->MutableDataY (),
98
+ i420->StrideY (), i420->MutableDataU (), i420->StrideU (),
99
+ i420->MutableDataV (), i420->StrideV (), config_.width , config_.height );
100
+ buffer = i420;
101
+ }
90
102
91
103
// タイムスタンプを計算
92
104
int64_t timestamp_us =
@@ -150,7 +162,7 @@ void FakeVideoCapturer::DrawAnimations(
150
162
ctx.set_fill_style (BLRgba32 (160 , 160 , 160 ));
151
163
uint32_t current_frame = frame_counter_;
152
164
ctx.fill_pie (0 , 0 , width * 0.3 , 0 ,
153
- (current_frame % fps) / static_cast <float >(fps) * 2 * M_PI);
165
+ (current_frame % fps) / static_cast <float >(fps) * 2 * M_PI);
154
166
155
167
// 円が一周したときにビープ音を鳴らす
156
168
auto fake_audio_capturer = GetAudioCapturer ();
@@ -260,7 +272,7 @@ void FakeVideoCapturer::DrawDigitalClock(
260
272
261
273
// ドット
262
274
ctx.fill_circle (x + colon_width * 0.3 , clock_y + digit_height * 0.8 ,
263
- digit_height * 0.05 );
275
+ digit_height * 0.05 );
264
276
x += colon_width + spacing;
265
277
266
278
// ミリ秒(3桁、少し小さめに表示)
@@ -385,4 +397,4 @@ void FakeVideoCapturer::DrawColon(BLContext& ctx,
385
397
ctx.fill_circle (x + dot_size, y + height * 0.7 , dot_size);
386
398
}
387
399
388
- #endif // USE_FAKE_CAPTURE_DEVICE
400
+ #endif // USE_FAKE_CAPTURE_DEVICE
0 commit comments