If you think the Android project remoteyourcam-usb listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/**
* Copyright 2013 Nils Assbeck, Guersel Ayaz and Michael Zoech
*//fromwww.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.remoteyourcam.usb.ptp;
import android.hardware.usb.UsbDeviceConnection;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbRequest;
publicclass PtpUsbConnection {
privatefinal UsbDeviceConnection connection;
privatefinal UsbEndpoint bulkOut;
privatefinal UsbEndpoint bulkIn;
privatefinalint vendorId;
privatefinalint productId;
public PtpUsbConnection(UsbDeviceConnection connection, UsbEndpoint bulkIn, UsbEndpoint bulkOut, int vendorId,
int productId) {
this.connection = connection;
this.bulkIn = bulkIn;
this.bulkOut = bulkOut;
this.vendorId = vendorId;
this.productId = productId;
}
publicint getVendorId() {
return vendorId;
}
publicint getProductId() {
return productId;
}
publicvoid close() {
connection.close();
}
publicint getMaxPacketInSize() {
return bulkIn.getMaxPacketSize();
}
publicint getMaxPacketOutSize() {
return bulkOut.getMaxPacketSize();
}
public UsbRequest createInRequest() {
UsbRequest r = new UsbRequest();
r.initialize(connection, bulkIn);
return r;
}
publicint bulkTransferOut(byte[] buffer, int length, int timeout) {
return connection.bulkTransfer(bulkOut, buffer, length, timeout);
}
publicint bulkTransferIn(byte[] buffer, int maxLength, int timeout) {
return connection.bulkTransfer(bulkIn, buffer, maxLength, timeout);
}
publicvoid requestWait() {
connection.requestWait();
}
}