Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 2012 Nate Bogdanowicz <natezb@gmail.com> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 #ifndef MARSYAS_GSTREAMERSOURCE_H 00020 #define MARSYAS_GSTREAMERSOURCE_H 00021 00022 #include "AbsSoundFileSource.h" 00023 #include <sys/stat.h> 00024 00025 #include <marsyas/common_header.h> 00026 00027 #include <glib.h> 00028 #include <gst/gst.h> 00029 #include <gst/app/gstappsink.h> 00030 00031 namespace Marsyas 00032 { 00033 00041 class GStreamerSource : public AbsSoundFileSource 00042 { 00043 private: 00044 mrs_natural size_, newpos_; 00045 mrs_string filename_, tfilename_; 00046 mrs_bool playing_, pipe_created_; 00047 MarControlPtr ctrl_pos_, ctrl_hasData_, ctrl_lastTickWithData_; 00048 00049 /* GStreamer Elements */ 00050 GstElement *pipe_, *dec_, *sink_; 00051 GstBuffer *buffer_; 00052 00053 /* These measured in # of SAMPLES per channel */ 00054 mrs_natural buffer_left_; 00055 mrs_natural buffer_size_; 00056 00057 void addControls(); 00058 void myUpdate(MarControlPtr sender); 00059 void getHeader(mrs_string filename); 00060 void init_pipeline(); 00061 mrs_bool seek(); 00062 mrs_bool pull_buffer(); 00063 void copyFromBuffer(GstBuffer *buf, 00064 mrs_natural buf_start, 00065 realvec& vec, 00066 mrs_natural vec_start, 00067 mrs_natural length); 00068 00069 public: 00070 GStreamerSource(std::string name); 00071 GStreamerSource(const GStreamerSource& a); 00072 ~GStreamerSource(); 00073 00074 MarSystem* clone() const; 00075 void myProcess(realvec& in,realvec &out); 00076 }; 00077 00078 }//namespace Marsyas 00079 00080 #endif // !MARSYAS_GSTREAMERSOURCE_H