Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "web_video_server/vp8_streamer.h"
00038
00039 namespace web_video_server
00040 {
00041
00042 Vp8Streamer::Vp8Streamer(const async_web_server_cpp::HttpRequest& request,
00043 async_web_server_cpp::HttpConnectionPtr connection, ros::NodeHandle& nh) :
00044 LibavStreamer(request, connection, nh, "webm", "libvpx", "video/webm")
00045 {
00046 quality_ = request.get_query_param_value_or_default("quality", "realtime");
00047 }
00048 Vp8Streamer::~Vp8Streamer()
00049 {
00050 }
00051
00052 void Vp8Streamer::initializeEncoder()
00053 {
00054 typedef std::map<std::string, std::string> AvOptMap;
00055 AvOptMap av_opt_map;
00056 av_opt_map["quality"] = quality_;
00057 av_opt_map["deadline"] = "1";
00058 av_opt_map["auto-alt-ref"] = "0";
00059 av_opt_map["lag-in-frames"] = "1";
00060 av_opt_map["rc_lookahead"] = "1";
00061 av_opt_map["drop_frame"] = "1";
00062 av_opt_map["error-resilient"] = "1";
00063
00064 for (AvOptMap::iterator itr = av_opt_map.begin(); itr != av_opt_map.end(); ++itr)
00065 {
00066 av_opt_set(codec_context_->priv_data, itr->first.c_str(), itr->second.c_str(), 0);
00067 }
00068
00069
00070 int bufsize = 10;
00071 codec_context_->rc_buffer_size = bufsize;
00072 codec_context_->rc_initial_buffer_occupancy = bufsize;
00073 av_opt_set_int(codec_context_->priv_data, "bufsize", bufsize, 0);
00074 av_opt_set_int(codec_context_->priv_data, "buf-initial", bufsize, 0);
00075 av_opt_set_int(codec_context_->priv_data, "buf-optimal", bufsize, 0);
00076 av_opt_set_int(codec_context_->priv_data, "skip_threshold", 10, 0);
00077 }
00078
00079 Vp8StreamerType::Vp8StreamerType() :
00080 LibavStreamerType("webm", "libvpx", "video/webm")
00081 {
00082 }
00083
00084 boost::shared_ptr<ImageStreamer> Vp8StreamerType::create_streamer(const async_web_server_cpp::HttpRequest& request,
00085 async_web_server_cpp::HttpConnectionPtr connection,
00086 ros::NodeHandle& nh)
00087 {
00088 return boost::shared_ptr<ImageStreamer>(new Vp8Streamer(request, connection, nh));
00089 }
00090
00091 }