28 AINFO <<
"Initialize video driver component.";
35 AINFO <<
"Velodyne config: " << video_config.DebugString();
38 camera_deivce_->Init();
40 if (camera_deivce_->Record()) {
44 AINFO <<
"Record folder: " << record_folder_;
47 if (stat(record_folder_.c_str(), &st) < 0) {
48 bool ret = EnsureDirectory(record_folder_);
49 AINFO_IF(ret) <<
"Record folder is created successfully.";
53 pb_image_->mutable_data()->reserve(1920 * 1080 * 4);
59 video_thread_ = std::shared_ptr<std::thread>(
60 new std::thread(std::bind(&CompCameraH265Compressed::VideoPoll,
this)));
61 video_thread_->detach();
66void CompCameraH265Compressed::VideoPoll() {
68 if (camera_deivce_->Record()) {
70 snprintf(name,
sizeof(name),
"%s/encode_%d.h265", record_folder_.c_str(),
71 camera_deivce_->Port());
72 AINFO <<
"Output file: " << name;
73 fout.open(name, std::ios::binary);
75 AERROR <<
"Failed to open output file: " << name;
78 int poll_failure_number = 0;
80 if (!camera_deivce_->Poll(pb_image_)) {
81 AERROR <<
"H265 poll failed on port: " << camera_deivce_->Port();
82 static constexpr int kTolerance = 256;
83 if (++poll_failure_number > kTolerance) {
84 AERROR <<
"H265 poll keep failing for " << kTolerance <<
" times, Exit";
89 poll_failure_number = 0;
90 pb_image_->mutable_header()->set_timestamp_sec(
92 AINFO <<
"Send compressed image.";
93 writer_->Write(pb_image_);
95 if (camera_deivce_->Record()) {
96 fout.write(pb_image_->data().c_str(), pb_image_->data().size());
100 if (camera_deivce_->Record()) {
bool GetProtoConfig(T *config) const
std::shared_ptr< Node > node_
static Time Now()
get the current time.
std::string GetEnv(const std::string &var_name, const std::string &default_value="")
bool EnsureDirectory(const std::string &directory_path)
Check if a specified directory specified by directory_path exists.
optional string output_channel
optional CompressConfig compress_conf