GNU Radio 3.7.3 C++ API
file_meta_sink.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_BLOCKS_FILE_META_SINK_H
24 #define INCLUDED_BLOCKS_FILE_META_SINK_H
25 
26 #include <gnuradio/blocks/api.h>
27 #include <gnuradio/sync_block.h>
28 
29 namespace gr {
30  namespace blocks {
31 
32  const char METADATA_VERSION = 0;
33  const size_t METADATA_HEADER_SIZE = 149;
34 
44  };
45 
46  /*!
47  * \brief Write stream to file with meta-data headers.
48  * \ingroup file_operators_blk
49  *
50  * \details
51  * These files represent data as binary information in between
52  * meta-data headers. The headers contain information about the
53  * type of data and properties of the data in the next segment of
54  * samples. The information includes:
55  *
56  * \li rx_rate (double): sample rate of data.
57  * \li rx_time (uint64_t, double): time stamp of first sample in segment.
58  * \li size (uint32_t): item size in bytes.
59  * \li type (::gr_file_types as int32_t): data type.
60  * \li cplx (bool): Is data complex?
61  * \li strt (uint64_t): Starting byte of data in this segment.
62  * \li bytes (uint64_t): Size in bytes of data in this segment.
63  *
64  * Tags can be sent to the file to update the information, which
65  * will create a new header. Headers are found by searching from
66  * the first header (at position 0 in the file) and reading where
67  * the data segment starts plus the data segment size. Following
68  * will either be a new header or EOF.
69  */
70  class BLOCKS_API file_meta_sink : virtual public sync_block
71  {
72  public:
73  // gr::blocks::file_meta_sink::sptr
75 
76  /*!
77  * \brief Create a meta-data file sink.
78  *
79  * \param itemsize (size_t): Size of data type.
80  * \param filename (string): Name of file to write data to.
81  * \param samp_rate (double): Sample rate of data. If sample rate will be
82  * set by a tag, such as rx_tag from a UHD source, this is
83  * basically ignored.
84  * \param relative_rate (double): Rate chance from source of sample
85  * rate tag to sink.
86  * \param type (gr_file_types): Data type (int, float, etc.)
87  * \param complex (bool): If data stream is complex
88  * \param max_segment_size (size_t): Length of a single segment
89  * before the header is repeated (in items).
90  * \param extra_dict (string): a serialized PMT dictionary of extra
91  * information. Currently not supported.
92  * \param detached_header (bool): Set to true to store the header
93  * info in a separate file (named filename.hdr)
94  */
95  static sptr make(size_t itemsize, const std::string &filename,
96  double samp_rate=1, double relative_rate=1,
97  gr_file_types type=GR_FILE_FLOAT, bool complex=true,
98  size_t max_segment_size=1000000,
99  const std::string &extra_dict="",
100  bool detached_header=false);
101 
102  virtual bool open(const std::string &filename) = 0;
103  virtual void close() = 0;
104  virtual void do_update() = 0;
105 
106  virtual void set_unbuffered(bool unbuffered) = 0;
107  };
108 
109  } /* namespace blocks */
110 } /* namespace gr */
111 
112 #endif /* INCLUDED_BLOCKS_FILE_META_SINK_H */
Definition: file_meta_sink.h:41
Definition: file_meta_sink.h:38
const char METADATA_VERSION
Definition: file_meta_sink.h:32
shared_ptr documentation stub
Definition: shared_ptr_docstub.h:15
Definition: file_meta_sink.h:39
Definition: file_meta_sink.h:37
boost::shared_ptr< file_meta_sink > sptr
Definition: file_meta_sink.h:74
Definition: file_meta_sink.h:40
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:30
synchronous 1:1 input to output with historyOverride work to provide the signal processing implementa...
Definition: sync_block.h:37
Definition: file_meta_sink.h:36
const size_t METADATA_HEADER_SIZE
Definition: file_meta_sink.h:33
Definition: file_meta_sink.h:42
gr_file_types
Definition: file_meta_sink.h:35
Write stream to file with meta-data headers.
Definition: file_meta_sink.h:70
Definition: file_meta_sink.h:43
BLOCKS_API size_t itemsize(vector_type type)