File: AppleDataBox.cs

package info (click to toggle)
banshee 0.11.2%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 11,976 kB
  • ctags: 9,958
  • sloc: cs: 54,529; xml: 21,240; sh: 8,835; ansic: 2,040; makefile: 1,248
file content (64 lines) | stat: -rw-r--r-- 2,207 bytes parent folder | download | duplicates (2)
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
namespace TagLib.Mpeg4
{
   public class AppleDataBox : FullBox
   {
      // This shows the type of data stored in the box.
      public enum FlagTypes
      {
          ContainsText      = 0x01,
          ContainsData      = 0x00,
          ForTempo          = 0x15,
          ContainsJpegData  = 0x0D,
          ContainsPngData   = 0x0E
      }
      
      
      //////////////////////////////////////////////////////////////////////////
      // public methods
      //////////////////////////////////////////////////////////////////////////
      public AppleDataBox (BoxHeader header, Box parent) : base (header, parent)
      {
         // Ensure that the data is loaded before the file is closed.
         LoadData ();
      }
      
      // Make a data box from the given data and flags.
      public AppleDataBox (ByteVector data, uint flags, Box parent) : base ("data", flags, parent)
      {
         Data = data;
      }
      
      // Make a data box from the given data and flags.
      public AppleDataBox (ByteVector data, uint flags) : this (data, flags, null)
      {
      }
      
      // Render the box. It starts with four reserved bytes.
      public override ByteVector Render ()
      {
         return Render (new ByteVector (4));
      }
      
      
      //////////////////////////////////////////////////////////////////////////
      // public methods
      //////////////////////////////////////////////////////////////////////////
      
      // If the flag type is ContainsText, then the data can be read as a UTF8
      // string. We can also store a UTF8 string as text if we set the flags to
      // show that.
      public string Text
      {
         get {return ((Flags & (int) FlagTypes.ContainsText) != 0) ? Data.ToString (StringType.UTF8) : null;}
         set
         {
            Flags = (int) FlagTypes.ContainsText;
            Data = ByteVector.FromString (value, StringType.UTF8);
         }
      }
      
      // Move the position and length to account for the reserved space.
      protected override long  DataPosition {get {return base.DataPosition + 4;}}
      protected override ulong DataSize     {get {return base.DataSize - 4;}}
   }
}