Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Baresip and libre, revert changes in H264Decoder and NvTransform specific to NVR and fix a memory leak in nvcodec decoder #389

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
6 changes: 0 additions & 6 deletions base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ IF(ENABLE_CUDA)
find_library(NVBUFUTILSLIB nvbuf_utils REQUIRED)
find_library(EGLSTREAM_CAMCONSUMER_LIB nveglstream_camconsumer REQUIRED)
find_library(NVARGUS_SOCKETCLINET_LIB nvargus_socketclient REQUIRED)
find_library(LIBRE_LIB NAMES libre.so libre.a REQUIRED)
find_library(BARESIP_LIB NAMES libbaresip.so REQUIRED)
find_package(Curses REQUIRED)

set(VCPKG_GTK_INCLUDE_DIRS
Expand Down Expand Up @@ -127,8 +125,6 @@ IF(ENABLE_CUDA)
ELSEIF(ENABLE_LINUX)
find_library(LIBNVCUVID libnvcuvid.so PATHS /usr/lib/x86_64-linux-gnu NO_DEFAULT_PATH)
find_library(LIBNVENCODE libnvidia-encode.so PATHS /usr/lib/x86_64-linux-gnu NO_DEFAULT_PATH)
find_library(LIBRE_LIB NAMES libre.so libre.a REQUIRED)
find_library(BARESIP_LIB NAMES libbaresip.so REQUIRED)
SET(NVCODEC_LIB ${LIBNVCUVID} ${LIBNVENCODE})
SET(NVCUDAToolkit_LIBS
libcuda.so
Expand Down Expand Up @@ -519,8 +515,6 @@ target_include_directories ( aprapipes PRIVATE
${OpenCV_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${LIBMP4_INC_DIR}
${BARESIP_INC_DIR}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets keep an option open to build with baresip if required

${LIBRE_INC_DIR}
${NVCODEC_INCLUDE_DIR}
)

Expand Down
2 changes: 1 addition & 1 deletion base/include/PipeLine.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PipeLine {
void stop();
void term();
void wait_for_all(bool ignoreStatus = false);
void interrup_wait_for_all();
void interrupt_wait_for_all();
void flushAllQueues();
const char* getStatus();
};
Expand Down
10 changes: 4 additions & 6 deletions base/src/H264Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,12 +733,10 @@ bool H264Decoder::shouldTriggerSOS()

bool H264Decoder::processEOS(string& pinId)
{
//THIS HAS BEEN COMMENTED IN NVR - BECAUSE EOS IS SENT FROM MP4READER WHICH COMES TO DECODER AND THE FOLLOWING PROCESS IS NOT REQUIRED IN NVR.

// auto frame = frame_sp(new EmptyFrame());
// mDetail->compute(frame->data(), frame->size(), frame->timestamp);
// LOG_ERROR << "processes sos " ;
//mShouldTriggerSOS = true;
auto frame = frame_sp(new EmptyFrame());
mDetail->compute(frame->data(), frame->size(), frame->timestamp);
LOG_ERROR << "processes sos " ;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is thie log error.

mShouldTriggerSOS = true;
return true;
}

Expand Down
9 changes: 8 additions & 1 deletion base/src/H264DecoderNvCodecHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once
#include <iostream>
#include <algorithm>
#include <chrono>
Expand Down Expand Up @@ -563,6 +562,14 @@ NvDecoder::~NvDecoder() {
delete[] pFrame;
}
}

if(m_cuContext)
{
if (m_pMutex) m_pMutex->lock();
cuCtxDestroy(m_cuContext);
if (m_pMutex) m_pMutex->unlock();
}

STOP_TIMER("Session Deinitialization Time: ");
}

Expand Down
4 changes: 2 additions & 2 deletions base/src/H264EncoderNVCodecHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ class H264EncoderNVCodecHelper::Detail
LOG_INFO << "Allocated <" << bufferLength << "> outputbitstreams to the encoder buffer.";
m_nvcodecResources->m_nFreeOutputBitstreams += bufferLength;
}
else
else if(!m_nvcodecResources->m_nFreeOutputBitstreams)
{
LOG_INFO << "waiting for free outputbitstream<> busy streams<" << m_nvcodecResources->m_nBusyOutputBitstreams << ">";
}
Expand Down Expand Up @@ -715,4 +715,4 @@ void H264EncoderNVCodecHelper::endEncode()
bool H264EncoderNVCodecHelper::getSPSPPS(void*& buffer, size_t& size, int& width, int& height)
{
return mDetail->getSPSPPS(buffer, size, width, height);
}
}
2 changes: 2 additions & 0 deletions base/src/H264Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,6 @@ H264Utils::H264_NAL_TYPE H264Utils::getNalTypeAfterSpsPps(void* frameData, size_
}
}
}

return typeFound;
}
3 changes: 1 addition & 2 deletions base/src/NvTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ void NvTransform::setMetadata(framemetadata_sp &metadata)

bool NvTransform::processEOS(string &pinId)
{
//THE FOLLOWING LINE IS COMMENTED FOR SPECIFIC USE IN NVR - MP4READER PASSING EOS WAS COMING HERE AND CAUSING EOS WHICH IS NOT REQUIRED FOR NVR
// mDetail->outputMetadata.reset();
mDetail->outputMetadata.reset();
return true;
}
28 changes: 26 additions & 2 deletions base/src/PipeLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ bool PipeLine::addControlModule(boost::shared_ptr<AbsControlModule> cModule)
for (int i = 0; i < modules.size(); i++)
{
modules[i]->addControlModule(cModule);
cModule->pipelineModules.push_back(modules[i]);
}
return true;
}
Expand Down Expand Up @@ -163,6 +162,7 @@ void PipeLine::run_all_threaded()
{
Module& m = *(modules[0]->controlModule);
m.myThread = boost::thread(ref(m));
Utils::setModuleThreadName(m.myThread, m.getId());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a merge with md/controlmodulepipelineFixes is required

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not reviewing this file

}
mPlay = true;
}
Expand Down Expand Up @@ -232,6 +232,11 @@ void PipeLine::stop()
i->get()->stop();
}
}

if ((modules[0]->controlModule) != nullptr)
{
modules[0]->controlModule->stop();
}
}

void PipeLine::wait_for_all(bool ignoreStatus)
Expand All @@ -242,6 +247,12 @@ void PipeLine::wait_for_all(bool ignoreStatus)
return;
}

if ((modules[0]->controlModule) != nullptr)
{
Module& m = *(modules[0]->controlModule);
m.myThread.join();
}

for (auto i = modules.begin(); i != modules.end(); i++)
{
Module& m = *(i->get());
Expand All @@ -250,25 +261,38 @@ void PipeLine::wait_for_all(bool ignoreStatus)
}


void PipeLine::interrup_wait_for_all()
void PipeLine::interrupt_wait_for_all()
{
if (myStatus > PL_STOPPING)
{
LOG_INFO << "Pipeline status " << getStatus() << " Can not be stopped !";
return;
}

if ((modules[0]->controlModule) != nullptr)
{
Module& m = *(modules[0]->controlModule);
m.myThread.interrupt();
}

for (auto i = modules.begin(); i != modules.end(); i++)
{
Module& m = *(i->get());
m.myThread.interrupt();
}

if ((modules[0]->controlModule) != nullptr)
{
Module& m = *(modules[0]->controlModule);
m.myThread.join();
}

for (auto i = modules.begin(); i != modules.end(); i++)
{
Module& m = *(i->get());
m.myThread.join();
}

myStatus = PL_STOPPED;
}

Expand Down
8 changes: 0 additions & 8 deletions base/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,6 @@
"name": "redis-plus-plus",
"platform": "!arm64"
},
{
"name": "re",
"platform": "!windows"
},
{
"name": "baresip",
"platform": "!windows"
},
{
"name": "libmp4"
}
Expand Down
Loading