一直以來都是用Cyberlink來當成開發UPnP的API,後來看到一篇論文是用Cling完成UPnP在Android平台的開發,想說來試試這套,或許也可以在自已的論文中比較這兩套的差異性。
話不多說,先去官網下載cling-distribution-1.0.5.zip,解壓縮後會有cling-core-1.0.5.jar及teleal-common-1.0.13.jar,將這兩個jar丟到java目錄的/lib/ext下。接著我們就可以先玩玩cling的workbench這支程式,其實就是一支UPnP ControlPoint,和Cyberlink比較起來,我還是比較喜歡Cyberlink的,畫面設計的比較面善,log吐出來的資訊較完整。至於功能面目前看來還差不多(還在研究中...)
依官網頁面Getting Strated先來試試看程式的結構性,恩!感覺好像要先啟一個UPnPService,這個Service可以是ControlPoint 或 Device?繼續看下去囉!
1.UpnpService upnpService = new UpnpServiceImp();
-實作一個UPnP Stack,有了這個stack,可以拿來做controlpoint(cling指client)及device(cling指server)
-不要了,就upnpService.shutdown()來切斷所有upnp network連線並通知大家byebye
2.兩個建構子
UpnpService upnpService = new UpnpServiceImp(RegisterListener...)
-馬上實作一個instance
UpnpService upnpService = new UpnpServiceImp(new DefaultUpnpServiceConfiguration(8081))
-DefaultUpnpServiceConfiguration也是一個介面
3.實作controlpoint
upnpService.getControlPoint()
若要search device
-upnpService.getControlPoint.search(new STAllHeader()) ->找所有device
(效果和upnpService.getControlPoint.search()一樣)
-upnpService.getControlPoint.search(new UDNHeader(udn)) ->針對某個udn
4.UDA vs. namespace
UDA是followUPnP Device Architecture下的命名規則
namespace則是依照vendor自行定義的
UPnP Service下有兩個重要元件
-state variable
-action
您好,請問針對使用Cyberlink來implement android上的upnp是否可以給我看sample檔,or有推薦哪些教學比較容易上手或有幫助的嗎:D
回覆刪除