diff options
Diffstat (limited to 'songdbj/org/tritonus/lowlevel/ogg/Packet.java')
-rw-r--r-- | songdbj/org/tritonus/lowlevel/ogg/Packet.java | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/songdbj/org/tritonus/lowlevel/ogg/Packet.java b/songdbj/org/tritonus/lowlevel/ogg/Packet.java new file mode 100644 index 0000000000..a5b3f6e7e2 --- /dev/null +++ b/songdbj/org/tritonus/lowlevel/ogg/Packet.java | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * Packet.java | ||
3 | * | ||
4 | * This file is part of Tritonus: http://www.tritonus.org/ | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * Copyright (c) 2000 - 2001 by Matthias Pfisterer | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU Library General Public License as published | ||
12 | * by the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU Library General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU Library General Public | ||
21 | * License along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | /* | ||
26 | |<--- this code is formatted to fit into 80 columns --->| | ||
27 | */ | ||
28 | |||
29 | package org.tritonus.lowlevel.ogg; | ||
30 | |||
31 | import org.tritonus.share.TDebug; | ||
32 | |||
33 | |||
34 | |||
35 | /** Wrapper for ogg_packet. | ||
36 | */ | ||
37 | public class Packet | ||
38 | { | ||
39 | static | ||
40 | { | ||
41 | Ogg.loadNativeLibrary(); | ||
42 | if (TDebug.TraceOggNative) | ||
43 | { | ||
44 | setTrace(true); | ||
45 | } | ||
46 | } | ||
47 | |||
48 | |||
49 | /** | ||
50 | * Holds the pointer to ogg_packet | ||
51 | * for the native code. | ||
52 | * This must be long to be 64bit-clean. | ||
53 | */ | ||
54 | private long m_lNativeHandle; | ||
55 | |||
56 | |||
57 | |||
58 | public Packet() | ||
59 | { | ||
60 | if (TDebug.TraceOggNative) { TDebug.out("Packet.<init>(): begin"); } | ||
61 | int nReturn = malloc(); | ||
62 | if (nReturn < 0) | ||
63 | { | ||
64 | throw new RuntimeException("malloc of ogg_packet failed"); | ||
65 | } | ||
66 | if (TDebug.TraceOggNative) { TDebug.out("Packet.<init>(): end"); } | ||
67 | } | ||
68 | |||
69 | |||
70 | |||
71 | public void finalize() | ||
72 | { | ||
73 | // TODO: call free() | ||
74 | // call super.finalize() first or last? | ||
75 | // and introduce a flag if free() has already been called? | ||
76 | } | ||
77 | |||
78 | |||
79 | |||
80 | private native int malloc(); | ||
81 | public native void free(); | ||
82 | |||
83 | |||
84 | |||
85 | /** Calls ogg_packet_clear(). | ||
86 | */ | ||
87 | public native void clear(); | ||
88 | |||
89 | |||
90 | |||
91 | /** Accesses packet and bytes. | ||
92 | */ | ||
93 | public native byte[] getData(); | ||
94 | |||
95 | |||
96 | /** Accesses b_o_s. | ||
97 | */ | ||
98 | public native boolean isBos(); | ||
99 | |||
100 | |||
101 | /** Accesses e_o_s. | ||
102 | */ | ||
103 | public native boolean isEos(); | ||
104 | |||
105 | |||
106 | private static native void setTrace(boolean bTrace); | ||
107 | } | ||
108 | |||
109 | |||
110 | |||
111 | |||
112 | |||
113 | /*** Packet.java ***/ | ||