Java Media Control API: Driver and Factory
In the last blog, I gave an overview of the core objects in Java Media Control API, a.k.a. JSR 309. But how do you create these media objects in the first place?
Here is the object ownership in Java Media Control API.
The root object – MsControlFactory – can be obtained from a Java Media Control Driver.
Java Media Control API uses a driver model similar to the JDBC driver model. Different implementations (for different media servers) register themselves to the DriverManager as Drivers. Or the implementations can be packaged as Service Provider jar and loaded by the DriverManager automatically.
DriverManager provides several static functions to get Drivers or MsControlFactory directly.
E.g. to get MsControlFactory for a Voxeo Prism’s driver, the following code can be used.
Properties props = new Properties(); props.put(MsControlFactory.MEDIA_SERVER_URI, "mrcp://127.0.0.1"); MsControlFactory factory = DriverManager.getFactory("com.voxeo.Driver_1.0", props);Or you can simply use dependency injection to let the container to create MsControlFactory automatically.
@Resource MsControlFactory factory;Once you have a MsControlFactory instance, you can create one or more MediaSessions, which is the container and factory for all the MediaObjects, such as NetworkConnection, MediaGroup, and MediaMixer.
Typically the first thing an application will do is to setup a NetworkConnection for each client that is connecting to the media server. I will go over that in detail in the next blog.
Originally from Voxeo Blogs


Leave a Reply