diff options
Diffstat (limited to 'iget_android/app/src/main/jni')
-rw-r--r-- | iget_android/app/src/main/jni/Android.mk | 118 | ||||
-rw-r--r-- | iget_android/app/src/main/jni/Application.mk | 21 | ||||
-rw-r--r-- | iget_android/app/src/main/jni/iget-wrapper.cpp | 137 | ||||
-rw-r--r-- | iget_android/app/src/main/jni/iget-wrapper.hpp | 40 |
4 files changed, 0 insertions, 316 deletions
diff --git a/iget_android/app/src/main/jni/Android.mk b/iget_android/app/src/main/jni/Android.mk deleted file mode 100644 index 9bf33d2c..00000000 --- a/iget_android/app/src/main/jni/Android.mk +++ /dev/null @@ -1,118 +0,0 @@ -############################################################################## -# Copyright (c) 2017 Cisco and/or its affiliates. -# 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. -############################################################################## - -LOCAL_PATH := $(call my-dir) -LOCAL_PATH_SAVED := $(LOCAL_PATH) -ARMDIST_ROOT := $(DISTILLERY_ROOT_DIR)/usr - -include $(CLEAR_VARS) -LOCAL_MODULE := libboost_system -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libboost_system.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libevent -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libevent.a -include $(PREBUILT_STATIC_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libcrypto -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libcrypto.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libssl -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libssl.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libcrystax -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libcrystax.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := liblongbow-ansiterm -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/liblongbow-ansiterm.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := liblongbow-textplain -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/liblongbow-textplain.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := liblongbow -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/liblongbow.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libparc -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libparc.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libccnx_common -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libccnx_common.so -include $(PREBUILT_SHARED_LIBRARY) - - -include $(CLEAR_VARS) -LOCAL_MODULE := libccnx_api_notify -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libccnx_api_notify.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libccnx_api_control -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libccnx_api_control.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libccnx_transport_rta -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libccnx_transport_rta.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libccnx_api_portal -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libccnx_api_portal.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libicnet -LOCAL_SRC_FILES := $(ARMDIST_ROOT)/lib/libicnet.so -include $(PREBUILT_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := iget-wrapper -LOCAL_SRC_FILES := iget-wrapper.cpp -LOCAL_LDLIBS := -llog -LOCAL_CPPFLAGS := -I$(ARMDIST_ROOT)/include - -LOCAL_STATIC_LIBRARIES := \ - libicnet \ - libccnx_api_portal \ - libccnx_transport_rta \ - libccnx_api_control \ - libccnx_api_notify \ - libccnx_common \ - libparc \ - liblongbow \ - liblongbow-textplain \ - liblongbow-ansiterm \ - libevent \ - libboost_system \ - libcrystax \ - libcrypto \ - libssl -include $(BUILD_SHARED_LIBRARY) diff --git a/iget_android/app/src/main/jni/Application.mk b/iget_android/app/src/main/jni/Application.mk deleted file mode 100644 index 4e149e3e..00000000 --- a/iget_android/app/src/main/jni/Application.mk +++ /dev/null @@ -1,21 +0,0 @@ -############################################################################## -# Copyright (c) 2017 Cisco and/or its affiliates. -# 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. -############################################################################## - -APP_ABI := armeabi-v7a - -APP_STL := gnustl_shared -APP_CPPFLAGS += -fexceptions -frtti -std=c++11 -Wno-deprecated-declarations -NDK_TOOLCHAIN_VERSION := 4.9 -APP_PLATFORM := android-21 diff --git a/iget_android/app/src/main/jni/iget-wrapper.cpp b/iget_android/app/src/main/jni/iget-wrapper.cpp deleted file mode 100644 index 57849378..00000000 --- a/iget_android/app/src/main/jni/iget-wrapper.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * 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. - */ - -#include "iget-wrapper.hpp" - -#include <stdlib.h> -#include <boost/property_tree/info_parser.hpp> -#include <boost/thread.hpp> -#include <mutex> -#include <icnet/icnet_socket_consumer.h> -#include <boost/date_time/posix_time/posix_time.hpp> -#include <android/log.h> - -typedef boost::posix_time::ptime Time; -typedef boost::posix_time::time_duration TimeDuration; - -Time t1(boost::posix_time::microsec_clock::local_time()); - -class CallbackContainer -{ - public: - CallbackContainer(): - work(new boost::asio::io_service::work(m_ioService)), - m_handler(std::async(std::launch::async, [this]() { m_ioService.run(); })) - { - m_seenManifestSegments = 0; - m_seenDataSegments = 0; - m_byteCounter = 0; - } - - ~CallbackContainer() - { - work.reset(); - } - - void processPayload(icnet::ConsumerSocket &c, const uint8_t *buffer, size_t bufferSize) - { - icnet::Name m_name; - c.getSocketOption(icnet::GeneralTransportOptions::NAME_PREFIX, m_name); - std::string filename = destinationPathString + "/" + m_name.toString().substr(1 + m_name.toString().find_last_of("/")); - - m_ioService.dispatch([buffer, bufferSize, filename]() { - Time t3(boost::posix_time::microsec_clock::local_time()); - std::ofstream file(filename.c_str(), std::ofstream::binary); - file.write((char *) buffer, bufferSize); - file.close(); - Time t2(boost::posix_time::microsec_clock::local_time()); - TimeDuration dt = t2 - t1; - TimeDuration dt3 = t3 - t1; - long msec = dt.total_milliseconds(); - long msec3 = dt3.total_milliseconds(); - __android_log_print(ANDROID_LOG_INFO, "ProcessPayLoad", "Elapsed Time: %.2f seconds -- %.2f [Mbps] -- %.2f", msec/1000.0, bufferSize*8/msec/1000.0, bufferSize*8/msec3/1000.0); - }); - } - - bool verifyData(icnet::ConsumerSocket &c, const icnet::ContentObject &content_object) - { - if (content_object.getContentType() == icnet::PayloadType::DATA) { - __android_log_print(ANDROID_LOG_INFO, "VerifyData", "VERIFY CONTENT"); - } else if (content_object.getContentType() == icnet::PayloadType::MANIFEST) { - __android_log_print(ANDROID_LOG_INFO, "VerifyData", "VERIFY MANIFEST"); - } - return true; - } - - void processLeavingInterest(icnet::ConsumerSocket &c, const icnet::Interest &interest) - { - //std::cout << "LEAVES " << interest.getName().toUri() << std::endl; - } - - void setDestinationPathString(std::string destinationPathString) - { - - this->destinationPathString = destinationPathString; - __android_log_print(ANDROID_LOG_ERROR, "setDestinationPathString", "xxx destinationPathString %s", this->destinationPathString.c_str()); - } - - private: - std::string destinationPathString; - int m_seenManifestSegments; - int m_seenDataSegments; - int m_byteCounter; - boost::asio::io_service m_ioService; - std::shared_ptr<boost::asio::io_service::work> work; - std::future<void> m_handler; -}; - - -JNIEXPORT void JNICALL -Java_com_cisco_ccnx_service_CCNxService_startIGet(JNIEnv *env, jobject obj, jstring downloadPath, jstring destinationPath) -{ - jboolean isCopy; - const char *downloadPathChar = env->GetStringUTFChars(downloadPath, &isCopy); - jboolean isCopyDestinatioPathChar; - const char *destinationPathChar = env->GetStringUTFChars(destinationPath, &isCopyDestinatioPathChar); - std::string destinationPathString(destinationPathChar, strlen(destinationPathChar)); - std::string url(downloadPathChar, strlen(downloadPathChar)); - std::string locator = ""; - std::string path = ""; - std::string name = ""; - size_t found = 0; - size_t pathBegin = 0; - found = url.find("//"); - pathBegin = url.find('/', found+2); - locator = url.substr(found+2, pathBegin - (found+2)); - path = url.substr(pathBegin, std::string::npos); - name = "ccnx:/" + locator + "/get" + path; - icnet::ConsumerSocket c(icnet::Name(name.c_str()), icnet::TransportProtocolAlgorithms::RAAQM); - CallbackContainer stubs; - stubs.setDestinationPathString(destinationPathString); - c.setSocketOption(icnet::ConsumerCallbacksOptions::CONTENT_RETRIEVED, - (icnet::ConsumerContentCallback) std::bind(&CallbackContainer::processPayload, - &stubs, - std::placeholders::_1, - std::placeholders::_2, - std::placeholders::_3)); - c.setSocketOption(icnet::ConsumerCallbacksOptions::INTEREST_OUTPUT, - (icnet::ConsumerInterestCallback) std::bind(&CallbackContainer::processLeavingInterest, - &stubs, - std::placeholders::_1, - std::placeholders::_2)); - c.consume(icnet::Name()); - c.stop(); -} - diff --git a/iget_android/app/src/main/jni/iget-wrapper.hpp b/iget_android/app/src/main/jni/iget-wrapper.hpp deleted file mode 100644 index 2df25453..00000000 --- a/iget_android/app/src/main/jni/iget-wrapper.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2017 Cisco and/or its affiliates. - * 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. - */ - -#include <jni.h> - - -#ifndef _Included_com_cisco_ccnx_service_CCNxService -#define _Included_com_cisco_ccnx_service_CCNxService -#ifdef __cplusplus -extern "C" { -#endif - -JNIEXPORT void JNICALL -Java_com_cisco_ccnx_service_CCNxService_startNfd(JNIEnv*, jclass, jobject); - -JNIEXPORT void JNICALL -Java_com_cisco_ccnx_service_CCNxService_stopNfd(JNIEnv*, jclass); - -JNIEXPORT void JNICALL -Java_com_cisco_ccnx_service_CCNxService_startIGet(JNIEnv *env, jobject obj, jstring downloadPath, jstring destinationPath); - -JNIEXPORT jobject JNICALL -Java_com_cisco_ccnx_service_CCNxService_getNfdLogModules(JNIEnv*, jclass); - -#ifdef __cplusplus -} -#endif -#endif |