mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-30 19:43:41 +08:00
encoder: add ability to request keyframes from livestream encoders (#38172)
* add param that requests keyframe * set keyframe request to false on cleanup * clean * timing and errors * remove other changes * clean diff * clean diff * clean up live adaptation params and functions * better function names * fix syntax * remove unused var * clean diff
This commit is contained in:
@@ -156,7 +156,6 @@ V4LEncoder::V4LEncoder(const EncoderInfo &encoder_info, int in_width, int in_hei
|
||||
|
||||
EncoderSettings encoder_settings = encoder_info.get_settings(in_width);
|
||||
current_bitrate = encoder_settings.bitrate;
|
||||
adaptive_bitrate = encoder_info.adaptive_bitrate;
|
||||
bool is_h265 = encoder_settings.encode_type == cereal::EncodeIndex::Type::FULL_H_E_V_C;
|
||||
|
||||
struct v4l2_format fmt_out = {
|
||||
@@ -307,7 +306,7 @@ void V4LEncoder::encoder_close() {
|
||||
}
|
||||
|
||||
void V4LEncoder::set_bitrate(int bitrate) {
|
||||
if (!adaptive_bitrate || bitrate == current_bitrate) return;
|
||||
if (bitrate == current_bitrate) return;
|
||||
if (bitrate <= 0) {
|
||||
LOGE("invalid livestream encoder bitrate %d", bitrate);
|
||||
return;
|
||||
@@ -325,6 +324,17 @@ void V4LEncoder::set_bitrate(int bitrate) {
|
||||
current_bitrate = bitrate;
|
||||
}
|
||||
|
||||
void V4LEncoder::request_keyframe() {
|
||||
struct v4l2_control ctrl = {
|
||||
.id = V4L2_CID_MPEG_VIDC_VIDEO_REQUEST_IFRAME,
|
||||
.value = 1,
|
||||
};
|
||||
|
||||
if (util::safe_ioctl(fd, VIDIOC_S_CTRL, &ctrl) == -1) {
|
||||
LOGE("failed to request keyframe for %s", encoder_info.publish_name);
|
||||
}
|
||||
}
|
||||
|
||||
V4LEncoder::~V4LEncoder() {
|
||||
encoder_close();
|
||||
v4l2_buf_type buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
|
||||
|
||||
Reference in New Issue
Block a user