diff --git a/v380/FlvStream.cpp b/v380/FlvStream.cpp index 67c90e7..98c12a1 100644 --- a/v380/FlvStream.cpp +++ b/v380/FlvStream.cpp @@ -204,6 +204,7 @@ FlvStream::FlvStream() , m_LastTimestamp(0) , m_EnableVideo(false) , m_EnableAudio(false) + , m_Inited(false) , m_Exit(false) { m_Thread = std::thread([&]() { @@ -248,6 +249,11 @@ void FlvStream::Init(bool enableVideo, bool enableAudio) { TFlvHeader header; + if (m_Inited) { + return; + } + m_Inited = true; + m_EnableVideo = enableVideo; m_EnableAudio = enableAudio; diff --git a/v380/FlvStream.h b/v380/FlvStream.h index 3713eff..c74ccab 100644 --- a/v380/FlvStream.h +++ b/v380/FlvStream.h @@ -24,6 +24,7 @@ class FlvStream bool m_EnableVideo; bool m_EnableAudio; + bool m_Inited; bool m_Exit; std::thread m_Thread; Semaphore m_Semaphore; diff --git a/v380/v380.cpp b/v380/v380.cpp index 5eb9f2f..62fd6f4 100644 --- a/v380/v380.cpp +++ b/v380/v380.cpp @@ -547,6 +547,8 @@ int main(int argc, const char* argv[]) socketStream.Send(ptzcmd); } } + + fprintf(stderr, "Stream stopped, restarting stream\n"); } catch (const std::exception& ex) {