IBM Books

Image, Audio, and Video Extenders Administration and Programming

DB2Video


Image Audio Video
    X

Stores the content of a video in a database table. The video source can be in a client buffer, client file, or server file. The video can be stored in the database table as a BLOB, or in a server file (referred to by the database table). The video source can be in a supported format, in which case the DB2 Video Extender identifies its attributes for storage, or in an unsupported format, in which case the attributes must be specified in the UDF.

Include file

dmbvideo.h

Syntax

Store content from buffer or client file

>>-DB2Video--(--dbname--,--content--,--format--,---------------->
 
>----target_file--,--comment--)--------------------------------><
 

Syntax

Store content from server file

>>-DB2Video--(--dbname--,--source_file--,--format--,--stortype--,-->
 
>---comment--)-------------------------------------------------><
 

Syntax

Store content with user-supplied attributes from buffer or client file

>>-DB2Video--(--dbname--,--content--,--target_file--,----------->
 
>----comment--,--attrs--,--thumbnail--)------------------------><
 

Syntax

Store content with user-supplied attributes from server file

>>-DB2Video--(--dbname--,--source_file--,--stortype--,--comment--,-->
 
>---attrs--,--thumbnail--)-------------------------------------><
 

Parameters (data type)

dbname (VARCHAR(18))
The name of the currently connected database, as indicated by the CURRENT SERVER special register.

content (BLOB(2G) AS LOCATOR)
The host variable that contains the content of the video. The host variable can be of data type BLOB, BLOB_FILE, or BLOB_LOCATOR. DB2 promotes the content to BLOB_LOCATOR and passes the LOB locator to the DB2Video UDF. If the content is in a client buffer, the buffer must contain at least the first 640 KB of the content to ensure that the complete video header is read.

format (VARCHAR(8))
The format of the source video. If a null value or empty string is specified, the Video Extender will attempt to determine the source format automatically. The video will be stored in the same format as its source.See Table 4 for supported video formats. For MPG1 format, you can specify MPG1, mpg1, MPEG1, or mpeg1. For MPG2 format, you can specify MPG2, mpg2, MPEG2, or mpeg2.

target_file (LONG VARCHAR)
The name of the target server file (for storage to a server file), or a null value or empty string (for storage into a database table as a BLOB). The server file can must be a fully qualified name. If the file name is unqualified, the DB2VIDEOSTORE and DB2MMSTORE environment variables on the server are used to locate the file.

source_file (LONG VARCHAR)
The name of the source server file. The name can be a fully qualified name or an unqualified name; it cannot be a null value or empty string. If the name is unqualified, the DB2VIDEOPATH and DB2MMPATH environment variables on the server will be used to locate the file.

stortype (INTEGER)
A value that indicates where the video will be stored. The constant MMDB_STORAGE_TYPE_INTERNAL (value=1) indicates that the video will be stored in the database as a BLOB; the constant MMDB_STORAGE_TYPE_EXTERNAL (value=0) indicates that the video content will be stored in a server file (pointed to from the database).

comment (LONG VARCHAR)
A comment to be stored with the video.

attrs (LONG VARCHAR FOR BIT DATA)
The attributes of the video.

thumbnail (LONG VARCHAR FOR BIT DATA)
A thumbnail image that represents the video.

Return values (data type)

Handle of the video (DB2VIDEO)

Examples

Insert a record that includes a video clip for Anita Jones into the employee table. The video source is in a client buffer. Store the video clip in the table as a BLOB:

EXEC SQL BEGIN DECLARE SECTION
     SQL TYPE IS BLOB (8M) vid;
EXEC SQL END DECLARE SECTION;
 
EXEC SQL INSERT INTO EMPLOYEE VALUES(
      '128557',
      'Anita Jones',
      DB2VIDEO(
         CURRENT SERVER,
         :vid,
         'MPEG1',
         CAST(NULL as LONG VARCHAR),
         'Anita''s video'));

Insert a record that includes a video clip for Robert Smith into the employee table. The video source is in a server file. The employee table record will point to the file:

EXEC SQL BEGIN DECLARE SECTION;
long hvStorageType;
EXEC SQL END DECLARE SECTION;
 
hvStorageType = MMDB_STORAGE_TYPE_EXTERNAL;
 
EXEC SQL INSERT INTO EMPLOYEE VALUES(
      '384779',
      'Robert Smith',
      DB2VIDEO(
         CURRENT SERVER,
         '/employee/videos/rsmith.mpg',
         'MPEG1',
         :hvStorageType,
         'Robert''s video'));

Insert a record that includes a video clip in a database table. The source video clip, which is in a server file, has a user-defined format. Keep the video content in the server file (the database table record will point to the file). Also store a thumbnail that represents the video:

EXEC SQL BEGIN DECLARE SECTION;
long hvStorageType;
struct {
       short len;
       char data[400];
}hvVidattrs;
struct {
       short len;
       char data[10000];
}hvThumbnail;
EXEC SQL END DECLARE SECTION;
 
MMDBVideoAttrs         *pvideoAttr;
 
hvStorageType = MMDB_STORAGE_TYPE_EXTERNAL;
 
pvideoAttr=(MMDBVideoAttrs *)hvVidattrs.data;
strcpy(pvideoAttr>cFormat,"Formatv");
pvideoAttr.len=sizeof(MMDBVideoAttrs);

·
·
·
/* Generate thumbnail and assign data */ /* in video structure */
·
·
·
EXEC SQL INSERT INTO EMPLOYEE VALUES( '128557', 'Anita Jones', DB2VIDEO( CURRENT SERVER, '/employee/videos/ajones.vid', :hvStorageType, 'Anita''s video', :hvVidattrs, :hvThumbnail) );


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]