UPnP 検索で見つかるカメラがあります。また、150 秒ごとに UPnP 検索と同じ応答を広告 (マルチキャスト) します。
UPnP検索またはマルチキャスト広告を聞くだけでカメラを識別できるAndroidアプリを作成しました。
マルチキャスト ソケットを作成し、あらゆるパケットをリッスンするだけでアドバタイズ リッスンを実現しました
new Thread(new Runnable() {
public void run() {
try{
Utils.showLog(TAG,"Searching Thread Started " );
// Get the address that we are going to connect to.
InetAddress address = InetAddress.getByName(INET_ADDR);
// Create a buffer of bytes, which will be used to store
// the incoming bytes containing the information from the server.
// Since the message is small here, 256 bytes should be enough.
byte[] buf = new byte[512];
// Create a new Multicast socket (that will allow other sockets/programs
// to join it as well.
try {
clientSocket = new MulticastSocket(PORT);
//Joint the Multicast group.
clientSocket.joinGroup(address);
isSocketOpen=true;
while (isSocketOpen) {
// Receive the information and print it.
DatagramPacket msgPacket = new DatagramPacket(buf, buf.length);
clientSocket.receive(msgPacket);
Utils.showLog(TAG, "------>SocketAddress: " + msgPacket.getSocketAddress());
Utils.showLog(TAG,"------>Port " + msgPacket.getPort());
String URL =getLocation(msgPacket).trim();
}
} catch (IOException ex) {
ex.printStackTrace();
}
} catch (UnknownHostException ex) {
ex.printStackTrace();
}
}
}).start();
今私の問題は、Asus Zenfone (Android バージョン 5.0) では正常に動作しますが、Lenovo A1000 (同じ Android バージョン) では失敗することです。
Lenovo A1000 は、Windows PC から SSDP パケットをキャプチャできます。問題は、カメラからのパケットのみです。
しかし、カメラからのパケットが破損した場合、Asus Zenfone ではどのようにキャプチャされるのでしょうか?
私の質問は、アンドロイドがアプリに到達する前にパケットをブロックすることですか?