Apollo 11.0
自动驾驶开放平台
socket_input.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 <unistd.h>
20
21#include <cstdio>
22#include <map>
23#include <memory>
24#include <string>
25
26#include "cyber/cyber.h"
27#include "modules/common_msgs/sensor_msgs/sensor_image.pb.h"
28
29namespace apollo {
30namespace drivers {
31namespace video {
32
33static const int SOCKET_TIMEOUT = -2;
34static const int RECEIVE_FAIL = -3;
35static const int POLL_TIMEOUT = 1000; // one second (in msec)
36static const size_t H265_FRAME_PACKAGE_SIZE = 4 * 1024 * 1024;
37static const size_t H265_PDU_SIZE = 1500;
38
41 public:
43 virtual ~SocketInput();
44 void Init(uint32_t port);
45 int GetFramePacket(std::shared_ptr<CompressedImage> h265);
46
47 private:
48 int sockfd_;
49 int port_;
50 uint8_t *buf_ = nullptr;
51 uint8_t *pdu_ = nullptr;
52 int pkg_num_;
53 int bytes_num_;
54 uint32_t frame_id_;
55 bool InputAvailable(int timeout);
56};
57
58} // namespace video
59} // namespace drivers
60} // namespace apollo
Live Velodyne input from socket.
int GetFramePacket(std::shared_ptr< CompressedImage > h265)
Get one camera packet.
class register implement
Definition arena_queue.h:37
@ POLL_TIMEOUT