CASampledSP
CAUtils.h
Go to the documentation of this file.
1 /*
2  * =================================================
3  * Copyright 2011 tagtraum industries incorporated
4  * This file is part of CASampledSP.
5  *
6  * FFSampledSP is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFSampledSP is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFSampledSP; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  * =================================================
20  *
21  * @author <a href="mailto:hs@tagtraum.com">Hendrik Schreiber</a>
22  */
23 #include <math.h>
24 #include <jni.h>
25 #include <AudioToolbox/AudioToolbox.h>
26 #include <CoreServices/CoreServices.h>
27 
28 
44 #define BUFFER_SIZE 32 * 1024
45 
49 struct CAAudioIO
50 {
51  JNIEnv * env;
52  jobject javaInstance;
53  AudioStreamBasicDescription srcFormat;
54  AudioStreamPacketDescription * pktDescs;
55  char * srcBuffer;
56  UInt32 srcBufferSize;
58  SInt64 pos;
59  SInt64 lastPos;
60  UInt32 frameOffset;
62  char * cookie;
63  UInt32 cookieSize;
64 };
65 
70 {
71  AudioConverterRef acref;
72  jobject sourceStream;
74 };
75 
80 {
81  AudioFileID afid;
82 };
83 
88 {
89  AudioFileStreamID asid;
90 };
91 
92 void throwUnsupportedAudioFileExceptionIfError(JNIEnv *, int, const char*);
93 
94 void throwIOExceptionIfError(JNIEnv *, int, const char*);
95 
96 void throwIllegalArgumentExceptionIfError(JNIEnv *, int, const char *);
97 
98 void throwFileNotFoundExceptionIfError(JNIEnv *, int, const char *);
99 
103 void ca_create_url_ref(JNIEnv *, jstring, CFURLRef&);
void throwIllegalArgumentExceptionIfError(JNIEnv *, int, const char *)
Throws an IllegalArgumentException.
Definition: CAUtils.cpp:73
UInt32 cookieSize
Cookie size.
Definition: CAUtils.h:63
void throwUnsupportedAudioFileExceptionIfError(JNIEnv *, int, const char *)
Throws an UnsupportedAudioFileException exception.
Definition: CAUtils.cpp:39
AudioStreamBasicDescription srcFormat
Source format.
Definition: CAUtils.h:53
UInt32 frameOffset
Frame offset (needed for seeking to the middles of a packet)
Definition: CAUtils.h:60
char * srcBuffer
Source buffer.
Definition: CAUtils.h:55
AudioFileStreamID asid
Stream id.
Definition: CAUtils.h:89
jobject sourceStream
Source stream object (Java)
Definition: CAUtils.h:72
Central context representing the native peer to the Java CAStreamInputStream object.
Definition: CAUtils.h:87
void throwIOExceptionIfError(JNIEnv *, int, const char *)
Throws an IOException.
Definition: CAUtils.cpp:56
AudioConverterRef acref
The used AudioConverter.
Definition: CAUtils.h:71
Central context representing the native peer to the Java CAURLInputStream object. ...
Definition: CAUtils.h:79
JNIEnv * env
JNI environment.
Definition: CAUtils.h:51
UInt32 srcBufferSize
Source buffer size.
Definition: CAUtils.h:56
Central context representing the native peer to the Java CACodecInputStream object.
Definition: CAUtils.h:69
void throwFileNotFoundExceptionIfError(JNIEnv *, int, const char *)
Throws an IllegalArgumentException.
Definition: CAUtils.cpp:90
CAAudioIO * sourceAudioIO
CAAudioIO of the stream that we want to convert.
Definition: CAUtils.h:73
char * cookie
Cookie.
Definition: CAUtils.h:62
AudioStreamPacketDescription * pktDescs
Packet descriptions.
Definition: CAUtils.h:54
AudioFileID afid
File id.
Definition: CAUtils.h:81
UInt32 srcSizePerPacket
Source size per packet.
Definition: CAUtils.h:61
jobject javaInstance
Calling java object.
Definition: CAUtils.h:52
void ca_create_url_ref(JNIEnv *, jstring, CFURLRef &)
Returns true if an error occurred.
Definition: CAUtils.cpp:101
SInt64 lastPos
Last position (in packets)
Definition: CAUtils.h:59
SInt64 pos
Current position (in packets)
Definition: CAUtils.h:58
UInt32 numPacketsPerRead
Number of packets per read.
Definition: CAUtils.h:57
Central context representing the native peer to the Java CANativePeerInputStream object.
Definition: CAUtils.h:49