From 142117991fae65646bc5dd59d96c4a5c5e8559ca Mon Sep 17 00:00:00 2001
From: houxiao <houxiao@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 10 八月 2017 14:54:25 +0800
Subject: [PATCH] bug fix
---
VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFunc.h | 78 ++++++++++++++++++++++-----------------
1 files changed, 44 insertions(+), 34 deletions(-)
diff --git a/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFunc.h b/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFunc.h
index 422237d..85e3adb 100644
--- a/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFunc.h
+++ b/VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFunc.h
@@ -9,53 +9,63 @@
#include <capnp/ez-rpc.h>
#include <logger.h>
-template <class T> class RemoteServer{
+template<class T>
+class RemoteServer
+{
public:
- RemoteServer(std::string host,int port):host(host),port(port){};
- ~RemoteServer(){};
+ RemoteServer(std::string host, int port) : host(host), port(port) {};
- bool start() {
- LOG_INFO << "server_thd::start" << LOG_ENDL;
+ ~RemoteServer() {};
- if(running == true){
- LOG_INFO << "The server_thd is already running" << LOG_ENDL;
- return false;
- }
- running = true;
- pthread_mutex_init(&mutexSerevr, NULL); // 鍒濆鍖栦簰鏂ュ璞�,鍔ㄦ�佸姞閿侊紝鐢ㄤ簬server
+ bool start()
+ {
+ LOG_INFO << "server_thd::start" << LOG_ENDL;
- int retServer = pthread_create(&server_thid, NULL, RemoteServer::rServer_thd, this);
+ if (running == true)
+ {
+ LOG_INFO << "The server_thd is already running" << LOG_ENDL;
+ return false;
+ }
+ running = true;
+ pthread_mutex_init(&mutexSerevr, NULL); // 鍒濆鍖栦簰鏂ュ璞�,鍔ㄦ�佸姞閿侊紝鐢ㄤ簬server
- if(retServer != 0)
- {
- LOGP(ERROR, "server_thd_create: %s/n", strerror(retServer));
- running = false;
- return false;
- }
- return true;
- }
- void stop(){
+ int retServer = pthread_create(&server_thid, NULL, RemoteServer::rServer_thd, this);
+
+ if (retServer != 0)
+ {
+ LOGP(ERROR, "server_thd_create: %s/n", strerror(retServer));
+ running = false;
+ return false;
+ }
+ return true;
+ }
+
+ void stop()
+ {
// LOG_INFO << "server_thd::stop" << LOG_ENDL;
// if (!running)
// return;
// running = false;
// pthread_mutex_destroy(&mutexSerevr);
- //#todo
- }
+ //#todo
+ }
- bool running;
+ bool running;
private:
- std::string host;
- int port;
+ std::string host;
+ int port;
- static void *rServer_thd(void *arg) {
- RemoteServer& rs = *(RemoteServer*)arg;
- capnp::EzRpcServer trpcServer(kj::heap<T>(),rs.host, rs.port);
- auto& serverLoop = trpcServer.getWaitScope();
- kj::NEVER_DONE.wait(serverLoop);
- }
- pthread_t server_thid;
- pthread_mutex_t mutexSerevr;
+ static void *rServer_thd(void *arg)
+ {
+ RemoteServer &rs = *(RemoteServer *) arg;
+ capnp::EzRpcServer trpcServer(kj::heap<T>(), rs.host, rs.port);
+ auto &serverLoop = trpcServer.getWaitScope();
+ kj::NEVER_DONE.wait(serverLoop);
+ }
+
+ pthread_t server_thid;
+ pthread_mutex_t mutexSerevr;
};
+
#endif //RTSPNATIVECODEC_REMOTEFUNC_H
--
Gitblit v1.8.0