diff --git a/cereal b/cereal index 591e389bf8..0a9b426e55 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit 591e389bf8e31f6f6ab921ec6598cafa53c19d36 +Subproject commit 0a9b426e55653daea6cc9d3c40c3f7600ec0db49 diff --git a/system/loggerd/encoder/encoder.cc b/system/loggerd/encoder/encoder.cc index c4bd91bcf7..313a0f57a1 100644 --- a/system/loggerd/encoder/encoder.cc +++ b/system/loggerd/encoder/encoder.cc @@ -6,7 +6,12 @@ VideoEncoder::VideoEncoder(const EncoderInfo &encoder_info, int in_width, int in out_width = encoder_info.frame_width > 0 ? encoder_info.frame_width : in_width; out_height = encoder_info.frame_height > 0 ? encoder_info.frame_height : in_height; - pm.reset(new PubMaster({encoder_info.publish_name})); + + std::vector pubs = {encoder_info.publish_name}; + if (encoder_info.thumbnail_name != NULL) { + pubs.push_back(encoder_info.thumbnail_name); + } + pm.reset(new PubMaster(pubs)); } void VideoEncoder::publisher_publish(VideoEncoder *e, int segment_num, uint32_t idx, VisionIpcBufExtra &extra, @@ -40,4 +45,15 @@ void VideoEncoder::publisher_publish(VideoEncoder *e, int segment_num, uint32_t kj::ArrayOutputStream output_stream(kj::ArrayPtr(e->msg_cache.data(), bytes_size)); capnp::writeMessage(output_stream, msg); e->pm->send(e->encoder_info.publish_name, e->msg_cache.data(), bytes_size); -} + + // Publish keyframe thumbnail + if ((flags & V4L2_BUF_FLAG_KEYFRAME) && e->encoder_info.thumbnail_name != NULL) { + MessageBuilder tm; + auto thumbnail = tm.initEvent().initThumbnail(); + thumbnail.setFrameId(extra.frame_id); + thumbnail.setTimestampEof(extra.timestamp_eof); + thumbnail.setThumbnail(dat); + thumbnail.setEncoding(cereal::Thumbnail::Encoding::KEYFRAME); + pm->send(e->encoder_info.thumbnail_name, tm); + } +} \ No newline at end of file diff --git a/system/loggerd/encoder/encoder.h b/system/loggerd/encoder/encoder.h index 7c203f9193..75183611b3 100644 --- a/system/loggerd/encoder/encoder.h +++ b/system/loggerd/encoder/encoder.h @@ -25,6 +25,8 @@ public: void publisher_publish(VideoEncoder *e, int segment_num, uint32_t idx, VisionIpcBufExtra &extra, unsigned int flags, kj::ArrayPtr header, kj::ArrayPtr dat); protected: + void publish_thumbnail(uint32_t frame_id, uint64_t timestamp_eof, kj::ArrayPtr dat); + int in_width, in_height; int out_width, out_height; const EncoderInfo encoder_info; diff --git a/system/loggerd/loggerd.h b/system/loggerd/loggerd.h index ea288f4861..5eef161834 100644 --- a/system/loggerd/loggerd.h +++ b/system/loggerd/loggerd.h @@ -33,6 +33,7 @@ constexpr char PRESERVE_ATTR_VALUE = '1'; class EncoderInfo { public: const char *publish_name; + const char *thumbnail_name = NULL; const char *filename = NULL; bool record = true; int frame_width = -1; @@ -76,6 +77,7 @@ const EncoderInfo main_driver_encoder_info = { const EncoderInfo stream_road_encoder_info = { .publish_name = "livestreamRoadEncodeData", + //.thumbnail_name = "thumbnail", .encode_type = cereal::EncodeIndex::Type::QCAMERA_H264, .record = false, .bitrate = LIVESTREAM_BITRATE,