GNU Radio Manual and C++ API Reference 3.8.5.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
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
29namespace gr {
30namespace blocks {
31
32const char METADATA_VERSION = 0;
33const size_t METADATA_HEADER_SIZE = 149;
34
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 */
70class BLOCKS_API file_meta_sink : virtual public sync_block
71{
72public:
73 // gr::blocks::file_meta_sink::sptr
74 typedef boost::shared_ptr<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: a PMT dictionary of extra
91 * information.
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,
96 const std::string& filename,
97 double samp_rate = 1,
98 double relative_rate = 1,
99 gr_file_types type = GR_FILE_FLOAT,
100 bool complex = true,
101 size_t max_segment_size = 1000000,
102 pmt::pmt_t extra_dict = pmt::make_dict(),
103 bool detached_header = false);
104
105 virtual bool open(const std::string& filename) = 0;
106 virtual void close() = 0;
107 virtual void do_update() = 0;
108
109 virtual void set_unbuffered(bool unbuffered) = 0;
110};
111
112} /* namespace blocks */
113} /* namespace gr */
114
115#endif /* INCLUDED_BLOCKS_FILE_META_SINK_H */
Write stream to file with meta-data headers.
Definition file_meta_sink.h:71
static sptr make(size_t itemsize, const std::string &filename, double samp_rate=1, double relative_rate=1, gr_file_types type=GR_FILE_FLOAT, bool complex=true, size_t max_segment_size=1000000, pmt::pmt_t extra_dict=pmt::make_dict(), bool detached_header=false)
Create a meta-data file sink.
virtual void close()=0
virtual void set_unbuffered(bool unbuffered)=0
virtual void do_update()=0
boost::shared_ptr< file_meta_sink > sptr
Definition file_meta_sink.h:74
virtual bool open(const std::string &filename)=0
synchronous 1:1 input to output with history
Definition sync_block.h:38
#define BLOCKS_API
Definition gr-blocks/include/gnuradio/blocks/api.h:30
const size_t METADATA_HEADER_SIZE
Definition file_meta_sink.h:33
const char METADATA_VERSION
Definition file_meta_sink.h:32
gr_file_types
Definition file_meta_sink.h:35
@ GR_FILE_LONG
Definition file_meta_sink.h:40
@ GR_FILE_BYTE
Definition file_meta_sink.h:36
@ GR_FILE_DOUBLE
Definition file_meta_sink.h:43
@ GR_FILE_CHAR
Definition file_meta_sink.h:37
@ GR_FILE_FLOAT
Definition file_meta_sink.h:42
@ GR_FILE_INT
Definition file_meta_sink.h:39
@ GR_FILE_LONG_LONG
Definition file_meta_sink.h:41
@ GR_FILE_SHORT
Definition file_meta_sink.h:38
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition basic_block.h:46
PMT_API pmt_t make_dict()
Make an empty dictionary.
boost::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting). See http://www.boost....
Definition pmt.h:96