YARP
Yet Another Robot Platform
H264Carrier.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 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
A carrier for receiving frames compressed in h264 over rtp.
Definition: H264Carrier.h:38
bool respondToHeader(yarp::os::ConnectionState &proto) override
Respond to the header.
bool canEscape() const override
Check if carrier can encode administrative messages, as opposed to just user data.
Definition: H264Carrier.cpp:49
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
Definition: H264Carrier.cpp:24
bool write(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer) override
Write a message.
bool expectSenderSpecifier(yarp::os::ConnectionState &proto) override
Expect the name of the sending port.
void handleEnvelope(const std::string &envelope) override
Carriers that do not distinguish data from administrative headers (i.e.
Definition: H264Carrier.cpp:54
bool isPush() const override
Check if carrier is "push" or "pull" style.
Definition: H264Carrier.cpp:75
bool expectIndex(yarp::os::ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
virtual bool sendIndex(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer)
bool isConnectionless() const override
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
Definition: H264Carrier.cpp:29
Carrier * create() const override
Factory method.
Definition: H264Carrier.h:46
bool expectExtraHeader(yarp::os::ConnectionState &proto) override
Receive any carrier-specific header.
bool isTextMode() const override
Check if carrier is textual in nature.
Definition: H264Carrier.cpp:44
bool supportReply() const override
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
Definition: H264Carrier.cpp:64
std::string toString() const override
Get name of carrier.
Definition: H264Carrier.cpp:80
void setParameters(const yarp::os::Bytes &header) override
Configure this carrier based on the first 8 bytes of the connection.
Definition: H264Carrier.cpp:94
bool prepareSend(yarp::os::ConnectionState &proto) override
Perform any initialization needed before writing on a connection.
bool isLocal() const override
Check if carrier operates within a single process.
Definition: H264Carrier.cpp:69
bool isActive() const override
Check if carrier is alive and error free.
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
bool reply(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer) override
bool canOffer() const override
Check if writing is implemented for this carrier.
Definition: H264Carrier.cpp:39
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...
bool sendHeader(yarp::os::ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
bool requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
Definition: H264Carrier.cpp:59
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
bool expectReplyToHeader(yarp::os::ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
bool canAccept() const override
Check if reading is implemented for this carrier.
Definition: H264Carrier.cpp:34
bool sendAck(yarp::os::ConnectionState &proto) override
Send an acknowledgement, if needed for this carrier.
bool expectAck(yarp::os::ConnectionState &proto) override
Receive an acknowledgement, if expected for this carrier.
yarp::os::Face * createFace() const override
Create new Face object that the carrier needs.
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
Definition: Carrier.h:48
The basic state of a connection - route, streams in use, etc.
The initial point-of-contact with a port.
Definition: Face.h:24
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:36