10 #ifndef MJPEGCARRIER_INC
11 #define MJPEGCARRIER_INC
81 this->envelope = envelope;
102 return "mjpeg_carrier";
107 const char *target =
"GET /?ac";
108 for (
size_t i=0; i<8 && i<header.
length(); i++) {
109 header.
get()[i] = target[i];
117 const char *target =
"GET /?ac";
118 for (
int i=0; i<8; i++) {
119 if (header.
get()[i] != target[i]) {
154 std::string target =
"HTTP/1.0 200 OK\r\n\
155 Connection: close\r\n\
156 Server: yarp/mjpeg_carrier/0.1\r\n\
157 Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0\r\n\
158 Pragma: no-cache\r\n\
159 Expires: Mon, 3 Jan 2000 12:34:56 GMT\r\n\
160 Content-Type: multipart/x-mixed-replace;boundary=boundarydonotcross\r\n\
162 --boundarydonotcross\r\n";
181 if (stream==NULL) {
return false; }
const yarp::os::LogComponent & MJPEGCARRIER()
A carrier for sending/receiving images via mjpeg over http.
virtual bool autoCompression() const
bool isActive() const override
Check if carrier is alive and error free.
bool canEscape() const override
Check if carrier can encode administrative messages, as opposed to just user data.
bool respondToHeader(yarp::os::ConnectionState &proto) override
Respond to the header.
bool expectExtraHeader(yarp::os::ConnectionState &proto) override
Receive any carrier-specific header.
void handleEnvelope(const std::string &envelope) override
Carriers that do not distinguish data from administrative headers (i.e.
bool isLocal() const override
Check if carrier operates within a single process.
bool reply(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer) override
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...
Carrier * create() const override
Factory method.
bool expectAck(yarp::os::ConnectionState &proto) override
Receive an acknowledgement, if expected for this carrier.
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...
bool supportReply() const override
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
bool isConnectionless() const override
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
bool canAccept() const override
Check if reading is implemented for this carrier.
void setParameters(const yarp::os::Bytes &header) override
Configure this carrier based on the first 8 bytes of the connection.
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
bool requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
bool prepareSend(yarp::os::ConnectionState &proto) override
Perform any initialization needed before writing on a connection.
bool isTextMode() const override
Check if carrier is textual in nature.
bool sendAck(yarp::os::ConnectionState &proto) override
Send an acknowledgement, if needed for this carrier.
bool isPush() const override
Check if carrier is "push" or "pull" style.
std::string toString() const override
Get name of carrier.
bool canOffer() const override
Check if writing is implemented for this carrier.
bool expectSenderSpecifier(yarp::os::ConnectionState &proto) override
Expect the name of the sending port.
bool write(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer) override
Write a message.
bool sendHeader(yarp::os::ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
bool expectReplyToHeader(yarp::os::ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
bool expectIndex(yarp::os::ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
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...
virtual bool sendIndex(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer)
A simple abstraction for a block of bytes.
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
The basic state of a connection - route, streams in use, etc.
virtual TwoWayStream * giveStreams()=0
Take ownership of the streams associated with the connection.
virtual void takeStreams(TwoWayStream *streams)=0
Provide streams to be used with the connection.
InputStream & is()
Shorthand for getInputStream()
OutputStream & os()
Shorthand for getOutputStream()
virtual void write(char ch)
Write a single byte to the stream.
Minimal requirements for an efficient Writer.
#define yCTrace(component,...)