View Javadoc

1   package org.rpi.providers;
2   
3   import org.apache.log4j.Logger;
4   import org.openhome.net.device.DvDevice;
5   import org.openhome.net.device.IDvInvocation;
6   import org.openhome.net.device.providers.DvProviderUpnpOrgConnectionManager1;
7   import org.rpi.config.Config;
8   import org.rpi.utils.Utils;
9   
10  public class PrvConnectionManager extends DvProviderUpnpOrgConnectionManager1 {
11  
12  	private Logger log = Logger.getLogger(PrvConnectionManager.class);
13  
14  	private String currentConnectionIDs = "0";
15  	// private String sinkProtocolInfo =
16  	// "http-get:*:audio/mpegurl:*,http-get:*:audio/mp3:*,http-get:*:audio/mpeg:*,http-get:*:audio/x-ms-wma:*,http-get:*:audio/wma:*,http-get:*:audio/mpeg3:*,http-get:*:video/x-ms-wmv:*,http-get:*:video/x-ms-asf:*,http-get:*:video/x-ms-avi:*,http-get:*:video/mpeg:*";
17  	private String sinkProtocolInfo = Config.getProtocolInfo();
18  	private String sourceProtocolInfo = "";// "http-get:*:*:*";//
19  											// "";//Config.getProtocolInfo();
20  
21  	private int iConnectionID = 0;
22  
23  	private int iAVTransportID = 0;
24  
25  	private int iRcsID = 0;
26  
27  	public PrvConnectionManager(DvDevice device) {
28  		super(device);
29  
30  		enablePropertySourceProtocolInfo();
31  		setPropertySourceProtocolInfo(sourceProtocolInfo);
32  		enablePropertySinkProtocolInfo();
33  		setPropertySinkProtocolInfo(sinkProtocolInfo);
34  		enablePropertyCurrentConnectionIDs();
35  		setPropertyCurrentConnectionIDs(currentConnectionIDs);
36  
37  		// enableActionPrepareForConnection();
38  		// enableActionConnectionComplete();
39  		enableActionGetCurrentConnectionIDs();
40  		enableActionGetCurrentConnectionInfo();
41  		enableActionGetProtocolInfo();
42  	}
43  
44  	@Override
45  	protected PrepareForConnection prepareForConnection(IDvInvocation paramIDvInvocation, String sinkProtocolInfo, String peerConnectionManager, int remoteConnId, String paramString3) {
46  		// setPropertyCurrentConnectionIDs("");
47  		// setPropertyCurrentConnectionIDs("0");
48  		setPropertySourceProtocolInfo(sinkProtocolInfo);
49  		// boolean res = setPropertyCurrentConnectionIDs("" + remoteConnId);
50  		// if (res) {
51  		// log.warn("#################### This happened");
52  		// }
53  		log.debug("PrepareForConnection: ProtocolInfo: " + sinkProtocolInfo + " PeerConnectionManager: " + peerConnectionManager + " RemoteConnId: " + remoteConnId + Utils.getLogText(paramIDvInvocation));
54  		PrepareForConnection prep = new PrepareForConnection(0, 0, 0);
55  		return prep;
56  	}
57  
58  	@Override
59  	protected void connectionComplete(IDvInvocation paramIDvInvocation, int paramInt) {
60  		log.debug("connectionComplete: " + paramInt + Utils.getLogText(paramIDvInvocation));
61  		setPropertyCurrentConnectionIDs("");
62  	}
63  
64  	@Override
65  	protected DvProviderUpnpOrgConnectionManager1.GetProtocolInfo getProtocolInfo(IDvInvocation paramIDvInvocation) {
66  		log.debug("GetProtocolInfo: " + Utils.getLogText(paramIDvInvocation));
67  
68  		log.debug("GetProtolInfo Source=" + sourceProtocolInfo + " Sink=" + sinkProtocolInfo);
69  		return new DvProviderUpnpOrgConnectionManager1.GetProtocolInfo(getPropertySourceProtocolInfo(), getPropertySinkProtocolInfo());
70  	}
71  
72  	@Override
73  	protected String getCurrentConnectionIDs(IDvInvocation paramIDvInvocation) {
74  		log.debug("getCurrentConnectionIDs " + Utils.getLogText(paramIDvInvocation));
75  		log.debug("ConnectionManager getCurrentConnectionIDs ConnectionIDs=" + getPropertyCurrentConnectionIDs());
76  		return getPropertyCurrentConnectionIDs();
77  	}
78  
79  	@Override
80  	protected DvProviderUpnpOrgConnectionManager1.GetCurrentConnectionInfo getCurrentConnectionInfo(IDvInvocation paramIDvInvocation, int paramInt) {
81  		log.debug("GetCurrentConnectionInfo: " + paramInt + Utils.getLogText(paramIDvInvocation));
82  		// int iRcsID = 0;
83  		// int iAVTransportID = 0;
84  		setPropertyCurrentConnectionIDs("" + paramInt);
85  		String iProtocolInfo = sinkProtocolInfo;
86  		String iPeerConnectionManager = "/";
87  		int iPeerConnectionID = -1;
88  		String iDirection = "Input";
89  		String iStatus = "Unknown";
90  
91  		log.debug("ConnectionManager response: GetCurrentConnectionInfo: RcsID=" + iRcsID + " AVTransportID=" + iAVTransportID + " ProtocolInfo=" + iProtocolInfo + " PeerConnectionManager=" + iPeerConnectionManager + " PeerConnectionID=" + iPeerConnectionID + " Direction=" + iDirection + " Status=" + iStatus);
92  		return new DvProviderUpnpOrgConnectionManager1.GetCurrentConnectionInfo(iRcsID, iAVTransportID, iProtocolInfo, iPeerConnectionManager, iPeerConnectionID, iDirection, iStatus);
93  	}
94  
95  
96  
97  	// protected String getProtocolInfo() {
98  	// log.debug("GetProtocol");
99  	// return sinkProtocolInfo;
100 	// }
101 
102 }