gr-baz Package
baz_file_source.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2012 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
11 *
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
21 */
22
23#ifndef INCLUDED_BAZ_FILE_SOURCE_H
24#define INCLUDED_BAZ_FILE_SOURCE_H
25
26#include <gnuradio/sync_block.h>
27
28namespace gr {
29 namespace baz {
30
31 /*!
32 * \brief Read stream from file
33 * \ingroup file_operators_blk
34 */
35 class BAZ_API file_source : virtual public sync_block
36 {
37 public:
38
39 // gr::blocks::file_source::sptr
40 typedef boost::shared_ptr<file_source> sptr;
41
42 /*!
43 * \brief Create a file source.
44 *
45 * Opens \p filename as a source of items into a flowgraph. The
46 * data is expected to be in binary format, item after item. The
47 * \p itemsize of the block determines the conversion from bits
48 * to items.
49 *
50 * If \p repeat is turned on, the file will repeat the file after
51 * it's reached the end.
52 *
53 * \param itemsize the size of each item in the file, in bytes
54 * \param filename name of the file to source from
55 * \param repeat repeat file from start
56 */
57 static sptr make(size_t itemsize, const char *filename, bool repeat = false, long offset = 0, const char *timing_filename = NULL, bool pad = false, double rate = 0.0, bool auto_load = true, const std::vector<std::string>& files = std::vector<std::string>());
58
59 /*!
60 * \brief seek file to \p seek_point relative to \p whence
61 *
62 * \param seek_point sample offset in file
63 * \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek)
64 */
65 virtual bool seek(long seek_point) = 0;
66 virtual bool seek(long seek_point, int whence) = 0;
67
68 /*!
69 * \brief Opens a new file.
70 *
71 * \param filename name of the file to source from
72 * \param repeat repeat file from start
73 */
74 virtual void open(const char *filename, bool repeat = false, long offset = 0, const char *timing_filename = NULL, bool pad = false, double rate = 0.0, bool auto_load = true, const std::vector<std::string>& files = std::vector<std::string>()) = 0;
75
76 /*!
77 * \brief Close the file handle.
78 */
79 virtual void close() = 0;
80
81 virtual size_t offset() = 0;
82 virtual size_t file_offset() = 0;
83 virtual double time(bool relative = false, bool raw = false) = 0;
84 virtual double sample_rate() = 0;
85 virtual double sample_count(bool raw = false) = 0;
86 virtual double duration() = 0;
87 virtual size_t file_index() = 0;
88 virtual std::string file_path() = 0;
89 virtual std::vector<std::string> files() = 0;
90 };
91
92 } /* namespace baz */
93} /* namespace gr */
94
95#endif /* INCLUDED_BAZ_FILE_SOURCE_H */
#define BAZ_API
Definition api.h:19
Read stream from file.
Definition baz_file_source.h:36
virtual std::string file_path()=0
virtual size_t file_index()=0
virtual size_t file_offset()=0
virtual double time(bool relative=false, bool raw=false)=0
boost::shared_ptr< file_source > sptr
Definition baz_file_source.h:40
virtual double sample_count(bool raw=false)=0
virtual bool seek(long seek_point, int whence)=0
virtual void close()=0
Close the file handle.
virtual bool seek(long seek_point)=0
seek file to seek_point relative to whence
virtual double duration()=0
virtual size_t offset()=0
virtual std::vector< std::string > files()=0
virtual double sample_rate()=0
virtual void open(const char *filename, bool repeat=false, long offset=0, const char *timing_filename=NULL, bool pad=false, double rate=0.0, bool auto_load=true, const std::vector< std::string > &files=std::vector< std::string >())=0
Opens a new file.
static sptr make(size_t itemsize, const char *filename, bool repeat=false, long offset=0, const char *timing_filename=NULL, bool pad=false, double rate=0.0, bool auto_load=true, const std::vector< std::string > &files=std::vector< std::string >())
Create a file source.
Definition baz_additive_scrambler_bb.h:28