How to change stream resolution when screencast?

141 views
Skip to first unread message

Jay

unread,
Aug 22, 2016, 2:22:21 PM8/22/16
to discuss-webrtc
I have a screencast inherited from cricket::VideoCapturer.
When I let IsScreencast() return false, video resolution in the receiver side will change dynamically, and I cannot control it.
If IsScreencast() returns true, video resolution will be always fixed the same as the frame resolution passed in screencast.SignalFrameCaptured(&screencast, frame).
Assert captured screen size is always 1920*1080, and I want the video stream resolution can be 960*540 or others. 
How to change stream resolution when screencast?

I try to use formats and constraints:

```
        vector<cricket::VideoFormat> formats;
        formats.push_back(cricket::VideoFormat(1920, 1080, 100, cricket::FOURCC_ABGR));
        formats.push_back(cricket::VideoFormat(960, 540, 100, cricket::FOURCC_ABGR));

        screencast.SetSupportedFormats(formats);
```
```
        webrtc::FakeConstraints constraints2;
        constraints2.SetMandatoryMaxFrameRate(20);
        constraints2.AddMandatory(webrtc::MediaConstraintsInterface::kMinWidth, 960);
        constraints2.AddMandatory(webrtc::MediaConstraintsInterface::kMinHeight, 540);
        constraints2.AddMandatory(webrtc::MediaConstraintsInterface::kMaxAspectRatio, 960.0/540.0);
        videoSource = mPeerConnectionFactoryPtr->CreateVideoSource(&screencast, &constraints2);
```
or use SDP max-recv-width and imageattr both in sender and receiver
```
a=rtpmap:100 VP8/90000
a=rtcp-fb:100 ccm fir
a=rtcp-fb:100 nack
a=rtcp-fb:100 nack pli
a=rtcp-fb:100 goog-remb
a=rtcp-fb:100 transport-cc
a=fmtp:100 max-recv-width=640;max-recv-height=480
```
```
a=rtpmap:100 VP8/90000
a=setup:active
a=ssrc:3555258440 cname:{95e6e7c3-309b-45b5-975a-5fad567b1fd1}
a=imageattr:100 recv [x=960,y=540] send [x=960,y=540]
```

all are not working.
Did I have something wrong?






Jay

unread,
Sep 1, 2016, 3:46:42 AM9/1/16
to discuss-webrtc
I find the code that is impossible to change resolution when set `IsScreencast()` return true.
below it will never get into `video_adapter_.AdaptFrameResolution()`.
```
  if (enable_video_adapter_ && !IsScreencast()) {
    if (!video_adapter_.AdaptFrameResolution(
            width, height, capture_time_ns,
            crop_width, crop_height, out_width, out_height)) {
      // VideoAdapter dropped the frame.
      return false;
    }
    *crop_x = (width - *crop_width) / 2;
    *crop_y = (height - *crop_height) / 2;
  } else { 
```
the workaround is to set `IsScreencast()` always return false even it's a screen cast.
Reply all
Reply to author
Forward
0 new messages