Skip to content

Commit 0d02085

Browse files
committed
update.
1 parent 22b00ce commit 0d02085

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

sdk/objc/native/src/objc_desktop_capture.mm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@
7272

7373
int width = frame->size().width();
7474
int height = frame->size().height();
75-
int real_width = frame->size().width();
75+
int real_width = width;
7676

77-
// A multiple of 32 must be used as the width of the src frame,
78-
// and the right black border needs to be cropped during conversion.
79-
if( (width % 32) !=0 ) {
80-
width = (width / 32 + 1) * 32;
77+
if(type_ == kWindow) {
78+
// A multiple of 32 must be used as the width of the src frame,
79+
// and the right black border needs to be cropped during conversion.
80+
if( (width % 32) !=0 ) {
81+
width = (width / 32 + 1) * 32;
82+
}
8183
}
8284

8385
if (!i420_buffer_ || !i420_buffer_.get() ||

sdk/objc/native/src/objc_desktop_media_list.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class ObjCDesktopMediaList : public rtc::MessageHandler {
4949

5050
class MediaSource {
5151
public:
52-
MediaSource(DesktopCapturer::Source src)
53-
: source(src) {}
52+
MediaSource(DesktopCapturer::Source src, DesktopType type)
53+
: source(src), type_(type) {}
5454
virtual ~MediaSource();
5555
DesktopCapturer::Source source;
5656
// source id
@@ -64,6 +64,7 @@ class ObjCDesktopMediaList : public rtc::MessageHandler {
6464
std::unique_ptr<webrtc::DesktopFrame> frame);
6565
private:
6666
std::vector<unsigned char> thumbnail_;
67+
DesktopType type_;
6768
};
6869
public:
6970
ObjCDesktopMediaList(DesktopType type, RTC_OBJC_TYPE(RTCDesktopMediaList)* objcMediaList);
@@ -101,6 +102,7 @@ class ObjCDesktopMediaList : public rtc::MessageHandler {
101102
std::unique_ptr<rtc::Thread> thread_;
102103
std::vector<std::shared_ptr<MediaSource>> sources_;
103104
RTC_OBJC_TYPE(RTCDesktopMediaList)* objcMediaList_;
105+
DesktopType type_;
104106
};
105107

106108
} // namespace webrtc

sdk/objc/native/src/objc_desktop_media_list.mm

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
ObjCDesktopMediaList::ObjCDesktopMediaList(DesktopType type,
3737
RTC_OBJC_TYPE(RTCDesktopMediaList)* objcMediaList)
38-
:thread_(rtc::Thread::Create()),objcMediaList_(objcMediaList) {
38+
:thread_(rtc::Thread::Create()),objcMediaList_(objcMediaList),type_(type) {
3939
options_ = webrtc::DesktopCaptureOptions::CreateDefault();
4040
options_.set_detect_updated_region(true);
4141
options_.set_allow_iosurface(true);
@@ -79,7 +79,7 @@
7979
}
8080
for (size_t i = 0; i < new_sources.size(); ++i) {
8181
if (old_source_set.find(new_sources[i].id) == old_source_set.end()) {
82-
MediaSource* source = new MediaSource(new_sources[i]);
82+
MediaSource* source = new MediaSource(new_sources[i],type_);
8383
sources_.insert(sources_.begin() + i, std::shared_ptr<MediaSource>(source));
8484
[objcMediaList_ mediaSourceAdded:i];
8585
}
@@ -163,10 +163,14 @@
163163

164164
int width = frame->size().width();
165165
int height = frame->size().height();
166-
int real_width = frame->size().width();
166+
int real_width = width;
167167

168-
if( (width % 32) !=0 ) {
169-
width = (width / 32 + 1) * 32;
168+
if(type_ == kWindow) {
169+
// A multiple of 32 must be used as the width of the src frame,
170+
// and the right black border needs to be cropped during conversion.
171+
if( (width % 32) !=0 ) {
172+
width = (width / 32 + 1) * 32;
173+
}
170174
}
171175

172176
cinfo.image_width = real_width;

0 commit comments

Comments
 (0)