Example #1
0
ID3_TagImpl &
ID3_TagImpl::operator=( const ID3_Tag &rTag )
{
  this->Clear();

  this->SetUnsync(rTag.GetUnsync());
  this->SetExtended(rTag.GetExtendedHeader());
  this->SetExperimental(rTag.GetExperimental());

  ID3_Tag::ConstIterator* iter = rTag.CreateIterator();
  const ID3_Frame* frame = NULL;
  while (NULL != (frame = iter->GetNext()))
  {
    this->AttachFrame(new ID3_Frame(*frame));
  }
  delete iter;
  return *this;
}
BOOL
ReadAllTags(ID3_Tag *id3, MBTag * tag) {


  ID3_Tag::ConstIterator* iter = (ID3_Tag::ConstIterator *)id3->CreateIterator();
  const ID3_Frame* frame = NULL;

  while (NULL != (frame = iter->GetNext()))
  {
	CString key,val;

    const char* desc = frame->GetDescription();
    if (!desc) desc = "";

	
    CString keylabel = (char*)frame->GetTextID();
    CString commkey;
    key = keylabel;
    if (keylabel == "COMM") {
        commkey = keylabel;
    }// else {
//        out += keylabel;
//        out += " ";
//    }
    ID3_FrameID eFrameID = frame->GetID();
    switch (eFrameID)
    {
      case ID3FID_ALBUM:
      case ID3FID_BPM:
      case ID3FID_COMPOSER:
      case ID3FID_CONTENTTYPE:
      case ID3FID_COPYRIGHT:
      case ID3FID_DATE:
      case ID3FID_PLAYLISTDELAY:
      case ID3FID_ENCODEDBY:
      case ID3FID_LYRICIST:
      case ID3FID_FILETYPE:
      case ID3FID_TIME:
      case ID3FID_CONTENTGROUP:
      case ID3FID_TITLE:
      case ID3FID_SUBTITLE:
      case ID3FID_INITIALKEY:
      case ID3FID_LANGUAGE:
      case ID3FID_SONGLEN:
      case ID3FID_MEDIATYPE:
      case ID3FID_ORIGALBUM:
      case ID3FID_ORIGFILENAME:
      case ID3FID_ORIGLYRICIST:
      case ID3FID_ORIGARTIST:
      case ID3FID_ORIGYEAR:
      case ID3FID_FILEOWNER:
      case ID3FID_LEADARTIST:
      case ID3FID_BAND:
      case ID3FID_CONDUCTOR:
      case ID3FID_MIXARTIST:
      case ID3FID_PARTINSET:
      case ID3FID_PUBLISHER:
      case ID3FID_TRACKNUM:
      case ID3FID_RECORDINGDATES:
      case ID3FID_NETRADIOSTATION:
      case ID3FID_NETRADIOOWNER:
      case ID3FID_SIZE:
      case ID3FID_ISRC:
      case ID3FID_ENCODERSETTINGS:
      case ID3FID_YEAR:
      {
        char *sText = ID3_GetString(frame, ID3FN_TEXT);
		val = sText;
        ID3_FreeString(sText);
        break;
      }
//#ifdef asdf
      case ID3FID_USERTEXT:
      {
        char 
        *sText = ID3_GetString(frame, ID3FN_TEXT), 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION);
		val = sDesc + CS(": ") + sText;
//        out += sDesc;
//        out += ": ";
//        out += sText;
//        out += "\r\n";
//		delete sText;
//		delete sDesc;
         ID3_FreeString(sText);
         ID3_FreeString(  sDesc);
        break;
      }
      case ID3FID_COMMENT:
      case ID3FID_UNSYNCEDLYRICS:
      {
        char 
        *sText = ID3_GetString(frame, ID3FN_TEXT), 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION), 
        *sLang = ID3_GetString(frame, ID3FN_LANGUAGE);
//        CString text = sText;
//        if (commkey == "COMM" && text.Left(4) == "FILE") {
//			file = text.Right(text.GetLength()-5);
//            filelabel = "\r\nOther info:\r\n" + text;
//        } else {
//            out += commkey ; out += " ";
//            out += sDesc;
//           out += " ";
//            out += sText;
//            out += "\r\n";
//        }
		val = sText;

         ID3_FreeString(  sText);
         ID3_FreeString(  sDesc);
         ID3_FreeString(  sLang);
        break;
      }
      case ID3FID_WWWAUDIOFILE:
      case ID3FID_WWWARTIST:
      case ID3FID_WWWAUDIOSOURCE:
      case ID3FID_WWWCOMMERCIALINFO:
      case ID3FID_WWWCOPYRIGHT:
      case ID3FID_WWWPUBLISHER:
      case ID3FID_WWWPAYMENT:
      case ID3FID_WWWRADIOPAGE:
      {
        char *sURL = ID3_GetString(frame, ID3FN_URL);
        val = sURL;
//        out += "\r\n";
         ID3_FreeString(  sURL);
//		delete sURL;
        break;
      }
      case ID3FID_WWWUSER:
      {
        char 
        *sURL = ID3_GetString(frame, ID3FN_URL),
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION);
        val = "(";
        val += sDesc; val += "): "; val += sURL;
         ID3_FreeString(  sURL);
         ID3_FreeString(  sDesc);
//		delete sURL;
//		delete sDesc;
        break;
      }
      case ID3FID_INVOLVEDPEOPLE:
      {
        size_t nItems = frame->GetField(ID3FN_TEXT)->GetNumTextItems();
        for (size_t nIndex = 0; nIndex < nItems; nIndex++)
        {
          char *sPeople = ID3_GetString(frame, ID3FN_TEXT, nIndex);
          val = sPeople;
           ID3_FreeString(  sPeople);
//		  delete sPeople;
          if (nIndex + 1 < nItems)
          {
            val += ", ";
          }
        }
//        out += "\r\n";
        break;
      }
      case ID3FID_PICTURE:
      {
        char
        *sMimeType = ID3_GetString(frame, ID3FN_MIMETYPE),
        *sDesc     = ID3_GetString(frame, ID3FN_DESCRIPTION),
        *sFormat   = ID3_GetString(frame, ID3FN_IMAGEFORMAT);
        size_t
        nPicType   = frame->GetField(ID3FN_PICTURETYPE)->Get(),
        nDataSize  = frame->GetField(ID3FN_DATA)->Size();
        val = "("; val += sDesc; val += ")["; val += sFormat; val += ", ";
        val += nPicType; val += "]: ";val += sMimeType;val += ", ";val += nDataSize;
        val += " bytes";

         ID3_FreeString(  sMimeType);
         ID3_FreeString(  sDesc);
         ID3_FreeString(  sFormat);
        break;
      }
      case ID3FID_GENERALOBJECT:
      {
        char 
        *sMimeType = ID3_GetString(frame, ID3FN_TEXT), 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION), 
        *sFileName = ID3_GetString(frame, ID3FN_FILENAME);
        size_t 
        nDataSize = frame->GetField(ID3FN_DATA)->Size();
        val = "(";
		val += sDesc;
		val += ")[" ;
		val += sFileName;val += "]: "; val += sMimeType;val += ", ";val += nDataSize;
        val += " bytes";
         ID3_FreeString(  sMimeType);
         ID3_FreeString(  sDesc);
         ID3_FreeString(  sFileName);

        break;
      }

      case ID3FID_UNIQUEFILEID:
      {
        CString sOwner = id3_GetStringUFID(frame, ID3FN_TEXT);
        if (sOwner.GetLength()) {
            size_t nDataSize = frame->GetField(ID3FN_DATA)->Size();
              val = sOwner;
        }
        break;
      }
      case ID3FID_PLAYCOUNTER:
      {
        size_t nCounter = frame->GetField(ID3FN_COUNTER)->Get();
        val = nCounter ;
        break;
      }
      case ID3FID_POPULARIMETER:
      {
        char *sEmail = ID3_GetString(frame, ID3FN_EMAIL);
        size_t
        nCounter = frame->GetField(ID3FN_COUNTER)->Get(),
        nRating = frame->GetField(ID3FN_RATING)->Get();
        val += sEmail;val += ", counter="; 
		val += nCounter; val += " rating=";val += nRating;
        ID3_FreeString(  sEmail);
        break;
      }
      case ID3FID_CRYPTOREG:
      case ID3FID_GROUPINGREG:
      {
        char *sOwner = ID3_GetString(frame, ID3FN_OWNER);
        size_t 
        nSymbol = frame->GetField(ID3FN_ID)->Get(),
        nDataSize = frame->GetField(ID3FN_DATA)->Size();
        val = "("; val += nSymbol;val += "): "; val += sOwner;
		val += ", "; val += nDataSize; val += " bytes";
        break;
      }
      case ID3FID_SYNCEDLYRICS:
      {
        char 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION), 
        *sLang = ID3_GetString(frame, ID3FN_LANGUAGE);
        size_t nTimestamp = frame->GetField(ID3FN_TIMESTAMPFORMAT)->Get();
        size_t nRating = frame->GetField(ID3FN_CONTENTTYPE)->Get();
        const char* format = (2 == nTimestamp) ? "ms" : "frames";
        val = "(";val += sDesc;val += ")["; val += sLang; val += "]: ";
        switch (nRating)
        {
          case ID3CT_OTHER:    val += "Other"; break;
          case ID3CT_LYRICS:   val += "Lyrics"; break;
          case ID3CT_TEXTTRANSCRIPTION:     val += "Text transcription"; break;
          case ID3CT_MOVEMENT: val += "Movement/part name"; break;
          case ID3CT_EVENTS:   val += "Events"; break;
          case ID3CT_CHORD:    val += "Chord"; break;
          case ID3CT_TRIVIA:   val += "Trivia/'pop up' information"; break;
        }

        ID3_Field* fld = frame->GetField(ID3FN_DATA);
        if (fld)
        {
          ID3_MemoryReader mr(fld->GetRawBinary(), fld->BinSize());
          while (!mr.atEnd())
          {
            val += io::readString(mr).c_str();
            val += " ["; val += io::readBENumber(mr, sizeof(uint32)); val += " " ;
			val += format; val += "] ";
          }
        }

         ID3_FreeString(  sDesc);
         ID3_FreeString(  sLang);
        break;
      }
      case ID3FID_AUDIOCRYPTO:
      case ID3FID_EQUALIZATION:
      case ID3FID_EVENTTIMING:
      case ID3FID_CDID:
      case ID3FID_MPEGLOOKUP:
      case ID3FID_OWNERSHIP:
      case ID3FID_PRIVATE:
      case ID3FID_POSITIONSYNC:
      case ID3FID_BUFFERSIZE:
      case ID3FID_VOLUMEADJ:
      case ID3FID_REVERB:
      case ID3FID_SYNCEDTEMPO:
      case ID3FID_METACRYPTO:
      {
        val = "(unimplemented)";
        break;
      }
      default:
      {
			if ("RVA2" == key) {
				size_t s = frame->GetDataSize();
				if (7 != s) {// not a Media Monkey rva2
					logger.log("found RVA2 but unknown format");
					break;
				}
				unsigned char * data = new BYTE[ s ];
				memcpy(data, frame->GetField(ID3FN_DATA)->GetRawBinary(),s);
//				BYTE * buf = new BYTE[ (s * 3)+1 ];
//				char * p = (char*)buf;
//				for (int i = 0 ; i < s; ++i) {
//					sprintf(p,"%02x ",data[i]);
//					p += 3;
//				}
//				buf[(s*3)] = 0;
//				val = "hex: "+CS(buf);
//				delete buf;

				if (1 != data[1]) {
					delete data;
					logger.log("found RVA2 but unknown format");
					break;
				}

				int rgfixed;
				double rgfloat;
				rgfixed = (data[3] << 8) | (data[2] << 0);
				rgfixed |= -(rgfixed & 0x8000);
				rgfloat = (double) rgfixed / 512;

				val = NTS(rgfloat);

//				unsigned int peak_bits;
//				peak_bits = data[4];
//				if (16 != peak_bits) {
//					delete data;
//					break;
//				}
//				rgfixed = (data[6] << 8) | (data[5] << 0);
//				rgfixed |= -(rgfixed & 0x8000);
//				rgfloat = (double) rgfixed / 512;
//
//				val += " " + NTS(rgfloat);

				delete data;
			} else {
				val = NTS(eFrameID) + " unknown ";
				size_t s = frame->GetDataSize();
				val += NTS(s);
			}
        break;
      }
    }
	if (key.GetLength() && val.GetLength()) {
		tag->setVal(key,val);
		if (tag->m_KeyCounter /*&& tag->IsAnMBKey(key)*/) {
			CString tmp = tag->m_KeyCounter->getVal(key);
			int c = atoi(tmp);
			c++;
			tag->m_KeyCounter->setVal(key,NTS(c));
		}
		if (tag->GettingInfo())
			tag->AppendInfo(key,val);
		if ("COMM" == key && tag->GettingComments())
			tag->AppendComments(val);
	}
  }
    delete iter;

#ifdef adsf
	AutoBuf buf(2000);
    Mp3Header mpg;
    if (mpg.mb_getFilePath(file) == TRUE) { 
		
		int chpos;
        chpos = sprintf(buf.p, "\r\nDuration    %d\r\n", mpg.getLengthInSeconds());
        chpos += sprintf((char*)buf.p + chpos, "Size       %d\r\n", mpg.getSize());
        chpos += sprintf((char*)buf.p + chpos, "Frames    %d\r\n", mpg.getNumberOfFrames());
        chpos += sprintf((char*)buf.p + chpos, "emphasis   %s\r\n", (LPCTSTR) mpg.getEmphasis());
        chpos += sprintf((char*)buf.p + chpos, "Original   %s\r\n", mpg.getOriginal() == TRUE ? "true" : "false" );
        chpos += sprintf((char*)buf.p + chpos, "Copyright  %s\r\n", mpg.getCopyright() == TRUE ? "true" : "false" );
        chpos += sprintf((char*)buf.p + chpos, "Protection %s\r\n", mpg.getProtection() == TRUE ? "true" : "false" );
        chpos += sprintf((char*)buf.p + chpos, "Version    %f\r\n", mpg.getVersion() );
        chpos += sprintf((char*)buf.p + chpos, "Layer      %d\r\n", mpg.getLayer() );
        chpos += sprintf((char*)buf.p + chpos, "Bitrate    %d\r\n", mpg.getBitrate() );
        chpos += sprintf((char*)buf.p + chpos, "Frequency  %d\r\n", mpg.getFrequency() );
        chpos += sprintf((char*)buf.p + chpos, "Mode       %s\r\n", (LPCTSTR)mpg.getMode() );
		out += buf.p;     
    } else {
        sprintf(buf.p, "No valid mp3 headers found\r\nDoes not appear to be an mp3 file.\r\n");
		out += buf.p;     
    }
#endif
	
    return TRUE;
}
CString
displayTag(ID3_Tag *id3, BOOL showLabels, CString file) {


  CString out,filelabel;

  if (showLabels) {
	out +=     "Genre:  ";
	out += Genre_normalize(id3_GetGenre(id3));
	out += "\r\nArtist: ";
	out += id3_GetArtist(id3);
	out += "\r\nAlbum:  ";
	out += id3_GetAlbum(id3);
	out += "\r\nTitle:  ";
	out += id3_GetTitle(id3);
	out += "\r\nTrack:  ";
	out += id3_GetTrack(id3);
	out += "\r\nYear:   ";
	out += id3_GetYear(id3);
	out += "\r\n\r\nRaw id3 tag:\r\n";
  }

  ID3_Tag::ConstIterator* iter = (ID3_Tag::ConstIterator *)id3->CreateIterator();
  const ID3_Frame* frame = NULL;

  while (NULL != (frame = iter->GetNext()))
  {
    const char* desc = frame->GetDescription();
    if (!desc) desc = "";

	
    CString keylabel = (char*)frame->GetTextID();
    CString commkey;
    filelabel = "";
    if (keylabel == "COMM") {
        commkey = keylabel;
    } else {
        out += keylabel;
        out += " ";
    }
    ID3_FrameID eFrameID = frame->GetID();
    switch (eFrameID)
    {
      case ID3FID_ALBUM:
      case ID3FID_BPM:
      case ID3FID_COMPOSER:
      case ID3FID_CONTENTTYPE:
      case ID3FID_COPYRIGHT:
      case ID3FID_DATE:
      case ID3FID_PLAYLISTDELAY:
      case ID3FID_ENCODEDBY:
      case ID3FID_LYRICIST:
      case ID3FID_FILETYPE:
      case ID3FID_TIME:
      case ID3FID_CONTENTGROUP:
      case ID3FID_TITLE:
      case ID3FID_SUBTITLE:
      case ID3FID_INITIALKEY:
      case ID3FID_LANGUAGE:
      case ID3FID_SONGLEN:
      case ID3FID_MEDIATYPE:
      case ID3FID_ORIGALBUM:
      case ID3FID_ORIGFILENAME:
      case ID3FID_ORIGLYRICIST:
      case ID3FID_ORIGARTIST:
      case ID3FID_ORIGYEAR:
      case ID3FID_FILEOWNER:
      case ID3FID_LEADARTIST:
      case ID3FID_BAND:
      case ID3FID_CONDUCTOR:
      case ID3FID_MIXARTIST:
      case ID3FID_PARTINSET:
      case ID3FID_PUBLISHER:
      case ID3FID_TRACKNUM:
      case ID3FID_RECORDINGDATES:
      case ID3FID_NETRADIOSTATION:
      case ID3FID_NETRADIOOWNER:
      case ID3FID_SIZE:
      case ID3FID_ISRC:
      case ID3FID_ENCODERSETTINGS:
      case ID3FID_YEAR:
      {
        char *sText = ID3_GetString(frame, ID3FN_TEXT);
        out += sText;
        out += (char*)"\r\n";
//       delete  sText;
         ID3_FreeString(sText);
        break;
      }
//#ifdef asdf
      case ID3FID_USERTEXT:
      {
        char 
        *sText = ID3_GetString(frame, ID3FN_TEXT), 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION);
        out += sDesc;
        out += ": ";
        out += sText;
        out += "\r\n";
//		delete sText;
//		delete sDesc;
         ID3_FreeString(sText);
         ID3_FreeString(  sDesc);
        break;
      }
      case ID3FID_COMMENT:
      case ID3FID_UNSYNCEDLYRICS:
      {
        char 
        *sText = ID3_GetString(frame, ID3FN_TEXT), 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION), 
        *sLang = ID3_GetString(frame, ID3FN_LANGUAGE);
        CString text = sText;
        if (commkey == "COMM" && text.Left(4) == "FILE") {
			file = text.Right(text.GetLength()-5);
            filelabel = "\r\nOther info:\r\n" + text;
        } else {
            out += commkey ; out += " ";
            out += sDesc;
            out += " ";
            out += sText;
            out += "\r\n";
        }

         ID3_FreeString(  sText);
         ID3_FreeString(  sDesc);
         ID3_FreeString(  sLang);
        break;
      }
      case ID3FID_WWWAUDIOFILE:
      case ID3FID_WWWARTIST:
      case ID3FID_WWWAUDIOSOURCE:
      case ID3FID_WWWCOMMERCIALINFO:
      case ID3FID_WWWCOPYRIGHT:
      case ID3FID_WWWPUBLISHER:
      case ID3FID_WWWPAYMENT:
      case ID3FID_WWWRADIOPAGE:
      {
        char *sURL = ID3_GetString(frame, ID3FN_URL);
        out += sURL;
        out += "\r\n";
         ID3_FreeString(  sURL);
//		delete sURL;
        break;
      }
      case ID3FID_WWWUSER:
      {
        char 
        *sURL = ID3_GetString(frame, ID3FN_URL),
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION);
        out += "(";
        out += sDesc; out += "): "; out += sURL; out += "\r\n";
         ID3_FreeString(  sURL);
         ID3_FreeString(  sDesc);
//		delete sURL;
//		delete sDesc;
        break;
      }
      case ID3FID_INVOLVEDPEOPLE:
      {
        size_t nItems = frame->GetField(ID3FN_TEXT)->GetNumTextItems();
        for (size_t nIndex = 0; nIndex < nItems; nIndex++)
        {
          char *sPeople = ID3_GetString(frame, ID3FN_TEXT, nIndex);
          out += sPeople;
           ID3_FreeString(  sPeople);
//		  delete sPeople;
          if (nIndex + 1 < nItems)
          {
            out += ", ";
          }
        }
        out += "\r\n";
        break;
      }
      case ID3FID_PICTURE:
      {
        char
        *sMimeType = ID3_GetString(frame, ID3FN_MIMETYPE),
        *sDesc     = ID3_GetString(frame, ID3FN_DESCRIPTION),
        *sFormat   = ID3_GetString(frame, ID3FN_IMAGEFORMAT);
        size_t
        nPicType   = frame->GetField(ID3FN_PICTURETYPE)->Get(),
        nDataSize  = frame->GetField(ID3FN_DATA)->Size();
        out += "("; out += sDesc; out += ")["; out += sFormat; out += ", ";
        out += nPicType; out += "]: ";out += sMimeType;out += ", ";out += nDataSize;
        out += " bytes"; out += "\r\n";

         ID3_FreeString(  sMimeType);
         ID3_FreeString(  sDesc);
         ID3_FreeString(  sFormat);
//		delete sMimeType;
//		delete sDesc;
//		delete sFormat;
        break;
      }
      case ID3FID_GENERALOBJECT:
      {
        char 
        *sMimeType = ID3_GetString(frame, ID3FN_TEXT), 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION), 
        *sFileName = ID3_GetString(frame, ID3FN_FILENAME);
        size_t 
        nDataSize = frame->GetField(ID3FN_DATA)->Size();
        out += "(";
		out += sDesc;
		out += ")[" ;
		out += sFileName;out += "]: "; out += sMimeType;out += ", ";out += nDataSize;
        out += " bytes";out += "\r\n";
         ID3_FreeString(  sMimeType);
         ID3_FreeString(  sDesc);
         ID3_FreeString(  sFileName);
//		delete sMimeType;
//		delete sDesc;
//		delete sFileName;
        break;
      }
//#endif
      case ID3FID_UNIQUEFILEID:
      {
        CString sOwner = id3_GetStringUFID(frame, ID3FN_TEXT);
        if (sOwner.GetLength()) {
            size_t nDataSize = frame->GetField(ID3FN_DATA)->Size();
//            out += sOwner;out += ", ";out += nDataSize;
//                 + " bytes" + "\r\n";
              out += sOwner;out += "\r\n"; 
//               ID3_FreeString(  sOwner);
//			delete sOwner;
        } else {
            out += "\r\n";
        }
        break;
      }
//#ifdef asdf
      case ID3FID_PLAYCOUNTER:
      {
        size_t nCounter = frame->GetField(ID3FN_COUNTER)->Get();
        out += nCounter + "\r\n";
        break;
      }
      case ID3FID_POPULARIMETER:
      {
        char *sEmail = ID3_GetString(frame, ID3FN_EMAIL);
        size_t
        nCounter = frame->GetField(ID3FN_COUNTER)->Get(),
        nRating = frame->GetField(ID3FN_RATING)->Get();
        out += sEmail;out += ", counter="; 
		out += nCounter; out += " rating=";out += nRating; out += "\r\n";
         ID3_FreeString(  sEmail);
//		delete sEmail;
        break;
      }
      case ID3FID_CRYPTOREG:
      case ID3FID_GROUPINGREG:
      {
        char *sOwner = ID3_GetString(frame, ID3FN_OWNER);
        size_t 
        nSymbol = frame->GetField(ID3FN_ID)->Get(),
        nDataSize = frame->GetField(ID3FN_DATA)->Size();
        out += "("; out += nSymbol;out += "): "; out += sOwner;
		out += ", "; out += nDataSize; out += " bytes"; out += "\r\n";
        break;
      }
      case ID3FID_SYNCEDLYRICS:
      {
        char 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION), 
        *sLang = ID3_GetString(frame, ID3FN_LANGUAGE);
        size_t nTimestamp = frame->GetField(ID3FN_TIMESTAMPFORMAT)->Get();
        size_t nRating = frame->GetField(ID3FN_CONTENTTYPE)->Get();
        const char* format = (2 == nTimestamp) ? "ms" : "frames";
        out += "(";out += sDesc;out += ")["; out += sLang; out += "]: ";
        switch (nRating)
        {
          case ID3CT_OTHER:    out += "Other"; break;
          case ID3CT_LYRICS:   out += "Lyrics"; break;
          case ID3CT_TEXTTRANSCRIPTION:     out += "Text transcription"; break;
          case ID3CT_MOVEMENT: out += "Movement/part name"; break;
          case ID3CT_EVENTS:   out += "Events"; break;
          case ID3CT_CHORD:    out += "Chord"; break;
          case ID3CT_TRIVIA:   out += "Trivia/'pop up' information"; break;
        }
        out += "\r\n";
        ID3_Field* fld = frame->GetField(ID3FN_DATA);
        if (fld)
        {
          ID3_MemoryReader mr(fld->GetRawBinary(), fld->BinSize());
          while (!mr.atEnd())
          {
            out += io::readString(mr).c_str();
            out += " ["; out += io::readBENumber(mr, sizeof(uint32)); out += " " ;
			out += format; out += "] ";
          }
        }
        out += "\r\n";
         ID3_FreeString(  sDesc);
         ID3_FreeString(  sLang);
//		delete sDesc;
//		delete sLang;
        break;
      }
      case ID3FID_AUDIOCRYPTO:
      case ID3FID_EQUALIZATION:
      case ID3FID_EVENTTIMING:
      case ID3FID_CDID:
      case ID3FID_MPEGLOOKUP:
      case ID3FID_OWNERSHIP:
      case ID3FID_PRIVATE:
      case ID3FID_POSITIONSYNC:
      case ID3FID_BUFFERSIZE:
      case ID3FID_VOLUMEADJ:
      case ID3FID_REVERB:
      case ID3FID_SYNCEDTEMPO:
      case ID3FID_METACRYPTO:
      {
        out += " (unimplemented)"; out += "\r\n";
        break;
      }
//#endif
      default:
      {
//        out += " frame"; out += "\r\n";
        break;
      }
    }
  }
//   ID3_Free((void*)iter);
    delete iter;
    out += filelabel;
//	out += "\r\n";

	AutoBuf buf(2000);
    Mp3Header mpg;
    if (mpg.mb_getFilePath(file) == TRUE) { 
		
		int chpos;
        chpos = sprintf(buf.p, "\r\nDuration    %d\r\n", mpg.getLengthInSeconds());
        chpos += sprintf((char*)buf.p + chpos, "Size       %d\r\n", mpg.getSize());
        chpos += sprintf((char*)buf.p + chpos, "Frames    %d\r\n", mpg.getNumberOfFrames());
        chpos += sprintf((char*)buf.p + chpos, "emphasis   %s\r\n", (LPCTSTR) mpg.getEmphasis());
        chpos += sprintf((char*)buf.p + chpos, "Original   %s\r\n", mpg.getOriginal() == TRUE ? "true" : "false" );
        chpos += sprintf((char*)buf.p + chpos, "Copyright  %s\r\n", mpg.getCopyright() == TRUE ? "true" : "false" );
        chpos += sprintf((char*)buf.p + chpos, "Protection %s\r\n", mpg.getProtection() == TRUE ? "true" : "false" );
        chpos += sprintf((char*)buf.p + chpos, "Version    %f\r\n", mpg.getVersion() );
        chpos += sprintf((char*)buf.p + chpos, "Layer      %d\r\n", mpg.getLayer() );
        chpos += sprintf((char*)buf.p + chpos, "Bitrate    %d\r\n", mpg.getBitrate() );
        chpos += sprintf((char*)buf.p + chpos, "Frequency  %d\r\n", mpg.getFrequency() );
        chpos += sprintf((char*)buf.p + chpos, "Mode       %s\r\n", (LPCTSTR)mpg.getMode() );
		out += buf.p;     
    } else {
        sprintf(buf.p, "No valid mp3 headers found\r\nDoes not appear to be an mp3 file.\r\n");
		out += buf.p;     
    }
	
    return out;
}
Example #4
0
void PrintInformation(const ID3_Tag &myTag)
{
  ID3_Tag::ConstIterator* iter = myTag.CreateIterator();
  const ID3_Frame* frame = NULL;
  while (NULL != (frame = iter->GetNext()))
  {
    const char* desc = frame->GetDescription();
    if (!desc) desc = "";
    cout << "=== " << frame->GetTextID() << " (" << desc << "): ";
    ID3_FrameID eFrameID = frame->GetID();
    switch (eFrameID)
    {
      case ID3FID_ALBUM:
      case ID3FID_BPM:
      case ID3FID_COMPOSER:
      case ID3FID_CONTENTTYPE:
      case ID3FID_COPYRIGHT:
      case ID3FID_DATE:
      case ID3FID_PLAYLISTDELAY:
      case ID3FID_ENCODEDBY:
      case ID3FID_LYRICIST:
      case ID3FID_FILETYPE:
      case ID3FID_TIME:
      case ID3FID_CONTENTGROUP:
      case ID3FID_TITLE:
      case ID3FID_SUBTITLE:
      case ID3FID_INITIALKEY:
      case ID3FID_LANGUAGE:
      case ID3FID_SONGLEN:
      case ID3FID_MEDIATYPE:
      case ID3FID_ORIGALBUM:
      case ID3FID_ORIGFILENAME:
      case ID3FID_ORIGLYRICIST:
      case ID3FID_ORIGARTIST:
      case ID3FID_ORIGYEAR:
      case ID3FID_FILEOWNER:
      case ID3FID_LEADARTIST:
      case ID3FID_BAND:
      case ID3FID_CONDUCTOR:
      case ID3FID_MIXARTIST:
      case ID3FID_PARTINSET:
      case ID3FID_PUBLISHER:
      case ID3FID_TRACKNUM:
      case ID3FID_RECORDINGDATES:
      case ID3FID_NETRADIOSTATION:
      case ID3FID_NETRADIOOWNER:
      case ID3FID_SIZE:
      case ID3FID_ISRC:
      case ID3FID_ENCODERSETTINGS:
      case ID3FID_YEAR:
      {
        char *sText = ID3_GetString(frame, ID3FN_TEXT);
        cout << sText << endl;
        delete [] sText;
        break;
      }
      case ID3FID_USERTEXT:
      {
        char 
        *sText = ID3_GetString(frame, ID3FN_TEXT), 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION);
        cout << "(" << sDesc << "): " << sText << endl;
        delete [] sText;
        delete [] sDesc;
        break;
      }
      case ID3FID_COMMENT:
      case ID3FID_UNSYNCEDLYRICS:
      {
        char 
        *sText = ID3_GetString(frame, ID3FN_TEXT), 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION), 
        *sLang = ID3_GetString(frame, ID3FN_LANGUAGE);
        cout << "(" << sDesc << ")[" << sLang << "]: "
             << sText << endl;
        delete [] sText;
        delete [] sDesc;
        delete [] sLang;
        break;
      }
      case ID3FID_WWWAUDIOFILE:
      case ID3FID_WWWARTIST:
      case ID3FID_WWWAUDIOSOURCE:
      case ID3FID_WWWCOMMERCIALINFO:
      case ID3FID_WWWCOPYRIGHT:
      case ID3FID_WWWPUBLISHER:
      case ID3FID_WWWPAYMENT:
      case ID3FID_WWWRADIOPAGE:
      {
        char *sURL = ID3_GetString(frame, ID3FN_URL);
        cout << sURL << endl;
        delete [] sURL;
        break;
      }
      case ID3FID_WWWUSER:
      {
        char 
        *sURL = ID3_GetString(frame, ID3FN_URL),
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION);
        cout << "(" << sDesc << "): " << sURL << endl;
        delete [] sURL;
        delete [] sDesc;
        break;
      }
      case ID3FID_INVOLVEDPEOPLE:
      {
        size_t nItems = frame->GetField(ID3FN_TEXT)->GetNumTextItems();
        for (size_t nIndex = 0; nIndex < nItems; nIndex++)
        {
          char *sPeople = ID3_GetString(frame, ID3FN_TEXT, nIndex);
          cout << sPeople;
          delete [] sPeople;
          if (nIndex + 1 < nItems)
          {
            cout << ", ";
          }
        }
        cout << endl;
        break;
      }
      case ID3FID_PICTURE:
      {
        char
        *sMimeType = ID3_GetString(frame, ID3FN_MIMETYPE),
        *sDesc     = ID3_GetString(frame, ID3FN_DESCRIPTION),
        *sFormat   = ID3_GetString(frame, ID3FN_IMAGEFORMAT);
        size_t
        nPicType   = frame->GetField(ID3FN_PICTURETYPE)->Get(),
        nDataSize  = frame->GetField(ID3FN_DATA)->Size();
        cout << "(" << sDesc << ")[" << sFormat << ", "
             << nPicType << "]: " << sMimeType << ", " << nDataSize
             << " bytes" << endl;
        delete [] sMimeType;
        delete [] sDesc;
        delete [] sFormat;
        break;
      }
      case ID3FID_GENERALOBJECT:
      {
        char 
        *sMimeType = ID3_GetString(frame, ID3FN_MIMETYPE), 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION), 
        *sFileName = ID3_GetString(frame, ID3FN_FILENAME);
        size_t 
        nDataSize = frame->GetField(ID3FN_DATA)->Size();
        cout << "(" << sDesc << ")[" 
             << sFileName << "]: " << sMimeType << ", " << nDataSize
             << " bytes" << endl;
        delete [] sMimeType;
        delete [] sDesc;
        delete [] sFileName;
        break;
      }
      case ID3FID_UNIQUEFILEID:
      {
        char *sOwner = ID3_GetString(frame, ID3FN_OWNER);
        size_t nDataSize = frame->GetField(ID3FN_DATA)->Size();
        cout << sOwner << ", " << nDataSize
             << " bytes" << endl;
        delete [] sOwner;
        break;
      }
      case ID3FID_PLAYCOUNTER:
      {
        size_t nCounter = frame->GetField(ID3FN_COUNTER)->Get();
        cout << nCounter << endl;
        break;
      }
      case ID3FID_POPULARIMETER:
      {
        char *sEmail = ID3_GetString(frame, ID3FN_EMAIL);
        size_t
        nCounter = frame->GetField(ID3FN_COUNTER)->Get(),
        nRating = frame->GetField(ID3FN_RATING)->Get();
        cout << sEmail << ", counter=" 
             << nCounter << " rating=" << nRating << endl;
        delete [] sEmail;
        break;
      }
      case ID3FID_CRYPTOREG:
      case ID3FID_GROUPINGREG:
      {
        char *sOwner = ID3_GetString(frame, ID3FN_OWNER);
        size_t 
        nSymbol = frame->GetField(ID3FN_ID)->Get(),
        nDataSize = frame->GetField(ID3FN_DATA)->Size();
        cout << "(" << nSymbol << "): " << sOwner
             << ", " << nDataSize << " bytes" << endl;
        break;
      }
      case ID3FID_SYNCEDLYRICS:
      {
        char 
        *sDesc = ID3_GetString(frame, ID3FN_DESCRIPTION), 
        *sLang = ID3_GetString(frame, ID3FN_LANGUAGE);
        size_t
        nTimestamp = frame->GetField(ID3FN_TIMESTAMPFORMAT)->Get(),
        nRating = frame->GetField(ID3FN_CONTENTTYPE)->Get();
        const char* format = (2 == nTimestamp) ? "ms" : "frames";
        cout << "(" << sDesc << ")[" << sLang << "]: ";
        switch (nRating)
        {
          case ID3CT_OTHER:    cout << "Other"; break;
          case ID3CT_LYRICS:   cout << "Lyrics"; break;
          case ID3CT_TEXTTRANSCRIPTION:     cout << "Text transcription"; break;
          case ID3CT_MOVEMENT: cout << "Movement/part name"; break;
          case ID3CT_EVENTS:   cout << "Events"; break;
          case ID3CT_CHORD:    cout << "Chord"; break;
          case ID3CT_TRIVIA:   cout << "Trivia/'pop up' information"; break;
        }
        cout << endl;
        ID3_Field* fld = frame->GetField(ID3FN_DATA);
        if (fld)
        {
          ID3_MemoryReader mr(fld->GetRawBinary(), fld->BinSize());
          while (!mr.atEnd())
          {
            cout << io::readString(mr).c_str();
            cout << " [" << io::readBENumber(mr, sizeof(uint32)) << " " 
                 << format << "] ";
          }
        }
        cout << endl;
        delete [] sDesc;
        delete [] sLang;
        break;
      }
      case ID3FID_AUDIOCRYPTO:
      case ID3FID_EQUALIZATION:
      case ID3FID_EVENTTIMING:
      case ID3FID_CDID:
      case ID3FID_MPEGLOOKUP:
      case ID3FID_OWNERSHIP:
      case ID3FID_PRIVATE:
      case ID3FID_POSITIONSYNC:
      case ID3FID_BUFFERSIZE:
      case ID3FID_VOLUMEADJ:
      case ID3FID_REVERB:
      case ID3FID_SYNCEDTEMPO:
      case ID3FID_METACRYPTO:
      {
        cout << " (unimplemented)" << endl;
        break;
      }
      default:
      {
        cout << " frame" << endl;
        break;
      }
    }
  }
  delete iter;
}