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 
33 namespace fawkes {
34 
35 class DynamicMJPEGStreamWebReply : public DynamicWebReply,
36  public WebviewJpegStreamProducer::Subscriber
37 {
38 public:
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 
50 private:
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
fawkes::DynamicMJPEGStreamWebReply::handle_buffer
virtual void handle_buffer(std::shared_ptr< WebviewJpegStreamProducer::Buffer > buffer)
Definition: mjpeg_reply.cpp:108
fawkes::Mutex
Definition: mutex.h:38
fawkes::WaitCondition
Definition: wait_condition.h:42
fawkes::DynamicMJPEGStreamWebReply::~DynamicMJPEGStreamWebReply
virtual ~DynamicMJPEGStreamWebReply()
Destructor.
Definition: mjpeg_reply.cpp:77
fawkes::DynamicMJPEGStreamWebReply::DynamicMJPEGStreamWebReply
DynamicMJPEGStreamWebReply(std::shared_ptr< WebviewJpegStreamProducer > stream_producer)
Constructor.
Definition: mjpeg_reply.cpp:48
fawkes
fawkes::DynamicMJPEGStreamWebReply::next_chunk
virtual size_t next_chunk(size_t pos, char *buffer, size_t buf_max_size)
Definition: mjpeg_reply.cpp:117
fawkes::DynamicMJPEGStreamWebReply::operator=
DynamicMJPEGStreamWebReply & operator=(const DynamicMJPEGStreamWebReply &other)
Assignment operator.
Definition: mjpeg_reply.cpp:89
fawkes::DynamicMJPEGStreamWebReply
Definition: mjpeg_reply.h:41
fawkes::DynamicMJPEGStreamWebReply::size
virtual size_t size()
Definition: mjpeg_reply.cpp:102