| 89 | |
| 90 | |
| 91 | int CacheFileRemuxer::muxThreadRun() |
| 92 | { |
| 93 | { |
| 94 | std::unique_lock<mutex> lock(mThreadMutex); |
| 95 | |
| 96 | if (mInterrupt || mWantStop) { |
| 97 | AF_LOGW("muxThreadRun() mInterrupt || mWantStop..."); |
| 98 | return -1; |
| 99 | } |
| 100 | } |
| 101 | AF_LOGD("muxThreadRun() start..."); |
| 102 | { |
| 103 | std::unique_lock<mutex> lock(mObjectMutex); |
| 104 | |
| 105 | if (mMuxer != nullptr) { |
| 106 | mMuxer->close(); |
| 107 | delete mMuxer; |
| 108 | mMuxer = nullptr; |
| 109 | } |
| 110 | |
| 111 | if (mDestFileCntl != nullptr) { |
| 112 | delete mDestFileCntl; |
| 113 | mDestFileCntl = nullptr; |
| 114 | } |
| 115 | |
| 116 | mMuxer = IMuxerPrototype::create(mDestFilePath, "mp4", mDescription); |
| 117 | mDestFileCntl = new FileCntl(mDestFilePath); |
| 118 | } |
| 119 | |
| 120 | if (mMuxer == nullptr) { |
| 121 | sendError(CACHE_ERROR_ENCRYPT_CHECK_FAIL); |
| 122 | return -1; |
| 123 | } |
| 124 | |
| 125 | initMuxer(); |
| 126 | int openRet = mMuxer->open(); |
| 127 | |
| 128 | if (openRet != 0) { |
| 129 | AF_LOGE("muxThreadRun() mMuxer->open() fail...ret = %d ", openRet); |
| 130 | //open fail.. |
| 131 | sendError(CACHE_ERROR_MUXER_OPEN); |
| 132 | return -1; |
| 133 | } |
| 134 | |
| 135 | bool hasError = false; |
| 136 | |
| 137 | while (true) { |
| 138 | { |
| 139 | std::unique_lock<mutex> lock(mQueueMutex); |
| 140 | |
| 141 | if (mFrameInfoQueue.empty()) { |
| 142 | |
| 143 | if (mFrameEof) { |
| 144 | AF_LOGW("muxThreadRun() mFrameEof..."); |
| 145 | break; |
| 146 | } |
| 147 | |
| 148 | mQueueCondition.wait_for(lock, std::chrono::milliseconds(10), |