Skip Headers

Oracle® interMedia Annotator User's Guide
Release 9.2
Part No. A96120-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Previous Next

5
Creating PL/SQL Upload Templates

Oracle interMedia Annotator can upload media data and an associated annotation into an Oracle database where Oracle interMedia has been installed. It does so through an Oracle PL/SQL Upload Template, which contains both PL/SQL calls and keywords specific to interMedia Annotator.

You create your own PL/SQL Upload Templates using a text editor.

5.1 Overview of Uploading Media Data

Oracle interMedia Annotator can use two different methods to upload the media data and associated annotation to your database: import and remote.

In the import upload method, the media source must be visible to the database server (either in a file system or through an HTTP stream). The media source will be loaded directly from the file system to the database. The import upload method uses the Oracle interMedia import( ) method.

In the remote upload method, the media source does not have to be visible to the database. The file is loaded into interMedia Annotator, which loads the file into the database through JDBC calls. The remote upload method uses the ${MANN_UPLOAD_SRC} interMedia Annotator-specific keyword.

Note the following about the upload methods:

Using a combination of PL/SQL and keywords specific to Oracle interMedia Annotator, you upload the media data and the annotation into a table in an Oracle database. The table must have at least one column of the appropriate interMedia object type, such as ORDSYS.ORDAudio for annotations for audio files, ORDSYS.ORDImage for annotations for image files, or ORDSYS.ORDVideo for annotations for video files.

You can insert the data into a new row in the table, or you can update an existing row in the table.

Section 5.3 describes the interMedia Annotator-specific keywords.

5.2 Creating a PL/SQL Upload Template

Use any text editor to create the PL/SQL Upload Template. Note the following about the structure of a PL/SQL Upload Template:

Depending on the platform of the database server, there may be a limit on the maximum size of the anonymous PL/SQL block. If you encounter this problem, you can work around it by packaging some of your statements into PL/SQL procedures in order to reduce the size of your PL/SQL block.

5.3 Annotator-Specific Keywords

In addition to standard PL/SQL calls, the PL/SQL Upload Templates contain Annotator-specific keywords. The keywords are delimited by a dollar sign and a left brace (${ ) at the beginning of a keyword and a right brace at the end of the keyword (}). These keywords are interpreted by the interMedia Annotator preprocessor, which then generates the appropriate PL/SQL code.


Note:

An interMedia Annotator-specific keyword must appear on its own line in the PL/SQL Upload Template. You cannot have multiple keywords on the same line.

You can use attributes names as keywords, as described in Section 5.3.1. In addition, you can use the keywords described in Section 5.3.2 through Section 5.3.6.

5.3.1 Attribute Values

Instead of hard-coding values for specific attributes in your PL/SQL Upload Template, you provide the name of the attribute, enclosed by the ${ and } characters. This tells the preprocessor to get the actual value of the attribute from the current annotation, and to use that value to replace the keyword in the PL/SQL Upload Template. This simple replacement lets you use the same PL/SQL Upload Template for multiple annotations.

Example 5-1 shows keywords that will later be replaced with attribute values.

Example 5-1 Attribute Names as Keywords

audioObj.setMimeType('${MEDIA_SOURCE_MIME_TYPE}');
INSERT INTO movieTable VALUES (videoSeq.NEXTVAL -- VideoID
                      '${MEDIA_SOURCE_FILENAME}', 
                      '${MEDIA_TITLE}',
                      '${MOVIE_DIRECTOR}', 
                      '${MOVIE_CAST}',
                      ORDSYS.ORDVIDEO.init());

For a list of attribute names defined by interMedia Annotator, see Appendix C.

5.3.2 ${MANN_BEGIN_ITERATE} and ${MANN_END_ITERATE}

The ${MANN_BEGIN_ITERATE} and ${MANN_END_ITERATE} keywords indicate that the code enclosed by the keywords should be repeated for each subannotation of the given type. The name of the annotation type follows the ${MANN_BEGIN_ITERATE} keyword.

Example 5-2 shows a block of code that will be run for each TextSampleAnn annotation that exists as a subannotation of the current annotation.

Example 5-2 ${MANN_BEGIN_ITERATE} and ${MANN_END_ITERATE}

${MANN_BEGIN_ITERATE} TextSampleAnn
     INSERT INTO txtSampleTable VALUES (currClipId,  -- VideoID 
                                        trackId,
                                        ROUND(${(seconds)SAMPLE_TIMESTAMP}, 4),
                                        '${TEXTSAMPLE_VALUE}' );

5.3.3 ${MANN_BEGIN_IFDEF} and ${MANN_END_IFDEF}

The ${MANN_BEGIN_IFDEF} and ${MANN_END_IFDEF} keywords indicate that the code enclosed by the keywords should be executed only if the current annotation has a defined value for a given attribute. The name of the attribute follows the ${MANN_BEGIN_IFDEF} keyword.

Example 5-3 shows a block of code that executes only if the MEDIA_SOURCE_MIME_TYPE attribute is defined in the current annotation.

Example 5-3 ${MANN_BEGIN_IFDEF} and ${MANN_END_IFDEF}

${MANN_BEGIN_IFDEF} MEDIA_SOURCE_MIME_TYPE
videoObj.setMimeType('${MEDIA_SOURCE_MIME_TYPE}');
${MANN_END_IFDEF}

5.3.4 ${MANN_BEGIN_IFEQUALS} and ${MANN_END_IFEQUALS}

The ${MANN_BEGIN_IFEQUALS} and ${MANN_END_IFEQUALS} keywords indicate that the code enclosed by the keywords should be executed only if the current annotation contains a given attribute of a given value. The name of the attribute and the value follow the ${MANN_BEGIN_IFEQUALS} keyword. The string comparison is case-sensitive.

Example 5-4 shows a block of code that is executed only if the MEDIA_SOURCE_MIME_TYPE attribute is defined as audio/basic in the current annotation.

Example 5-4 ${MANN_BEGIN_IFEQUALS} and ${MANN_END_IFEQUALS}

${MANN_BEGIN_IFEQUALS} MEDIA_SOURCE_MIME_TYPE audio/basic
audioObj.setMimeType('${MEDIA_SOURCE_MIME_TYPE}');
${MANN_END_IFEQUALS}

5.3.5 ${MANN_UPLOAD_SRC}

The ${MANN_UPLOAD_SRC} keyword indicates that the media source data associated with the current annotation should be uploaded to the current Oracle database table using JDBC. The file is loaded into interMedia Annotator, which loads the file into the database. The name of the server-side object and attribute (of the BLOB type) follows the ${MANN_UPLOAD_SRC} keyword.

Upload performance with the ${MANN_UPLOAD_SRC} keyword may be slow if you are using the JDBC Thin driver to upload a large media source, or if you have a slow network connection. You may get better results by using the interMedia import( ) method. See Section 5.1 for more information on the differences between the two upload options. See Oracle interMedia User's Guide and Reference for more information on the import( ) method.

Example 5-5 shows a block of code that uploads the current media source data to the source.localData attribute of the server-side interMedia object videoObj.

Example 5-5 ${MANN_UPLOAD_SRC}

${MANN_UPLOAD_SRC} videoObj.source.localData

5.3.6 ${MANN_UPLOAD_XML}

The ${MANN_UPLOAD_XML} keyword indicates that the current annotation should be uploaded to the current Oracle database table. The annotation should be uploaded to a CLOB in an Oracle interMedia object. The name of the server-side object and CLOB attribute follows the ${MANN_UPLOAD_XML} keyword.

Example 5-6 shows a block of code that uploads the current annotation to the comments attribute of the server-side interMedia object videoObj.

Example 5-6 ${MANN_UPLOAD_XML}

${MANN_UPLOAD_XML} videoObj.comments

For more information on Oracle interMedia APIs, see Oracle interMedia User's Guide and Reference.

5.4 Complete PL/SQL Upload Template Example

Example 5-7 contains a sample PL/SQL Upload Template. It uploads a video object and its associated annotation to an Oracle database table named MediaTable. The sample contains one anonymous PL/SQL block containing a mix of PL/SQL calls and keywords specific to interMedia Annotator.

Example 5-7 PL/SQL Upload Template Sample

DECLARE
   videoObj       ORDSYS.ORDVIDEO;
   ctx            RAW(64) := NULL;
BEGIN
   INSERT INTO MediaTable VALUES (
      1,
      ORDSYS.ORDVIDEO.init();
   SELECT M.mediaSource INTO videoObj 
   FROM   MediaTable M
   WHERE  M.MediaId = 1
   FOR UPDATE;
   ${MANN_BEGIN_IFDEF} MEDIA_SOURCE_MIME_TYPE
   videoObj.setMimeType('${MEDIA_SOURCE_MIME_TYPE}');
   ${MANN_END_IFDEF}
   ${MANN_UPLOAD_SRC} videoObj.source.localData
   ${MANN_UPLOAD_XML} videoObj.comments
   UPDATE MediaTable M SET M.mediaSource = videoObj
   WHERE  M.mediaId = 1;
END;

In addition to setting the MEDIA_SOURCE_MIME_TYPE as shown in Example 5-7, you can set other attributes, such as the MEDIA_TITLE, MEDIA_SOURCE_DIRECTORY, and MEDIA_SOURCE_FILE_FORMAT. See Oracle interMedia User's Guide and Reference for more information.

5.5 Saving Files

After you have written your PL/SQL Upload Template, save it with the suffix .ofm. Oracle interMedia Annotator uses the following default directory for PL/SQL Upload Templates:

To change the default directory, modify the value of the ofmDirectory parameter in the Annotator.prefs file.




Previous Next
Oracle Logo
Copyright © 1999,  2002 Oracle Corporation

All rights reserved
Go To Documentation Library
Library
Go To Product List
Product
Go To Table Of Contents
Contents

Master Index
Go To Index
Index

Feedback