houxiao
2017-08-10 dea825c24eea9fa92dd9f0ccf2e24af4ed89683c
VisitFace/RtspNativeCodec/app/src/main/cpp/RemoteFunc.h
@@ -9,15 +9,20 @@
#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(){};
    bool start() {
   bool start()
   {
        LOG_INFO << "server_thd::start" << LOG_ENDL;
        if(running == true){
      if (running == true)
      {
            LOG_INFO << "The server_thd is already running" << LOG_ENDL;
            return false;
        }
@@ -34,7 +39,9 @@
        }
        return true;
    }
    void stop(){
   void stop()
   {
//    LOG_INFO << "server_thd::stop" << LOG_ENDL;
//    if (!running)
//        return;
@@ -48,14 +55,17 @@
    std::string host;
    int port;
    static void *rServer_thd(void *arg) {
   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