Skip to main content

How to get Player to use a custom DataSource

2 replies [Last post]
jeng_sci
Offline
Joined: 2008-11-11

Hi,

I am just starting out with OCAP development and have a question. I have created a new DataSource class that retrieves streaming MPEG packets from my video server. When I try to create the DataSource object to pass it to my Player, I get a NoDataSourceException.

I have read in JMF books that I need to register my protocol prefix with the PackageManager first. I have done this, however, when I try to commit() my changes, I get a SecurityException.

So what do I have to do to make my xlet find and use my custom DataSource.

Here is a code snippet.

package com.testme;
// My DataSource is located at com.testme.media.protocol.xyz.DataSource;

private void CreateMyPlayer()
{
javax.media.MediaLocator locator = null;
javax.media.protocol.DataSource ds = null;
javax.media.Player player = null;

try {
// Tell the PackageManager about my datasource.
Vector packagePrefix = PackageManager.getProtocolPrefixList();
packagePrefix.insertElementAt("com.testme.media.protocol", 0);
PackageManager.setProtocolPrefixList(packagePrefix);
//PackageManager.commitProtocolPrefixList(); // this generates a SecurityException.

locator = new MediaLocator("xyz://myServer?a=123");
ds = Manager.createDataSource(locator); // this generates a NoDataSourceException
player = Manager.createPlayer(ds);
}
catch (Exception e) {
e.printStackTrace();
}
}

I have verified that my class prefix is listed in the PackageManager temporarily. Also, the DataSource is found if I run this as a plain Java application and not a Xlet.

Thanks,
jeng_sci

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
krishnaveni17
Offline
Joined: 2008-09-24

Hi,

The javadoc for commitProtocolPrefixList() method indicates that a SecurityException is thrown if the calling thread does not have access to system properties. The Read/Write permission for a particular system property is set by the constructor for the java.util.PropertyPermission Class. However, in general, access to properties is set by the current security manager. Since running the app as a java app does not throw an exception, then the problem is with setting properties for the xlet, which in this case has been treated like an applet. Thus, the permissions have to be set in the Security Manager with java.lang.System.setSecurityManger().

Please let me know if it works for you or in case you need further information.

Thanks,
krishna.

jeng_sci
Offline
Joined: 2008-11-11

Thanks for the reply. Changing the Security Permissions is a good place to resolve this issue. I am currently using the Vision Workbench to do my developing. This program uses a permission file (XML) and checks it against "http://www.opencable.com/ocap/dtd/permissionrequestfile-1-0.dtd". I cant get the DTD to determine which system property to change.

Do you know which system property I need to change?
or
where I can get a copy of the DTD?
or
where there is a full example of using a permission file?

Thanks,
jeng_sci