Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit cb4e86d

Browse files
authored
Fix video resolution issue (#604)
1 parent 7daba5d commit cb4e86d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

source/core/rtc_adapter/VideoReceiveAdapter.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ int32_t VideoReceiveAdapterImpl::AdapterDecoder::Decode(const webrtc::EncodedIma
6464
{
6565
RTC_DLOG(LS_VERBOSE) << "AdapterDecoder Decode";
6666
owt_base::FrameFormat format = FRAME_FORMAT_UNKNOWN;
67-
bool notifyStats = false;
6867

6968
switch (m_codec) {
7069
case webrtc::VideoCodecType::kVideoCodecVP8:
@@ -90,15 +89,20 @@ int32_t VideoReceiveAdapterImpl::AdapterDecoder::Decode(const webrtc::EncodedIma
9089
RTC_DLOG(LS_INFO) << "AdapterDecoder increase buffer size: " << m_bufferSize;
9190
}
9291

92+
if (encodedImage._encodedWidth > 0 && encodedImage._encodedHeight > 0) {
93+
m_width = encodedImage._encodedWidth;
94+
m_height = encodedImage._encodedHeight;
95+
}
96+
9397
memcpy(m_frameBuffer.get(), encodedImage.data(), encodedImage.size());
9498
Frame frame;
9599
memset(&frame, 0, sizeof(frame));
96100
frame.format = format;
97101
frame.payload = m_frameBuffer.get();
98102
frame.length = encodedImage.size();
99103
frame.timeStamp = encodedImage.Timestamp();
100-
frame.additionalInfo.video.width = encodedImage._encodedWidth;
101-
frame.additionalInfo.video.height = encodedImage._encodedHeight;
104+
frame.additionalInfo.video.width = m_width;
105+
frame.additionalInfo.video.height = m_height;
102106
frame.additionalInfo.video.isKeyFrame = (encodedImage._frameType == webrtc::VideoFrameType::kVideoFrameKey);
103107

104108
if (m_parent) {
@@ -113,13 +117,11 @@ int32_t VideoReceiveAdapterImpl::AdapterDecoder::Decode(const webrtc::EncodedIma
113117
m_parent->m_format = format;
114118
statsChanged = true;
115119
}
116-
if (encodedImage._encodedWidth != 0 && encodedImage._encodedHeight != 0) {
117-
if ((m_parent->m_width != encodedImage._encodedWidth) || (m_parent->m_height != encodedImage._encodedHeight)) {
118-
// Update width and height
119-
m_parent->m_width = encodedImage._encodedWidth;
120-
m_parent->m_height = encodedImage._encodedHeight;
121-
statsChanged = true;
122-
}
120+
if ((m_parent->m_width != m_width) || (m_parent->m_height != m_height)) {
121+
// Update width and height
122+
m_parent->m_width = m_width;
123+
m_parent->m_height = m_height;
124+
statsChanged = true;
123125
}
124126
if (statsChanged) {
125127
// Notify the stats

source/core/rtc_adapter/VideoReceiveAdapter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class VideoReceiveAdapterImpl : public VideoReceiveAdapter,
6464
private:
6565
VideoReceiveAdapterImpl* m_parent;
6666
webrtc::VideoCodecType m_codec;
67+
uint16_t m_width;
68+
uint16_t m_height;
6769
std::unique_ptr<uint8_t[]> m_frameBuffer;
6870
uint32_t m_bufferSize;
6971
};

0 commit comments

Comments
 (0)