General Information |
Required Schemas |
MDSYS
ORD
ORDPLUGINS |
ordsys.ORDVideo Columns |
Column Name |
Data Type |
DESCRIPTION |
VARCHAR2(4000) |
SOURCE |
ordsys.ORDSOURCE |
|
ordsys.ORDSource Columns |
Column Name |
Data Type |
LOCALDATA |
BLOB |
SRCTYPE |
VARCHAR2(4000) |
SRCLOCATION |
VARCHAR2(4000) |
SRCNAME |
VARCHAR2(4000) |
UPDATETIME |
DATE |
LOCAL |
NUMBER |
|
System Privileges |
GRANT create any directory TO <schema_name> |
GRANT create any directory TO
uwclass; |
|
InterMedia Video
Demo |
Actions As SYS |
CREATE USER uwclass
IDENTIFIED BY uwclass
DEFAULT TABLESPACE uwdata
TEMPORARY TABLESPACE temp
QUOTA 0 ON SYSTEM
QUOTA UNLIMITED ON uwdata;
GRANT create session TO uwclass;
GRANT create any directory TO uwclass;
GRANT create table TO uwclass; |
Actions As Schema Owner |
CONN uwclass/uwclass
CREATE OR REPLACE DIRECTORY videodir AS 'c: emp';
-- verify required objects are visible to schema
SELECT owner, object_name, status
FROM all_objects
WHERE object_name LIKE 'ORD%';
CONN ordsys/ordsys
set linesize 120
col owner format a15
col library_name format a20
col file_spec format a45
SELECT *
FROM all_libraries;
conn uwclass/uwclass
CREATE TABLE t_video (
id NUMBER,
video ordsys.ordvideo);
set describe depth all
desc t_video
set describe depth all linenum on indent on
desc t_video
-- explore what ordvideo is
conn ordsys/ordsys
SELECT object_type
FROM user_objects
WHERE object_name = 'ORDVIDEO';
SELECT DISTINCT object_name
FROM user_arguments
WHERE package_name = 'ORDVIDEO';
conn uwclass/uwclass
-- create initial records
INSERT INTO t_video VALUES (1, ordsys.ordvideo.init());
INSERT INTO t_video VALUES (2, ordsys.ordvideo.init());
COMMIT;
SELECT * FROM t_video;
SELECT id FROM t_video;
set serveroutput on
-- check video attributes by calling methods
DECLARE
obj ordsys.ordvideo;
BEGIN
SELECT video
INTO obj
FROM t_video
WHERE id = 1;
-- access methods
dbms_output.put_line('METHODS');
dbms_output.put_line('-------');
dbms_output.put_line('Description: '||obj.getDescription);
dbms_output.put_line('MimeType: '||obj.getMimeType);
EXCEPTION
WHEN ordsys.ordvideoexceptions.description_is_not_set THEN
dbms_output.put_line('Description: NOT SET');
END;
/
-- set description then invoke a method
DECLARE
obj1 ordsys.ordvideo;
BEGIN
SELECT video
INTO obj1
FROM t_video
WHERE id = 1 FOR UPDATE;
obj1.setDescription('My New Video File');
obj1.setMimeType('video/avi');
dbms_output.put_line('Description: '||obj1.getDescription);
dbms_output.put_line('MimeType: '||obj1.getMimeType);
UPDATE t_video
SET video = obj1
WHERE id=1;
EXCEPTION
WHEN ordsys.ordvideoexceptions.description_is_not_set THEN
dbms_output.put_line('Description: NOT SET');
END;
/
-- try the previous anonymous block again to
-- make sure that no exception is raised
-- try getting the format
DECLARE
obj ordsys.ordvideo;
BEGIN
SELECT video
INTO obj
FROM t_video
WHERE id = 1;
-- access methods
dbms_output.put_line('METHODS');
dbms_output.put_line('-------');
dbms_output.put_line('Format: '|| obj.getFormat);
EXCEPTION
WHEN ordsys.ordvideoexceptions.video_format_is_null THEN
dbms_output.put_line('Format: NOT SET');
END;
/
-- set all the attributes
DECLARE
obj1 ordsys.ordvideo;
ctx RAW(4000) := NULL;
BEGIN
SELECT video
INTO obj1
FROM t_video
WHERE id = 1
FOR UPDATE;
-- set description
obj1.setDescription('Video from a BFILE');
-- set mimetype
obj1.setMimeType('video/x-quicktime');
-- set source
obj1.setSource('FILE', 'VIDEODIR','sphere.mpg');
-- import data
obj1.import(ctx);
-- set video attributes
obj1.setKnownAttributes('MOOV', 400, 300, 1024, 10, 3600, 36000, 'NONE', 256,
28000);
UPDATE t_video
SET video = obj1
WHERE id = 1;
END;
/
-- try again and display different attributes
DECLARE
obj ordsys.ordvideo;
width INTEGER;
height INTEGER;
ctx RAW(4000) := NULL;
BEGIN
SELECT video
INTO obj
FROM t_video
WHERE id = 1;
dbms_output.put_line('METHODS');
dbms_output.put_line('-------');
dbms_output.put_line('Description: '||obj.getDescription);
dbms_output.put_line('Format: '||obj.getFormat);
dbms_output.put_line('MimeType: '||obj.getMimeType);
dbms_output.put_line('Source: '||obj.getSource);
dbms_output.put_line('ContentLength: '||obj.getContentLength(ctx));
obj.getFrameSize(width, height);
dbms_output.put_line('Frame Size: Width: '||width||' , Height: '||height);
dbms_output.put_line('Frame Resolution: '|| obj.getFrameResolution);
dbms_output.put_line('Frame Rate: '||obj.getFrameRate);
dbms_output.put_line('Video Duration: '||obj.getVideoDuration);
dbms_output.put_line('Number Of Frames: '||obj.getNumberOfFrames);
dbms_output.put_line('CompressionType: '||obj.getCompressionType);
dbms_output.put_line('Colors: '|| obj.getNumberOfColors);
dbms_output.put_line('Bit Rate: '||obj.getBitRate);
END;
/
-- use SQL statements to access length, mimetype and commentlength
SELECT t.video.getMimeType() MimeType
FROM t_video t
WHERE t.id = 1;
SELECT t.video.getContentLength()
FROM t_video t
WHERE t.id = 1;
SELECT t.video.getCommentLength()
FROM t_video t
WHERE t.id = 1;
-- now set the source for 2 rows
-----------------------------------------------------------------
-- NOTE THAT VIDEODIR has been defined and the appropriate video
-- file exists in the directory
--
-- If you are using URL then make sure that the specified URL
-- exists and that the video file is accessible from it
-----------------------------------------------------------------
DECLARE
obj1 ordsys.ordvideo;
obj2 ordsys.ordvideo;
BEGIN
SELECT video
INTO obj1
FROM t_video
WHERE id = 1
FOR UPDATE;
SELECT video
INTO obj2
FROM t_video
WHERE id = 2
FOR UPDATE;
obj1.setSource('FILE','VIDEODIR','sphere.mpg');
obj2.setSource('FILE','VIDEODIR','lesson.avi');
-----------------------------------------------
-- HTTP ACCESS
----------------------------------------------- obj2.setSource('HTTP','www.psoug.org/files/intermedia','video2.au');
dbms_output.put_line(obj1.getSource);
dbms_output.put_line(obj2.getSource);
UPDATE t_video
SET video = obj1
WHERE id=1;
UPDATE t_video
SET video = obj2
WHERE id=2;
COMMIT;
END;
/
-- check content lengths and also method not implemented exception
DECLARE
obj ordsys.ordvideo;
ctx RAW(4000) := NULL;
BEGIN
SELECT video
INTO obj
FROM t_video
WHERE id = 1 ;
dbms_output.put_line(obj.getSource);
dbms_output.put_line(obj.getContentLength(ctx));
EXCEPTION
WHEN ordsys.ordvideoexceptions.method_not_supported THEN
dbms_output.put_line('Content length not available for this source');
END;
/
-- check content lengths and also check for
-- source plugin exceptio exception
-- with the current scenario, it means that the
-- method is not implemented
DECLARE
obj2 ordsys.ordvideo;
ctx RAW(4000) := NULL;
BEGIN
SELECT video
INTO obj2
FROM t_video
WHERE id = 2;
dbms_output.put_line(obj2.getSource);
dbms_output.put_line(obj2.getContentLength(ctx));
EXCEPTION
WHEN ordsys.ordsourceexceptions.source_plugin_exception THEN
dbms_output.put_line('Source plugin raised an exception');
WHEN OTHERS THEN
dbms_output.put_line('EXCEPTION CAUGHT');
END;
/
-- import data from both the sources
-----------------------------------------------------
-- All the methods from this point on will only be useful
-- and will not raise exception if the data has been
-- made available
-----------------------------------------------------
DECLARE
obj1 ordsys.ordvideo;
obj2 ordsys.ordvideo;
ctx RAW(4000) := NULL;
BEGIN
SELECT video
INTO obj1
FROM t_video
WHERE id = 1
FOR UPDATE;
SELECT video
INTO obj2
FROM t_video
WHERE id = 2
FOR UPDATE;
dbms_output.put_line(obj1.getSource);
IF obj1.source.isLocal THEN
dbms_output.put_line('OBJ1: Data is local');
ELSE
dbms_output.put_line('OBJ1: Data is external');
END IF;
obj1.import(ctx);
dbms_output.put_line(obj1.getContentLength(ctx));
IF obj1.source.isLocal THEN
dbms_output.put_line('OBJ1: Data is local');
ELSE
dbms_output.put_line('OBJ1: Data is external');
END IF;
dbms_output.put_line(obj2.getSource);
IF obj2.source.isLocal THEN
dbms_output.put_line('OBJ2: Data is local');
ELSE
dbms_output.put_line('OBJ2: Data is external');
END IF;
obj2.import(ctx);
dbms_output.put_line(obj2.getContentLength(ctx));
IF obj2.source.isLocal THEN
dbms_output.put_line('OBJ2: Data is local');
ELSE
dbms_output.put_line('OBJ2: Data is external');
END IF;
UPDATE t_video
SET video = obj1
WHERE id = 1;
UPDATE t_video
SET video = obj2
WHERE id = 2;
COMMIT;
END;
/
-- INSTALL YOUR OWN FORMAT PLUGIN
-- 1. log onto ordplugins/<ordplugins_password>
-- 2. create the type ... see fplugins.sql and fpluginb.sql
-- 3. grant privs to public so that the plugin is visible
-- to all the users
set serveroutput on;
DECLARE
obj ordsys.ordvideo;
BEGIN
SELECT video
INTO obj
FROM t_video
WHERE id = 2
FOR UPDATE;
-- set description
obj.setDescription('Video from a BFILE');
-- set mimetype
obj.setMimeType('video/x-quicktime');
UPDATE t_video
SET VIDEO = obj
WHERE id=2;
END;
/
DECLARE
obj ordsys.ordvideo;
BEGIN
SELECT video
INTO obj
FROM t_video
WHERE id = 2
FOR UPDATE;
obj.setFormat('DEMO');
dbms_output.put_line('FORMAT NOW IS: '||obj.getFormat);
UPDATE t_video
SET video = obj
WHERE id=2;
COMMIt;
END;
/
-- get all stored attributes
DECLARE
obj ordsys.ordvideo;
width INTEGER;
height INTEGER;
ctx RAW(4000) := NULL;
BEGIN
SELECT video
INTO obj
FROM t_video
WHERE id = 2;
dbms_output.put_line('METHODS');
dbms_output.put_line('-------');
dbms_output.put_line('Description: '||obj.getDescription);
dbms_output.put_line('Format: '||obj.getFormat);
dbms_output.put_line('MimeType: '||obj.getMimeType);
dbms_output.put_line('Source: '||obj.getSource);
dbms_output.put_line('ContentLength: '||obj.getContentLength(ctx));
obj.getFrameSize(width, height);
dbms_output.put_line('Frame Size: Width: '||width||' , Height: '||height);
dbms_output.put_line('Frame Resolution: '|| obj.getFrameResolution);
dbms_output.put_line('Frame Rate: '||obj.getFrameRate);
dbms_output.put_line('Video Duration: '||obj.getVideoDuration);
dbms_output.put_line('Number Of Frames: '||obj.getNumberOfFrames);
dbms_output.put_line('CompressionType: '||obj.getCompressionType);
dbms_output.put_line('Colors: '|| obj.getNumberOfColors);
dbms_output.put_line('Bit Rate: '||obj.getBitRate);
END;
/
-- invoke plugin to get attributes
DECLARE
obj ordsys.ordvideo;
width INTEGER;
height INTEGER;
outdata RAW(4000);
retdata RAW(4000);
ctx RAW(4000) := NULL;
BEGIN
SELECT video
INTO obj
FROM t_video
WHERE id = 2;
dbms_output.put_line('METHODS');
dbms_output.put_line('-------');
dbms_output.put_line('Description: '||obj.getDescription);
dbms_output.put_line('Format: '||obj.getFormat);
dbms_output.put_line('MimeType: '||obj.getMimeType);
dbms_output.put_line('Source: '||obj.getSource);
dbms_output.put_line('ContentLength: '||obj.getContentLength(ctx));
obj.getFrameSize(ctx, width, height);
dbms_output.put_line('Frame Size: Width: '||width||' , Height: '||height);
dbms_output.put_line('Frame Resolution: '||
obj.getFrameResolution(ctx));
dbms_output.put_line('Frame Rate: '||obj.getFrameRate(ctx));
dbms_output.put_line('Video Duration: '||obj.getVideoDuration(ctx));
dbms_output.put_line('Number Of Frames: '||obj.getNumberOfFrames(ctx));
dbms_output.put_line('CompressionType: '||obj.getCompressionType(ctx));
dbms_output.put_line('Colors: '|| obj.getNumberOfColors(ctx));
dbms_output.put_line('Bit Rate: '||obj.getBitRate(ctx));
-- get attributes by name
dbms_output.put_line('Copyright: '||obj.getAttribute(ctx, 'Copyright'));
dbms_output.put_line('Owner: '||obj.getAttribute(ctx, 'Owner'));
-- send a command to be processed
retdata := obj.processVideoCommand(ctx, 'increment','4', outdata);
dbms_output.put_line('Result of incrementing 4: '||
utl_raw.cast_to_varchar2(outdata));
END;
/ |
|
|
|