24#pragma warning (disable : 4091)
59#ifdef LIBJPEG_TURBO_VERSION
91 const char *
brk =
"\r\n";
92 std::snprintf(
hdr,
hdr_size,
"Content-Type: image/jpeg%s\
93Content-Length: %d%s%s",
brk, len,
brk,
brk);
96 Bytes buf((
char *)data,len);
117 dest->buffer = &(dest->cache[0]);
118 dest->bufsize =
sizeof(dest->cache);
119 dest->pub.next_output_byte = dest->buffer;
120 dest->pub.free_in_buffer = dest->bufsize;
126 send_net_data(dest->buffer,dest->bufsize-dest->pub.free_in_buffer,
128 dest->pub.next_output_byte = dest->buffer;
129 dest->pub.free_in_buffer = dest->bufsize;
136 send_net_data(dest->buffer,dest->bufsize-dest->pub.free_in_buffer,
148 if (cinfo->dest ==
nullptr) {
164 if (img ==
nullptr) {
167 int w = img->
width();
177 cinfo.client_data = &proto;
180 cinfo.image_width = w;
181 cinfo.image_height = h;
182#ifndef LIBJPEG_TURBO_VERSION
186 yCTrace(
MJPEGCARRIER,
"Pixel format not supported, please compile YARP with libjpeg-turbo to support it.");
196 if(!envelope.empty()) {
201 while (cinfo.next_scanline < cinfo.image_height) {
219 std::string
pathValue =
n.getCarrierModifier(
"path");
220 std::string target =
"GET /?action=stream\n\n";
225 target +=
" HTTP/1.1\n";
233 Bytes b((
char*)target.c_str(),target.length());
239#ifdef MJPEG_AUTOCOMPRESS
static const std::map< int, int > yarpCode2Channels
static boolean empty_net_output_buffer(j_compress_ptr cinfo)
static const std::map< int, J_COLOR_SPACE > yarpCode2Mjpeg
void jpeg_net_dest(j_compress_ptr cinfo)
net_destination_mgr * net_destination_ptr
static void init_net_destination(j_compress_ptr cinfo)
void send_net_data(JOCTET *data, int len, void *client)
static void term_net_destination(j_compress_ptr cinfo)
const yarp::os::LogComponent & MJPEGCARRIER()
virtual bool autoCompression() const
bool reply(yarp::os::ConnectionState &proto, yarp::os::SizedWriter &writer) override
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.
A mini-server for performing network communication in the background.
BufferedPort()
Constructor.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
A simple abstraction for a block of bytes.
The basic state of a connection - route, streams in use, etc.
OutputStream & os()
Shorthand for getOutputStream()
virtual const Route & getRoute() const =0
Get the route associated with this connection.
Simple abstraction for a YARP port name.
virtual void write(char ch)
Write a single byte to the stream.
Minimal requirements for an efficient Writer.
Image class with user control of representation details.
size_t width() const
Gets width of image in pixels.
size_t getRowSize() const
Size of the underlying image buffer rows.
unsigned char * getRawImage() const
Access to the internal image buffer.
size_t height() const
Gets height of image in pixels.
virtual int getPixelCode() const
Gets pixel type identifier.
#define yCTrace(component,...)
#define yCWarning(component,...)
An interface to the operating system, including Port based communication.
struct jpeg_destination_mgr pub