/* * mp3plot - Bitrate analysis tool * * Copyright (C) 2007 Toni Corvera * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // $Id: mp3_file.h 753 2007-05-26 00:04:38Z $ #ifndef ONET_MP3FILE_H #define ONET_MP3FILE_H #include #include #include #include #include #include #include "named_ifstream.h" #include "mp3_common.h" #include "mp3_tags.h" #include "mp3_frame.h" #include "mp3_bitrate_dist.h" #include "mp3_bitrate_plotter.h" /*! * \brief Top level namespace. */ namespace net_outlyer { /*! * \brief MP3 related classes. * The only class meant to be used externally is mp3file. * \see mp3file */ namespace mp3 { /*! * \brief MP3 File Interface. * Other classes in this namespace are meant to be used by this class, * this is the only one that should be used directly. */ class mp3file { protected: /*! * \brief The kind of mp3 file represented. * This refers to the file structure and not the kind of encoding. */ mp3_filetype_t file_type; //! ID3v2 header id3v2header id3v2; //! The frames in the file frame_vector_t frames; /*! * \brief ID3v1 header * \note At least now it isn't used. */ id3v1header id3v1; /*! * \brief Meta information of the file. * It is fetched from the first frame. */ mp3_meta_info meta_info; //! The input file file_utils::named_ifstream file; private: //! Bitrate distribution table bitrate_distribution br_dist; protected: /*! * Advances the input file to the next start of the next frame. * The get pointer is positioned at the frame start. * \throw e_read_failure if no more frames are found */ void seek_to_next_frame() throw (e_read_failure); /*! * Fills the bitrate distribution table. * \note If already filled does nothing * \pre The file has already been red (read_info() called before) * \see read_info() * \see br_dist */ void fill_bitrate_distribution(); public: /*! * \desc Opens the input file. * \pre The input file exists and can be opened * \param file_path The input's file path */ mp3file(const std::string & file_path); ~mp3file() {} /*! * \brief Checks the file type and sets file_type accordingly. * \throw e_error if the file type is unknown * \note An unknown file type doesn't mean the file isn't * an mp3 *stream* but it isn't checked right now * \see mp3_filetype_t */ void check_file_type() throw (e_error); /*! * \brief Reads the file. * \throw e_error If a read error occurs */ void read_info() throw (e_error); /*! * \brief Prints the file meta information. * \see mp3_meta_info */ void dump_meta_info() const; //! Prints the bitrate plot. void plot(bitrate_plotter::plotter_type_t pref = bitrate_plotter::TEXT); /*! * \brief Returns the list of frames * \return List of red frames */ const frame_vector_t & get_frames() const { return frames; } /*! * \brief Returns the bitrate distribution * \see fill_bitrate_distribution() */ const bitrate_distribution & get_br_distribution() const { return br_dist; } //! Returns the file name const std::string & name() const { return file.file_name(); } }; } // namespace mp3 } // namespace net_outlyer #endif // ONET_MP3FILE_H /* vim:set ts=4 et ai: */