/* * strawberry_mpegheader.h last updated by David Parker <david@neongoat.com> * $Id: strawberry_mpegheader.h,v 1.4 2000/02/08 03:07:29 dap24 Exp $ * * Strawberry Library - A class for MPEG header extraction and ID3 tag manipulation * Copyright (C) 1999-2000 David Parker, Neon Goat Productions. All rights reserved. * http://www.neongoat.com - david@neongoat.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ // strawberry_mpegheader.h: interface for the SB_MPEGHeader class. // #if !defined(AFX_STRAWBERRY_MPEGHEADER_H__806D7661_1AB0_11D3_B3F8_00A0CC3D7E01__INCLUDED_) #define AFX_STRAWBERRY_MPEGHEADER_H__806D7661_1AB0_11D3_B3F8_00A0CC3D7E01__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 class SB_MPEGHeader { public: SB_MPEGHeader(); ~SB_MPEGHeader(); enum SB_MPEG_VERSION {MPEG_VERSION_UNDEF=0, MPEG_VERSION_1, MPEG_VERSION_2, MPEG_VERSION_25}; enum SB_MPEG_LAYER {MPEG_LAYER_UNDEF=0, MPEG_LAYER_1, MPEG_LAYER_2, MPEG_LAYER_3}; enum SB_MPEG_CHANNELMODE {MPEG_MODE_UNDEF=0, MPEG_MODE_STEREO, MPEG_MODE_JOINTSTEREO, MPEG_MODE_DUALCHANNEL, MPEG_MODE_SINGLECHANNEL}; enum SB_MPEG_CHANNELEXTENSION {MPEG_EXTENSION_UNDEF=0, MPEG_EXTENSION_12_4_31, MPEG_EXTENSION_12_8_31, MPEG_EXTENSION_12_12_31, MPEG_EXTENSION_12_16_31, MPEG_EXTENSION_3_NI_NM, MPEG_EXTENSION_3_YI_NM, MPEG_EXTENSION_3_NI_YM, MPEG_EXTENSION_3_YI_YM}; //obfuscated, i know... you know a better way? :) enum SB_MPEG_EMPHASIS {MPEG_EMPH_UNDEF=0, MPEG_EMPH_NONE, MPEG_EMPH_5015MS, MPEG_EMPH_CCITT_J17}; bool Open(CFile *openfile); bool Open(const CString &filename); bool ExtractHeader(); bool Close(); void EraseAllFields(); CString GenerateReport(); //accessors: bool IsFrameSynced() {return m_Sync;}; SB_MPEG_VERSION GetVersion() {return m_Version;}; CString GetVersionString(); SB_MPEG_LAYER GetLayer() {return m_Layer;}; CString GetLayerString(); bool IsCRCs() {return m_CRC;}; int GetBitrate() {return m_Bitrate;}; CString GetBitrateString(); int GetSamplingRate() {return m_SamplingRate;}; CString GetSamplingRateString(); bool IsPadded() {return m_Padding;}; bool IsPrivate() {return m_Private;}; SB_MPEG_CHANNELMODE GetChannelMode() {return m_ChannelMode;}; CString GetChannelModeString(); SB_MPEG_CHANNELEXTENSION GetChannelModeExtension() {return m_ChannelModeExtension;}; CString GetChannelModeExtensionString(); bool IsCopyrighted() {return m_Copyright;}; bool IsOriginal() {return m_Original;}; SB_MPEG_EMPHASIS GetEmphasis() {return m_Emphasis;}; CString GetEmphasisString(); long GetNumFrames() {return m_numframes;}; long GetNumSeconds() {return m_numseconds;}; //10-330 protected: DWORD SwapEndian(DWORD binary); int ExtractBinary(DWORD binary, int leastSig, int mostSig); bool ExtractHeader(long offset); void ScanFrames(); //MPEG header items: bool m_Sync; SB_MPEG_VERSION m_Version; SB_MPEG_LAYER m_Layer; bool m_CRC; int m_Bitrate; int m_SamplingRate; bool m_Padding; bool m_Private; //not defined, available for private use SB_MPEG_CHANNELMODE m_ChannelMode; SB_MPEG_CHANNELEXTENSION m_ChannelModeExtension; // unimplemented, here as a placeholder bool m_Copyright; bool m_Original; SB_MPEG_EMPHASIS m_Emphasis; //MPEG general information: long m_numbytes; long m_numseconds; long m_numframes; private: DWORD *rawdata; CFile *openfile; bool myOpenfile; CString filename; long m_framesize; /************************************** BEGIN DOXYGEN DOCUMENTATION COMMENTS **************************************/ }; const int bitrates[5][16] = { // 0 = free (application specific) // -1 = undefined /* MPEG 1.0 Layer 1 */ {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1}, /* MPEG 1.0 Layer 2 */ {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1}, /* MPEG 1.0 Layer 3 */ {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1}, /* MPEG 2.x Layer 1 */ {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, -1}, /* MPEG 2.x Layer 2 and 3 */ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1} }; const int samplingrates[3][4] = { // -1 = undef /* MPEG 1.0 */ {44100, 48000, 32000, -1}, /* MPEG 2.0 */ {22050, 24000, 16000, -1}, /* MPEG 2.5 */ {11025, 12000, 8000, -1} }; #endif // !defined(AFX_STRAWBERRY_MPEGHEADER_H__806D7661_1AB0_11D3_B3F8_00A0CC3D7E01__INCLUDED_)