⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventdata.h

📁 FreeAMP(MP3播放)程序源代码-用来研究MP3解码
💻 H
📖 第 1 页 / 共 2 页
字号:
/*____________________________________________________________________________
        
        FreeAmp - The Free MP3 Player

        Portions Copyright (C) 1998-1999 EMusic.com

        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., 675 Mass Ave, Cambridge, MA 02139, USA.
        
        $Id: eventdata.h,v 1.68 2001/02/21 04:19:08 ijr Exp $
____________________________________________________________________________*/

#ifndef INCLUDED_EVENTDATA_H_
#define INCLUDED_EVENTDATA_H_

#include <string.h>
#include <stdlib.h>

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

#include "event.h"
#include "playlist.h"
#include "utility.h"

class     LogicalMediaConverter;
class     PhysicalMediaOutput;

class     UserMessageEvent:public Event
{
   private:
   char     *m_info;

   public:

   virtual ~ UserMessageEvent()
   {
      if (m_info)
      {
         delete [] m_info;
                   m_info = NULL;
      }
   }
   UserMessageEvent()
   {
      m_type = INFO_UserMessage;
      m_info = NULL;
   }
   UserMessageEvent(const char *info)
   {
      m_type = INFO_UserMessage;
      m_info = strdup_new(info);
   }
   const char *GetInfo()
   {
      return m_info;
   }
};

class StatusMessageEvent:public Event
{
   private:
   char     *m_info;

   public:
   virtual ~ StatusMessageEvent()
   {
      if (m_info)
      {
         delete [] m_info;
         m_info = NULL;
      }
   }
   StatusMessageEvent()
   {
      m_type = INFO_StatusMessage;
      m_info = NULL;
   }
   StatusMessageEvent(const char *info)
   {
      m_type = INFO_StatusMessage;
      m_info = strdup_new(info);
   }
   const char *GetStatusMessage()
   {
      return m_info;
   }
};

class ErrorMessageEvent:public Event
{
   private:
   char     *m_info;

   public:
   virtual ~ ErrorMessageEvent()
   {
      if (m_info)
      {
         delete [] m_info;
         m_info = NULL;
      }
   }
   ErrorMessageEvent()
   {
      m_type = INFO_ErrorMessage;
      m_info = NULL;
   }
   ErrorMessageEvent(const char *info)
   {
      m_type = INFO_ErrorMessage;
      m_info = strdup_new(info);
   }
   const char *GetErrorMessage()
   {
      return m_info;
   }
};


class     BrowserMessageEvent:public Event
{
   private:
   string m_info;

   public:
   virtual ~ BrowserMessageEvent() {}
   BrowserMessageEvent()
   {
      m_type = INFO_BrowserMessage;
      m_info = "";
   }
   BrowserMessageEvent(const string &info)
   {
      m_type = INFO_BrowserMessage;
      m_info = info;
   }
   const char *GetBrowserMessage()
   {
      return m_info.c_str();
   }
};

class     HeadlineMessageEvent:public Event
{
   private:
   char     *m_info, *m_url;

   public:
   virtual ~ HeadlineMessageEvent()
   {
      if (m_info)
      {
         delete [] m_info;
      }
      if (m_url)
      {
         delete [] m_url;
      }
   }
   HeadlineMessageEvent()
   {
      m_type = INFO_HeadlineText;
      m_info = NULL;
      m_url = NULL;
   }
   HeadlineMessageEvent(const char *info, const char *url)
   {
      m_type = INFO_HeadlineText;
      m_info = strdup_new(info);
      m_url = strdup_new(url);
   }
   const char *GetHeadlineMessage()
   {
      return m_info;
   }
   const char *GetHeadlineURL()
   {
      return m_url;
   }
};


class     MediaInfoEvent:public Event
{
   public:

   vector<Event*>*  m_childEvents;
   bool             m_filled;
   float            m_totalSeconds;
   int32            m_indexOfSong;
   int32            m_totalSongs;
   char             m_filename[512];
   uint32           m_plmID;
   bool             m_copy;

   virtual ~ MediaInfoEvent()
   {
      if (m_childEvents && (m_childEvents->size() != 0) && !m_copy)
      {
            vector<Event *>::iterator i = m_childEvents->begin();

            for (; i != m_childEvents->end(); i++) 
                delete *i;
            delete m_childEvents;
            m_childEvents = NULL;
      }
   }

   MediaInfoEvent()
   {
      m_type = INFO_MediaInfo;
      m_filled = false;
      m_copy = false;
      m_filename[0] = '\0';
      m_childEvents = new vector<Event *>;
   }

   MediaInfoEvent(MediaInfoEvent &other):Event(other)
   {
      m_copy = true;
      m_type = other.m_type;
      m_filled = other.m_filled;
      m_totalSeconds = other.m_totalSeconds;
      m_indexOfSong = other.m_indexOfSong;
      m_totalSongs = other.m_totalSongs;
      strcpy(m_filename, other.m_filename);

      m_childEvents = new vector <Event *>(other.m_childEvents->size());

      copy(other.m_childEvents->begin(), other.m_childEvents->end(),
           m_childEvents->begin());
   }

   MediaInfoEvent(const char *fn,
                  float ts)
   {
      m_copy = false;
      m_childEvents = new vector<Event *>;
      m_filled = true;
      m_type = INFO_MediaInfo;
      m_totalSeconds = ts;
      m_indexOfSong = 0;
      m_totalSongs = 0;

      if (fn)
      {
         strncpy(m_filename, fn, 511);
         m_filename[511] = '\0';
      }
      else
      {
         m_filename[0] = '\0';
      }
   }
   void      AddChildEvent(Event * pE)
   {
      if (pE)
      {
         m_childEvents->push_back(pE);
      }
   }
};

class     MediaTimeInfoEvent:public Event
{
   public:
   int32 m_hours, m_minutes, m_seconds, m_milliseconds, m_frame;
   float     m_totalSeconds;
             MediaTimeInfoEvent(int32 h, int32 m, int32 s, int32 ms, float ts, int32 f)
   {
      m_type = INFO_MediaTimeInfo;
      m_totalSeconds = ts;
      m_hours = h;
      m_minutes = m;
      m_seconds = s;
      m_milliseconds = ms;
      m_frame = f;
   }
   virtual ~ MediaTimeInfoEvent()
   {
   }
};

class     VolumeEvent:public Event
{
   private:
   int32 m_left, m_right;
   public:
   VolumeEvent(int32 t, int32 left = 0, int32 right = 0)
   {
      m_type = t;
      m_left = left;
      m_right = right;
   }
   int32     GetLeftVolume()
   {
      return m_left;
   }
   int32     GetRightVolume()
   {
      return m_right;
   }
   virtual ~ VolumeEvent()
   {
   }
};

class     ChangePositionEvent:public Event
{
   private:
   int32 m_frame;
   public:
   ChangePositionEvent(int32 p)
   {
      m_type = CMD_ChangePosition;
      m_frame = p;
   }
   int32     GetPosition()
   {
      return m_frame;
   }
   virtual ~ ChangePositionEvent()
   {
   }
};

class     MpegInfoEvent:public Event
{
   public:
   enum
   {
      STEREO = 1, JOINT_STEREO = 2, DUAL = 3, MONO = 4
   };
   enum
   {
      LAYER_1 = 1, LAYER_2, LAYER_3
   };
   enum
   {
      MPEG_1 = 1, MPEG_2 = 2, MPEG_25 = 3
   };
             private:
             int32 m_totalFrames;
   float     m_secondsPerFrame;
   int32     m_bytesPerFrame;
   int32     m_bitrate;
   int32     m_sampleRate;
   int32     m_layer;
   int32     m_mpeg;
   int32     m_channels;
   int32     m_original;
   int32     m_copyright;
   int32     m_emphasis;
   int32     m_stereo;
   int32     m_modeExt;
   int32     m_crc;
             public:
             MpegInfoEvent()
   {
      m_type = INFO_MPEGInfo;
   }
   MpegInfoEvent(int32 tf, float spf, int32 bpf, int32 br, int32 sr, int32 layer, int32 mpeg, int32 chans, int32 orig, int32 copy, int32 emph, int32 stereo, int32 mode_ext)
   {
      m_type = INFO_MPEGInfo;
      m_totalFrames = tf;
      m_secondsPerFrame = spf;
      m_bytesPerFrame = bpf;
      m_bitrate = br;
      m_sampleRate = sr;
      m_layer = layer;
      m_mpeg = mpeg;
      m_channels = chans;
      m_original = orig & 0x1;
      m_copyright = copy & 0x1;
      m_emphasis = emph;
      m_stereo = stereo;
      m_modeExt = mode_ext;
   }
   int32     GetTotalFrames()
   {
      return m_totalFrames;
   }
   float     GetSecondsPerFrame()
   {
      return m_secondsPerFrame;
   }
   int32     GetBytesPerFrame()
   {
      return m_bytesPerFrame;
   }
   int32     GetBitRate()
   {
      return m_bitrate;
   }
   int32     GetSampleRate()
   {
      return m_sampleRate;
   }
   int32     GetLayer()
   {
      return m_layer;
   }
   int32     GetMpegVersion()
   {
      return m_mpeg;
   }
   int32     GetChannels()
   {
      return m_channels;
   }
   int32     GetOriginal()
   {
      return m_original;
   }
   int32     GetCopyright()
   {
      return m_copyright;
   }
   int32     GetEmphasis()
   {
      return m_emphasis;
   }
   int32     GetStereo()
   {
      return m_stereo;
   }
   int32     GetModeExt()
   {
      return m_modeExt;
   }
   int32     GetCRC()
   {
      return m_crc;
   }
   virtual ~MpegInfoEvent()
   {
   }

};

class VorbisInfoEvent:public Event
{
   public:
   VorbisInfoEvent(int32 bitrate, int32 channels, int32 rate, float spf)
   {
      m_type = INFO_VorbisInfo;
      m_bitrate = bitrate;
      m_channels = channels;
      m_rate = rate; 
      m_secondsPerFrame = spf;
   }
   int32     GetBitRate()
   {
      return m_bitrate;
   };
   int32     GetSampleRate()
   {
      return m_rate;
   };
   int32     GetChannels()
   {
      return m_channels;
   };
   float     GetSecondsPerFrame()
   {
      return m_secondsPerFrame;
   }
   private:
   int32     m_bitrate;
   int32     m_rate;
   int32     m_channels;
   float     m_secondsPerFrame;
};

class     SetEqualizerDataEvent:public Event
{
   private:
      float    *m_eq;
      bool      m_enable;
      bool      m_IsEQData;
      float     m_preamp;

   public:

   SetEqualizerDataEvent(bool enable)
   {
      m_type = CMD_SetEQData;
      m_enable = enable;
      m_IsEQData = false;
   }
   SetEqualizerDataEvent(float *eq, float preamp)
   {
      m_type = CMD_SetEQData;
      m_eq = eq;
      m_IsEQData = true;
      m_preamp = preamp;
   }
   float    *GetEQData()
   {
      return m_eq;
   }
   bool      IsEQData()
   {
      return m_IsEQData;
   }
   float     GetPreamp()
   {
      return m_preamp;
   }
   bool      GetEnableState()
   {
      return m_enable;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -