123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- #include <string.h>
- #include <memory.h>
- #include "id3_tag.h"
- #include "id3_misc_support.h"
- luint ID3_Frame::Render (uchar *buffer)
- {
- luint bytesUsed = 0;
- ID3_FrameHeader header;
- ID3_FrameDef *info;
- luint flags;
- luint extras = 0;
- header.SetVersion (version, revision);
- bytesUsed += header.Size();
-
-
- if (strlen (encryptionID))
- {
- buffer[bytesUsed] = encryptionID[0];
- bytesUsed++, extras++;
- }
- if (strlen (groupingID))
- {
- buffer[bytesUsed] = groupingID[0];
- bytesUsed++, extras++;
- }
-
-
-
-
- UpdateStringTypes();
- for (luint i = 0; i < numFields; i++)
- {
- fields[i]->SetVersion (version, revision);
- bytesUsed += fields[i]->Render (&buffer[bytesUsed]);
- }
-
-
-
-
-
-
- if (info = ID3_FindFrameDef (frameID))
- {
- bool didCompress = false;
- flags = 0;
- if (version == 4)
- {
- if (info->tagDiscard)
- flags |= ID3FL_TAGALTER_2_4;
- if (info->fileDiscard)
- flags |= ID3FL_FILEALTER_2_4;
- if (didCompress)
- flags |= ID3FL_COMPRESSION_2_4;
- if (strlen (encryptionID))
- flags |= ID3FL_ENCRYPTION_2_4;
- if (strlen (groupingID))
- flags |= ID3FL_GROUPING_2_4;
- }
- else
- {
- if (info->tagDiscard)
- flags |= ID3FL_TAGALTER_2_3;
- if (info->fileDiscard)
- flags |= ID3FL_FILEALTER_2_3;
- if (didCompress)
- flags |= ID3FL_COMPRESSION_2_3;
- if (strlen (encryptionID))
- flags |= ID3FL_ENCRYPTION_2_3;
- if (strlen (groupingID))
- flags |= ID3FL_GROUPING_2_3;
- }
- }
- else
- ID3_THROW (ID3E_InvalidFrameID);
- header.SetFrameID(frameID);
- header.SetFlags(flags);
- header.SetDataSize(bytesUsed - header.Size());
- header.Render(buffer);
- hasChanged = false;
- return bytesUsed;
- }
|