Skip to content

Commit

Permalink
Flv: Allow stream restart when closed
Browse files Browse the repository at this point in the history
  • Loading branch information
prsyahmi committed Dec 5, 2020
1 parent fe2070c commit e06ae42
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions v380/FlvStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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([&]() {
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions v380/FlvStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions v380/v380.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit e06ae42

Please sign in to comment.