Oracle interMedia User's Guide and Reference Release 9.0.1 Part Number A88786-01 |
|
Oracle interMedia contains information about the ORDAudio type:
The examples in this chapter assume that the test audio table TAUD has been created and filled with data. This table was created using the SQL statements described in Section 6.3.1.
Methods invoked at the ORDSource level that are handed off to the source plug-in for processing have ctx(RAW(4000)) as the first argument. Before calling any of these methods for the first time, the client must allocate the ctx structure, initialize it to NULL, and invoke the openSource( ) method. At this point, the source plug-in can initialize context for this client. When processing is complete, the client should invoke the closeSource( ) method.
Methods invoked from a source plug-in call have the first argument as ctx (RAW(4000)).
Methods invoked at the ORDAudio level that are handed off to the format plug-in for processing have ctx (RAW(4000)) as the first argument. Before calling any of these methods for the first time, the client must allocate the ctx structure and initialize it to NULL.
You should use any of the individual set methods to set the value of the attribute for an object for formats not natively supported; otherwise, for formats natively supported, use the setProperties( ) method to populate the attributes of the object.
Oracle interMedia describes the ORDAudio object type, which supports the storage and management of audio data.
The ORDAudio object type supports the storage and management of audio data. This object type is defined as follows:
CREATE OR REPLACE TYPE ORDAudio AS OBJECT ( -- ATTRIBUTES description VARCHAR2(4000), source ORDSource, format VARCHAR2(31), mimeType VARCHAR2(4000), comments CLOB, -- AUDIO RELATED ATTRIBUTES encoding VARCHAR2(256), numberOfChannels INTEGER, samplingRate INTEGER, sampleSize INTEGER, compressionType VARCHAR2(4000), audioDuration INTEGER, -- METHODS -- CONSTRUCTORS -- STATIC FUNCTION init( ) RETURN ORDAudio, STATIC FUNCTION init(srcType IN VARCHAR2, srcLocation IN VARCHAR2, srcName IN VARCHAR2) RETURN ORDAudio, -- Methods associated with the date attribute MEMBER FUNCTION getUpdateTime( ) RETURN DATE, PRAGMA RESTRICT_REFERENCES(getUpdateTime, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setUpdateTime(current_time DATE), -- Methods associated with the description attribute MEMBER PROCEDURE setDescription(user_description IN VARCHAR2), MEMBER FUNCTION getDescription( ) RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getDescription, WNDS, WNPS, RNDS, RNPS), -- Methods associated with the mimeType attribute MEMBER PROCEDURE setMimeType(mime IN VARCHAR2), MEMBER FUNCTION getMimeType( ) RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getMimeType, WNDS, WNPS, RNDS, RNPS), -- Methods associated with the source attribute MEMBER FUNCTION processSourceCommand( ctx IN OUT RAW, cmd IN VARCHAR2, arguments IN VARCHAR2, result OUT RAW) RETURN RAW, MEMBER FUNCTION isLocal( ) RETURN BOOLEAN, PRAGMA RESTRICT_REFERENCES(isLocal, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setLocal( ), MEMBER PROCEDURE clearLocal( ), MEMBER PROCEDURE setSource( source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2), MEMBER FUNCTION getSource( ) RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSource, WNDS, WNPS, RNDS, RNPS), MEMBER FUNCTION getSourceType( ) RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSourceType, WNDS, WNPS, RNDS, RNPS), MEMBER FUNCTION getSourceLocation( ) RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSourceLocation, WNDS, WNPS, RNDS, RNPS), MEMBER FUNCTION getSourceName( ) RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSourceName, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE import(ctx IN OUT RAW), MEMBER PROCEDURE importFrom( ctx IN OUT RAW, source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2), MEMBER PROCEDURE export( ctx IN OUT RAW, source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2), MEMBER FUNCTION getContentLength(ctx IN OUT RAW) RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getContentLength, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE getContentInLob( ctx IN OUT RAW, dest_lob IN OUT NOCOPY BLOB, mimeType OUT VARCHAR2, format OUT VARCHAR2), MEMBER FUNCTION getContent( ) RETURN BLOB, PRAGMA RESTRICT_REFERENCES(getContent, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE deleteContent( ), MEMBER FUNCTION getBFILE( ) RETURN BFILE, PRAGMA RESTRICT_REFERENCES(getBFILE, WNDS, WNPS, RNDS, RNPS), -- Methods associated with file operations on the source MEMBER FUNCTION openSource(userArg IN RAW, ctx OUT RAW) RETURN INTEGER, MEMBER FUNCTION closeSource(ctx IN OUT RAW) RETURN INTEGER, MEMBER FUNCTION trimSource(ctx IN OUT RAW, newlen IN INTEGER) RETURN INTEGER, MEMBER PROCEDURE readFromSource( ctx IN OUT RAW, startPos IN INTEGER, numBytes IN OUT INTEGER, buffer OUT RAW), MEMBER PROCEDURE writeToSource( ctx IN OUT RAW, startPos IN INTEGER, numBytes IN OUT INTEGER, buffer IN RAW), -- Methods associated with audio attributes accessors MEMBER PROCEDURE setFormat(knownformat IN VARCHAR2), MEMBER FUNCTION getFormat( ) RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getFormat, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setEncoding(knownEncoding IN VARCHAR2), MEMBER FUNCTION getEncoding( ) RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getEncoding, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setNumberOfChannels(knownNumberOfChannels IN INTEGER), MEMBER FUNCTION getNumberOfChannels( ) RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getNumberOfChannels, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setSamplingRate(knownSamplingRate IN INTEGER), MEMBER FUNCTION getSamplingRate( ) RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getSamplingRate, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setSampleSize(knownSampleSize IN INTEGER), MEMBER FUNCTION getSampleSize( ) RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getSampleSize, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setCompressionType(knownCompressionType IN VARCHAR2), MEMBER FUNCTION getCompressionType( ) RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getCompressionType, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setAudioDuration(knownAudioDuration IN INTEGER), MEMBER FUNCTION getAudioDuration( ) RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getAudioDuration, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setKnownAttributes( knownFormat IN VARCHAR2, knownEncoding IN VARCHAR2, knownNumberOfChannels IN INTEGER, knownSamplingRate IN INTEGER, knownSampleSize IN INTEGER, knownCompressionType IN VARCHAR2, knownAudioDuration IN INTEGER), -- Methods associated with setting all the properties MEMBER PROCEDURE setProperties(ctx IN OUT RAW, setComments IN BOOLEAN), MEMBER FUNCTION checkProperties(ctx IN OUT RAW) RETURN BOOLEAN, MEMBER FUNCTION getAttribute( ctx IN OUT RAW, name IN VARCHAR2) RETURN VARCHAR2, MEMBER PROCEDURE getAllAttributes( ctx IN OUT RAW, attributes IN OUT NOCOPY CLOB), -- Methods associated with audio processing MEMBER FUNCTION processAudioCommand( ctx IN OUT RAW, cmd IN VARCHAR2, arguments IN VARCHAR2, result OUT RAW) RETURN RAW );
where:
This section describes the constructor functions.
The interMedia constructor functions are as follows:
init( ) RETURN ORDAudio;
Allows for easy initialization of instances of the ORDAudio object type.
None.
None.
None.
This static method initializes all the ORDAudio attributes to NULL with the following exceptions:
You should begin using the init( ) method as soon as possible to allow you to more easily initialize the ORDAudio object type, especially if the ORDAudio type evolves and attributes are added in a future release. INSERT statements left unchanged using the default constructor (which initializes each object attribute), will fail under these circumstances.
Initialize the ORDAudio object attributes:
BEGIN INSERT INTO taud VALUES (ORDSYS.ORDAudio.init()); END; /
init(srcType IN VARCHAR2,
srcLocation IN VARCHAR2,
srcName IN VARCHAR2)
RETURN ORDAudio;
Allows for easy initialization of instances of the ORDAudio object type.
The source type of the audio data.
The source location of the audio data.
The source name of the audio data.
None.
None.
This static method initializes all the ORDAudio attributes to NULL with the following exceptions:
You should begin using the init( ) method as soon as possible to allow you to more easily initialize the ORDAudio object type, especially if the ORDAudio type evolves and attributes are added in a future release. INSERT statements left unchanged using the default constructor (which initializes each object attribute), will fail under these circumstances.
Initialize the ORDAudio object attributes:
BEGIN INSERT INTO taud VALUES (ORDSYS.ORDAudio.init('file','AUDDIR','audio1.au')); END; /
This section presents reference information on the Oracle interMedia methods used for audio data manipulation. These methods are described in the following groupings:
For the known attributes that ORDAudio understands, it sets the properties for these attributes. These include: format, encoding type, data type, number of channels, sampling rate, and sample size of the audio data. See "setMimeType( )" for information.
For more information on object types and methods, see Oracle9i Database Concepts.
The methods described in this reference chapter show examples based on a test audio table TAUD. Refer to the TAUD table definition that follows when reading through the examples:
CREATE TABLE TAUD(n NUMBER, aud ORDSYS.ORDAUDIO) storage (initial 100K next 100K pctincrease 0); INSERT INTO TAUD VALUES(1, ORDSYS.ORDAudio.init()); INSERT INTO TAUD VALUES(2, ORDSYS.ORDAudio.init());
checkProperties(ctx IN OUT RAW) RETURN BOOLEAN;
Checks the properties of the stored audio data, including the following audio attributes: sample size, sample rate, number of channels, format, and encoding type.
The format plug-in context information.
If the format is set to NULL, then the checkProperties( ) method uses the default format plug-in; otherwise, it uses the plug-in specified by the format.
The checkProperties( ) method does not check the MIME type because a file can have multiple correct MIME types and this is not well defined.
None.
AUDIO_PLUGIN_EXCEPTION
This exception is raised if you call the checkProperties( ) method and the audio plug-in raises an exception.
Check property information for known audio attributes:
DECLARE obj ORDSYS.ORDAudio; ctx RAW(4000) :=NULL; BEGIN select aud into obj from TAUD where N =1 for update; if( obj.checkProperties(ctx) = TRUE ) then DBMS_OUTPUT.put_line('true'); else DBMS_OUTPUT.put_line('false'); end if; EXCEPTION WHEN ORDSYS.ORDAudioExceptions.AUDIO_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('ORDAudioExceptions.AUDIO_PLUGIN_EXCEPTION caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
getAllAttributes(
ctx IN OUT RAW,
attributes IN OUT NOCOPY CLOB);
Returns a formatted string for convenient client access. For natively supported formats, the string includes the following list of audio data attributes separated by a comma (,): fileFormat, mimeType, encoding, numberOfChannels, samplingRate, sampleSize, compressionType, and audioDuration. For user-defined formats, the string is defined by the format plug-in.
The format plug-in context information.
The attributes.
These audio data attributes are available from the header of the formatted audio data.
None.
AUDIO_PLUGIN_EXCEPTION
This exception is raised if you call the getAllAttributes( ) method and the audio plug-in raises an exception.
Return all audio attributes for audio data stored in the database:
DECLARE obj ORDSYS.ORDAudio; tempLob CLOB; ctx RAW(4000) :=NULL; BEGIN SELECT aud INTO obj FROM TAUD WHERE N=1; DBMS_OUTPUT.PUT_LINE('getting comma separated list of all attribs'); DBMS_OUTPUT.PUT_LINE('-------------------------------------------'); DBMS_LOB.CREATETEMPORARY(tempLob, FALSE, DBMS_LOB.CALL); obj.getAllAttributes(ctx,tempLob); DBMS_OUTPUT.put_line(DBMS_LOB.substr(tempLob, DBMS_LOB.getLength(tempLob) , 1));
EXCEPTION WHEN ORDSYS.ORDAudioExceptions.AUDIO_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.PUT_LINE('ORDAudioExceptions.AUDIO_PLUGIN_EXCEPTION caught');
END; /
getAttribute(
ctx IN OUT RAW,
name IN VARCHAR2)
RETURN VARCHAR2;
Returns the value of the requested attribute from audio data for user-defined formats only.
The format plug-in context information.
The name of the attribute.
The audio data attributes are available from the header of the formatted audio data.
Audio data attribute information can be extracted from the audio data itself. You can extend support to a format not understood by the ORDAudio object by implementing an ORDPLUGINS.ORDX_<format>_AUDIO package that supports that format. See Section 3.4.13 for more information.
None.
AUDIO_PLUGIN_EXCEPTION
This exception is raised if you call the getAttribute( ) method and the audio plug-in raises an exception.
Return information for the specified audio attribute for audio data stored in the database:
DECLARE obj ORDSYS.ORDAudio; res VARCHAR2(4000); ctx RAW(4000) :=NULL; BEGIN SELECT aud INTO obj FROM TAUD WHERE N=1; DBMS_OUTPUT.PUT_LINE('getting audio sample size'); DBMS_OUTPUT.PUT_LINE('---------------------'); res := obj.getAttribute(ctx,'sample_size'); EXCEPTION WHEN ORDSYS.ORDSourceExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('Source METHOD_NOT_SUPPORTED caught'); WHEN ORDSYS.ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('SOURCE PLUGIN EXCEPTION caught'); WHEN ORDSYS.ORDAudioExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('AUDIO METHOD_NOT_SUPPORTED EXCEPTION caught'); WHEN ORDSYS.ORDAudioExceptions.AUDIO_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('AUDIO PLUGIN EXCEPTION caught'); WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('EXCEPTION caught'); END; /
getAudioDuration( ) RETURN INTEGER;
Returns the value of the audioDuration attribute of the audio object.
None.
None.
PRAGMA RESTRICT_REFERENCES(getAudioDuration, WNDS,
WNPS, RNDS, RNPS)
None.
See the example in setProperties( ).
getContentLength(ctx IN OUT RAW) RETURN INTEGER;
Returns the length of the audio data content stored in the source.
The source plug-in context information.
This method is not supported for all source types. For example, HTTP type sources do not support this method. If you want to implement this call for HTTP type sources, you must define your own modified HTTP source type and implement this method on it.
PRAGMA RESTRICT_REFERENCES(getContentLength, WNDS,
WNPS, RNDS, RNPS)
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the getContentLength( ) method and the value of srcType is NULL and data is not stored locally in the BLOB.
ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION
This exception is raised if you call the getContentLength( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
See the example in import( ).
getCompressionType( ) RETURN VARCHAR2;
Returns the value of the compressionType attribute of the audio object.
None.
None.
PRAGMA RESTRICT_REFERENCES(getCompressionType, WNDS,
WNPS, RNDS, RNPS)
None.
See the example in setProperties( ).
getContentInLob(
ctx IN OUT RAW,
dest_lob IN OUT NOCOPY BLOB,
mimeType OUT VARCHAR2,
format OUT VARCHAR2);
Copies data from a data source into the specified BLOB. The BLOB must not be the BLOB in source.localData.
The source plug-in context information.
The LOB in which to receive data.
The MIME type of the data; this may or may not be returned.
The format of the data; this may or may not be returned.
None.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the getContentInLob( ) method and the value of srcType is NULL.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the getContentInLob( ) method and this method is not supported by the source plug-in being used.
ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION
This exception is raised if you call the getContentInLob( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Get data from a data source and put it into the specified BLOB:
DECLARE obj ORDSYS.ORDAudio; tempBLob BLOB; mimeType VARCHAR2(4000); format VARCHAR2(4000); ctx RAW(4000) :=NULL; BEGIN SELECT aud INTO obj FROM TAUD WHERE N = 1 ; if(obj.isLocal) then DBMS_OUTPUT.put_line('local is true'); end if; DBMS_LOB.CREATETEMPORARY(tempBLob, true, 10); obj.getContentInLob(ctx,tempBLob, mimeType,format); DBMS_OUTPUT.PUT_LINE(TO_CHAR(DBMS_LOB.getLength(tempBLob))); EXCEPTION WHEN ORDSYS.ORDSourceExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('ORDSourceExceptions.METHOD_NOT_SUPPORTED caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
getDescription( ) RETURN VARCHAR2;
Returns the description of the audio data.
None.
None.
PRAGMA RESTRICT_REFERENCES(getDescription, WNDS, WNPS, RNDS, RNPS)
DESCRIPTION_IS_NOT_SET
This exception is raised if you call the getDescription( ) method and the description is not set.
See the example in setDescription( ).
getEncoding( ) RETURN VARCHAR2;
Returns the value of the encoding attribute of the audio object.
None.
None.
PRAGMA RESTRICT_REFERENCES(getEncoding, WNDS, WNPS, RNDS, RNPS)
None.
See the example in setProperties( ).
getFormat( ) RETURN VARCHAR2;
Returns the value of the format attribute of the audio object.
None.
None.
PRAGMA RESTRICT_REFERENCES(getFormat, WNDS, WNPS, RNDS, RNPS)
AUDIO_FORMAT_IS_NULL
This exception is raised if you call the getFormat( ) method and the value for format is NULL.
See the example in setProperties( ).
getNumberOfChannels( ) RETURN INTEGER;
Returns the value of the numberOfChannels attribute of the audio object.
None.
None.
PRAGMA RESTRICT_REFERENCES(getNumberOfChannels, WNDS,
WNPS, RNDS, RNPS)
None.
See the example in setProperties( ).
getSampleSize( ) RETURN INTEGER;
Returns the value of the sampleSize attribute of the audio object.
None.
None.
PRAGMA RESTRICT_REFERENCES(getSampleSize, WNDS, WNPS, RNDS, RNPS)
None.
See the example in setProperties( ).
getSamplingRate( ) IN INTEGER;
Returns the value of the samplingRate attribute of the audio object. The unit is Hz.
None.
None.
PRAGMA RESTRICT_REFERENCES(getSamplingRate, WNDS,
WNPS, RNDS, RNPS)
None.
See the example in setProperties( ).
import(ctx IN OUT RAW);
Transfers audio data from an external audio data source to a local source (localData) within an Oracle database.
The source plug-in context information.This must be allocated. You must call the openSource( ) method; see the introduction to this chapter for more information.
Use the setSource( ) method to set the external source type, location, and name prior to calling the import( ) method.
You must ensure that the directory exists or is created before you use this method for srcType 'file'.
After importing data from an external audio data source to a local source (within an Oracle database), the source information remains unchanged (that is, pointing to the source from where the data was imported).
Invoking this method implicitly calls the setUpdateTime( ) and setLocal methods.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the import( ) method and the value of srcType is NULL.
ORDSourceExceptions.NULL_SOURCE
This exception is raised if you call the import( ) method and the value of dlob is NULL.
ORDSourceExceptionsMETHOD_NOT_SUPPORTED
This exception is raised if you call the import( ) method and the import( ) method is not supported by the source plug-in being used.
ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION
This exception is raised if you call the import( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Import audio data from an external audio data source into the local source:
DECLARE obj ORDSYS.ORDAudio; ctx RAW(4000) :=NULL; BEGIN SELECT aud INTO obj FROM TAUD WHERE N=1 FOR UPDATE; DBMS_OUTPUT.PUT_LINE('setting and getting source'); DBMS_OUTPUT.PUT_LINE('--------------------------'); -- set source to a file obj.setSource('file','AUDIODIR','testaud.dat'); -- get source information DBMS_OUTPUT.PUT_LINE(obj.getSource()); -- import data obj.import(ctx); -- check size DBMS_OUTPUT.PUT_LINE(TO_CHAR(obj.getContentLength(ctx))); DBMS_OUTPUT.PUT_LINE(obj.getSource()); DBMS_OUTPUT.PUT_LINE('deleting contents'); DBMS_OUTPUT.PUT_LINE('-----------------'); obj.deleteContent(); DBMS_OUTPUT.PUT_LINE(TO_CHAR(obj.getContentLength(ctx))); UPDATE TAUD SET aud=obj WHERE N=1; COMMIT; END; /
importFrom(ctx IN OUT RAW,
source_type IN VARCHAR2,
source_location IN VARCHAR2,
source_name IN VARCHAR2);
Transfers audio data from the specified external audio data source to a local source (localData) within an Oracle database.
The source plug-in context information. This must be allocated. You must call the openSource( ) method; see the introduction to this chapter for more information.
The source type of the audio data.
The location from where the audio data is to be imported.
The name of the audio data.
This method is similar to the import( ) method except the source information is specified as parameters to the method instead of separately.
You must ensure that the directory exists or is created before you use this method for srcType 'file'.
After importing data from an external audio data source to a local source (within an Oracle database), the source information (that is, pointing to the source from where the data was imported) is set to the input values.
Invoking this method implicitly calls the setUpdateTime( ) and setLocal methods.
None.
ORDSourceExceptions.NULL_SOURCE
This exception is raised if you call the importFrom( ) method and the value of dlob is NULL.
ORDSourceExceptionsMETHOD_NOT_SUPPORTED
This exception is raised if you call the importFrom( ) method and this method is not supported by the source plug-in being used.
ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION
This exception is raised if you call the importFrom( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Import audio data from the specified external data source into the local source:
DECLARE obj ORDSYS.ORDAudio; ctx RAW(4000) :=NULL; BEGIN SELECT aud INTO obj FROM TAUD WHERE N=1 FOR UPDATE; DBMS_OUTPUT.PUT_LINE('setting and getting source'); DBMS_OUTPUT.PUT_LINE('--------------------------'); -- set source to a file -- import data obj.importFrom(ctx,'file','AUDIODIR','testaud.dat'); -- check size DBMS_OUTPUT.PUT_LINE(TO_CHAR(obj.getContentLength(ctx))); DBMS_OUTPUT.PUT_LINE(obj.getSource()); DBMS_OUTPUT.PUT_LINE('deleting contents'); DBMS_OUTPUT.PUT_LINE('-----------------'); obj.deleteContent(); DBMS_OUTPUT.PUT_LINE(TO_CHAR(obj.getContentLength(ctx))); DBMS_OUTPUT.PUT_LINE(TO_CHAR(DBMS_LOB.GETLENGTH(obj.getContent()))); UPDATE TAUD SET aud=obj WHERE N=1; COMMIT; EXCEPTION WHEN ORDSYS.ORDAudioExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.PUT_LINE('Source not specified'); END; /
processAudioCommand(
ctx IN OUT RAW,
cmd IN VARCHAR2,
arguments IN VARCHAR2,
result OUT RAW)
RETURN RAW;
Allows you to send a command and related arguments to the format plug-in for processing.
The format plug-in context information.
Any command recognized by the format plug-in.
The arguments of the command.
The result of calling this function returned by the format plug-in.
Use this method to send any audio commands and their respective arguments to the format plug-in. Commands are not interpreted; they are taken and passed through to a format plug-in to be processed.
If the format is set to NULL, then the processAudioCommand( ) method uses the default format plug-in; otherwise, it uses your user-defined format plug-in.
You can extend support to a format that is not understood by the ORDAudio object by preparing an ORDPLUGINS.ORDX_<format>_AUDIO package that supports that format. See Section 3.4.13 for more information.
None.
AUDIO_PLUGIN_EXCEPTION
This exception is raised if you call the processAudioCommand( ) method and the audio plug-in raises an exception.
Process a set of commands:
DECLARE obj ORDSYS.ORDAudio; res RAW(4000); result RAW(4000); command VARCHAR(4000); argList VARCHAR(4000); ctx RAW(4000) :=NULL; BEGIN select aud into obj from TAUD where N =1 for UPDATE; -- assign command -- assign argList res := obj.processAudioCommand (ctx, command, argList, result); UPDATE TAUD SET aud=obj WHERE N=1 ; COMMIT; EXCEPTION WHEN ORDSYS.ORDSourceExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('Source METHOD_NOT_SUPPORTED caught'); WHEN ORDSYS.ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('SOURCE PLUGIN EXCEPTION caught'); WHEN ORDSYS.ORDAudioExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('AUDIO METHOD_NOT_SUPPORTED EXCEPTION caught'); WHEN ORDSYS.ORDAudioExceptions.AUDIO_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('AUDIO PLUGIN EXCEPTION caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
setAudioDuration(knownAudioDuration IN INTEGER);
Sets the value of the audioDuration attribute of the audio object.
A known audio duration.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
NULL_INPUT_VALUE
This exception is raised if you call the setAudioDuration( ) method and the value for the knownAudioDuration parameter is NULL.
See the example in setProperties( ).
setCompressionType(knownCompressionType IN VARCHAR2);
Sets the value of the compressionType attribute of the audio object.
A known compression type.
The value of the compressionType always matches that of the encoding value because in many audio formats, encoding and compression type are tightly integrated. See Appendix A for more information.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
NULL_INPUT_VALUE
This exception is raised if you call the setCompressionType( ) method and the value for the knownCompressionType parameter is NULL.
See the example in setProperties( ).
setDescription (user_description IN VARCHAR2);
Sets the description of the audio data.
The description of the audio data.
Each audio object may need a description to help some client applications. For example, a Web-based client can show a list of audio descriptions from which a user can select one to access the audio data.
Web-access components and other client components provided with Oracle interMedia make use of this description attribute to present audio data to users.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
None.
Set the description attribute for some audio data:
DECLARE obj ORDSYS.ORDAudio; BEGIN SELECT aud INTO obj FROM TAUD WHERE N=1 FOR UPDATE; DBMS_OUTPUT.PUT_LINE('writing title'); DBMS_OUTPUT.PUT_LINE('-------------'); obj.setDescription('audio1.wav'); DBMS_OUTPUT.PUT_LINE(obj.getDescription()); UPDATE TAUD SET aud=obj WHERE N=1; COMMIT; END; /
setEncoding(knownEncoding IN VARCHAR2);
Sets the value of the encoding attribute of the audio object.
A known encoding type.
The value of encoding always matches that of the compressionType value because in many audio formats, encoding and compression type are tightly integrated. See Appendix A for more information.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
NULL_INPUT_VALUE
This exception is raised if you call the setEncoding( ) method and the value for the knownEncoding parameter is NULL.
See the example in setProperties( ).
setFormat(knownFormat IN VARCHAR2);
Sets the format attribute of the audio object.
The known format of the audio data to be set in the audio object.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
NULL_INPUT_VALUE
This exception is raised if you call the setFormat( ) method and the value for the knownFormat parameter is NULL.
Set the format for some audio data:
DECLARE obj ORDSYS.ORDAudio; BEGIN select aud into obj from TAUD where N =1 for update; obj.setFormat('AUFF'); obj.setEncoding('MULAW'); obj.setNumberOfChannels(1); obj.setSamplingRate(8); obj.setSampleSize(8); obj.setCompressionType('8BITMONOAUDIO'); obj.setAudioDuration(16); DBMS_OUTPUT.put_line('format: ' || obj.getformat); DBMS_OUTPUT.put_line('encoding: ' || obj.getEncoding); DBMS_OUTPUT.put_line('numberOfChannels: ' || TO_CHAR(obj.getNumberOfChannels)); DBMS_OUTPUT.put_line('samplingRate: ' || TO_CHAR(obj.getSamplingRate)); DBMS_OUTPUT.put_line('sampleSize: ' || TO_CHAR(obj.getSampleSize)); DBMS_OUTPUT.put_line('compressionType : ' || obj.getCompressionType); DBMS_OUTPUT.put_line('audioDuration: ' || TO_CHAR(obj.getAudioDuration)); COMMIT; EXCEPTION WHEN ORDSYS.ORDAudioExceptions.NULL_INPUT_VALUE THEN DBMS_OUTPUT.put_line('ORDAudioExceptions.NULL_INPUT_VALUE caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
setKnownAttributes(
knownFormat IN VARCHAR2,
knownEncoding IN VARCHAR2,
knownNumberOfChannels IN INTEGER,
knownSamplingRate IN INTEGER,
knownSamleSize IN INTEGER,
knownCompressionType IN VARCHAR2,
knownAudioDuration IN INTEGER);
Sets the known audio attributes for the audio object.
The known format.
The known encoding type.
The known number of channels.
The known sampling rate.
The known sample size.
The known compression type.
The known audio duration.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
None.
Set the known attributes for the audio data.
DECLARE obj ORDSYS.ORDAudio; BEGIN select aud into obj from TAUD where N =1 for update; obj.setKnownAttributes('AUFF','MULAW', 1, 8, 8, '8BITMONOAUDIO',16); DBMS_OUTPUT.put_line('format: ' || obj.getformat()); DBMS_OUTPUT.put_line('encoding: ' || obj.getEncoding()); DBMS_OUTPUT.put_line('numberOfChannels: ' || TO_CHAR(obj.getNumberOfChannels())); DBMS_OUTPUT.put_line('samplingRate: ' || TO_CHAR(obj.getSamplingRate())); DBMS_OUTPUT.put_line('sampleSize: ' || TO_CHAR(obj.getSampleSize())); DBMS_OUTPUT.put_line('compressionType : ' || obj.getCompressionType()); DBMS_OUTPUT.put_line('audioDuration: ' || TO_CHAR(obj.getAudioDuration())); COMMIT; EXCEPTION WHEN ORDSYS.ORDAudioExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('ORDAudioExceptions.METHOD_NOT_SUPPORTED caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
setNumberOfChannels(knownNumberOfChannels IN INTEGER);
Sets the value of the numberOfChannels attribute for the audio object.
A known number of channels.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
NULL_INPUT_VALUE
This exception is raised if you call the setNumberOfChannels( ) method and the value for the knownNumberOfChannels parameter is NULL.
See the example in setProperties( ).
setProperties(ctx IN OUT RAW,
setComments IN BOOLEAN);
Reads the audio data to get the values of the object attributes and then stores them in the object attributes. This method sets the properties for the following attributes of the audio data: format, encoding type, number of channels, sampling rate, and sample size. It populates the comments field of the object with a rich set of format and application properties in XML form if the value of the setComments parameter is TRUE.
The format plug-in context information.
If the value is TRUE, then the comments field of the object is populated with a rich set of format and application properties of the audio object in XML form, identical to what is provided by the interMedia Annotator utility; otherwise, if the value is FALSE, the comments field of the object remains unpopulated. The default value is FALSE.
If the property cannot be extracted from the media source, then the respective attribute is set to NULL.
If the format is set to NULL, then the setProperties( ) method uses the default format plug-in; otherwise, it uses the plug-in specified by the format.
None.
AUDIO_PLUGIN_EXCEPTION
This exception is raised if you call the setProperties( ) method and the audio plug-in raises an exception.
Set the property information for known audio attributes:
DECLARE obj ORDSYS.ORDAudio; ctx RAW(4000) :=NULL; BEGIN select aud into obj from TAUD where N =1 for update; obj.setProperties(ctx,FALSE); --DBMS_OUTPUT.put_line('format: ' || obj.getformat()); DBMS_OUTPUT.put_line('encoding: ' || obj.getEncoding()); DBMS_OUTPUT.put_line('numberOfChannels: ' || TO_CHAR(obj.getNumberOfChannels())); DBMS_OUTPUT.put_line('samplingRate: ' || TO_CHAR(obj.getSamplingRate())); DBMS_OUTPUT.put_line('sampleSize: ' || TO_CHAR(obj.getSampleSize())); update TAUD set aud = obj where N =1 ; COMMIT; EXCEPTION WHEN ORDSYS.ORDAudioExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('ORDAudioExceptions.METHOD_NOT_SUPPORTED caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
setSamplingRate(knownSamplingRate IN INTEGER);
Sets the value of the samplingRate attribute of the audio object. The unit is Hz.
A known sampling rate.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
NULL_INPUT_VALUE
This exception is raised if you call the setSamplingRate( ) method and the value for the knownSamplingRate parameter is NULL.
See the example in setProperties( ).
setSampleSize(knownSampleSize IN INTEGER);
Sets the value of the sampleSize attribute of the audio object.
A known sample size.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
NULL_INPUT_VALUE
This exception is raised if you call the setSampleSize( ) method and the value for the knownSampleSize parameter is NULL.
See the example in setProperties( ).
This section presents reference information on the packages or PL/SQL plug-ins provided. Table 6-1 describes the PL/SQL plug-in packages provided in the ORDPLUGINS schema.
Section 6.4.1 describes the ORDPLUGINS.ORDX_DEFAULT_AUDIO package, the methods supported, and the level of support. Note that the methods supported and the level of support for the other PL/SQL plug-in packages described in Table 6-1 are identical for all plug-in packages, therefore, refer to Section 6.4.1.
Use the following provided ORDPLUGINS.ORDX_DEFAULT_AUDIO package as a guide in developing your own ORDPLUGINS.ORDX_<format>_AUDIO audio format package. This package sets the mimeType field in the setProperties( ) method with a MIME type value that is dependent on the file format.
CREATE OR REPLACE PACKAGE ORDX_DEFAULT_AUDIO authid current_user AS --AUDIO ATTRIBUTES ACCESSORS --Deprecated Functions Deprecated in Release 8.1.6 Begin Here FUNCTION getFormat(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN VARCHAR2; FUNCTION getEncoding(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN VARCHAR2; FUNCTION getNumberOfChannels(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN INTEGER; FUNCTION getSamplingRate(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN INTEGER; FUNCTION getSampleSize(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN INTEGER; FUNCTION getCompressionType(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN VARCHAR2; FUNCTION getAudioDuration(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN INTEGER; --Deprecated Functions Deprecated in Release 8.1.6 End Here PROCEDURE setProperties(ctx IN OUT RAW, obj IN OUT NOCOPY ORDSYS.ORDAudio, setComments IN NUMBER := 0); FUNCTION checkProperties(ctx IN OUT RAW, obj IN OUT ORDSYS.ORDAudio) RETURN NUMBER; FUNCTION getAttribute(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio, name IN VARCHAR2) RETURN VARCHAR2; PROCEDURE getAllAttributes(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio, attributes IN OUT NOCOPY CLOB); --AUDIO PROCESSING METHODS FUNCTION processCommand(ctx IN OUT RAW, obj IN OUT NOCOPY ORDSYS.ORDAudio, cmd IN VARCHAR2, arguments IN VARHAR2, result OUT RAW) RETURN RAW; PRAGMA RESTRICT_REFERENCES(getFormat, WNDS, WNPS, RNDS, RNPS); PRAGMA RESTRICT_REFERENCES(getEncoding, WNDS, WNPS, RNDS, RNPS); PRAGMA RESTRICT_REFERENCES(getNumberOfChennels, WNDS, WNPS, RNDS, RNPS); PRAGMA RESTRICT_REFERENCES(getSamplingRate, WNDS, WNPS, RNDS, RNPS); PRAGMA RESTRICT_REFERENCES(getSampleSize, WNDS, WNPS, RNDS, RNPS); PRAGMA RESTRICT_REFERENCES(getCompressionType, WNDS, WNPS, RNDS, RNPS); PRAGMA RESTRICT_REFERENCES(getAttribute, WNDS, WNPS, RNDS, RNPS); PRAGMA RESTRICT_REFERENCES(getAudioDuration, WNDS, WNPS, RNDS, RNPS); END; /
Table 6-2 shows the methods supported in the
ORDPLUGINS.ORDX_DEFAULT_AUDIO package and the exceptions raised if you call a method that is not supported.
Extending interMedia to support a new audio data format consists of four steps:
Section 3.1.12 briefly describes how to extend interMedia to support a new audio data format and describes the interface. A package body listing is provided in Example 6-1 to assist you in this operation. Add your variables to the places that say "--Your variables go here" and add your code to the places that say "--Your code goes here".
See Section F.1 for more information on installing your own audio format plug-in and running the sample scripts provided.
CREATE OR REPLACE PACKAGE BODY ORDX_MY_AUDIO AS --AUDIO ATTRIBUTES ACCESSORS FUNCTION getFormat(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN VARCHAR2 IS --Your variables go here BEGIN --Your code goes here END; FUNCTION getEncoding(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN VARCHAR2 IS --Your variables go here BEGIN --Your code goes here END; FUNCTION getNumberOfChannels(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN INTEGER IS --Your variables go here BEGIN --Your code goes here END; FUNCTION getSamplingRate(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN INTEGER IS --Your variables go here BEGIN --Your code goes here END; FUNCTION getSampleSize(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN INTEGER IS --Your variables go here BEGIN --Your code goes here END; FUNCTION getCompressionType(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN VARCHAR2 IS --Your variables go here BEGIN --Your code goes here END; FUNCTION getAudioDuration(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio) RETURN INTEGER IS --Your variables go here BEGIN --Your code goes here END; PROCEDURE setProperties(ctx IN OUT RAW, obj IN OUT NOCOPY ORDSYS.ORDAudio, setComments IN NUMBER :=0) IS --Your variables go here BEGIN --Your code goes here END; FUNCTION checkProperties(ctx IN OUT RAW, obj IN OUT ORDSYS.ORDAudio) RETURN NUMBER IS --Your variables go here BEGIN --Your code goes here END; FUNCTION getAttribute(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio, name IN VARCHAR2) RETURN VARCHAR2 IS --Your variables go here BEGIN --Your code goes here END; PROCEDURE getAllAttributes(ctx IN OUT RAW, obj IN ORDSYS.ORDAudio, attributes IN OUT NOCOPY CLOB) IS --Your variables go here BEGIN --Your code goes here END; -- AUDIO PROCESSING METHODS FUNCTION processCommand( ctx IN OUT RAW, obj IN OUT NOCOPY ORDSYS.ORDAudio, cmd IN VARCHAR2, arguments IN VARCHAR2, result OUT RAW) RETURN RAW IS --Your variables go here BEGIN --Your code goes here END; END; / show errors;
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|