Oracle interMedia Audio, Image, and Video Java Classes User's Guide and Reference Release 8.1.7 Part Number A85374-01 |
|
interMedia Java Classes describes the ORDAudio object type, which supports the storage and management of audio data.
Methods invoked at the ORDAudio level that are handed off for processing to the database source plug-in or database format plug-in have byte[ ] ctx[ ]
as a context parameter. In cases where a client system is connecting to a database server, the space for the parameter is created by the client (in the reference examples, 4000 bytes of space), but the content of the context parameter is generated by the server. The context parameter is passed from the client to the server for the processing of context information.
You will need to include the following import statements in your Java file in order to run interMedia methods:
import java.sql.*; import java.io.*; import oracle.jdbc.driver.*; import oracle.sql.*; import oracle.ord.im.*;
The examples in this reference chapter are based on the assumption that the following operations have already been performed:
For examples of making a connection and populating a local object, see Section 2.1.2.
This section presents reference information on the methods that operate on ORDAudio objects.
public boolean checkProperties(byte[ ] ctx[ ])
Checks if the properties stored in the media data of the local object are consistent with the attributes of the local object.
The format plug-in context information. It is set to NULL if there is no context information.
This method returns TRUE if the attribute values stored in the object attributes are the same as the properties stored in the BLOB data; FALSE otherwise.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; if(audObj.checkProperties(ctx)) System.out.println("checkProperties successful");
where:
public void clearLocal( )
Clears the source local field of the application ORDAudio object.
None.
None.
java.sql.SQLException
audObj.clearLocal( )
public int closeSource(byte[ ] ctx[ ])
Closes the ORDAudio file source.
The source plug-in context information. It is set to NULL if there is no context information.
This method returns 0 if the operation is successful, or an integer greater than 0 in case of failure.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; int i = audObj.closeSource(ctx); if(i == 0) System.out.println("Source close successful"); else System.out.println("Source close unsuccessful");
where:
public void deleteContent( )
Deletes the media data in the BLOB in the application ORDAudio object.
None.
None.
java.sql.SQLException
audObj.deleteContent( );
public void export (byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)
Exports the data from the application ORDAudio object BLOB to the location specified in the parameters. The location is of the form:
sourceType://sourceLocation/sourceName
This method will only work if you are running Oracle8i database server version 8.1.7 or later.
See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
The source plug-in context information. It is set to NULL if there is no context information.
The source type to which the content will be exported. Only FILE is natively supported.
The location on the database server to which the content will be exported.
The name of the source to which the content will be exported.
None.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; audObj.export(ctx,"FILE","AUDIODIR","complete.wav");
where:
public CLOB getAllAttributes(byte[ ] ctx[ ])
Gets all the attributes from the application ORDAudio object and puts them in a CLOB.
The format plug-in context information. It is set to NULL if there is no context information.
This method returns a CLOB that contains the attribute values of the ORDAudio object.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; CLOB attributes = audObj.getAllAttributes(ctx);
where:
public String getAttribute(byte[ ] ctx[ ], String name)
Gets the value of a specified attribute from the application ORDAudio object as a String.
The format plug-in context information. It is set to NULL if there is no context information.
The name of the attribute.
This method returns the value of the specified attribute, as a String.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; int attribute = audObj.getAttribute(ctx,"numberOfChannels")
where:
public int getAudioDuration( )
Gets the audio duration of the application ORDAudio object.
None.
This method returns the audio duration of the ORDAudio object, in seconds.
java.sql.SQLException
int audioDuration = audObj.getAudioDuration( );
public oracle.sql.BFILE getBFILE( )
Gets the BFILE attribute of the application ORDAudio object.
None.
This method returns the BFILE.
java.sql.SQLException
BFILE audioBFILE = audObj.getBFILE( );
public oracle.sql.CLOB getComments( )
Gets the comments from the application ORDAudio object and puts them in a CLOB.
None.
This method returns a CLOB that contains the comments from the ORDAudio object.
java.sql.SQLException
CLOB comments = audObj.getComments( )
public String getCompressionType( )
Gets the compression type of the application ORDAudio object as a String.
None.
This method returns the compression type of the ORDAudio object, as a String.
java.sql.SQLException
String compressionType = audObj.getComressionType( );
public oracle.sql.BLOB getContent( )
Gets the LOB locator from the application ORDAudio object.
None.
This method returns the LOB locator of the application ORDAudio object.
java.sql.SQLException
BLOB localContent = audObj.getContent( );
public BLOB getContentInLob(byte[ ] ctx[ ], String mimetype[ ], String format[ ])
Gets the content of the application ORDAudio object and puts it in a BLOB.
The source plug-in context information. It is set to NULL if there is no context information.
The MIME type of the content returned, stored in mimetype[0].
The format of the content returned, stored in format[0].
This method returns the LOB content of the application ORDAudio object in a LOB locator.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; String mimeType[ ] = new String[1]; mimeType[0] = "video/x-msvideo" String format[ ] = new String[1]; format[0] = "RIFF" BLOB localContent = audObj.getContentInLob(ctx,mimeType,format);
where:
public int getContentLength( )
Gets the content length of the media data in the application ORDAudio object.
None.
This method returns the content length of the media data.
java.sql.SQLException
int contentLength = audObj.getContentLength( );
public int getContentLength(byte[ ] ctx[ ])
Gets the content length of the media data in the application ORDAudio object.
The source plug-in context information. It is set to NULL if there is no context information.
This method returns the content length of the media data.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; int contentLength = audObj.getContentLength(ctx);
where:
public byte[ ] getDataInByteArray( )
Gets data from the LOB locator of the application ORDAudio object and puts it in a local byte array.
None.
This method returns the byte array from which the data will be read.
java.sql.SQLException
java.io.IOException
java.lang.OutOfMemoryError
byte[ ] byteArr = audObj.getDataInByteArray( );
public boolean getDataInFile(String filename)
Gets data from the LOB locator of the application ORDAudio object and puts it in a local file.
The name of the file into which the data will be loaded.
This method returns TRUE if loading is successful; FALSE otherwise.
java.sql.SQLException
java.io.IOException
boolean load = audObj.getDataInFile("output1.dat"); if(load) System.out.println("getDataInFile completed successfully"); else System.out.println("Error in getDataInFile");
where:
public InputStream getDataInStream( )
Gets data from the LOB locator of the application ORDAudio object and puts it in a local input stream.
None.
This method returns the input stream from which the data will be read.
java.sql.SQLException
InputStream inpStream = audObj.getDataInStream( );
public String getDescription( )
Gets the description attribute of the application ORDAudio object.
None.
This method returns the description attribute as a String.
java.sql.SQLException
String desc = audObj.getDescription( );
public String getEncoding( )
Gets the encoding of the application ORDAudio object as a String.
None.
This method returns the encoding of the ORDAudio object as a String.
java.sql.SQLException
String encoding = audObj.getEncoding( );
public String getFormat( )
Gets the format attribute of the application ORDAudio object as a String.
None.
This method returns the format attribute as a String.
java.sql.SQLException
String format = audObj.getFormat( );
public String getMimeType( )
Gets the MIME type of the application ORDAudio object as a String.
None.
This method returns the MIME type of the ORDAudio object as a String.
java.sql.SQLException
String mimeType = audObj.getMimeType( );
public int getNumberOfChannels( )
Gets the number of channels in the application ORDAudio object.
None.
This method returns the number of channels in the ORDAudio object as an integer.
java.sql.SQLException
int channels = audObj.getNumberOfChannels( );
public int getSampleSize( )
Gets the sample size of the application ORDAudio object as an integer.
None.
This method returns the sample size of the ORDAudio object.
java.sql.SQLException
int sampleSize = audObj.getSampleSize( );
public int getSamplingRate( )
Gets the sampling rate of the application ORDAudio object as an integer.
None.
This method returns the sampling rate of the ORDAudio object in bytes per second.
java.sql.SQLException
int samplingRate = audObj.getSamplingRate( );
public String getSource( )
Gets the object source information of the application ORDAudio object, including the source location, name, and type.
None.
This method returns a String containing the object source information.
java.sql.SQLException
String source = audObj.getSource( );
public String getSourceLocation( )
Gets the source location of the application ORDAudio object as a String.
None.
This method returns a String containing the object source location.
java.sql.SQLException
String location = audObj.getSourceLocation( );
public String getSourceName( )
Gets the source name of the application ORDAudio object as a String.
None.
This method returns a String containing the object source name.
java.sql.SQLException
String name = audObj.getSourceName( );
public String getSourceType( )
Gets the source location of the application ORDAudio object as a String.
None.
This method returns a String containing the object source type.
java.sql.SQLException
String type = audObj.getSourceType( );
public java.sql.Timestamp getUpdateTime( )
Gets a Timestamp object that contains information on when the application ORDAudio object was most recently updated.
None.
This method returns a Timestamp object that contains the time of the most recent update.
java.sql.SQLException
Timestamp time = audObj.getUpdateTime( );
public void importData(byte[ ] ctx[ ])
Imports data from an external source into the application ORDAudio object.
The srcType, srcLocation, and srcName attributes must all be defined for this method to work.
The source plug-in context information. It is set to NULL if there is no context information.
None.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; audObj.importData(ctx);
where:
public void importFrom(byte[ ] ctx[ ], String sourceType, String sourceLocation, String sourceName)
Imports data from an external source into the application ORDAudio object. The location of the external source is of the form:
sourceType://sourceLocation/sourceName
The source plug-in context information. See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
The source type from which the data will be imported.
The source location on the database server from which the data will be imported.
The source name from which the data will be imported.
None.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; audObj.importFrom("FILE","AUDIODIR","testaud.dat");
where:
public boolean isLocal( )
Checks if the application ORDAudio object local attribute is set.
None.
This method returnsTRUE if the ORDAudio object local attribute is set; FALSE otherwise.
java.sql.SQLException
if(audObj.isLocal( )) System.out.println("local attribute is set to true"); else System.out.println("lcoal attribute is set to false");
public boolean loadDataFromByteArray(byte[ ] byteArr)
Loads data from the local byte buffer into the database ORDAudio object LOB locator and into the application object. It also calls setLocal( ), which sets the local field of the application ORDAudio object, but not the database object, and setUpdateTime(null), which sets the updateTime attribute to the SYSDATE of the database server.
The name of the local byte array from which the data will be loaded.
This method returns TRUE if loading is successful; FALSE otherwise.
java.sql.SQLException
java.io.IOException
byte[ ] data = new byte[32000]; FileInputStream fStream = new FileInputStream("testaud.dat"); fStream.read(data,0,32300); boolean success = audObj.loadDataFromByteArray(data); if(success) System.out.println("loadDataFromByteArray was successful"); else System.out.println("loadDataFromByteArray was unsuccessful");
where:
public boolean loadDataFromFile(String filename)
Loads data from the local file into the database ORDAudio object LOB locator and into the application object. It also calls setLocal( ), which sets the local field of the application ORDAudio object, but not the database object, and setUpdateTime(null), which sets the updateTime attribute to the SYSDATE of the database server.
The name of the local file from which to load data.
This method returns TRUE if loading is successful; FALSE otherwise.
java.sql.SQLException
java.io.IOException
audObj.loadDataFromFile("testaud.dat");
where:
public boolean loadDataFromInputStream(InputStream inpStream)
Loads data from the local input stream into the database ORDAudio object LOB locator and into the application object. It also calls setLocal( ), which sets the local field of the application ORDAudio object, but not the database object, and setUpdateTime(null), which sets the updateTime attribute to the SYSDATE of the database server.
The name of the local input stream from which to load data.
This method returns TRUE if loading is successful; FALSE otherwise.
java.sql.SQLException
java.io.IOException
FileInputStream fStream = new FileInputStream("testaud.dat"); audObj.loadDataFromInputStream(fStream);
where:
public int openSource(byte[ ] userarg, byte[ ] ctx[ ])
Opens the ORDAudio file source.
Permission-related parameters that are supplied by the user, such as READONLY. These may be used by user-defined source plug-ins.
The source plug-in context information. See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
This method returns 0 if the operation is successful, or an integer greater than 0 in case of failure.
java.lang.Exception
byte[ ] userarg = new byte[4000]; byte[ ] ctx[ ] = new byte[4000][1]; int i = audObj.openSource(userarg,ctx); if(i == 0) System.out.println("openSource successful"); else System.out.println("openSource unsuccessful");
where:
public OrdAudio( )
Creates an ORDAudio object.
This method is the default ORDAudio constructor.
None.
None.
None.
None.
public byte[ ] processAudioCommand(byte[ ] ctx[ ], String command, String args, byte[ ] result[ ])
Processes the specified command on the application ORDAudio object by calling the database processAudioCommand( ) method.
The format plug-in context information. It is set to NULL if there is no context information.
The command to be executed. The command must be recognized by the database format plug-in.
The arguments of the command.
The results of the command.
This method returns the results of the execution of the command.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1] String command; String arguments; byte[ ] result; //assign a command value to command //assign any arguments to args byte[ ] commandResults = audObj.processAudioCommand(ctx,command, arguments,result);
where:
public byte[ ] processSourceCommand(byte[ ] ctx[ ], String command, String args, byte[ ] result[ ])
Processes the specified command on the application ORDAudio object by calling the database processSourceCommand( ) method.
The source plug-in context information. See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
The command to be executed. The command must be recognized by the database source plug-in.
The arguments of the command to be executed.
The results of the command.
This method returns the results of executing the command.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; String command; String arguments; byte[ ] result; //assign a command value to command //assign any arguments to args byte[ ] commandResults = audObj.processSourceCommand(ctx,command, arguments,result);
where:
public int readFromSource(byte[ ] ctx[ ], int startpos, int numbytes, byte[ ] buffer)
Reads data from the comments field of the application ORDAudio object.
The source plug-in context information. See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
The initial position in the comments field.
The number of bytes to be read.
The buffer into which to read the content.
This method returns the number of bytes read.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; byte[ ] commentBuffer = new byte[12]; int i = audObj.readFromSource(ctx,0,12,commentBuffer);
where:
public void setAudioDuration(int audioDuration)
Sets the audio duration of the application ORDAudio object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.
The audio duration (in seconds) to be set in the ORDAudio object.
None.
java.sql.SQLException
audObj.setAudioDuration(16);
where:
public void setComments(oracle.sql.CLOB comments)
Sets the comments in the application ORDAudio object.
The comments attribute is reserved for use by interMedia. You can set your own value, but it could be overwritten by interMedia Annotator.
A CLOB that contains comments for the ORDAudio object.
None.
java.sql.SQLException
audObj.setComments(commentsData);
where:
public void setCompressionType(String CompressionType)
Sets the compression type of the application ORDAudio object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.
The compression type of the ORDAudio object, as a String.
None.
java.sql.SQLException
audObj.setCompressionType("8BITMONOAUDIO");
where:
public void setDescription(String description)
Sets the description attribute of the application ORDAudio object.
A String that describes the contents of the ORDAudio object.
None.
java.sql.SQLException
audObj.setDescription("My audio file");
where:
public void setEncoding(String encoding)
Sets the encoding of the application ORDAudio object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.
The encoding of the contents of an ORDAudio object, as a String.
None.
java.sql.SQLException
audObj.setEncoding("MULAW");
where:
public void setFormat(String format)
Sets the format attribute of the application ORDAudio object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.
The format of the contents of the ORDAudio object, as a String.
None.
java.sql.SQLException
audObj.setFormat("AUFF");
where:
public void setKnownAttributes(String knownformat, String knownencoding,
int knownnumberofchannels, int knownsamplingrate,
int knownsamplesize, String knowncompressiontype,
int knownaudioduration)
Sets the known attributes of the ORDAudio object.
setProperties( ) will automatically set these attributes; use this method only if you are not using setProperties( ). Also, this method will set only the attribute values; it does not change the media file itself.
The audio data format.
The audio data encoding.
The number of channels.
The sampling rate.
The sample size.
The compression type.
The audio duration.
None.
java.sql.SQLException
audObj.setKnownAttributes("AUFF","MULAW",1,8,8,"8BITMONOAUDIO",16);
where:
public void setLocal( )
Sets the source local field of the application ORDAudio object.
None.
None.
java.sql.SQLException
audObj.setLocal( );
public void setMimeType(String MimeType)
Sets the MIME type of the application ORDAudio object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.
The MIME type of the contents of the ORDAudio object, as a String.
None.
java.sql.SQLException
audObj.setMimeType("audio/basic");
where:
public void setNumberOfChannels(int numberOfChannels)
Sets the number of the channels in the application ORDAudio object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.
The number of channels to be set.
None.
java.sql.SQLException
audObj.setNumberOfChannels(1);
where:
public void setProperties(byte[ ] ctx[ ])
Reads the audio data, extracts the properties, and sets the properties in the application ORDAudio object.
The properties to be set include format, encoding, number of channels, sampling rate, sample size, compression type, and audio duration.
The format plug-in context information. It is set to NULL if there is no context information.
None.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; audObj.setProperties(ctx);
where:
public void setProperties(byte[ ] ctx[ ], boolean setComments)
Reads the media data, extracts the properties, and sets the properties in the application ORDAudio object.
The properties to be set include format, encoding, number of channels, sampling rate, sample size, compression type, and audio duration.
The format plug-in context information. It is set to NULL if there is no context information.
A Boolean value to determine whether or not to set the comments in the ORDAudio object. If TRUE, the comments field is populated with a set of format and application properties of the audio object in XML. If FALSE, the comments field remains unpopulated. The default value is FALSE.
None.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; audObj.setProperties(ctx,true);
where:
public void setSampleSize(int sampleSize)
Sets the sample size in the application ORDAudio object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.
The sample size of the ORDAudio object.
None.
java.sql.SQLException
audObj.setSampleSize(8);
where:
public void setSamplingRate(int samplingRate)
Sets the sampling rate of the application ORDAudio object.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.
The sampling rate value to be set, in samples per second.
None.
java.sql.SQLException
audObj.setSamplingRate(8);
where:
public void setSource(String sourceType, String sourceLocation, String sourceName)
Sets the application ORDAudio object source information.
The type of the source.
The location of the source.
The name of the source.
None.
java.sql.SQLException
audObj.setSource("FILE","AUDIODIR","audio.au");
where:
public void setUpdateTime(java.sql.Timestamp currentTime)
Sets the update time in the application ORDAudio object to the current time.
setProperties( ) will automatically set this attribute; use this method only if you are not using setProperties( ). Also, this method will set only the attribute value; it does not change the media file itself.
The current time, which will be set in the ORDAudio object. This value should be NULL; the method will then use the SYSDATE of the database server.
None.
java.sql.SQLException
audObj.setUpdateTime(null);
public int trimSource(byte[ ] ctx[ ], int newLen)
Trim the file source of the application ORDAudio object to the given length.
The source plug-in context information. See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
The length to which the source will be trimmed.
This method returns 0 if the operation is successful, or an integer greater than 0 in case of failure.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; int i = audObj.trimSource(ctx,10); if (i == 0) System.out.println("trimSource successful"); else System.out.println("trimSource unsuccessful");
where:
public int writeToSource(byte[ ] ctx[ ], int startpos, int numbytes, byte[ ] buffer)
Writes data to the comments field of the application ORDAudio object.
The source plug-in context information. See Chapter 4 of Oracle8i interMedia Audio, Image, and Video User's Guide and Reference for more information.
The initial position in the comments field.
The number of bytes to be written.
The buffer containing the content to be written.
This method returns the number of bytes written.
java.sql.SQLException
byte[ ] ctx[ ] = new byte[4000][1]; byte[ ] data = new byte[20]; //populate data with 20 bytes of content int i = audObj.writeToSource(ctx,1,20,data);
where:
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|