summaryrefslogtreecommitdiff
path: root/songdbj/org/tritonus/lowlevel/ogg/Page.java
diff options
context:
space:
mode:
Diffstat (limited to 'songdbj/org/tritonus/lowlevel/ogg/Page.java')
-rw-r--r--songdbj/org/tritonus/lowlevel/ogg/Page.java131
1 files changed, 131 insertions, 0 deletions
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 ***/