Apollo 10.0
自动驾驶开放平台
microphone_component.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#pragma once
18
19#include <atomic>
20#include <cmath>
21#include <future>
22#include <memory>
23#include <string>
24#include <vector>
25
26#include "cyber/cyber.h"
28#include "modules/drivers/microphone/proto/audio.pb.h"
29#include "modules/drivers/microphone/proto/microphone_config.pb.h"
31
32namespace apollo {
33namespace drivers {
34namespace microphone {
35
36using apollo::common::util::FillHeader;
43
45 public:
46 bool Init() override;
48
49 private:
50 void run();
51 void fill_channel_data(int chunk_i);
52
53 // Configuration
54 int n_chunks_, n_channels_, chunk_, chunk_size_, n_chunk_,
55 sample_width_;
56
57 // class data
58 std::shared_ptr<AudioData> audio_data_ptr_;
59 std::shared_ptr<Writer<AudioData>> writer_ptr_;
60 std::unique_ptr<Respeaker> microphone_device_ptr_;
61 std::vector<std::string *> channel_data_ptrs_;
62 std::shared_ptr<MicrophoneConfig> microphone_config_ptr_;
63 char *buffer_;
64
65 std::future<void> async_result_;
66 std::atomic<bool> running_ = {false};
67};
68
70} // namespace microphone
71} // namespace drivers
72} // namespace apollo
Reader subscribes a channel, it has two main functions:
Definition reader.h:69
#define CYBER_REGISTER_COMPONENT(name)
Definition component.h:656
Some string util functions.
class register implement
Definition arena_queue.h:37