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
29
namespace
apollo
{
30
namespace
drivers {
31
namespace
video {
32
33
static
const
int
SOCKET_TIMEOUT = -2;
34
static
const
int
RECEIVE_FAIL = -3;
35
static
const
int
POLL_TIMEOUT
= 1000;
// one second (in msec)
36
static
const
size_t
H265_FRAME_PACKAGE_SIZE = 4 * 1024 * 1024;
37
static
const
size_t
H265_PDU_SIZE = 1500;
38
40
class
SocketInput
{
41
public
:
42
SocketInput
();
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
apollo::drivers::video::SocketInput
Live Velodyne input from socket.
Definition
socket_input.h:40
apollo::drivers::video::SocketInput::Init
void Init(uint32_t port)
Definition
socket_input.cc:61
apollo::drivers::video::SocketInput::GetFramePacket
int GetFramePacket(std::shared_ptr< CompressedImage > h265)
Get one camera packet.
Definition
socket_input.cc:112
apollo::drivers::video::SocketInput::SocketInput
SocketInput()
constructor
Definition
socket_input.cc:44
apollo::drivers::video::SocketInput::~SocketInput
virtual ~SocketInput()
destructor
Definition
socket_input.cc:51
cyber.h
apollo
class register implement
Definition
arena_queue.h:37
POLL_TIMEOUT
@ POLL_TIMEOUT
Definition
protocol_asensing.cc:27
modules
drivers
video
socket_input.h