YARP
Yet Another Robot Platform
H264Carrier.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #ifndef H264CARRIER_INC
10 #define H264CARRIER_INC
11 
12 #include <yarp/os/Carrier.h>
13 #include <yarp/os/Face.h>
14 #include "H264Decoder.h"
15 
16 
36 class H264Carrier :
37  public yarp::os::Carrier
38 {
39 private:
40  std::string envelope;
41  h264Decoder_cfgParamters cfgParams;
42 public:
44  {}
45 
46  Carrier *create() const override
47  {
48  return new H264Carrier();
49  }
50 
51  std::string getName() const override;
52 
53  bool isConnectionless() const override;
54 
55  bool canAccept() const override;
56 
57  bool canOffer() const override;
58 
59  bool isTextMode() const override;
60 
61  bool canEscape() const override;
62 
63  void handleEnvelope(const std::string& envelope) override;
64 
65  bool requireAck() const override;
66 
67  bool supportReply() const override;
68 
69  bool isLocal() const override;
70 
71  // this is important - flips expected flow of messages
72  bool isPush() const override;
73 
74  std::string toString() const override;
75 
76  void getHeader(yarp::os::Bytes& header) const override;
77 
78  bool checkHeader(const yarp::os::Bytes& header) override;
79 
80  void setParameters(const yarp::os::Bytes& header) override;
81 
82 
83  // Now, the initial hand-shaking
84 
85  bool prepareSend(yarp::os::ConnectionState& proto) override;
86 
87  bool sendHeader(yarp::os::ConnectionState& proto) override;
88 
90 
91  bool expectExtraHeader(yarp::os::ConnectionState& proto) override;
92 
93  bool respondToHeader(yarp::os::ConnectionState& proto) override;
94 
95  bool expectReplyToHeader(yarp::os::ConnectionState& proto) override;
96 
97  bool isActive() const override;
98 
99 
100  // Payload time!
101 
102  bool write(yarp::os::ConnectionState& proto, yarp::os::SizedWriter& writer) override;
103 
104  bool reply(yarp::os::ConnectionState& proto, yarp::os::SizedWriter& writer) override;
105 
106  virtual bool sendIndex(yarp::os::ConnectionState& proto, yarp::os::SizedWriter& writer);
107 
108  bool expectIndex(yarp::os::ConnectionState& proto) override;
109 
110  bool sendAck(yarp::os::ConnectionState& proto) override;
111 
112  bool expectAck(yarp::os::ConnectionState& proto) override;
113 
114  std::string getBootstrapCarrierName() const override;
115 
116  yarp::os::Face* createFace() const override;
117 
118 };
119 
120 #endif
H264Carrier::H264Carrier
H264Carrier()
Definition: H264Carrier.h:43
H264Carrier::setParameters
void setParameters(const yarp::os::Bytes &header) override
Configure this carrier based on the first 8 bytes of the connection.
Definition: H264Carrier.cpp:94
yarp::os::Carrier
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
Definition: Carrier.h:48
H264Decoder.h
H264Carrier::supportReply
bool supportReply() const override
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
Definition: H264Carrier.cpp:64
H264Carrier::createFace
yarp::os::Face * createFace() const override
Create new Face object that the carrier needs.
Definition: H264Carrier.cpp:220
Face.h
H264Carrier::expectReplyToHeader
bool expectReplyToHeader(yarp::os::ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
Definition: H264Carrier.cpp:155
H264Carrier::isLocal
bool isLocal() const override
Check if carrier operates within a single process.
Definition: H264Carrier.cpp:69
H264Carrier::expectAck
bool expectAck(yarp::os::ConnectionState &proto) override
Receive an acknowledgement, if expected for this carrier.
Definition: H264Carrier.cpp:210
H264Carrier::handleEnvelope
void handleEnvelope(const std::string &envelope) override
Carriers that do not distinguish data from administrative headers (i.e.
Definition: H264Carrier.cpp:54
H264Carrier::isActive
bool isActive() const override
Check if carrier is alive and error free.
Definition: H264Carrier.cpp:179
H264Carrier::getBootstrapCarrierName
std::string getBootstrapCarrierName() const override
Get the name of the carrier that should be used prior to handshaking, if a port is registered with th...
Definition: H264Carrier.cpp:215
H264Carrier::expectSenderSpecifier
bool expectSenderSpecifier(yarp::os::ConnectionState &proto) override
Expect the name of the sending port.
Definition: H264Carrier.cpp:137
h264Decoder_cfgParamters
Definition: H264Decoder.h:17
H264Carrier
A carrier for receiving frames compressed in h264 over rtp.
Definition: H264Carrier.h:38
H264Carrier::requireAck
bool requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
Definition: H264Carrier.cpp:59
H264Carrier::sendAck
bool sendAck(yarp::os::ConnectionState &proto) override
Send an acknowledgement, if needed for this carrier.
Definition: H264Carrier.cpp:205
yarp::os::Bytes
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
H264Carrier::canEscape
bool canEscape() const override
Check if carrier can encode administrative messages, as opposed to just user data.
Definition: H264Carrier.cpp:49
H264Carrier::create
Carrier * create() const override
Factory method.
Definition: H264Carrier.h:46
yarp::os::ConnectionState
The basic state of a connection - route, streams in use, etc.
Definition: ConnectionState.h:31
H264Carrier::isConnectionless
bool isConnectionless() const override
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
Definition: H264Carrier.cpp:29
H264Carrier::write
bool write(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer) override
Write a message.
Definition: H264Carrier.cpp:184
H264Carrier::prepareSend
bool prepareSend(yarp::os::ConnectionState &proto) override
Perform any initialization needed before writing on a connection.
Definition: H264Carrier.cpp:117
H264Carrier::getName
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
Definition: H264Carrier.cpp:24
Carrier.h
H264Carrier::getHeader
void getHeader(yarp::os::Bytes &header) const override
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to se...
Definition: H264Carrier.cpp:85
H264Carrier::isTextMode
bool isTextMode() const override
Check if carrier is textual in nature.
Definition: H264Carrier.cpp:44
H264Carrier::canOffer
bool canOffer() const override
Check if writing is implemented for this carrier.
Definition: H264Carrier.cpp:39
H264Carrier::reply
bool reply(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer) override
Definition: H264Carrier.cpp:190
H264Carrier::toString
std::string toString() const override
Get name of carrier.
Definition: H264Carrier.cpp:80
H264Carrier::isPush
bool isPush() const override
Check if carrier is "push" or "pull" style.
Definition: H264Carrier.cpp:75
H264Carrier::sendIndex
virtual bool sendIndex(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer)
Definition: H264Carrier.cpp:195
yarp::os::Face
The initial point-of-contact with a port.
Definition: Face.h:24
H264Carrier::respondToHeader
bool respondToHeader(yarp::os::ConnectionState &proto) override
Respond to the header.
Definition: H264Carrier.cpp:149
H264Carrier::checkHeader
bool checkHeader(const yarp::os::Bytes &header) override
Given the first 8 bytes received on a connection, decide if this is the right carrier type to use for...
Definition: H264Carrier.cpp:89
H264Carrier::canAccept
bool canAccept() const override
Check if reading is implemented for this carrier.
Definition: H264Carrier.cpp:34
H264Carrier::sendHeader
bool sendHeader(yarp::os::ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
Definition: H264Carrier.cpp:131
yarp::os::SizedWriter
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:36
H264Carrier::expectExtraHeader
bool expectExtraHeader(yarp::os::ConnectionState &proto) override
Receive any carrier-specific header.
Definition: H264Carrier.cpp:143
H264Carrier::expectIndex
bool expectIndex(yarp::os::ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
Definition: H264Carrier.cpp:200