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_RECORD_REPEAT_H 00029 #define PANGOLIN_VIDEO_RECORD_REPEAT_H 00030 00031 #include "pangolin.h" 00032 00033 #include "video.h" 00034 #include "video_recorder.h" 00035 00036 namespace pangolin 00037 { 00038 00039 struct VideoRecordRepeat : public VideoInterface 00040 { 00041 VideoRecordRepeat( 00042 std::string uri, std::string save_filename, int buffer_size_bytes 00043 ); 00044 ~VideoRecordRepeat(); 00045 00046 unsigned Width() const; 00047 unsigned Height() const; 00048 size_t SizeBytes() const; 00049 std::string PixFormat() const; 00050 00051 void Start(); 00052 void Stop(); 00053 bool GrabNext( unsigned char* image, bool wait = true ); 00054 bool GrabNewest( unsigned char* image, bool wait = true ); 00055 00056 void Record(); 00057 void Play(bool realtime = true); 00058 void Source(); 00059 00060 int FrameId(); 00061 00062 bool IsRecording() const; 00063 bool IsPlaying() const; 00064 00065 protected: 00066 VideoInterface* video_src; 00067 VideoInterface* video_file; 00068 VideoRecorder* video_recorder; 00069 00070 std::string filename; 00071 int buffer_size_bytes; 00072 00073 int frame_num; 00074 }; 00075 00076 } 00077 00078 #endif // PANGOLIN_VIDEO_RECORD_REPEAT_H