JMF: getting player for current service question

On interactivetvweb.org I found something like this:

// Get a reference to the JavaTV ServiceContextFactory

ServiceContextFactory factory;

factory = ServiceContextFactory.getInstance();

// From this, we can get a reference to the parent

// service context of our Xlet. To do this, we need a

// reference to our Xlet context. It's times like this

// that show why your application should always keep a

// reference to its Xlet context

ServiceContext myContext;

myContext = factory.getServiceContext(myXletContext);

// ServiceContentHandler objects are responsible for

// presenting the different parts of the service. This

// includes the media components

ServiceContentHandler[] handlers;

handlers = myContext.getServiceContentHandlers();

for(int i=0; i < handlers.length ; i++){

if (handlers[i]instanceof ServiceMediaHandler){

// This is a Player for part of the service, since

// ServiceMediaHandler objects are instances of JMF

// Player objects

//so I guess here i can do something like:

Player p = (Player) handlers[i];

p.start();

break;

}

}

But do I have to do something like

myContext.select(s);

before getting service content handlers (where s is an instance of Service)? Because I don't quite understand idea of getting player from context.

[2112 byte] By [el_chea] at [2007-10-2 7:48:49]
# 1

No, you don't need to do a select() first. Because you are getting the service context that your own app is running in, you known that a service will be selected (because your app must be part of a service).

There may not be any JMF players associated with that service, of course, but the service context will be presenting a service.

Steve.

stevem_twa at 2007-7-16 21:35:57 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 2

Well...I have questions about this, too.

If in this case, we don't need to call servicecontext.select(s);

When do we need to do this?

And in the book"interactive TV standards", it said that the number of servicecontexts may limited in the number of tuners. So, the number of player is the same like servicecontext? or in a servicecontext, there may be two or more players in it ?

Thanks for any apply ^^

redcherrya at 2007-7-16 21:35:57 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 3

You needto do this if you want to control the player for the current service (e.g. you want to scale the currently playing video so that you can view a thumbnail of it in your application).

The number of service contexts that are available will depend on the receiver. A receiver will support a service context for its main tuner, and may optionally support a service context for any other tuners in the box (but not always - for a tuner used only for picture-in-picture, this may not make any sense). The receiver may also be able to support one or more service contexts for built-in applications, but this is optional and may depend on the available memory. It's always safest to assume that you only have the same number of service contexts as you have tuners.

For players, you may have more than one player per service context. You may have one player presenting broadcast video and another player presenting MPEG audio, for instance. While there is no limit to this within MHP, in practice you soon run into resource management issues with MPEG decoding. Since you typically need one MPEG decoder for every player that is actually playing media, this restricts the number of active players that you can have.

Steve.

stevem_twa at 2007-7-16 21:35:57 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 4

Dear stevem,

Thanks for your apply. It is useful for me. The another question about this issue is, if the number of service context is at least the same as the number of tuner, I suppose that means the ServiceContext.select(new Service) can only select the another service in the same transport stream. Is my assumption is correct? If so, if the ap want to select the new service in another ts, the ap should call the tunning api, then it can call the select() to select ap's desired service. it's right? ^^ If my assumption is false, could you share me the correct using flow ^^ ? Thx a lot~

Happy new year! ^^

redcherry1023a at 2007-7-16 21:35:57 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 5

Using ServiceContext.select() will cause the receiver to tune to a new TS if necessary. Apart from the DAVIC tuning API, this is the only way that an app can tune to a new transport stream. Tuning to the new stream yourself will not hurt, but it's not necessary,

What you have said is true for JMF - if you want to use JMF to present a stream from a different TS, then you will need to use the DAVIC tuning API first. Otherwise, you will not be able to present the stream(s).

Steve.

stevem_twa at 2007-7-16 21:35:57 > top of Java-index,Java Mobility Forums,Consumer and Commerce...