Removing "initialized lambda captures" (C++14 feature).

WebRTC is still targeting C++11, this C++14 only feature sneaked in
because the Android toolchain used to build WebRTC on the trybots
uses C++14 features.

Bug: None
Change-Id: I095fb76134dff729c72b7660cdb3d6abc4de2e0c
Reviewed-on: https://webrtc-review.googlesource.com/42501
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21711}
This commit is contained in:
Mirko Bonadei
2018-01-22 13:40:37 +01:00
committed by Commit Bot
parent 3b790f316c
commit 848f31e57d

View File

@ -193,45 +193,60 @@ void VideoEncoderWrapper::OnEncodedFrame(JNIEnv* jni,
memcpy(buffer_copy.data(), buffer, buffer_size); memcpy(buffer_copy.data(), buffer, buffer_size);
const int qp = JavaToNativeOptionalInt(jni, j_qp).value_or(-1); const int qp = JavaToNativeOptionalInt(jni, j_qp).value_or(-1);
encoder_queue_->PostTask( struct Lambda {
[ VideoEncoderWrapper* video_encoder_wrapper;
this, task_buffer = std::move(buffer_copy), qp, encoded_width, std::vector<uint8_t> task_buffer;
encoded_height, capture_time_ns, frame_type, rotation, complete_frame int qp;
]() { jint encoded_width;
FrameExtraInfo frame_extra_info; jint encoded_height;
do { jlong capture_time_ns;
if (frame_extra_infos_.empty()) { jint frame_type;
RTC_LOG(LS_WARNING) jint rotation;
<< "Java encoder produced an unexpected frame with timestamp: " jboolean complete_frame;
<< capture_time_ns; std::deque<FrameExtraInfo>* frame_extra_infos;
return; EncodedImageCallback* callback;
}
frame_extra_info = frame_extra_infos_.front(); void operator()() const {
frame_extra_infos_.pop_front(); FrameExtraInfo frame_extra_info;
// The encoder might drop frames so iterate through the queue until do {
// we find a matching timestamp. if (frame_extra_infos->empty()) {
} while (frame_extra_info.capture_time_ns != capture_time_ns); RTC_LOG(LS_WARNING)
<< "Java encoder produced an unexpected frame with timestamp: "
RTPFragmentationHeader header = ParseFragmentationHeader(task_buffer); << capture_time_ns;
EncodedImage frame(const_cast<uint8_t*>(task_buffer.data()), return;
task_buffer.size(), task_buffer.size());
frame._encodedWidth = encoded_width;
frame._encodedHeight = encoded_height;
frame._timeStamp = frame_extra_info.timestamp_rtp;
frame.capture_time_ms_ = capture_time_ns / rtc::kNumNanosecsPerMillisec;
frame._frameType = (FrameType)frame_type;
frame.rotation_ = (VideoRotation)rotation;
frame._completeFrame = complete_frame;
if (qp == -1) {
frame.qp_ = ParseQp(task_buffer);
} else {
frame.qp_ = qp;
} }
frame_extra_info = frame_extra_infos->front();
frame_extra_infos->pop_front();
// The encoder might drop frames so iterate through the queue until
// we find a matching timestamp.
} while (frame_extra_info.capture_time_ns != capture_time_ns);
CodecSpecificInfo info(ParseCodecSpecificInfo(frame)); RTPFragmentationHeader header =
callback_->OnEncodedImage(frame, &info, &header); video_encoder_wrapper->ParseFragmentationHeader(task_buffer);
}); EncodedImage frame(const_cast<uint8_t*>(task_buffer.data()),
task_buffer.size(), task_buffer.size());
frame._encodedWidth = encoded_width;
frame._encodedHeight = encoded_height;
frame._timeStamp = frame_extra_info.timestamp_rtp;
frame.capture_time_ms_ = capture_time_ns / rtc::kNumNanosecsPerMillisec;
frame._frameType = (FrameType)frame_type;
frame.rotation_ = (VideoRotation)rotation;
frame._completeFrame = complete_frame;
if (qp == -1) {
frame.qp_ = video_encoder_wrapper->ParseQp(task_buffer);
} else {
frame.qp_ = qp;
}
CodecSpecificInfo info(
video_encoder_wrapper->ParseCodecSpecificInfo(frame));
callback->OnEncodedImage(frame, &info, &header);
}
};
encoder_queue_->PostTask(Lambda{this, std::move(buffer_copy),
qp, encoded_width, encoded_height, capture_time_ns, frame_type,
rotation, complete_frame, &frame_extra_infos_, callback_});
} }
int32_t VideoEncoderWrapper::HandleReturnCode(JNIEnv* jni, int32_t VideoEncoderWrapper::HandleReturnCode(JNIEnv* jni,