Oracle MultiMedia Audio
Version 11.2.0.1
 
General Information
Source {$ORACLE_HOME}/ord/im/admin
Required Schemas
MDSYS ORDPLUGINS ORDSYS
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
Required System Privileges GRANT create any directory TO <schema_name>;
GRANT create any directory TO uwlass;
Sample Video File Click here to download sphere.mpg
For the demo on this page copy sphere.mpg to c:\temp or if on a real operating system to $HOME and make the appropriate change to the CREATE DIRECTORY DDL below.
 
MultiMedia Audio Demo
Actions as SYS conn / as sysdba

alter user ordsys account unlock identified by ordsys;

-- if an application schema does not already exist
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;
GRANT create directory TO uwclass;
Actions as application owner conn uwclass/uwclass

CREATE OR REPLACE DIRECTORY audiodir AS 'c:\temp';

-- verify required objects are visible to schema
SELECT owner, object_name, status
FROM all_objects
WHERE object_name LIKE 'ORD%';

conn ordsys/ordsys

col owner format a10
col library_name format a15
col file_spec format a55

SELECT *
FROM all_libraries;

-- explore what ordaudio is
SELECT object_type
FROM user_objects
WHERE object_name = 'ORDAUDIO';

SELECT DISTINCT object_name
FROM user_arguments
WHERE package_name = 'ORDAUDIO'
ORDER BY 1;

conn uwclass/uwclass

CREATE TABLE t_audio (
aid   NUMBER,
audio ordsys.ordaudio);

desc t_audio

set describe depth all

desc t_audio

set describe depth all linenum on indent on

desc t_audio

-- create initial records
INSERT INTO t_audio VALUES (1, ordsys.ordaudio.init());
INSERT INTO t_audio VALUES (2, ordsys.ordaudio.init());
COMMIT;

-- this will fail
SELECT * FROM t_audio;

SELECT aid FROM t_audio;

set serveroutput on

-- check audio attributes by calling methods
DECLARE
 obj ordsys.ordaudio;
BEGIN
  SELECT audio
  INTO obj
  FROM t_audio
  WHERE aid = 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.ordaudioexceptions.description_is_not_set THEN
    dbms_output.put_line('Description: NOT SET');
END;
/

-- set description then invoke a method
DECLARE
obj ordsys.ordaudio;
BEGIN
  SELECT audio
  INTO obj
  FROM t_audio
  WHERE aid = 1 FOR UPDATE;

  obj.setDescription('My New Audio File');
  obj.setMimeType('audio/basic');

  dbms_output.put_line('Description: ' || obj.getDescription);
  dbms_output.put_line('MimeType: ' || obj.getMimeType);

  UPDATE t_audio
  SET audio = obj
  WHERE aid=1;
EXCEPTION
  WHEN ordsys.ordaudioexceptions.description_is_not_set THEN
    dbms_output.put_line('Description: NOT SET');
END;
/

-- load audio files from disk to table
DECLARE
 obj1 ordsys.ordaudio;
 obj2 ordsys.ordaudio;
BEGIN
  SELECT audio
  INTO obj1
  FROM t_audio
  WHERe id = 1
  FOR UPDATE;

  SELECT audio
  INTO obj2
  FROM t_audio
  WHERE id = 2
  FOR UPDATE;

  obj1.setSource('FILE', 'AUDIODIR', 'aud1.wav');
  obj2.setSource('FILE', 'AUDIODIR', 'aud2.mp3');

-----------------------------------------------
-- HTTP ACCESS
-----------------------------------------------
----------------------------------------------------------
-- THE NEXT LINE HAS BEEN COMMENTED FOR AUTOMATED TESTING
-- PLEASE UNCOMMENT IT TO TRY OUT THE COMMAND.
----------------------------------------------------------
--obj2.setSource('HTTP','www.mlib.org/multimedia','audio2.au');

  dbms_output.put_line(obj1.getSource);
  dbms_output.put_line(obj2.getSource);

  UPDATE t_audio
  SET audio=obj1
  WHERE aid=1;

  UPDATE t_audio
  SET audio=obj2
  WHERE aid=2;

  COMMIT;
END;
/


hmm
-- try to retrieve the format
DECLARE
obj ordsys.ordaudio;
BEGIN
  SELECT audio
  INTO obj
  FROM t_audio
  WHERE aid = 1;

  -- access methods
  dbms_output.put_line('METHODS');
  dbms_output.put_line('-------');
  dbms_output.put_line('Format: '|| obj.getFormat);
EXCEPTION
  WHEN ordsys.ordaudioexceptions.audio_format_is_null THEN
    dbms_output.put_line('Format: NOT SET');
END;
/

-- use SQL statements to access length, mimetype and commentlength
SELECT T.audio.getMimeType() MimeType
FROM t_audio t WHERE t.aid = 1;

SELECT t.audio.getContentLength()
FROM t_audio T WHERE t.aid = 1;

SELECT T.audio.getCommentLength()
FROM t_audio T WHERE t.aid = 1;

-- set all attributes
DECLARE
 obj ordsys.ordvideo;
 ctx RAW(4000) := NULL;
BEGIN
  SELECT video
  INTO obj
  FROM t_video
  WHERE vid = 1
  FOR UPDATE;

  -- set description
  obj.setDescription('Video from a BFILE');
  -- set mimetype
  obj.setMimeType('video/x-quicktime');
  -- set source
  obj.setSource('FILE', 'VIDEODIR','sphere.mpg');
  -- import data
  obj.import(ctx);
  -- set video attributes
  obj.setKnownAttributes('MOOV', 400, 300, 1024, 10, 3600, 36000, 'NONE', 256, 28000);

  UPDATE t_video
  SET video = obj
  WHERE vid = 1;
END;
/

-- do it again and display different attributes
DECLARE
 obj     ordsys.ordvideo;
 ctx     RAW(4000) := NULL;
 width   INTEGER;
 height  INTEGER;
BEGIN
  SELECT video
  INTO obj
  FROM t_video
  WHERE vid = 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.vid = 1;

SELECT t.video.getContentLength()
FROM t_video t
WHERE t.vid = 1;

SELECT t.video.getCommentLength()
FROM t_video t
WHERE t.vid = 1;

-- 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 vid = 1
  FOR UPDATE;

  SELECT video
  INTO obj2
  FROM t_video
  WHERE vid = 2
  FOR UPDATE;

  obj1.setSource('FILE','VIDEODIR','sphere.mpg');
  obj2.setSource('FILE','VIDEODIR','navigation.avi');

-----------------------------------------------
-- HTTP ACCESS
-----------------------------------------------
--
  obj2.setSource('HTTP','www.mlib.org/files/intermedia','video2.au');

  dbms_output.put_line(obj1.getSource);
  dbms_output.put_line(obj2.getSource);

  UPDATE t_video
  SET video = obj1
  WHERE vid=1;

  UPDATE t_video
  SET video = obj2
  WHERE vid=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 vid = 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
 obj ordsys.ordvideo;
 ctx RAW(4000) := NULL;
BEGIN
  SELECT video
  INTO obj
  FROM t_video
  WHERE vid = 2;

  dbms_output.put_line(obj.getSource);
  dbms_output.put_line(obj.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 vid = 1
  FOR UPDATE;

  SELECT video
  INTO obj2
  FROM t_video
  WHERE vid = 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 vid = 1;

  UPDATE t_video
  SET video = obj2
  WHERE vid = 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


DECLARE
 obj ordsys.ordvideo;
BEGIN
  SELECT video
  INTO obj
  FROM t_video
  WHERE vid = 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 vid=2;
END;
/

DECLARE
 obj ordsys.ordvideo;
BEGIN
  SELECT video
  INTO obj
  FROM t_video
  WHERE vid = 2
  FOR UPDATE;

  obj.setFormat('DEMO');

  dbms_output.put_line('FORMAT NOW IS: '||obj.getFormat);

  UPDATE t_video
  SET video = obj
  WHERE vid=2;

  COMMIT;
END;
/

-- get all stored attributes
DECLARE
 obj    ordsys.ordvideo;
 ctx    RAW(4000) := NULL;
 width  INTEGER;
 height INTEGER;
BEGIN
  SELECT video
  INTO obj
  FROM t_video
  WHERE vid = 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;
 ctx     RAW(4000) := NULL;
 outdata RAW(4000);
 retdata RAW(4000);
 width   INTEGER;
 height  INTEGER;
BEGIN
  SELECT video
  INTO obj
  FROM uwclass.t_video
  WHERE vid = 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);

  -- the last lines are commented out while I get a fix from MOS.
  -- 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;
/
 
 
Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2014 Daniel A. Morgan All Rights Reserved