AndroidVideoCapturer: Delegate framerate choice to VideoCapturerAndroid.java

webrtc::VideoSource resolves the kMaxFrameRate constraint by capping the desired framerate to kMaxFrameRate. That framerate is then passed into cricket::VideoCapturer::GetBestCaptureFormat(). The default implementation will choose a format from the supported formats list. Instead, we should override this function in AndroidVideoCapturer to give VideoCapturerAndroid.java the opportunity to choose a suitable framerate range.

BUG=webrtc:4938
R=glaznev@webrtc.org

Review URL: https://codereview.webrtc.org/1308953004 .

Cr-Commit-Position: refs/heads/master@{#9805}
This commit is contained in:
Magnus Jedvert
2015-08-28 11:40:59 +02:00
parent 98f3cc54da
commit 6ec1f921b1
3 changed files with 18 additions and 10 deletions

View File

@ -137,18 +137,17 @@ AndroidVideoCapturer::~AndroidVideoCapturer() {
cricket::CaptureState AndroidVideoCapturer::Start(
const cricket::VideoFormat& capture_format) {
LOG(LS_INFO) << " AndroidVideoCapturer::Start w = " << capture_format.width
<< " h = " << capture_format.height;
CHECK(thread_checker_.CalledOnValidThread());
CHECK(!running_);
const int fps = cricket::VideoFormat::IntervalToFps(capture_format.interval);
LOG(LS_INFO) << " AndroidVideoCapturer::Start " << capture_format.width << "x"
<< capture_format.height << "@" << fps;
frame_factory_ = new AndroidVideoCapturer::FrameFactory(delegate_.get());
set_frame_factory(frame_factory_);
running_ = true;
delegate_->Start(
capture_format.width, capture_format.height,
cricket::VideoFormat::IntervalToFps(capture_format.interval), this);
delegate_->Start(capture_format.width, capture_format.height, fps, this);
SetCaptureFormat(&capture_format);
current_state_ = cricket::CS_STARTING;
return current_state_;
@ -210,4 +209,12 @@ void AndroidVideoCapturer::OnOutputFormatRequest(
video_adapter()->OnOutputFormatRequest(format);
}
bool AndroidVideoCapturer::GetBestCaptureFormat(
const cricket::VideoFormat& desired,
cricket::VideoFormat* best_format) {
// Delegate this choice to VideoCapturerAndroid.startCapture().
*best_format = desired;
return true;
}
} // namespace webrtc

View File

@ -76,6 +76,10 @@ class AndroidVideoCapturer : public cricket::VideoCapturer {
AndroidVideoCapturerDelegate* delegate() { return delegate_.get(); }
// cricket::VideoCapturer implementation.
bool GetBestCaptureFormat(const cricket::VideoFormat& desired,
cricket::VideoFormat* best_format) override;
private:
// cricket::VideoCapturer implementation.
// Video frames will be delivered using

View File

@ -157,12 +157,9 @@ bool NewFormatWithConstraints(
value = 1;
}
}
if (value <= cricket::VideoFormat::IntervalToFps(format_in.interval)) {
if (value <= cricket::VideoFormat::IntervalToFps(format_in.interval))
format_out->interval = cricket::VideoFormat::FpsToInterval(value);
return true;
} else {
return false;
}
return true;
} else if (constraint.key == MediaConstraintsInterface::kMinAspectRatio) {
double value = rtc::FromString<double>(constraint.value);
// The aspect ratio in |constraint.value| has been converted to a string and