View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.support.avtransport.impl.state;
17  
18  import org.fourthline.cling.support.avtransport.lastchange.AVTransportVariable;
19  import org.fourthline.cling.support.model.AVTransport;
20  import org.fourthline.cling.support.model.TransportAction;
21  import org.fourthline.cling.support.model.TransportInfo;
22  import org.fourthline.cling.support.model.TransportState;
23  
24  import java.net.URI;
25  import java.util.logging.Logger;
26  
27  /**
28   * @author Christian Bauer
29   */
30  public abstract class NoMediaPresent<T extends AVTransport> extends AbstractState<T> {
31  
32      final private static Logger log = Logger.getLogger(Stopped.class.getName());
33  
34      public NoMediaPresent(T transport) {
35          super(transport);
36      }
37  
38      public void onEntry() {
39          log.fine("Setting transport state to NO_MEDIA_PRESENT");
40          getTransport().setTransportInfo(
41                  new TransportInfo(
42                          TransportState.NO_MEDIA_PRESENT,
43                          getTransport().getTransportInfo().getCurrentTransportStatus(),
44                          getTransport().getTransportInfo().getCurrentSpeed()
45                  )
46          );
47          getTransport().getLastChange().setEventedValue(
48                  getTransport().getInstanceId(),
49                  new AVTransportVariable.TransportState(TransportState.NO_MEDIA_PRESENT),
50                  new AVTransportVariable.CurrentTransportActions(getCurrentTransportActions())
51          );
52      }
53  
54      public abstract Class<? extends AbstractState> setTransportURI(URI uri, String metaData);
55  
56      public TransportAction[] getCurrentTransportActions() {
57          return new TransportAction[] {
58                  TransportAction.Stop
59          };
60      }
61  }