@@ -36,20 +36,28 @@ void V4l2DmaTrackSource::OnFrameCaptured(V4l2Buffer decoded_buffer) {
3636 const int64_t translated_timestamp_us =
3737 timestamp_aligner.TranslateTimestamp (timestamp_us, rtc::TimeMicros ());
3838
39- int adapted_width, adapted_height, crop_width, crop_height, crop_x, crop_y;
40- if (!AdaptFrame (width, height, timestamp_us, &adapted_width, &adapted_height, &crop_width,
41- &crop_height, &crop_x, &crop_y)) {
42- return ;
43- }
39+ if (capturer->config ().fixed_resolution ) {
40+ auto dst_buffer = V4l2FrameBuffer::Create (config_width_, config_height_, decoded_buffer,
41+ V4L2_PIX_FMT_YUV420);
42+ OnFrame (webrtc::VideoFrame::Builder ()
43+ .set_video_frame_buffer (dst_buffer)
44+ .set_rotation (webrtc::kVideoRotation_0 )
45+ .set_timestamp_us (translated_timestamp_us)
46+ .build ());
47+ } else {
48+ int adapted_width, adapted_height, crop_width, crop_height, crop_x, crop_y;
49+ if (!AdaptFrame (width, height, timestamp_us, &adapted_width, &adapted_height, &crop_width,
50+ &crop_height, &crop_x, &crop_y)) {
51+ return ;
52+ }
4453
45- if (adapted_width != config_width_ || adapted_height != config_height_) {
46- config_width_ = adapted_width;
47- config_height_ = adapted_height;
48- scaler =
49- V4l2Scaler::Create (width, height, config_width_, config_height_, is_dma_src_, true );
50- }
54+ if (!scaler || adapted_width != config_width_ || adapted_height != config_height_) {
55+ config_width_ = adapted_width;
56+ config_height_ = adapted_height;
57+ scaler =
58+ V4l2Scaler::Create (width, height, config_width_, config_height_, is_dma_src_, true );
59+ }
5160
52- if (scaler) {
5361 scaler->EmplaceBuffer (
5462 decoded_buffer, [this , translated_timestamp_us](V4l2Buffer scaled_buffer) {
5563 auto dst_buffer = V4l2FrameBuffer::Create (config_width_, config_height_,
@@ -61,13 +69,5 @@ void V4l2DmaTrackSource::OnFrameCaptured(V4l2Buffer decoded_buffer) {
6169 .set_timestamp_us (translated_timestamp_us)
6270 .build ());
6371 });
64- } else {
65- auto dst_buffer = V4l2FrameBuffer::Create (config_width_, config_height_, decoded_buffer,
66- V4L2_PIX_FMT_YUV420);
67- OnFrame (webrtc::VideoFrame::Builder ()
68- .set_video_frame_buffer (dst_buffer)
69- .set_rotation (webrtc::kVideoRotation_0 )
70- .set_timestamp_us (translated_timestamp_us)
71- .build ());
7272 }
7373}
0 commit comments