/
JvID3v2Base.pas
8975 lines (7728 loc) · 243 KB
/
JvID3v2Base.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvID3v2Base.PAS, released on 2003-04-16.
The Initial Developer of the Original Code is Remko Bonte [remkobonte att myrealbox dott com]
Portions created by Remko Bonte are Copyright (C) 2003 Remko Bonte.
All Rights Reserved.
Contributor(s):
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.delphi-jedi.org
Known Issues:
* Encryption, compression not supported
* Footer in v2.4 tags not supported
* Some tags are not supported, see var DefaultFrameClasses. Values nil in that
list indicate not supported frames.
-----------------------------------------------------------------------------}
// $Id$
unit JvID3v2Base;
{$I jvcl.inc}
interface
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
{$IFDEF MSWINDOWS}
Windows,
{$ENDIF MSWINDOWS}
{$IFDEF HAS_UNIT_TYPES}
Types,
{$ENDIF HAS_UNIT_TYPES}
SysUtils, Classes,
JclUnicode,
JvComponentBase, JvId3v2Types, JvId3v1;
const
{ Only v2.2, v2.3 and v2.4 are supported }
CSupportedVersions = [ive2_2, ive2_3, ive2_4];
type
EJvID3Error = class(Exception);
TJvID3ActivateChangeEvent = procedure(Sender: TObject; Activated: Boolean) of object;
TJvID3HandleError = (heAutoCorrect, heRaise, heBoolean);
TJvMPEGLayer = (mlNotDefined, mlLayerIII, mlLayerII, mlLayerI);
TJvMPEGVersion = (mvVersion25, mvReserved, mvVersion2, mvVersion1);
TJvMPEGChannelMode = (mcStereo, mcJointStereo, mcDualChannel, mcSingleChannel);
TJvMPEGBit = (mbProtection, mbPrivate, mbCopyrighted, mbOriginal);
TJvMPEGBits = set of TJvMPEGBit;
TJvMPEGEmphasis = (meNone, me5015ms, meReserved, meCCITJ17);
TJvMPEGModeExtension = (meModeExt0, meModeExt1, meModeExt2, meModeExt3);
TJvID3ControllerOption = (coAutoCorrect, coRemoveEmptyFrames);
TJvID3ControllerOptions = set of TJvID3ControllerOption;
TJvID3Event = (
{ Fired when the content of 1 or more frames in a tag changes }
ideFrameChange,
{ Fired when the whole tag has changed, because of reading/writing }
ideID3Change,
{ Fired when frames are added, deleted etc. }
ideFrameListChange);
TJvID3Controller = class;
TJvID3Stream = class(TMemoryStream)
private
FReadingFrame: Boolean;
FWritingFrame: Boolean;
FSourceEncoding: TJvID3Encoding;
FDestEncoding: TJvID3Encoding;
FAllowedEncodings: TJvID3Encodings;
FStartPosition: Integer;
FCurrentFrameSize: Integer;
procedure MoveToNextFrame;
function GetBytesTillEndOfTag: Longint;
function GetBytesTillEndOfFrame: Longint;
procedure UpdateDestEncoding;
procedure SetSourceEncoding(const Value: TJvID3Encoding);
protected
{ ISO-8859-1 }
function ReadStringA(var SA: AnsiString): Longint;
function ReadUserStringA(var SA1, SA2: AnsiString): Longint;
function WriteStringA(const SA: AnsiString): Longint;
function WriteUserStringA(const SA1, SA2: AnsiString): Longint;
function WriteTerminatorA: Longint;
{ UTF-16 & UTF-16BE }
function ReadStringW(var SW: WideString): Longint;
function ReadUserStringW(var SW1, SW2: WideString): Longint;
function WriteStringW(const SW: WideString): Longint;
function WriteUserStringW(const SW1, SW2: WideString): Longint;
function WriteTerminatorW: Longint;
{ UTF-8 }
function ReadStringUTF8(var SW: WideString): Longint;
function ReadUserStringUTF8(var SW1, SW2: WideString): Longint;
function WriteStringUTF8(const SW: WideString): Longint;
function WriteUserStringUTF8(const SW1, SW2: WideString): Longint;
public
procedure BeginReadFrame(const AFrameSize: Integer);
procedure BeginWriteFrame(const AFrameSize: Integer);
procedure EndReadFrame;
procedure EndWriteFrame;
{ Inits FAllowedEncodings depending on the wanted version and encoding }
procedure InitAllowedEncodings(const AVersion: TJvID3Version;
const AEncoding: TJvID3ForceEncoding);
{ Checks whether ACount bytes can be read }
function CanRead(const ACount: Cardinal): Boolean;
{ Checks whether we are still in the frame }
function InFrame(P: Pointer): Boolean;
{ Read }
function ReadDate(var ADate: TDateTime): Longint;
function ReadLanguage(var Language: AnsiString): Longint;
function ReadNumber(var AValue: Cardinal): Longint;
function ReadEnc(var AEncoding: TJvID3Encoding): Longint;
function ReadStringEnc(var S: WideString): Longint;
function ReadUserString(var S1, S2: WideString): Longint;
{ Only for v2.2 }
function ReadFixedNumber3(var AValue: Cardinal): Longint;
{ Only for v2.3 }
function ReadFixedNumber(var AValue: Cardinal): Longint;
{ Only for v2.4 }
function ReadSyncSafeInteger(var AInt: Cardinal): Longint; overload;
function ReadSyncSafeInteger(var AInt: Cardinal; const ASize: Byte): Longint; overload;
function ReadSyncSafeInteger(var AInt: Int64; const ASize: Byte = 4): Longint; overload;
procedure ReadFromStream(AStream: TStream; const ASize: Integer);
{ Write }
function WriteDate(const ADate: TDateTime): Longint;
function WriteLanguage(const Language: AnsiString): Longint;
function WriteNumber(AValue: Cardinal): Longint;
function WriteEnc: Longint;
function WritePadding(const Count: Longint): Longint;
function WriteStringEnc(const S: WideString): Longint;
function WriteUserString(const S1, S2: WideString): Longint;
function WriteTerminatorEnc: Longint;
{ Only for v2.2 }
function WriteFixedNumber3(AValue: Cardinal): Longint;
{ Only for v2.3 }
function WriteFixedNumber(AValue: Cardinal): Longint;
{ Only for v2.4 }
function WriteSyncSafeInteger(const AInt: Int64; const ASize: Byte = 4): Longint; overload;
function WriteSyncSafeInteger(const AInt: Cardinal; const ASize: Byte): Longint; overload;
function WriteSyncSafeInteger(const AInt: Cardinal): Longint; overload;
property BytesTillEndOfFrame: Longint read GetBytesTillEndOfFrame;
property BytesTillEndOfTag: Longint read GetBytesTillEndOfTag;
{ SourceEncoding =
- When reading: encoding of the ID3 stream
- When writing: encoding of current frame in the TJvID3Controller }
property SourceEncoding: TJvID3Encoding read FSourceEncoding write SetSourceEncoding;
{ DestEncoding =
- When reading: encoding of current frame in the TJvID3Controller
- When writing: encoding of the ID3 stream }
property DestEncoding: TJvID3Encoding read FDestEncoding;
property AllowedEncodings: TJvID3Encodings read FAllowedEncodings;
end;
TJvID3Frame = class;
TJvID3Frames = class;
TJvID3FrameClass = class of TJvID3Frame;
{ Base component for TJvID3Header & TJvID3ExtendedHeader }
TJvID3Base = class(TPersistent)
private
FController: TJvID3Controller;
function GetStream: TJvID3Stream;
protected
procedure Read; virtual; abstract;
procedure Write; virtual; abstract;
procedure Reset; virtual; abstract;
property Stream: TJvID3Stream read GetStream;
public
constructor Create(AController: TJvID3Controller); virtual;
procedure AfterConstruction; override;
procedure ChangeToVersion(const ANewVersion: TJvID3Version); virtual; abstract;
procedure Assign(Source: TPersistent); override;
property Controller: TJvID3Controller read FController;
end;
TJvID3Header = class(TJvID3Base)
private
FFlags: TJvID3HeaderFlags;
FHasTag: Boolean;
FMajorVersion: Byte;
FRevisionNumber: Byte;
FSize: Cardinal;
procedure SetFlags(const Value: TJvID3HeaderFlags);
protected
procedure Read; override;
procedure Write; override;
procedure Reset; override;
public
procedure Assign(Source: TPersistent); override;
procedure ChangeToVersion(const ANewVersion: TJvID3Version); override;
published
property MajorVersion: Byte read FMajorVersion;
property RevisionNumber: Byte read FRevisionNumber;
property HasTag: Boolean read FHasTag;
property Flags: TJvID3HeaderFlags read FFlags write SetFlags;
property Size: Cardinal read FSize;
end;
TJvID3ExtendedHeader = class(TJvID3Base)
private
FFlags: TJvID3HeaderExtendedFlags;
FRestrictions: TJvID3Restrictions;
FSizeOfPadding: Cardinal;
FTotalFrameCRC: Cardinal;
function GetSize: Cardinal;
function GetSizeForVersion(const AVersion: TJvID3Version): Cardinal;
procedure SetFlags(const Value: TJvID3HeaderExtendedFlags);
protected
procedure Read; override;
procedure Write; override;
procedure Reset; override;
public
procedure Assign(Source: TPersistent); override;
procedure ChangeToVersion(const ANewVersion: TJvID3Version); override;
property Size: Cardinal read GetSize;
published
property TotalFrameCRC: Cardinal read FTotalFrameCRC write FTotalFrameCRC;
property SizeOfPadding: Cardinal read FSizeOfPadding;
property Flags: TJvID3HeaderExtendedFlags read FFlags write SetFlags;
end;
{ Base class for all frames }
{ TODO : Change to TPersistent? }
TJvID3Frame = class(TComponent)
private
FController: TJvID3Controller;
FFrames: TJvID3Frames;
FFrameID: TJvID3FrameID;
FFrameIDStr: AnsiString;
FFrameSize: Cardinal;
FDataLengthIndicator: Cardinal; { v2.4 }
FDecompressedSize: Cardinal;
FEncoding: TJvID3Encoding;
FEncryptionID: Byte;
FFlags: TJvID3FrameHeaderFlags;
FGroupID: Byte;
function GetFrameName: AnsiString;
function GetFrameIDStrForVersion(const Version: TJvID3Version): AnsiString;
function GetIndex: Integer;
function GetStream: TJvID3Stream;
procedure SetController(const AController: TJvID3Controller);
procedure SetEncoding(const Value: TJvID3Encoding);
procedure SetFlags(const Value: TJvID3FrameHeaderFlags);
procedure SetFrameID(const Value: TJvID3FrameID);
procedure SetFrameName(NewFrameName: AnsiString);
procedure SetIndex(const Value: Integer);
protected
procedure Read;
procedure Write;
procedure ReadEncoding;
procedure ReadFrame; virtual; abstract;
procedure ReadFrameHeader;
procedure WriteEncoding;
procedure WriteFrame; virtual; abstract;
procedure WriteFrameHeader(const AFrameSize: Cardinal);
procedure WriteID;
procedure ChangeToVersion(const ANewVersion: TJvID3Version); virtual;
function SupportsVersion(const AVersion: TJvID3Version): Boolean; virtual;
{ Checks whether this frame is empty, thus can be removed }
function GetIsEmpty: Boolean; virtual;
{ Checks whether there are no other frames with the same unique
identifier as this frame }
function CheckIsUnique: Boolean;
procedure CheckFrameID(const AFrameID: TJvID3FrameID);
procedure CheckFrameIDStr(const S: AnsiString);
{ Checks whether Frame has the same unique identifier as this frame }
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; virtual;
function MustWriteAsUTF: Boolean; virtual;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; virtual; abstract;
procedure UpdateFrameSize;
procedure DataChanged;
procedure Changed; virtual;
procedure Error(const Msg: string);
procedure ErrorFmt(const Msg: string; const Args: array of const);
property Stream: TJvID3Stream read GetStream;
public
constructor Create(AOwner: TComponent; const AFrameID: TJvID3FrameID;
const AFrameIDStr: AnsiString = ''); reintroduce; virtual;
destructor Destroy; override;
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; virtual;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; virtual;
procedure Assign(Source: TPersistent); override;
procedure Clear; virtual;
property Controller: TJvID3Controller read FController write SetController stored False;
property FrameSize: Cardinal read FFrameSize;
property IsEmpty: Boolean read GetIsEmpty;
published
property Encoding: TJvID3Encoding read FEncoding write SetEncoding;
property EncryptionID: Byte read FEncryptionID write FEncryptionID;
property Flags: TJvID3FrameHeaderFlags read FFlags write SetFlags;
property FrameID: TJvID3FrameID read FFrameID write SetFrameID;
property FrameName: AnsiString read GetFrameName write SetFrameName;
property GroupID: Byte read FGroupID write FGroupID;
property Index: Integer read GetIndex write SetIndex stored False;
end;
TJvID3Frames = class(TJvID3Base)
private
FList: TList;
protected
procedure Changed;
procedure CheckCanAddFrame(FrameID: TJvID3FrameID);
procedure Read; override;
procedure Write; override;
procedure Reset; override;
function GetCount: Integer;
function GetFrame(Index: Integer): TJvID3Frame;
procedure SetFrame(Index: Integer; Value: TJvID3Frame);
procedure SetFrameIndex(Frame: TJvID3Frame; Value: Integer);
public
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
procedure Assign(Source: TPersistent); override;
procedure Add(Frame: TJvID3Frame);
procedure Clear;
function FindFrame(const FrameName: AnsiString): TJvID3Frame; overload;
function FindFrame(const FrameID: TJvID3FrameID): TJvID3Frame; overload;
function FrameByName(const FrameName: AnsiString): TJvID3Frame;
function FrameByID(const FrameID: TJvID3FrameID): TJvID3Frame;
procedure GetFrameNames(List: TStrings);
function GetFrameIDs: TJvID3FrameIDs;
procedure ChangeToVersion(const ANewVersion: TJvID3Version); override;
function IndexOf(Frame: TJvID3Frame): Integer;
function CheckIsUnique(Frame: TJvID3Frame): Boolean;
function CheckFrames(const HandleError: TJvID3HandleError): Boolean;
procedure RemoveEmptyFrames;
procedure Remove(Frame: TJvID3Frame);
property Count: Integer read GetCount;
property Frames[Index: Integer]: TJvID3Frame read GetFrame write SetFrame; default;
end;
{ MCDI - fiCDID - Music CD identifier
There may only be one 'MCDI' frame in each tag.
}
TJvID3BinaryFrame = class(TJvID3Frame)
private
FData: PByte;
FDataSize: Cardinal;
protected
procedure ReadData(ASize: Cardinal); virtual;
procedure WriteData; virtual;
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3BinaryFrame;
class function FindOrCreate(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3BinaryFrame;
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
function SetData(P: Pointer; const Size: Cardinal): Boolean;
function GetData(P: Pointer; const Size: Cardinal): Boolean;
procedure LoadFromFile(const FileName: string); virtual;
procedure SaveToFile(const FileName: string); virtual;
procedure LoadFromStream(Stream: TStream); virtual;
procedure SaveToStream(Stream: TStream); virtual;
property DataSize: Cardinal read FDataSize;
end;
TJvID3SkipFrame = class(TJvID3BinaryFrame)
protected
procedure ChangeToVersion(const ANewVersion: TJvID3Version); override;
end;
{ IPLS - fiInvolvedPeople - Involved people list
There may only be one "IPLS" frame in each tag.
TIPL - fiInvolvedPeople2 - Involved people list
TMCL - fiMusicianCreditList - Musician credits list
There may only be one text information frame of its kind in an tag
}
TJvID3DoubleListFrame = class(TJvID3Frame)
private
FList: {$IFDEF COMPILER12_UP}TStrings{$ELSE}TWideStrings{$ENDIF COMPILER12_UP};
procedure ListChanged(Sender: TObject);
procedure SetList(Value: {$IFDEF COMPILER12_UP}TStrings{$ELSE}TWideStrings{$ENDIF COMPILER12_UP});
function GetNames(const Index: Integer): WideString;
function GetValues(const Index: Integer): WideString;
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function MustWriteAsUTF: Boolean; override;
procedure ChangeToVersion(const ANewVersion: TJvID3Version); override;
function SupportsVersion(const AVersion: TJvID3Version): Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3DoubleListFrame;
class function FindOrCreate(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3DoubleListFrame;
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
property Names[const Index: Integer]: WideString read GetNames;
property Values[const Index: Integer]: WideString read GetValues;
published
property List: {$IFDEF COMPILER12_UP}TStrings{$ELSE}TWideStrings{$ENDIF COMPILER12_UP} read FList write SetList;
end;
{ COMM - fiComment - Comments
There may be more than one comment frame in each tag, but only one with
the same language and content descriptor.
USLT - fiUnsyncedLyrics - Unsynchronized lyric/text transcription
There may be more than one 'Unsynchronized lyrics/text transcription' frame
in each tag, but only one with the same language and content descriptor.
}
TJvID3ContentFrame = class(TJvID3Frame)
private
FLanguage: AnsiString;
FText: WideString;
FDescription: WideString;
procedure SetDescription(const Value: WideString);
procedure SetLanguage(const Value: AnsiString);
procedure SetText(const Value: WideString);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function MustWriteAsUTF: Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3ContentFrame;
class function FindOrCreate(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3ContentFrame;
published
property Language: AnsiString read FLanguage write SetLanguage;
property Description: WideString read FDescription write SetDescription;
property Text: WideString read FText write SetText;
end;
{ GEOB - fiGeneralObject - General encapsulated object
There may be more than one "GEOB" frame in each tag, but only one with the
same content descriptor
}
TJvID3GeneralObjFrame = class(TJvID3BinaryFrame)
private
FContentDescription: WideString;
FMIMEType: AnsiString;
FFileName: WideString;
procedure SetContentDescription(const Value: WideString);
procedure SetFileName(const Value: WideString);
procedure SetMIMEType(const Value: AnsiString);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function MustWriteAsUTF: Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller): TJvID3GeneralObjFrame; overload;
class function Find(AController: TJvID3Controller; const AContentDescription: WideString): TJvID3GeneralObjFrame; overload;
class function FindOrCreate(AController: TJvID3Controller): TJvID3GeneralObjFrame; overload;
class function FindOrCreate(AController: TJvID3Controller; const AContentDescription: WideString): TJvID3GeneralObjFrame; overload;
published
property MIMEType: AnsiString read FMIMEType write SetMIMEType;
property FileName: WideString read FFileName write SetFileName;
property ContentDescription: WideString read FContentDescription write SetContentDescription;
end;
{ POPM - fiPopularimeter - Popularimeter
There may be more than one "POPM" frame in each tag, but only one with the
same email address.
}
TJvID3PopularimeterFrame = class(TJvID3Frame)
private
FRating: Byte;
FCounter: Cardinal;
FEMailAddress: AnsiString;
procedure SetCounter(const Value: Cardinal);
procedure SetEMailAddress(const Value: AnsiString);
procedure SetRating(const Value: Byte);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller): TJvID3PopularimeterFrame; overload;
class function Find(AController: TJvID3Controller; const AEmailAddress: AnsiString): TJvID3PopularimeterFrame; overload;
class function FindOrCreate(AController: TJvID3Controller): TJvID3PopularimeterFrame; overload;
class function FindOrCreate(AController: TJvID3Controller; const AEmailAddress: AnsiString): TJvID3PopularimeterFrame; overload;
published
property EMailAddress: AnsiString read FEMailAddress write SetEMailAddress;
property Rating: Byte read FRating write SetRating;
property Counter: Cardinal read FCounter write SetCounter;
end;
{ PCNT - fiPlayCounter - Play counter
There may only be one "PCNT" frame in each tag.
}
TJvID3PlayCounterFrame = class(TJvID3Frame)
private
FCounter: Cardinal;
procedure SetCounter(const Value: Cardinal);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller): TJvID3PlayCounterFrame;
class function FindOrCreate(AController: TJvID3Controller): TJvID3PlayCounterFrame;
published
property Counter: Cardinal read FCounter write SetCounter;
end;
{ AENC - fiAudioCrypto - Audio encryption
There may be more than one "AENC" frames in a tag, but only one with
the same 'Owner identifier'.
}
TJvID3AudioEncryptionFrame = class(TJvID3BinaryFrame)
private
FOwnerID: AnsiString;
FPreviewStart: Word;
FPreviewLength: Word;
procedure SetOwnerID(const Value: AnsiString);
procedure SetPreviewLength(const Value: Word);
procedure SetPreviewStart(const Value: Word);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller; const AOwnerID: AnsiString): TJvID3AudioEncryptionFrame;
class function FindOrCreate(AController: TJvID3Controller; const AOwnerID: AnsiString): TJvID3AudioEncryptionFrame;
published
property OwnerID: AnsiString read FOwnerID write SetOwnerID;
property PreviewStart: Word read FPreviewStart write SetPreviewStart;
property PreviewLength: Word read FPreviewLength write SetPreviewLength;
end;
{ USER - fiTermsOfUse - Terms of use
There may only be one "USER" frame in a tag.
}
TJvID3TermsOfUseFrame = class(TJvID3Frame)
private
FText: WideString;
FLanguage: AnsiString;
procedure SetLanguage(const Value: AnsiString);
procedure SetText(const Value: WideString);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function MustWriteAsUTF: Boolean; override;
function SupportsVersion(const AVersion: TJvID3Version): Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller): TJvID3TermsOfUseFrame;
class function FindOrCreate(AController: TJvID3Controller): TJvID3TermsOfUseFrame;
published
property Language: AnsiString read FLanguage write SetLanguage;
property Text: WideString read FText write SetText;
end;
{ OWNE - fiOwnership - Ownership frame
There may only be one "OWNE" frame in a tag.
}
TJvID3OwnershipFrame = class(TJvID3Frame)
private
FPricePayed: AnsiString;
FSeller: WideString;
FDateOfPurch: TDateTime;
procedure SetDateOfPurch(const Value: TDateTime);
procedure SetPricePayed(const Value: AnsiString);
procedure SetSeller(const Value: WideString);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function MustWriteAsUTF: Boolean; override;
function SupportsVersion(const AVersion: TJvID3Version): Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller): TJvID3OwnershipFrame;
class function FindOrCreate(AController: TJvID3Controller): TJvID3OwnershipFrame;
published
property PricePayed: AnsiString read FPricePayed write SetPricePayed;
property DateOfPurch: TDateTime read FDateOfPurch write SetDateOfPurch;
property Seller: WideString read FSeller write SetSeller;
end;
{ APIC - fiPicture - Attached picture
There may be several pictures attached to one file, each in their individual
"APIC" frame, but only one with the same content descriptor(*). There may only
be one picture with the picture type declared as picture type $01 and $02 (**)
respectively.
(*) content descriptor = FPictureType, FDescription
(**) $01 = ptFileIcon; $02 = ptOtherFileIcon
}
TJvID3PictureFrame = class(TJvID3BinaryFrame)
private
FMIMEType: AnsiString;
FPictureType: TJvID3PictureType;
FDescription: WideString;
FURL: AnsiString;
procedure SetDescription(const Value: WideString);
procedure SetMIMEType(const Value: AnsiString);
procedure SetURL(const Value: AnsiString);
function GetHasOnlyURL: Boolean;
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function MustWriteAsUTF: Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
procedure AssignTo(Dest: TPersistent); override;
{ There is the possibility to put only a link to the image file by using the 'MIME
type' "-->" and having a complete URL [URL] instead of picture data.
The use of linked files should however be used sparingly since there
is the risk of separation of files: }
property HasOnlyURL: Boolean read GetHasOnlyURL;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller; const AType: TJvID3PictureType): TJvID3PictureFrame;
class function FindOrCreate(AController: TJvID3Controller; const AType: TJvID3PictureType): TJvID3PictureFrame;
published
property MIMEType: AnsiString read FMIMEType write SetMIMEType;
property PictureType: TJvID3PictureType read FPictureType write FPictureType;
property Description: WideString read FDescription write SetDescription;
{ Only used when MIMEType = '-->' }
property URL: AnsiString read FURL write SetURL;
end;
TJvID3CustomTextFrame = class(TJvID3Frame)
protected
function GetText: WideString; virtual; abstract;
procedure SetText(const ANewText: WideString); virtual; abstract;
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function MustWriteAsUTF: Boolean; override;
function SupportsVersion(const AVersion: TJvID3Version): Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
property Text: WideString read GetText write SetText;
end;
TJvID3SimpleListFrame = class(TJvID3CustomTextFrame)
private
FList: {$IFDEF COMPILER12_UP}TStrings{$ELSE}TWideStrings{$ENDIF COMPILER12_UP};
procedure SetList(Value: {$IFDEF COMPILER12_UP}TStrings{$ELSE}TWideStrings{$ENDIF COMPILER12_UP});
function GetSeparator: WideChar;
function GetFixedStringLength: Integer;
procedure ListChanged(Sender: TObject);
function GetIsNullSeparator: Boolean;
protected
function GetText: WideString; override;
procedure SetText(const ANewText: WideString); override;
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
public
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
class function Find(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3SimpleListFrame;
class function FindOrCreate(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3SimpleListFrame;
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
property FixedStringLength: Integer read GetFixedStringLength;
property Separator: WideChar read GetSeparator;
property IsNullSeparator: Boolean read GetIsNullSeparator;
published
property List: {$IFDEF COMPILER12_UP}TStrings{$ELSE}TWideStrings{$ENDIF COMPILER12_UP} read FList write SetList;
end;
TJvID3NumberFrame = class(TJvID3CustomTextFrame)
private
FValue: Cardinal;
procedure SetValue(const AValue: Cardinal);
protected
function GetText: WideString; override;
procedure SetText(const ANewText: WideString); override;
procedure ChangeToVersion(const ANewVersion: TJvID3Version); override;
function GetIsEmpty: Boolean; override;
public
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
class function Find(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3NumberFrame;
class function FindOrCreate(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3NumberFrame;
published
property Value: Cardinal read FValue write SetValue;
end;
TJvID3TimestampFrame = class(TJvID3CustomTextFrame)
private
FValue: TDateTime;
procedure SetValue(const AValue: TDateTime);
protected
function GetText: WideString; override;
procedure SetText(const ANewText: WideString); override;
procedure ChangeToVersion(const ANewVersion: TJvID3Version); override;
public
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
class function Find(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3TimestampFrame;
class function FindOrCreate(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3TimestampFrame;
published
property Value: TDateTime read FValue write SetValue;
end;
TJvID3TextFrame = class(TJvID3CustomTextFrame)
private
FText: WideString;
protected
function GetText: WideString; override;
procedure SetText(const ANewText: WideString); override;
procedure ChangeToVersion(const ANewVersion: TJvID3Version); override;
public
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
class function Find(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3TextFrame;
class function FindOrCreate(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3TextFrame;
published
property Text;
end;
TJvID3URLFrame = class(TJvID3Frame)
private
FURL: AnsiString;
procedure SetURL(const Value: AnsiString);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function SameUniqueIDAs(const Frame: TJvID3Frame): Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3URLFrame;
class function FindOrCreate(AController: TJvID3Controller; const AFrameID: TJvID3FrameID): TJvID3URLFrame;
published
property URL: AnsiString read FURL write SetURL;
end;
{ TXXX - fiUserText - User defined text information
}
TJvID3UserFrame = class(TJvID3Frame)
private
FValue: WideString;
FDescription: WideString;
procedure SetDescription(const AValue: WideString);
procedure SetValue(const AValue: WideString);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function MustWriteAsUTF: Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller; const Index: Integer): TJvID3UserFrame;
class function FindOrCreate(AController: TJvID3Controller; const Index: Integer): TJvID3UserFrame;
published
property Description: WideString read FDescription write SetDescription;
property Value: WideString read FValue write SetValue;
end;
{ WXXX - fiWWWUser - User defined URL link
}
TJvID3URLUserFrame = class(TJvID3Frame)
private
FDescription: WideString;
FURL: AnsiString;
procedure SetDescription(const Value: WideString);
procedure SetURL(const Value: AnsiString);
protected
procedure ReadFrame; override;
procedure WriteFrame; override;
function GetFrameSize(const ToEncoding: TJvID3Encoding): Cardinal; override;
function GetIsEmpty: Boolean; override;
function MustWriteAsUTF: Boolean; override;
public
class function CanAddFrame(AController: TJvID3Controller; AFrameID: TJvID3FrameID): Boolean; override;
function CheckFrame(const HandleError: TJvID3HandleError): Boolean; override;
procedure Assign(Source: TPersistent); override;
procedure Clear; override;
class function Find(AController: TJvID3Controller; const Index: Integer): TJvID3URLUserFrame;
class function FindOrCreate(AController: TJvID3Controller; const Index: Integer): TJvID3URLUserFrame;
published
property Description: WideString read FDescription write SetDescription;
property URL: AnsiString read FURL write SetURL;
end;
TJvID3FileInfo = class(TPersistent)
private
FAudioSize: Int64;
FBitrate: Integer;
FBits: TJvMPEGBits;
FChannelMode: TJvMPEGChannelMode;
FEmphasis: TJvMPEGEmphasis;
FFileSize: Int64;
FFrameCount: Integer;
FFrameLengthInBytes: Integer;
FHasID3v1Tag: Boolean;
FHeaderFoundAt: Int64;
FIsVBR: Boolean;
FLayer: TJvMPEGLayer;
FLengthInSec: Integer;
FModeExtension: TJvMPEGModeExtension;
FPaddingLength: Integer;