GNU Radio 3.6.5 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* Copyright 2012 Free Software Foundation, Inc. 00003 * 00004 * This file is part of GNU Radio 00005 * 00006 * GNU Radio is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 3, or (at your option) 00009 * any later version. 00010 * 00011 * GNU Radio is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with GNU Radio; see the file COPYING. If not, write to 00018 * the Free Software Foundation, Inc., 51 Franklin Street, 00019 * Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H 00023 #define INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H 00024 00025 #include <digital/header_payload_demux.h> 00026 00027 namespace gr { 00028 namespace digital { 00029 00030 class header_payload_demux_impl : public header_payload_demux 00031 { 00032 private: 00033 int d_header_len; //!< Number of bytes per header 00034 int d_items_per_symbol; //!< Bytes per symbol 00035 int d_gi; //!< Bytes per guard interval 00036 pmt::pmt_t d_len_tag_key; //!< Key of length tag 00037 pmt::pmt_t d_trigger_tag_key; //!< Key of trigger tag (if used) 00038 bool d_output_symbols; //!< If true, output is symbols, not items 00039 size_t d_itemsize; //!< Bytes per item 00040 bool d_uses_trigger_tag; //!< If a trigger tag is used 00041 int d_ninput_items_reqd; //!< Helper for forecast() 00042 int d_state; //!< Current read state 00043 int d_remaining_symbols; //!< When in payload or header state, the number of symbols still to transmit 00044 00045 // Helpers to make the state machine more readable 00046 00047 //! Helper function that does the reading from the msg port 00048 bool parse_header_data_msg(); 00049 00050 //! Helper function that returns true if a trigger signal is detected. 00051 // Searches input 1 (if active), then the tags. Sets \p pos to the position 00052 // of the first tag. 00053 bool find_trigger_signal( 00054 int &pos, 00055 int noutput_items, 00056 gr_vector_const_void_star &input_items); 00057 00058 //! Helper function, copies one symbol from in to out and updates all pointers and counters 00059 void copy_symbol(const unsigned char *&in, unsigned char *&out, int port, int &nread, int &nproduced); 00060 00061 public: 00062 00063 header_payload_demux_impl( 00064 int header_len, 00065 int items_per_symbol, 00066 int guard_interval, 00067 const std::string &length_tag_key, 00068 const std::string &trigger_tag_key, 00069 bool output_symbols, 00070 size_t itemsize); 00071 ~header_payload_demux_impl(); 00072 00073 void forecast (int noutput_items, gr_vector_int &ninput_items_required); 00074 00075 int general_work(int noutput_items, 00076 gr_vector_int &ninput_items, 00077 gr_vector_const_void_star &input_items, 00078 gr_vector_void_star &output_items); 00079 }; 00080 00081 } // namespace digital 00082 } // namespace gr 00083 00084 #endif /* INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H */ 00085