Fawkes API Fawkes Development Version
mjpeg_reply.h
1
2/***************************************************************************
3 * mjpeg_reply.h - Web request MJPEG stream reply
4 *
5 * Created: Wed Feb 05 17:54:06 2014
6 * Copyright 2006-2014 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL file in the doc directory.
21 */
22
23#ifndef _PLUGINS_WEBVIEW_MJPEG_REPLY_H_
24#define _PLUGINS_WEBVIEW_MJPEG_REPLY_H_
25
26#include "jpeg_stream_producer.h"
27
28#include <webview/reply.h>
29
30#include <cstdio>
31#include <memory>
32
33namespace fawkes {
34
37{
38public:
39 DynamicMJPEGStreamWebReply(std::shared_ptr<WebviewJpegStreamProducer> stream_producer);
42
44
45 virtual size_t size();
46 virtual size_t next_chunk(size_t pos, char *buffer, size_t buf_max_size);
47
48 virtual void handle_buffer(std::shared_ptr<WebviewJpegStreamProducer::Buffer> buffer);
49
50private:
51 std::shared_ptr<WebviewJpegStreamProducer> stream_producer_;
52
53 std::shared_ptr<WebviewJpegStreamProducer::Buffer> buffer_;
54 size_t buffer_bytes_written_;
55
56 std::shared_ptr<WebviewJpegStreamProducer::Buffer> next_buffer_;
57 fawkes::Mutex * next_buffer_mutex_;
58 fawkes::WaitCondition * next_buffer_waitcond_;
59
60 bool next_frame_;
61};
62
63} // end namespace fawkes
64
65#endif
Dynamic raw file transfer reply.
Definition: mjpeg_reply.h:37
virtual size_t next_chunk(size_t pos, char *buffer, size_t buf_max_size)
Get data of next chunk.
virtual void handle_buffer(std::shared_ptr< WebviewJpegStreamProducer::Buffer > buffer)
Notification if a new buffer is available.
virtual ~DynamicMJPEGStreamWebReply()
Destructor.
Definition: mjpeg_reply.cpp:77
virtual size_t size()
Total size of the web reply.
DynamicMJPEGStreamWebReply & operator=(const DynamicMJPEGStreamWebReply &other)
Assignment operator.
Definition: mjpeg_reply.cpp:89
DynamicMJPEGStreamWebReply(std::shared_ptr< WebviewJpegStreamProducer > stream_producer)
Constructor.
Definition: mjpeg_reply.cpp:48
Dynamic web reply.
Definition: reply.h:126
Mutex mutual exclusion lock.
Definition: mutex.h:33
Wait until a given condition holds.
Fawkes library namespace.