video_recorder.h
Go to the documentation of this file.
00001 /* This file is part of the Pangolin Project.
00002  * http://github.com/stevenlovegrove/Pangolin
00003  *
00004  * Copyright (c) 2011 Steven Lovegrove
00005  *
00006  * Permission is hereby granted, free of charge, to any person
00007  * obtaining a copy of this software and associated documentation
00008  * files (the "Software"), to deal in the Software without
00009  * restriction, including without limitation the rights to use,
00010  * copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following
00013  * conditions:
00014  *
00015  * The above copyright notice and this permission notice shall be
00016  * included in all copies or substantial portions of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00019  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00020  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00021  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
00022  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
00023  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00025  * OTHER DEALINGS IN THE SOFTWARE.
00026  */
00027 
00028 #ifndef PANGOLIN_VIDEO_RECORDER_H
00029 #define PANGOLIN_VIDEO_RECORDER_H
00030 
00031 #include <vector>
00032 #include <string>
00033 
00034 #include <boost/thread.hpp>
00035 #include <boost/thread/mutex.hpp>
00036 
00037 #include "video/pvn_video.h"
00038 #include "threadedfilebuf.h"
00039 
00040 namespace pangolin
00041 {
00042 struct VideoRecorderException : std::exception
00043 {
00044     VideoRecorderException(std::string str) : desc(str) {}
00045     VideoRecorderException(std::string str, std::string detail)
00046     {
00047         desc = str + "\n\t" + detail;
00048     }
00049     ~VideoRecorderException() throw() {}
00050     const char* what() const throw()
00051     {
00052         return desc.c_str();
00053     }
00054     std::string desc;
00055 };
00056 
00057 class VideoRecorder
00058 {
00059 public:
00060     VideoRecorder(
00061         const std::string& filename,
00062         int stream0_width, int stream0_height, std::string stream0_fmt,
00063         unsigned int buffer_size_bytes = 1024*1024*100
00064     );
00065     ~VideoRecorder();
00066 
00067     // Save img (with correct format and resolution) to video, returning video frame id.
00068     int RecordFrame(void* img);
00069 
00070     void operator()();
00071 
00072 protected:
00073     int frames;
00074     std::vector<VideoStream> stream_info;
00075 
00076     threadedfilebuf buffer;
00077     std::ostream writer;
00078 
00079     void WriteFileHeader();
00080 };
00081 }
00082 
00083 #endif // PANGOLIN_VIDEO_RECORDER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


pangolin_wrapper
Author(s): Todor Stoyanov
autogenerated on Wed Feb 13 2013 14:03:25