summaryrefslogtreecommitdiff
path: root/songdbj/org/tritonus/lowlevel/ogg
diff options
context:
space:
mode:
Diffstat (limited to 'songdbj/org/tritonus/lowlevel/ogg')
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/Buffer.java173
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/Ogg.java104
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/Packet.java113
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/Page.java131
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/StreamState.java143
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/SyncState.java127
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/package.html12
7 files changed, 803 insertions, 0 deletions
diff --git a/songdbj/org/tritonus/lowlevel/ogg/Buffer.java b/songdbj/org/tritonus/lowlevel/ogg/Buffer.java
new file mode 100644
index 0000000000..2903f0e17e
--- /dev/null
+++ b/songdbj/org/tritonus/lowlevel/ogg/Buffer.java
@@ -0,0 +1,173 @@
1/*
2 * Buffer.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
29package org.tritonus.lowlevel.ogg;
30
31import org.tritonus.share.TDebug;
32
33
34/** Wrapper for oggpack_buffer.
35 */
36public class Buffer
37{
38 static
39 {
40 Ogg.loadNativeLibrary();
41 if (TDebug.TraceOggNative)
42 {
43 setTrace(true);
44 }
45 }
46
47
48 /**
49 * Holds the pointer to oggpack_buffer
50 * for the native code.
51 * This must be long to be 64bit-clean.
52 */
53 private long m_lNativeHandle;
54
55
56
57 public Buffer()
58 {
59 if (TDebug.TraceOggNative) { TDebug.out("Buffer.<init>(): begin"); }
60 int nReturn = malloc();
61 if (nReturn < 0)
62 {
63 throw new RuntimeException("malloc of ogg_page failed");
64 }
65 if (TDebug.TraceOggNative) { TDebug.out("Buffer.<init>(): end"); }
66 }
67
68
69
70 public void finalize()
71 {
72 // TODO: call free()
73 // call super.finalize() first or last?
74 // and introduce a flag if free() has already been called?
75 }
76
77
78
79 private native int malloc();
80 public native void free();
81
82
83 /** Calls oggpack_writeinit().
84 */
85 public native void writeInit();
86
87
88 /** Calls oggpack_writetrunc().
89 */
90 public native void writeTrunc(int nBits);
91
92
93 /** Calls oggpack_writealign().
94 */
95 public native void writeAlign();
96
97
98 /** Calls oggpack_writecopy().
99 */
100 public native void writeCopy(byte[] abSource, int nBits);
101
102
103 /** Calls oggpack_reset().
104 */
105 public native void reset();
106
107
108 /** Calls oggpack_writeclear().
109 */
110 public native void writeClear();
111
112
113 /** Calls oggpack_readinit().
114 */
115 public native void readInit(byte[] abBuffer, int nBytes);
116
117
118 /** Calls oggpack_write().
119 */
120 public native void write(int nValue, int nBits);
121
122
123 /** Calls oggpack_look().
124 */
125 public native int look(int nBits);
126
127
128 /** Calls oggpack_look1().
129 */
130 public native int look1();
131
132
133 /** Calls oggpack_adv().
134 */
135 public native void adv(int nBits);
136
137
138 /** Calls oggpack_adv1().
139 */
140 public native void adv1();
141
142
143 /** Calls oggpack_read().
144 */
145 public native int read(int nBits);
146
147
148 /** Calls oggpack_read1().
149 */
150 public native int read1();
151
152
153 /** Calls oggpack_bytes().
154 */
155 public native int bytes();
156
157
158 /** Calls oggpack_bits().
159 */
160 public native int bits();
161
162
163 /** Calls oggpack_get_buffer().
164 */
165 public native byte[] getBuffer();
166
167
168 private static native void setTrace(boolean bTrace);
169}
170
171
172
173/*** Buffer.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/Ogg.java b/songdbj/org/tritonus/lowlevel/ogg/Ogg.java
new file mode 100644
index 0000000000..1ad6bde789
--- /dev/null
+++ b/songdbj/org/tritonus/lowlevel/ogg/Ogg.java
@@ -0,0 +1,104 @@
1/*
2 * Ogg.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 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Library General Public License as published
13 * by the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 */
26
27/*
28|<--- this code is formatted to fit into 80 columns --->|
29*/
30
31package org.tritonus.lowlevel.ogg;
32
33import org.tritonus.share.TDebug;
34
35
36/** libogg loading.
37 */
38public class Ogg
39{
40 private static boolean sm_bIsLibraryAvailable = false;
41
42
43
44 static
45 {
46 Ogg.loadNativeLibrary();
47 }
48
49
50
51 public static void loadNativeLibrary()
52 {
53 if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibrary(): begin"); }
54
55 if (! isLibraryAvailable())
56 {
57 loadNativeLibraryImpl();
58 }
59 if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibrary(): end"); }
60 }
61
62
63
64 /** Load the native library for ogg vorbis.
65
66 This method actually does the loading of the library. Unlike
67 {@link loadNativeLibrary() loadNativeLibrary()}, it does not
68 check if the library is already loaded.
69
70 */
71 private static void loadNativeLibraryImpl()
72 {
73 if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibraryImpl(): loading native library tritonusvorbis"); }
74 try
75 {
76 System.loadLibrary("tritonusvorbis");
77 // only reached if no exception occures
78 sm_bIsLibraryAvailable = true;
79 }
80 catch (Error e)
81 {
82 if (TDebug.TraceOggNative ||
83 TDebug.TraceAllExceptions)
84 {
85 TDebug.out(e);
86 }
87 // throw e;
88 }
89 if (TDebug.TraceOggNative) { TDebug.out("Ogg.loadNativeLibraryImpl(): loaded"); }
90 }
91
92
93
94 /** Returns whether the libraries are installed correctly.
95 */
96 public static boolean isLibraryAvailable()
97 {
98 return sm_bIsLibraryAvailable;
99 }
100}
101
102
103
104/*** Ogg.java ***/
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
29package org.tritonus.lowlevel.ogg;
30
31import org.tritonus.share.TDebug;
32
33
34
35/** Wrapper for ogg_packet.
36 */
37public 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 ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/Page.java b/songdbj/org/tritonus/lowlevel/ogg/Page.java
new file mode 100644
index 0000000000..ae30f210d4
--- /dev/null
+++ b/songdbj/org/tritonus/lowlevel/ogg/Page.java
@@ -0,0 +1,131 @@
1/*
2 * Page.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
29package org.tritonus.lowlevel.ogg;
30
31import org.tritonus.share.TDebug;
32
33
34
35/** Wrapper for ogg_page.
36 */
37public class Page
38{
39 static
40 {
41 Ogg.loadNativeLibrary();
42 if (TDebug.TraceOggNative)
43 {
44 setTrace(true);
45 }
46 }
47 /**
48 * Holds the pointer to ogg_page
49 * for the native code.
50 * This must be long to be 64bit-clean.
51 */
52 private long m_lNativeHandle;
53
54
55
56 public Page()
57 {
58 if (TDebug.TraceOggNative) { TDebug.out("Page.<init>(): begin"); }
59 int nReturn = malloc();
60 if (nReturn < 0)
61 {
62 throw new RuntimeException("malloc of ogg_page failed");
63 }
64 if (TDebug.TraceOggNative) { TDebug.out("Page.<init>(): end"); }
65 }
66
67
68
69 public void finalize()
70 {
71 // TODO: call free()
72 // call super.finalize() first or last?
73 // and introduce a flag if free() has already been called?
74 }
75
76
77
78 private native int malloc();
79 public native void free();
80
81
82 /** Calls ogg_page_version().
83 */
84 public native int getVersion();
85
86 /** Calls ogg_page_continued().
87 */
88 public native boolean isContinued();
89
90 /** Calls ogg_page_packets().
91 */
92 public native int getPackets();
93
94 /** Calls ogg_page_bos().
95 */
96 public native boolean isBos();
97
98 /** Calls ogg_page_eos().
99 */
100 public native boolean isEos();
101
102 /** Calls ogg_page_granulepos().
103 */
104 public native long getGranulePos();
105
106 /** Calls ogg_page_serialno().
107 */
108 public native int getSerialNo();
109
110 /** Calls ogg_page_pageno().
111 */
112 public native int getPageNo();
113
114 /** Calls ogg_page_checksum_set().
115 */
116 public native void setChecksum();
117
118
119 public native byte[] getHeader();
120
121 public native byte[] getBody();
122
123
124 private static native void setTrace(boolean bTrace);
125}
126
127
128
129
130
131/*** Page.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/StreamState.java b/songdbj/org/tritonus/lowlevel/ogg/StreamState.java
new file mode 100644
index 0000000000..34b970c5e2
--- /dev/null
+++ b/songdbj/org/tritonus/lowlevel/ogg/StreamState.java
@@ -0,0 +1,143 @@
1/*
2 * StreamState.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
29package org.tritonus.lowlevel.ogg;
30
31import org.tritonus.share.TDebug;
32
33
34/** Wrapper for ogg_stream_state.
35 */
36public class StreamState
37{
38 static
39 {
40 Ogg.loadNativeLibrary();
41 if (TDebug.TraceOggNative)
42 {
43 setTrace(true);
44 }
45 }
46
47
48 /**
49 * Holds the pointer to ogg_stream_state
50 * for the native code.
51 * This must be long to be 64bit-clean.
52 */
53 private long m_lNativeHandle;
54
55
56
57 public StreamState()
58 {
59 if (TDebug.TraceOggNative) { TDebug.out("StreamState.<init>(): begin"); }
60 int nReturn = malloc();
61 if (nReturn < 0)
62 {
63 throw new RuntimeException("malloc of ogg_stream_state failed");
64 }
65 if (TDebug.TraceOggNative) { TDebug.out("StreamState.<init>(): end"); }
66 }
67
68
69
70 public void finalize()
71 {
72 // TODO: call free()
73 // call super.finalize() first or last?
74 // and introduce a flag if free() has already been called?
75 }
76
77
78
79 private native int malloc();
80 public native void free();
81
82
83
84 /** Calls ogg_stream_init().
85 */
86 public native int init(int nSerialNo);
87
88 /** Calls ogg_stream_clear().
89 */
90 public native int clear();
91
92 /** Calls ogg_stream_reset().
93 */
94 public native int reset();
95
96 /** Calls ogg_stream_destroy().
97 */
98 public native int destroy();
99
100 /** Calls ogg_stream_eos().
101 */
102 public native boolean isEOSReached();
103
104
105
106 /** Calls ogg_stream_packetin().
107 */
108 public native int packetIn(Packet packet);
109
110
111 /** Calls ogg_stream_pageout().
112 */
113 public native int pageOut(Page page);
114
115
116 /** Calls ogg_stream_flush().
117 */
118 public native int flush(Page page);
119
120
121 /** Calls ogg_stream_pagein().
122 */
123 public native int pageIn(Page page);
124
125
126 /** Calls ogg_stream_packetout().
127 */
128 public native int packetOut(Packet packet);
129
130
131 /** Calls ogg_stream_packetpeek().
132 */
133 public native int packetPeek(Packet packet);
134
135
136 private static native void setTrace(boolean bTrace);
137}
138
139
140
141
142
143/*** StreamState.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/SyncState.java b/songdbj/org/tritonus/lowlevel/ogg/SyncState.java
new file mode 100644
index 0000000000..3b3b535fbe
--- /dev/null
+++ b/songdbj/org/tritonus/lowlevel/ogg/SyncState.java
@@ -0,0 +1,127 @@
1/*
2 * SyncState.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
29package org.tritonus.lowlevel.ogg;
30
31import org.tritonus.share.TDebug;
32
33
34/** Wrapper for ogg_sync_state.
35 */
36public class SyncState
37{
38 static
39 {
40 Ogg.loadNativeLibrary();
41 if (TDebug.TraceOggNative)
42 {
43 setTrace(true);
44 }
45 }
46
47
48 /**
49 * Holds the pointer to ogg_sync_state
50 * for the native code.
51 * This must be long to be 64bit-clean.
52 */
53 private long m_lNativeHandle;
54
55
56
57 public SyncState()
58 {
59 if (TDebug.TraceOggNative) { TDebug.out("SyncState.<init>(): begin"); }
60 int nReturn = malloc();
61 if (nReturn < 0)
62 {
63 throw new RuntimeException("malloc of ogg_sync_state failed");
64 }
65 if (TDebug.TraceOggNative) { TDebug.out("SyncState.<init>(): end"); }
66 }
67
68
69
70 public void finalize()
71 {
72 // TODO: call free()
73 // call super.finalize() first or last?
74 // and introduce a flag if free() has already been called?
75 }
76
77
78
79 private native int malloc();
80 public native void free();
81
82
83
84 /** Calls ogg_sync_init().
85 */
86 public native void init();
87
88
89 /** Calls ogg_sync_clear().
90 */
91 public native void clear();
92
93
94 /** Calls ogg_sync_reset().
95 */
96 public native void reset();
97
98
99 /** Calls ogg_sync_destroy().
100 */
101 public native void destroy();
102
103
104 /** Calls ogg_sync_buffer()
105 and ogg_sync_wrote().
106 */
107 public native int write(byte[] abBuffer, int nBytes);
108
109
110 /** Calls ogg_sync_pageseek().
111 */
112 public native int pageseek(Page page);
113
114
115 /** Calls ogg_sync_pageout().
116 */
117 public native int pageOut(Page page);
118
119
120 private static native void setTrace(boolean bTrace);
121}
122
123
124
125
126
127/*** SyncState.java ***/
diff --git a/songdbj/org/tritonus/lowlevel/ogg/package.html b/songdbj/org/tritonus/lowlevel/ogg/package.html
new file mode 100644
index 0000000000..4202aaebac
--- /dev/null
+++ b/songdbj/org/tritonus/lowlevel/ogg/package.html
@@ -0,0 +1,12 @@
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3 <head>
4 </head>
5
6 <body>
7 <p>Access to the native ogg library.
8 The classes provided here .</p>
9
10 @see org.tritonus.sampled.convert.vorbis
11 </body>
12</html>