GNU Radio C++ API Reference: file_meta_sink.h Source File

| GNU Radio C++ API Reference 3.10.12.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 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef INCLUDED_BLOCKS_FILE_META_SINK_H
12#define INCLUDED_BLOCKS_FILE_META_SINK_H
13
14#include <gnuradio/blocks/api.h>
15#include <gnuradio/sync_block.h>
16
17namespace gr {
18namespace blocks {
19
20 constexpr char METADATA_VERSION = 0;
21 constexpr size_t METADATA_HEADER_SIZE = 149;
22
23 enum gr_file_types {
24 GR_FILE_BYTE = 0,
25 GR_FILE_CHAR = 0,
26 GR_FILE_SHORT = 1,
27 GR_FILE_INT,
28 GR_FILE_LONG,
29 GR_FILE_LONG_LONG,
30 GR_FILE_FLOAT,
31 GR_FILE_DOUBLE,
32};
33
34/*!
35 * \brief Write stream to file with meta-data headers.
36 * \ingroup file_operators_blk
37 *
38 * \details
39 * These files represent data as binary information in between
40 * meta-data headers. The headers contain information about the
41 * type of data and properties of the data in the next segment of
42 * samples. The information includes:
43 *
44 * \li rx_rate (double): sample rate of data.
45 * \li rx_time (uint64_t, double): time stamp of first sample in segment.
46 * \li size (uint32_t): item size in bytes.
47 * \li type (::gr_file_types as int32_t): data type.
48 * \li cplx (bool): Is data complex?
49 * \li strt (uint64_t): Starting byte of data in this segment.
50 * \li bytes (uint64_t): Size in bytes of data in this segment.
51 *
52 * Tags can be sent to the file to update the information, which
53 * will create a new header. Headers are found by searching from
54 * the first header (at position 0 in the file) and reading where
55 * the data segment starts plus the data segment size. Following
56 * will either be a new header or EOF.
57 */
58 class BLOCKS_API file_meta_sink : virtual public sync_block
59{
60public:
61 // gr::blocks::file_meta_sink::sptr
62 typedef std::shared_ptr<file_meta_sink> sptr;
63
64 /*!
65 * \brief Create a meta-data file sink.
66 *
67 * \param itemsize (size_t): Size of data type.
68 * \param filename (string): Name of file to write data to.
69 * \param samp_rate (double): Sample rate of data. If sample rate will be
70 * set by a tag, such as rx_tag from a UHD source, this is
71 * basically ignored.
72 * \param relative_rate (double): Rate chance from source of sample
73 * rate tag to sink.
74 * \param type (gr_file_types): Data type (int, float, etc.)
75 * \param complex (bool): If data stream is complex
76 * \param max_segment_size (size_t): Length of a single segment
77 * before the header is repeated (in items).
78 * \param extra_dict: a PMT dictionary of extra
79 * information.
80 * \param detached_header (bool): Set to true to store the header
81 * info in a separate file (named filename.hdr)
82 */
83 static sptr make(size_t itemsize,
84 const std::string& filename,
85 double samp_rate = 1,
86 double relative_rate = 1,
87 gr_file_types type = GR_FILE_FLOAT,
88 bool complex = true,
89 size_t max_segment_size = 1000000,
90 pmt::pmt_t extra_dict = pmt::make_dict(),
91 bool detached_header = false);
92
93 virtual bool open(const std::string& filename) = 0;
94 virtual void close() = 0;
95 virtual void do_update() = 0;
96
97 virtual void set_unbuffered(bool unbuffered) = 0;
98};
99
100} /* namespace blocks */
101} /* namespace gr */
102
103#endif /* INCLUDED_BLOCKS_FILE_META_SINK_H */
gr::block::relative_rate
double relative_rate() const
return the approximate output rate / input rate
Definition gnuradio-runtime/include/gnuradio/block.h:305
gr::blocks::file_meta_sink
Write stream to file with meta-data headers.
Definition file_meta_sink.h:59
gr::blocks::file_meta_sink::make
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.
gr::blocks::file_meta_sink::close
virtual void close()=0
gr::blocks::file_meta_sink::set_unbuffered
virtual void set_unbuffered(bool unbuffered)=0
gr::blocks::file_meta_sink::do_update
virtual void do_update()=0
gr::blocks::file_meta_sink::sptr
std::shared_ptr< file_meta_sink > sptr
Definition file_meta_sink.h:62
gr::blocks::file_meta_sink::open
virtual bool open(const std::string &filename)=0
gr::sync_block::sync_block
sync_block(void)
Definition sync_block.h:28
api.h
BLOCKS_API
#define BLOCKS_API
Definition gr-blocks/include/gnuradio/blocks/api.h:18
gr::blocks
Definition abs_blk.h:20
gr::blocks::METADATA_VERSION
constexpr char METADATA_VERSION
Definition file_meta_sink.h:20
gr::blocks::gr_file_types
gr_file_types
Definition file_meta_sink.h:23
gr::blocks::GR_FILE_LONG
@ GR_FILE_LONG
Definition file_meta_sink.h:28
gr::blocks::GR_FILE_BYTE
@ GR_FILE_BYTE
Definition file_meta_sink.h:24
gr::blocks::GR_FILE_DOUBLE
@ GR_FILE_DOUBLE
Definition file_meta_sink.h:31
gr::blocks::GR_FILE_CHAR
@ GR_FILE_CHAR
Definition file_meta_sink.h:25
gr::blocks::GR_FILE_FLOAT
@ GR_FILE_FLOAT
Definition file_meta_sink.h:30
gr::blocks::GR_FILE_INT
@ GR_FILE_INT
Definition file_meta_sink.h:27
gr::blocks::GR_FILE_LONG_LONG
@ GR_FILE_LONG_LONG
Definition file_meta_sink.h:29
gr::blocks::GR_FILE_SHORT
@ GR_FILE_SHORT
Definition file_meta_sink.h:26
gr::blocks::METADATA_HEADER_SIZE
constexpr size_t METADATA_HEADER_SIZE
Definition file_meta_sink.h:21
gr
GNU Radio logging wrapper.
Definition basic_block.h:29
pmt::pmt_t
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition pmt.h:83
pmt::make_dict
PMT_API pmt_t make_dict()
Make an empty dictionary.
sync_block.h