encoder: remove function `publisher_init`, init PubMaster in constructor (#28980)

old-commit-hash: 65fe3c8c34
beeps
Dean Lee 2 years ago committed by GitHub
parent 4185aeb93b
commit bd93cd7db3
  1. 7
      system/loggerd/encoder/encoder.cc
  2. 8
      system/loggerd/encoder/encoder.h
  3. 2
      system/loggerd/encoder/ffmpeg_encoder.cc
  4. 2
      system/loggerd/encoder/v4l_encoder.cc

@ -1,10 +1,7 @@
#include <cassert>
#include "system/loggerd/encoder/encoder.h"
VideoEncoder::~VideoEncoder() {}
void VideoEncoder::publisher_init() {
// publish
VideoEncoder::VideoEncoder(const EncoderInfo &encoder_info, int in_width, int in_height)
: encoder_info(encoder_info), in_width(in_width), in_height(in_height) {
pm.reset(new PubMaster({encoder_info.publish_name}));
}

@ -14,14 +14,12 @@
class VideoEncoder {
public:
VideoEncoder(const EncoderInfo &encoder_info, int in_width, int in_height)
: encoder_info(encoder_info), in_width(in_width), in_height(in_height) {}
virtual ~VideoEncoder();
VideoEncoder(const EncoderInfo &encoder_info, int in_width, int in_height);
virtual ~VideoEncoder() {};
virtual int encode_frame(VisionBuf* buf, VisionIpcBufExtra *extra) = 0;
virtual void encoder_open(const char* path) = 0;
virtual void encoder_close() = 0;
void publisher_init();
static void publisher_publish(VideoEncoder *e, int segment_num, uint32_t idx, VisionIpcBufExtra &extra, unsigned int flags, kj::ArrayPtr<capnp::byte> header, kj::ArrayPtr<capnp::byte> dat);
@ -32,7 +30,5 @@ protected:
private:
// total frames encoded
int cnt = 0;
// publishing
std::unique_ptr<PubMaster> pm;
};

@ -40,8 +40,6 @@ FfmpegEncoder::FfmpegEncoder(const EncoderInfo &encoder_info, int in_width, int
if (in_width != encoder_info.frame_width || in_height != encoder_info.frame_height) {
downscale_buf.resize(encoder_info.frame_width * encoder_info.frame_height * 3 / 2);
}
publisher_init();
}
FfmpegEncoder::~FfmpegEncoder() {

@ -251,8 +251,6 @@ V4LEncoder::V4LEncoder(const EncoderInfo &encoder_info, int in_width, int in_hei
for (unsigned int i = 0; i < BUF_IN_COUNT; i++) {
free_buf_in.push(i);
}
publisher_init();
}
void V4LEncoder::encoder_open(const char* path) {

Loading…
Cancel
Save