/******************************************************************
*
* CyberLink for Java
*
* Copyright (C) Satoshi Konno 2002-2004
*
* File: Device.java
*
* Revision:
*
* 11/28/02
* - first revision.
* 02/26/03
* - URLBase is updated automatically.
* - Description of a root device is returned from the XML node tree.
* 05/13/03
* - URLBase is updated when the request is received.
* - Changed to create socket threads each local interfaces.
* (HTTP, SSDPSearch)
* 06/17/03
* - Added notify all state variables when a new subscription is received.
* 06/18/03
* - Fixed a announce bug when the bind address is null on J2SE v 1.4.1_02 and Redhat 9.
* 09/02/03
* - Giordano Sassaroli <sassarol@cefriel.it>
* - Problem : bad request response sent even with successful subscriptions
* - Error : a return statement is missing in the httpRequestRecieved method
* 10/21/03
* - Updated a udn field by a original uuid.
* 10/22/03
* - Added setActionListener().
* - Added setQueryListener().
* 12/12/03
* - Added a static() to initialize UPnP class.
* 12/25/03
* - Added advertiser functions.
* 01/05/04
* - Added isExpired().
* 03/23/04
* - Oliver Newell <newell@media-rush.com>
* - Changed to update the UDN only when the field is null.
* 04/21/04
* - Added isDeviceType().
* 06/18/04
* - Added setNMPRMode() and isNMPRMode().
* - Changed getDescriptionData() to update only when the NMPR mode is false.
* 06/21/04
* - Changed start() to send a bye-bye before the announce.
* - Changed annouce(), byebye() and deviceSearchReceived() to send the SSDP
* messsage four times when the NMPR and the Wireless mode are true.
* 07/02/04
* - Fixed announce() and byebye() to send the upnp::rootdevice message despite embedded devices.
* - Fixed getRootNode() to return the root node when the device is embedded.
* 07/24/04
* - Thanks for Stefano Lenzi <kismet-sl@users.sourceforge.net>
* - Added getParentDevice().
* 10/20/04
* - Brent Hills <bhills@openshores.com>
* - Changed postSearchResponse() to add MYNAME header.
* 11/19/04
* - Theo Beisch <theo.beisch@gmx.de>
* - Added getStateVariable(String serviceType, String name).
* 03/22/05
* - Changed httpPostRequestRecieved() to return the bad request when the post request isn't the soap action.
* 03/23/05
* - Added loadDescription(String) to load the description from memory.
* 03/30/05
* - Added getDeviceByDescriptionURI().
* - Added getServiceBySCPDURL().
* 03/31/05
* - Changed httpGetRequestRecieved() to return the description stream using
* Device::getDescriptionData() and Service::getSCPDData() at first.
* 04/25/05
* - Thanks for Mikael Hakman <mhakman@dkab.net>
* Changed announce() and byebye() to close the socket after the posting.
* 04/25/05
* - Thanks for Mikael Hakman <mhakman@dkab.net>
* Changed deviceSearchResponse() answer with USN:UDN::<device-type> when request ST is device type.
* 04/25/05
* - Thanks for Mikael Hakman <mhakman@dkab.net>
* - Changed getDescriptionData() to add a XML declaration at first line.
* 04/25/05
* - Thanks for Mikael Hakman <mhakman@dkab.net>
* - Added a new setActionListener() and serQueryListner() to include the sub devices.
* 07/24/05
* - Thanks for Stefano Lenzi <kismet-sl@users.sourceforge.net>
* - Fixed a bug of getParentDevice() to return the parent device normally.
* 02/21/06
* - Changed httpRequestRecieved() not to ignore HEAD requests.
* 04/12/06
* - Added setUserData() and getUserData() to set a user original data object.
* 03/29/08
* - Added isRunning() to know whether the device is running.
*
******************************************************************/
package org.cybergarage.upnp;
import java.io.File;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.URL;
import java.util.Calendar;
import org.cybergarage.http.HTTP;
import org.cybergarage.http.HTTPRequest;
import org.cybergarage.http.HTTPResponse;
import org.cybergarage.http.HTTPServerList;
import org.cybergarage.http.HTTPStatus;
import org.cybergarage.net.HostInterface;
import org.cybergarage.soap.SOAPResponse;
import org.cybergarage.upnp.control.ActionListener;
import org.cybergarage.upnp.control.ActionRequest;
import org.cybergarage.upnp.control.ActionResponse;
import org.cybergarage.upnp.control.ControlRequest;
import org.cybergarage.upnp.control.ControlResponse;
import org.cybergarage.upnp.control.QueryListener;
import org.cybergarage.upnp.control.QueryRequest;
import org.cybergarage.upnp.device.Advertiser;
import org.cybergarage.upnp.device.Description;
import org.cybergarage.upnp.device.InvalidDescriptionException;
import org.cybergarage.upnp.device.NTS;
import org.cybergarage.upnp.device.ST;
import org.cybergarage.upnp.device.SearchListener;
import org.cybergarage.upnp.device.USN;
import org.cybergarage.upnp.event.Subscriber;
import org.cybergarage.upnp.event.Subscription;
import org.cybergarage.upnp.event.SubscriptionRequest;
import org.cybergarage.upnp.event.SubscriptionResponse;
import org.cybergarage.upnp.ssdp.SSDPNotifyRequest;
import org.cybergarage.upnp.ssdp.SSDPNotifySocket;
import org.cybergarage.upnp.ssdp.SSDPPacket;
import org.cybergarage.upnp.ssdp.SSDPSearchResponse;
import org.cybergarage.upnp.ssdp.SSDPSearchResponseSocket;
import org.cybergarage.upnp.ssdp.SSDPSearchSocketList;
import org.cybergarage.upnp.xml.DeviceData;
import org.cybergarage.util.Debug;
import org.cybergarage.util.FileUtil;
import org.cybergarage.util.Mutex;
import org.cybergarage.util.TimerUtil;
import org.cybergarage.xml.Node;
import org.cybergarage.xml.Parser;
import org.cybergarage.xml.ParserException;
import org.cybergarage.xml.XML;
public class Device implements org.cybergarage.http.HTTPRequestListener, SearchListener
{
////////////////////////////////////////////////
// Constants
////////////////////////////////////////////////
public final static String ELEM_NAME = "device";
public final static String UPNP_ROOTDEVICE = "upnp:rootdevice";
public final static int DEFAULT_STARTUP_WAIT_TIME = 1000;
public final static int DEFAULT_DISCOVERY_WAIT_TIME = 300;
public final static int DEFAULT_LEASE_TIME = 30 * 60;
public final static int HTTP_DEFAULT_PORT = 4004;
public final static String DEFAULT_DESCRIPTION_URI = "/description.xml";
////////////////////////////////////////////////
// Member
////////////////////////////////////////////////
private Node rootNode;
private Node deviceNode;
public Node getRootNode()
{
if (rootNode != null)
return rootNode;
if (deviceNode == null)
return null;
return deviceNode.getRootNode();
}
public Node getDeviceNode()
{
return deviceNode;
}
public void setRootNode(Node node)
{
rootNode = node;
}
public void setDeviceNode(Node node)
{
deviceNode = node;
}
////////////////////////////////////////////////
// Initialize
////////////////////////////////////////////////
static
{
UPnP.initialize();
}
////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////
public Device(Node root, Node device)
{
rootNode = root;
deviceNode = device;
setUUID(UPnP.createUUID());
setWirelessMode(false);
}
public Device()
{
this(null, null);
}
public Device(Node device)
{
this(null, device);
}
public Device(File descriptionFile) throws InvalidDescriptionException
{
this(null, null);
loadDescription(descriptionFile);
}
/**
* @since 1.8.0
*/
public Device(InputStream input) throws InvalidDescriptionException
{
this(null, null);
loadDescription(input);
}
public Device(String descriptionFileName) throws InvalidDescriptionException
{
this(new File(descriptionFileName));
}
////////////////////////////////////////////////
// Mutex
////////////////////////////////////////////////
private Mutex mutex = new Mutex();
public void lock()
{
mutex.lock();
}
public void unlock()
{
mutex.unlock();
}
////////////////////////////////////////////////
// getAbsolut
没有合适的资源?快使用搜索试试~ 我知道了~
droiddlnaplayer源码
共308个文件
svn-base:152个
java:122个
xml:16个
5星 · 超过95%的资源 需积分: 9 44 下载量 117 浏览量
2012-10-30
10:58:22
上传
评论
收藏 533KB RAR 举报
温馨提示
这是一个开源的DLNA For Android 客户端的源码,官方的描述如下: Dlna player for Android 2.0+ devices. Player uses Amazon web services to fetch cover art for songs.
资源推荐
资源详情
资源评论
收起资源包目录
droiddlnaplayer源码 (308个子文件)
wc.db 152KB
entries 3B
format 3B
commons-codec-1.3.jar 46KB
Device.java 54KB
ControlPoint.java 25KB
Service.java 22KB
HTTPPacket.java 22KB
AudioPlayerActivity.java 17KB
StateVariable.java 13KB
HTTPRequest.java 12KB
Tools.java 12KB
Action.java 11KB
SignedRequestsHelper.java 10KB
Node.java 10KB
ContentActivity.java 9KB
DlnaService.java 9KB
MediaPlayerService.java 9KB
UPnP.java 7KB
NetworkActivity.java 7KB
HostInterface.java 7KB
PlaylistActivity.java 6KB
HTTPMUSocket.java 6KB
DeviceData.java 6KB
HTTPSocket.java 6KB
SubscriptionRequest.java 6KB
HTTPUSocket.java 6KB
HTTP.java 6KB
HTTPServer.java 6KB
NotifyRequest.java 6KB
Argument.java 5KB
SSDPSearchSocket.java 5KB
SSDPPacket.java 5KB
ControlRequest.java 4KB
ControlResponse.java 4KB
SOAPRequest.java 4KB
SSDPNotifySocket.java 4KB
HTTPStatus.java 4KB
SOAPResponse.java 4KB
PictureViewerActivity.java 4KB
PlayerImageView.java 4KB
SSDPSearchResponseSocketList.java 4KB
JaxpParser.java 4KB
SSDPSearchSocketList.java 4KB
Subscriber.java 4KB
ActionRequest.java 3KB
Icon.java 3KB
Date.java 3KB
HTTPHeader.java 3KB
Parser.java 3KB
QueryRequest.java 3KB
ActionResponse.java 3KB
ArgumentList.java 3KB
XmlPullParser.java 3KB
HTTPServerList.java 3KB
SSDPResponse.java 3KB
SSDPNotifySocketList.java 3KB
Item.java 3KB
SSDPSearchResponseSocket.java 3KB
SSDP.java 3KB
AllowedValueRange.java 3KB
StringUtil.java 3KB
SOAP.java 2KB
ServiceData.java 2KB
HTTPResponse.java 2KB
SSDPRequest.java 2KB
QueryResponse.java 2KB
Subscription.java 2KB
XML.java 2KB
UPnPStatus.java 2KB
Debug.java 2KB
AllowedValue.java 2KB
SubscriptionResponse.java 2KB
ST.java 2KB
DeviceData.java 2KB
ThreadCore.java 2KB
FileUtil.java 2KB
Advertiser.java 1KB
StateVariableData.java 1KB
RenewSubscriber.java 1KB
Disposer.java 1KB
AllowedValueList.java 1KB
PlaylistHelper.java 1KB
Property.java 1KB
SSDPSearchRequest.java 1KB
HTTPServerThread.java 1KB
ActionData.java 1KB
MainActivity.java 1KB
NodeList.java 1KB
ServiceList.java 1KB
Parameter.java 1KB
Attribute.java 1KB
ParameterList.java 1018B
ServiceStateTable.java 963B
PropertyList.java 929B
Mutex.java 927B
ActionList.java 914B
IconList.java 900B
SubscriberList.java 897B
AnimationHelper.java 875B
共 308 条
- 1
- 2
- 3
- 4
Kenny_Chung
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页