Extending interMedia Image, Audio and Video Format Support

C. Extending interMedia Video Format Support

 

interMedia provides native support and understanding for popular video formats including RealMedia, QuickTime, and AVI. For all formats, both those natively understood, and those not natively understood, interMedia is able to store and retrieve the video, and associate the video with other relational data. 


This section describes the two levels of support that are possible for video formats that are not natively understood by interMedia:

 

To store and retrieve video data in the database (no attribute extraction)

Any video, regardless of format, can be stored in the interMedia ORDVideo object. However, the setProperties() method cannot be used to automatically extract attributes from foreign video formats. Instead, video data can be stored, and video attributes can be set explicitly in ORDVideo object attributes. 

If you do not need automatic metadata extraction or processing of your foreign video format, you can perform the following steps to load/retrieve foreign video with the ORDVideo object: 

  • Create an empty ORDVideo object. 
  • Call the setMimeType() method and provide a MIME type.
  • Check the target client player documentation to determine if additional attributes are needed by the player to read and play rich media data retrieved from Oracle8i. 
  • Use the import() method to load the video from the file system or URL into the database. 

 

Example 7: Loading a foreign video (Loading a Macromedia Flash movie)
set serveroutput on
set echo on

create table movies
(id			number,
 video		ordsys.ordvideo);

create or replace directory viddir as 'c:\temp\';


create sequence videoseq start with 1;

create or replace procedure load_video_swf(file_name varchar)
as
	obj ORDSYS.ORDVideo;
	nxtSeq number;
	ctx raw(4000):=null;

BEGIN
	select videoseq.nextval into nxtseq from dual;


	insert into movies (id, video) values (nxtseq,
		ORDSYS.ORDVideo(NULL,ORDSYS.ORDSource(EMPTY_BLOB(),
			NULL,NULL,NULL,SYSDATE,NULL),NULL,NULL, EMPTY_CLOB(), 					
			NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL)); 

	select t.video into obj from movies t
	where t.id = nxtseq for update;

	obj.setMimeType('application/x-shockwave-flash');
	obj.importFrom(ctx, 'FILE', 'VIDDIR', file_name);

	update movies t set t.video=obj
	where t.id = nxtseq;


	commit;
END;
/
show errors;


-- format is load_video_swf(file_name)
begin load_video_swf('title_movie.swf'); 
end;
/

 

To extend the interMedia ORDVideo data type with new format support

 

Extending interMedia to understand a new video format consists of several steps:
  1. Design your new video data format
  2. Implement your new video data format as a PL/SQL package called ORDX_<format>_VIDEO  (where <format> is the name of the new video data format).
  3. Install your new ORDX_<format>_VIDEO plug-in in the ORDPLUGINS schema.
  4. Grant EXECUTE privilege on your new plug-in
To support a new video data format, implement the required interfaces in the ORDX_<format>_VIDEO package in the ORDPLUGINS schema (where <format> represents the name of the new video data format). See Section 5.3 "Packages or PL/SQL Plug-ins" in Oracle interMedia Audio, Image, and Video User's Guide and Reference for a complete description of the interfaces for the ORDX_DEFAULT_VIDEO package. Use the package body example in Section 5.3.2 as a template to create the video package body.   For your convenience, this example is duplicated here as Example 9.  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". Note that these procedures may call JAVA stored procedures in the database or an external 'C' code procedure to parse the data. 

Install your new format plug-in by running SQL*Plus, logging into the ORDPLUGINS schema and loading the SQL scripts that contain your package and package body definitions.  Then grant execute privilege on your plug-in package.  Assuming ORDX_FLASH_VIDEO.SQL contains your package and package body, the following commands will load the plug-in and grant execute privilege on the plug-in.

    SQL> connect ORDPLUGINS/<ordplugins password>
    SQL> @ORDX_FLASH_VIDEO.SQL
    SQL> grant EXECUTE on ORDX_FLASH_VIDEO to public with grant option;

Now that the plug-in is loaded and available to interMedia, it can be used to manipulate video data of format "FLASH" stored in an ORDVideo object.  To cause interMedia to invoke your new format plug-in, first set the format attribute of the ORDVideo object to your format ("FLASH" in the above example) using the setFormat method.  Subsequent method invocations will execute the functions and procedures defined in your format plug-in.

 

Example 8: Invoking Your New Video Format Plug-in

DECLARE
        obj ORDSYS.ORDVideo;
        ctx raw(4000):=null;

BEGIN
        select t.video into obj from movies t
             where t.id = 1 for update;

        obj.setFormat('FLASH');
        obj.setProperties(ctx);

        update movies t set t.video=obj
            where t.id = 1;

        commit;
END;
/
show errors;
 
 

To support video data processing, that is, the passing of an video processing command and set of arguments to a format plug-in for processing, use the processVideoCommand( ) method. This method is only available for user-defined formats. See "processVideoCommand( ) Method" in Chapter 5 and Section 2.3.12 for a description.

 


Example 9: The Package Body for Extending Support to a New Video Data Format

CREATE OR REPLACE PACKAGE BODY ORDX_MY_VIDEO
AS
  --VIDEO ATTRIBUTES ACCESSORS
  FUNCTION  getFormat(ctx
                      IN OUT RAW,
                      obj IN ORDSYS.ORDVideo)
  RETURN VARCHAR2
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  FUNCTION  getAttribute(ctx IN OUT RAW,
                         obj IN ORDSYS.ORDVideo,
                         name IN VARCHAR2)
  RETURN VARCHAR2
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;
 
  PROCEDURE getFrameSize(ctx IN OUT RAW,
                         obj IN ORDSYS.ORDVideo,
                         width OUT INTEGER,
                         height OUT INTEGER)
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  FUNCTION  getFrameResolution(ctx IN OUT RAW,
                               obj IN ORDSYS.ORDVideo)
  RETURN INTEGER
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  FUNCTION  getFrameRate(ctx IN OUT RAW,
                         obj IN ORDSYS.ORDVideo)
  RETURN INTEGER
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  FUNCTION  getVideoDuration(ctx IN OUT RAW,
                             obj IN ORDSYS.ORDVideo)
  RETURN INTEGER
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  FUNCTION  getNumberOfFrames(ctx IN OUT RAW,
                              obj IN ORDSYS.ORDVideo)
  RETURN INTEGER
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  FUNCTION  getCompressionType(ctx IN OUT RAW,
                               obj IN ORDSYS.ORDVideo)
  RETURN VARCHAR2
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  FUNCTION  getNumberOfColors(ctx IN OUT RAW,
                              obj IN ORDSYS.ORDVideo)
  RETURN INTEGER
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  FUNCTION  getBitRate(ctx IN OUT RAW,
                       obj IN ORDSYS.ORDVideo)
  RETURN INTEGER
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  PROCEDURE setProperties(ctx IN OUT RAW, 
                          obj IN OUT NOCOPY ORDSYS.ORDVideo,
                          setComments IN NUMBER :=0)
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  FUNCTION checkProperties(ctx IN OUT RAW,
                           obj IN ORDSYS.ORDVideo)
  RETURN NUMBER
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  PROCEDURE getAllAttributes(ctx IN OUT RAW,
                             obj IN ORDSYS.ORDVideo,
                             attributes IN OUT NOCOPY CLOB)
  IS
--Your variables go here
  BEGIN
--Your code goes here
  END;

  -- VIDEO PROCESSING METHODS
  FUNCTION  processCommand(ctx       IN OUT RAW,
                           obj       IN OUT NOCOPY ORDSYS.ORDVideo,
                           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;



 

E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy