GNU Radio Manual and C++ API Reference 3.10.5.1
The Free & Open Software Radio Ecosystem
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
20constexpr char METADATA_VERSION = 0;
21constexpr size_t METADATA_HEADER_SIZE = 149;
22
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 */
58class 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,
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 */
Write stream to file with meta-data headers.
Definition: file_meta_sink.h:59
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
std::shared_ptr< file_meta_sink > sptr
Definition: file_meta_sink.h:62
virtual bool open(const std::string &filename)=0
synchronous 1:1 input to output with history
Definition: sync_block.h:26
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:18
constexpr char METADATA_VERSION
Definition: file_meta_sink.h:20
gr_file_types
Definition: file_meta_sink.h:23
@ GR_FILE_LONG
Definition: file_meta_sink.h:28
@ GR_FILE_BYTE
Definition: file_meta_sink.h:24
@ GR_FILE_DOUBLE
Definition: file_meta_sink.h:31
@ GR_FILE_CHAR
Definition: file_meta_sink.h:25
@ GR_FILE_FLOAT
Definition: file_meta_sink.h:30
@ GR_FILE_INT
Definition: file_meta_sink.h:27
@ GR_FILE_LONG_LONG
Definition: file_meta_sink.h:29
@ GR_FILE_SHORT
Definition: file_meta_sink.h:26
constexpr size_t METADATA_HEADER_SIZE
Definition: file_meta_sink.h:21
GR_RUNTIME_API size_t itemsize(types::vector_type type)
GNU Radio logging wrapper.
Definition: basic_block.h:29
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:83
PMT_API pmt_t make_dict()
Make an empty dictionary.