Пример #1
0
/* LPCTSTR means const char * */
size_t RemoveFrame(ID3_Tag& pTag, ID3_FrameID fID, LPCTSTR sDescription)
{
    size_t nCount = 0;
    const ID3_Frame * frame = NULL;

    do {
        if (!sDescription)
        {
            cerr << "*** description is null" << endl;
            frame = pTag.Find(fID);
        }
        else
        {
            cerr << "*** description is \"" << sDescription << "\"" << endl;
            frame = pTag.Find(fID, ID3FN_DESCRIPTION, sDescription);
        }

        if (frame)
        {
            ID3_Field* fld = frame->GetField(ID3FN_TEXT);
            String text(fld->GetRawText(), fld->Size());
            cerr << "*** delete frame with text \"" << text << "\"" << endl;
            /* pTag is an ID3_Tag */
            delete pTag.RemoveFrame(frame);
            nCount++;
        }
    } while (frame != NULL);

    return nCount;
}
Пример #2
0
//following routine courtesy of John George
size_t ID3_GetPictureDataOfPicType(ID3_Tag* tag, const char* TempPicPath, ID3_PictureType pictype)
{
    if (NULL == tag)
        return 0;
    else
    {
        ID3_Frame* frame = NULL;
        ID3_Tag::Iterator* iter = tag->CreateIterator();

        while (NULL != (frame = iter->GetNext() ))
        {
            if(frame->GetID() == ID3FID_PICTURE)
            {
                if(frame->GetField(ID3FN_PICTURETYPE)->Get() == (uint32)pictype)
                    break;
            }
        }
        delete iter;

        if (frame != NULL)
        {
            ID3_Field* myField = frame->GetField(ID3FN_DATA);
            if (myField != NULL)
            {
                myField->ToFile(TempPicPath);
                return (size_t)myField->Size();
            }
            else return 0;
        }
        else return 0;
    }
}
Пример #3
0
ID3_Frame *ID3_TagImpl::Find(ID3_FrameID id, ID3_FieldID fldID, String data) const
{
  ID3_Frame *frame = NULL;
  ID3D_NOTICE( "Find: looking for comment with data = " << data.c_str() );

  // reset the cursor if it isn't set
  if (_frames.end() == _cursor)
  {
    _cursor = _frames.begin();
    ID3D_NOTICE( "Find: resetting cursor" );
  }

  for (int iCount = 0; iCount < 2 && frame == NULL; iCount++)
  {
    ID3D_NOTICE( "Find: iCount = " << iCount );
    // We want to cycle through the list to find the matching frame.  We
    // should begin from the cursor, search each successive frame, wrapping
    // if necessary.  The enclosing loop and the assignment statments below
    // ensure that we first begin at the cursor and search to the end of the
    // list and, if unsuccessful, start from the beginning of the list and
    // search to the cursor.
    const_iterator
      begin  = (0 == iCount ? _cursor       : _frames.begin()),
      end    = (0 == iCount ? _frames.end() : _cursor);
    // search from the cursor to the end
    for (const_iterator cur = begin; cur != end; ++cur)
    {
      ID3D_NOTICE( "Find: frame = 0x" << hex << (uint32) *cur << dec );
      if ((*cur != NULL) && ((*cur)->GetID() == id) &&
          (*cur)->Contains(fldID))
      {
        ID3_Field* fld = (*cur)->GetField(fldID);
        if (NULL == fld)
        {
          continue;
          ID3D_NOTICE( "Find: didn't have the right field" );
        }

        String text( NULL == fld->GetRawText() ? "" : fld->GetRawText() , fld->Size()); //PHF
        ID3D_NOTICE( "Find: text = " << text.c_str() );

        if (text == data)
        {
          // We've found a valid frame.  Set cursor to be the next element
          frame = *cur;
          _cursor = ++cur;
          break;
        }
      }
    }
  }

  return frame;
}
BString id3::v2::getSyncLyrics(const ID3_TagImpl& tag, String lang, String desc)
{
  // check if a SYLT frame of this language or descriptor exists
  ID3_Frame* frame = NULL;
  (frame = tag.Find(ID3FID_SYNCEDLYRICS, ID3FN_LANGUAGE, lang.c_str())) ||
  (frame = tag.Find(ID3FID_SYNCEDLYRICS, ID3FN_DESCRIPTION, desc.c_str())) ||
  (frame = tag.Find(ID3FID_SYNCEDLYRICS));

  // get the lyrics size
  ID3_Field* fld = frame->GetField(ID3FN_DATA);
  return BString(reinterpret_cast<const BString::value_type *>(fld->GetRawBinary()), fld->Size());
}
/** Helper function to get a "good" string for a field, no matter what. */
String id3::v2::getStringAtIndex(const ID3_Frame* frame, ID3_FieldID fldName,
                                 size_t nIndex)
{
  if (!frame)
    return "";

  ID3_Field* fp = frame->GetField(fldName);
  if (!fp)
    return "";

  return fp->GetText( nIndex, fp->GetEncoding() );
}
Пример #6
0
QString PlaybackControls::getComment(QString file)
{
	QString field;
	ID3_Tag mTag(file.toStdString().c_str());
	ID3_Frame* myFrame = mTag.Find(ID3FID_COMMENT);
	if (myFrame)
	{
		ID3_Field* myField = myFrame->GetField(ID3FN_TEXT);
		if (myField)
		{
			field = myField->GetRawText();
		}
	}
	return field;
}
Пример #7
0
QPixmap PlaybackControls::getPicture(QString file)
{
	QPixmap field;
	ID3_Tag mTag(file.toStdString().c_str());
	ID3_Frame* myFrame = mTag.Find(ID3FID_PICTURE);
	if (myFrame)
	{
		ID3_Field* myField = myFrame->GetField(ID3FN_DATA);
		if (myField)
		{
			const uchar *test = myField->GetRawBinary();
			field.loadFromData(test, myField->Size());
		}
	}
	return field;
}
Пример #8
0
ID3_Frame *ID3_TagImpl::Find(ID3_FrameID id, ID3_FieldID fldID, WString data) const
{
  ID3_Frame *frame = NULL;

  // reset the cursor if it isn't set
  if (_frames.end() == _cursor)
  {
    _cursor = _frames.begin();
  }

  for (int iCount = 0; iCount < 2 && frame == NULL; iCount++)
  {
    // We want to cycle through the list to find the matching frame.  We
    // should begin from the cursor, search each successive frame, wrapping
    // if necessary.  The enclosing loop and the assignment statments below
    // ensure that we first begin at the cursor and search to the end of the
    // list and, if unsuccessful, start from the beginning of the list and
    // search to the cursor.
    const_iterator
      begin  = (0 == iCount ? _cursor       : _frames.begin()),
      end    = (0 == iCount ? _frames.end() : _cursor);
    // search from the cursor to the end
    for (const_iterator cur = begin; cur != end; ++cur)
    {
      if ((*cur != NULL) && ((*cur)->GetID() == id) &&
          (*cur)->Contains(fldID))
      {
        ID3_Field* fld = (*cur)->GetField(fldID);
        if (NULL == fld)
        {
          continue;
        }
        WString text = toWString(fld->GetRawUnicodeText(), fld->Size());

        if (text == data)
        {
          // We've found a valid frame.  Set cursor to be the next element
          frame = *cur;
          _cursor = ++cur;
          break;
        }
      }
    }
  }

  return frame;
}
Пример #9
0
// Caller must delete [] dst after use.
static void field_text(char** dst, ID3_Frame* frame) {
  iconv_t cd = iconv_open("UTF8","UTF16BE");
  const int bufsize = 1000;
  char buf[bufsize];

  if (NULL != frame) {
    ID3_Field* field = frame->GetField(ID3FN_TEXT);
    if (NULL != field) {

      switch(field->GetEncoding()){
      case ID3TE_UTF16:
      case ID3TE_UTF16BE:
        // Convert to UTF-8 before returning the data to Go.
        if ( cd != (iconv_t) -1 ) {
          char* in = (char*) field->GetRawUnicodeText();
          size_t insize = field->Size();

          char* bufptr = buf;
          size_t bufbytes = bufsize;
          size_t rc = 0;

          // Initialize iconv state
          if( iconv(cd, NULL, NULL, &bufptr, &bufbytes) == (size_t) -1 ){
            *dst = empty_string();
            break;
          }

          if ( (rc = iconv(cd, &in, &insize, &bufptr, &bufbytes)) != (size_t) -1 ) {
            *bufptr = '\0';
            *dst = new char[bufsize-bufbytes+1];
            memcpy(*dst, buf, bufsize-bufbytes);
            (*dst)[bufsize-bufbytes] = '\0';
          } else {
            *dst = empty_string();
          }
        } else {
          *dst = empty_string();
        }
        break;
      default:
        // Ascii
        *dst = new char[field->Size()+1];
        (*dst)[0] = '\0';
        size_t len = field->Get(*dst, field->Size()+1);
        (*dst)[field->Size()] = '\0';
      }
    }
  }

  iconv_close(cd);
}
Пример #10
0
//following routine courtesy of John George
int ID3_GetPictureData(const ID3_Tag *tag, const char *TempPicPath)
{
    if (NULL == tag)
        return 0;
    else
    {
        ID3_Frame* frame = NULL;
        frame = tag->Find(ID3FID_PICTURE);
        if (frame != NULL)
        {
            ID3_Field* myField = frame->GetField(ID3FN_DATA);
            if (myField != NULL)
            {
                myField->ToFile(TempPicPath);
                return (int)myField->Size();
            }
            else return 0;
        }
        else return 0;
    }
}
Пример #11
0
void ID3_FrameImpl::_InitFields()
{
  const ID3_FrameDef* info = _hdr.GetFrameDef();
  if (NULL == info)
  {
    // log this
    ID3_Field* fld = new ID3_FieldImpl(ID3_FieldDef::DEFAULT[0]);
    _fields.push_back(fld);
    _bitset.set(fld->GetID());
  }
  else
  {
    
    for (size_t i = 0; info->aeFieldDefs[i]._id != ID3FN_NOFIELD; ++i)
    {
      ID3_Field* fld = new ID3_FieldImpl(info->aeFieldDefs[i]);
      _fields.push_back(fld);
      _bitset.set(fld->GetID());
    }
    
    _changed = true;
  }
}
Пример #12
0
char *ID3_GetString(const ID3_Frame *frame, ID3_FieldID fldName)
{
    char *text = NULL;
//  if (NULL != frame)
    ID3_Field* fld;
    if (NULL != frame && NULL != (fld = frame->GetField(fldName)))
    {
//    ID3_Field* fld = frame->GetField(fldName);
        ID3_TextEnc enc = fld->GetEncoding();
        fld->SetEncoding(ID3TE_ISO8859_1);
        size_t nText = fld->Size();
        text = new char[nText + 1];
        fld->Get(text, nText + 1);
        fld->SetEncoding(enc);
    }
    return text;
}
Пример #13
0
String id3::v2::getString(const ID3_Frame* frame, ID3_FieldID fldName)
{
  if (!frame)
  {
    return "";
  }
  ID3_Field* fp = frame->GetField(fldName);
  if (!fp)
  {
    return "";
  }
  ID3_TextEnc enc = fp->GetEncoding();
  fp->SetEncoding(ID3TE_ASCII);

  String text(fp->GetRawText(), fp->Size());

  fp->SetEncoding(enc);
  return text;
}
Пример #14
0
String id3::v2::getStringAtIndex(const ID3_Frame* frame, ID3_FieldID fldName,
                                 size_t nIndex)
{
  if (!frame)
  {
    return "";
  }
  String text;
  ID3_Field* fp = frame->GetField(fldName);
  if (fp && fp->GetNumTextItems() < nIndex)
  {
    ID3_TextEnc enc = fp->GetEncoding();
    fp->SetEncoding(ID3TE_ASCII);

    text = fp->GetRawTextItem(nIndex);

    fp->SetEncoding(enc);
  }
  return text;
}
Пример #15
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;
}
Пример #16
0
void MP3TagReader::ImportTags(MatroskaTagInfo *target) {
#ifdef USING_ID3LIB
	
	// use an std::auto_ptr here to handle object cleanup automatically
  ID3_Tag::Iterator *iter = m_Tag.CreateIterator();
  ID3_Frame *myFrame = NULL;
  while (NULL != (myFrame = iter->GetNext())) {
		// do something with myFrame
		//myFrame;
		ID3_Field *textField = myFrame->GetField(ID3FN_TEXTENC);
		ID3_Field *intField = myFrame->GetField(ID3FN_COUNTER);
		
		if (myFrame->GetID() == ID3FID_PLAYCOUNTER) {
			target->Tag_PlayCounter = intField->Get();

		} else if (myFrame->GetID() == ID3FID_POPULARIMETER) {
			target->Tag_Popularimeter = intField->Get();

		} else if (myFrame->GetID() == ID3FID_ALBUM) {
			MatroskaTagMultiTitleItem *newTagItem = new MatroskaTagMultiTitleItem();
			newTagItem->Type = KaxTagMultiTitleType_AlbumMovieShowTitle;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiTitleItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_BPM) {
			target->Tag_BPM = intField->Get();

		} else if (myFrame->GetID() == ID3FID_COMPOSER) {
			MatroskaTagMultiEntityItem *newTagItem = new MatroskaTagMultiEntityItem();
			newTagItem->Type = KaxTagMultiEntitiesType_Composer;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiEntityItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_PLAYLISTDELAY) {	
			target->Tag_PlaylistDelay = intField->Get();

		} else if (myFrame->GetID() == ID3FID_ENCODEDBY) {	
			MatroskaTagMultiEntityItem *newTagItem = new MatroskaTagMultiEntityItem();
			newTagItem->Type = KaxTagMultiEntitiesType_EncodedBy;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiEntityItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_LYRICIST) {	
			MatroskaTagMultiEntityItem *newTagItem = new MatroskaTagMultiEntityItem();
			newTagItem->Type = KaxTagMultiEntitiesType_LyricistTextWriter;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiEntityItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_TITLE) {
			MatroskaTagMultiTitleItem *newTagItem = new MatroskaTagMultiTitleItem();
			newTagItem->Type = KaxTagMultiTitleType_TrackTitle;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiTitleItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_SUBTITLE) {
			MatroskaTagMultiTitleItem *newTagItem = new MatroskaTagMultiTitleItem();
			newTagItem->Type = KaxTagMultiTitleType_TrackTitle;
			newTagItem->SubTitle = textField->GetRawUnicodeText();
			target->AddMultiTitleItem(newTagItem);

		} 
		
  }
  delete iter;

#endif
};
Пример #17
0
MP3Data * MP3DataGenerator::readMetadata( const char * p_filePath)
{
	// Set up file connection.
	myID3_Tag = new ID3_Tag();
	myID3_Tag->Link( p_filePath);

	// Storage with default initialization.
	MP3Data * myMP3Data = new MP3Data();
	myMP3Data->setAll( "<undefinded>");

	// Retrieve metadata.
	ID3_Tag::Iterator * tagIter = myID3_Tag->CreateIterator();
	ID3_Frame * myFrame = NULL;
	while( NULL != ( myFrame = tagIter->GetNext()))
	{			
		if( NULL != myFrame)
		{			
			ID3_Field * myField = myFrame->GetField( ID3FN_TEXT);
			// Check if current frame is part of the set aka a field of interest.
			std::set<ID3_FrameID>::iterator current = interestingID3_FrameIDs->find( myFrame->GetID());
			if ( NULL != myField && current != interestingID3_FrameIDs->end())
			{
				ID3_FrameID_LUT * myLUT = new ID3_FrameID_LUT();
				std::string frameRealname = std::string( myLUT->getRealname( myFrame->GetID()));
				// @TODO Show encoding in gui (optional)
				if( myField->GetEncoding() == ID3TE_ASCII || ID3TE_ISO8859_1)
				{
					encoding += frameRealname + ": ISO8859_1 , ";
					// Genre needs to be converted.
					if( myFrame->GetID() == ID3FID_CONTENTTYPE) // ID3_FrameID = 32
					{
						const char * genre = myField->GetRawText();
						// ID3V1 genre has is an int surrounded by round brackets; ID3V2 genre is text.
						unsigned int genreIntegerAlias = removeBrackets( genre);
						if( genreIntegerAlias < ID3_NR_OF_V1_GENRES && genre[0] == '(')
							myMP3Data->setGenre( ID3_v1_genre_description[ genreIntegerAlias]);
						else 
							myMP3Data->setGenre( genre);
					}
					// All other tags.
					else if( myFrame->GetID() == ID3FID_TITLE)
						myMP3Data->setTitle( myField->GetRawText());
					else if( myFrame->GetID() == ID3FID_ALBUM)
						myMP3Data->setAlbum( myField->GetRawText());
					else if( myFrame->GetID() == ID3FID_YEAR)
						myMP3Data->setYear( myField->GetRawText());
					else if( myFrame->GetID() == ID3FID_TRACKNUM)
						myMP3Data->setTracknumber( myField->GetRawText());
					else if( myFrame->GetID() == ID3FID_LEADARTIST)
						myMP3Data->setArtist( myField->GetRawText());
				}
				else if( myField->GetEncoding() == ID3TE_UTF8)
				{
					encoding += frameRealname + ": utf8 , ";
					myMP3Data->setAll( "<unicode utf8 encoding>");
				}
				else if( myField->GetEncoding() == ID3TE_UNICODE || ID3TE_UTF16)
				{
					encoding += frameRealname + ": utf16 ,";
					// @TODO Conversion to std::string ... myField->GetRawUnicodeText();
					myMP3Data->setAll( "<unicode utf16 encoding>");
				}
				else if( myField->GetEncoding() == ID3TE_UTF16BE)
				{
					encoding += frameRealname + ": utf16be , ";
					myMP3Data->setAll( "<unicode utf16be encoding>");
				}
				else if( myField->GetEncoding() == ID3TE_NUMENCODINGS)
				{
					encoding += frameRealname + ": numencodings , ";
					myMP3Data->setAll( "<numencoding>");
				}
				else
				{
					encoding += frameRealname + ": unknown , ";
					myMP3Data->setAll( "<<unknown encoding>");
				}
			}
		}
	}
	// Retrieve file path and file name.
	myMP3Data->setFilepath( p_filePath);
	myMP3Data->setFilename( getFilename( p_filePath).c_str());
	return myMP3Data;
}
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;
}
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;
}
Пример #20
0
void play_debug_meta(char* filename){
  ID3_Tag tag(filename);

  ID3_Tag::Iterator* iter = tag.CreateIterator();
  ID3_Frame* frame = NULL;
  char buf[1000];

  // Iconv conversion descriptor: UTF-16 -> UTF-8
  iconv_t cd = iconv_open("UTF8","UTF16BE");

  while (NULL != (frame = iter->GetNext()))
  {
    char* val = NULL;
    field_text(&val, frame); 
    printf("Frame: type %d %s %s:\n", frame->GetID(), frame->GetTextID(), frame->GetDescription());
    ID3_Frame::Iterator* fieldIter = frame->CreateIterator();
    ID3_Field* field = NULL;

    while (NULL != (field = fieldIter->GetNext())) {
      printf("  Field: type ");
      ID3_FieldType type = field->GetType();
      switch(type) {
      case ID3FTY_NONE:
        printf("none"); break;
      case ID3FTY_INTEGER:
        printf("int"); break;
      case ID3FTY_BINARY:
        printf("binary"); break;
      case ID3FTY_TEXTSTRING:
        field->Get(buf, 1000);
        printf("text with %d items, encoding ", field->GetNumTextItems());
        switch(field->GetEncoding()){
        case ID3TE_UTF16: printf("UTF-16"); 

          if ( cd != (iconv_t) -1 ) {
            char* in = (char*) field->GetRawUnicodeText();
            size_t insize = field->Size();

            char* bufptr = buf;
            size_t bufsize = 1000;
            size_t rc = 0;

            // Initialize iconv state
            if( iconv(cd, NULL, NULL, &bufptr, &bufsize) == (size_t) -1 ){
              printf("iconv init Failed\n");
            }
            if ( (rc = iconv(cd, &in, &insize, &bufptr, &bufsize)) != (size_t) -1 ) {
              *bufptr = '\0';
              printf(": '%s' (%d chars)\n", buf, rc);
            } else {
              printf("<conversion using iconv failed>");
              perror("iconv");
            }
          }
          break;
        case ID3TE_UTF16BE: printf("UTF-16BE"); 
          printf(": '%s'", buf);
          break;
        case ID3TE_UTF8: printf("UTF-8");
          printf(": '%s'", buf);
          break;
        case ID3TE_NONE: printf("none");
          printf(": '%s'", buf);
          break;
        case ID3TE_ISO8859_1: printf("ISO-8859-1/ASCII");
          printf(": '%s'", buf);
          break;
        }
        break;
      }
      printf("\n");
    }
    delete fieldIter;
    delete [] val;
  }
  delete iter;

  iconv_close(cd);
}