vp8_streamer.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, Worcester Polytechnic Institute
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the Worcester Polytechnic Institute nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  *********************************************************************/
36 
38 
39 namespace web_video_server
40 {
41 
44  LibavStreamer(request, connection, nh, "webm", "libvpx", "video/webm")
45 {
46  quality_ = request.get_query_param_value_or_default("quality", "realtime");
47 }
49 {
50 }
51 
53 {
54  typedef std::map<std::string, std::string> AvOptMap;
55  AvOptMap av_opt_map;
56  av_opt_map["quality"] = quality_;
57  av_opt_map["deadline"] = "1";
58  av_opt_map["auto-alt-ref"] = "0";
59  av_opt_map["lag-in-frames"] = "1";
60  av_opt_map["rc_lookahead"] = "1";
61  av_opt_map["drop_frame"] = "1";
62  av_opt_map["error-resilient"] = "1";
63 
64  for (AvOptMap::iterator itr = av_opt_map.begin(); itr != av_opt_map.end(); ++itr)
65  {
66  av_opt_set(codec_context_->priv_data, itr->first.c_str(), itr->second.c_str(), 0);
67  }
68 
69  // Buffering settings
70  int bufsize = 10;
71  codec_context_->rc_buffer_size = bufsize;
72  codec_context_->rc_initial_buffer_occupancy = bufsize; //bitrate/3;
73  av_opt_set_int(codec_context_->priv_data, "bufsize", bufsize, 0);
74  av_opt_set_int(codec_context_->priv_data, "buf-initial", bufsize, 0);
75  av_opt_set_int(codec_context_->priv_data, "buf-optimal", bufsize, 0);
76  av_opt_set_int(codec_context_->priv_data, "skip_threshold", 10, 0);
77 }
78 
80  LibavStreamerType("webm", "libvpx", "video/webm")
81 {
82 }
83 
87 {
88  return boost::shared_ptr<ImageStreamer>(new Vp8Streamer(request, connection, nh));
89 }
90 
91 }
boost::shared_ptr< HttpConnection >
web_video_server::LibavStreamer::codec_context_
AVCodecContext * codec_context_
Definition: libav_streamer.h:40
web_video_server::Vp8Streamer::initializeEncoder
virtual void initializeEncoder()
Definition: vp8_streamer.cpp:86
web_video_server::LibavStreamerType
Definition: libav_streamer.h:62
web_video_server::Vp8Streamer
Definition: vp8_streamer.h:82
web_video_server::Vp8StreamerType::Vp8StreamerType
Vp8StreamerType()
Definition: vp8_streamer.cpp:113
async_web_server_cpp::HttpRequest
async_web_server_cpp::HttpRequest::get_query_param_value_or_default
std::string get_query_param_value_or_default(const std::string &name, const std::string &default_value) const
web_video_server::Vp8Streamer::Vp8Streamer
Vp8Streamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, ros::NodeHandle &nh)
Definition: vp8_streamer.cpp:76
web_video_server
Definition: h264_streamer.h:9
vp8_streamer.h
web_video_server::Vp8Streamer::quality_
std::string quality_
Definition: vp8_streamer.h:125
web_video_server::Vp8Streamer::~Vp8Streamer
~Vp8Streamer()
Definition: vp8_streamer.cpp:82
web_video_server::Vp8StreamerType::create_streamer
virtual boost::shared_ptr< ImageStreamer > create_streamer(const async_web_server_cpp::HttpRequest &request, async_web_server_cpp::HttpConnectionPtr connection, ros::NodeHandle &nh)
Definition: vp8_streamer.cpp:118
ros::NodeHandle


web_video_server
Author(s): Mitchell Wills
autogenerated on Wed Mar 2 2022 01:13:35