Skip to content

Commit

Permalink
fix memory leak in v4l2 h264 capturer
Browse files Browse the repository at this point in the history
  • Loading branch information
mpromonet committed Apr 5, 2021
1 parent 1129431 commit b15c7a3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions inc/V4l2Capturer.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ class V4l2Capturer : public rtc::VideoSourceInterface<webrtc::VideoFrame>
{
char* buffer = new char[m_capture->getBufferSize()];
int frameSize = m_capture->read(buffer, m_capture->getBufferSize());
int64_t ts = std::chrono::high_resolution_clock::now().time_since_epoch().count()/1000/1000;

rtc::scoped_refptr<webrtc::EncodedImageBufferInterface> encodedData = webrtc::EncodedImageBuffer::Create((uint8_t*)buffer, frameSize);
rtc::scoped_refptr<webrtc::VideoFrameBuffer> frameBuffer = new rtc::RefCountedObject<EncodedVideoFrameBuffer>(m_capture->getWidth(), m_capture->getHeight(), encodedData);
delete [] buffer;

int64_t ts = std::chrono::high_resolution_clock::now().time_since_epoch().count()/1000/1000;
rtc::scoped_refptr<webrtc::VideoFrameBuffer> frameBuffer = new rtc::RefCountedObject<EncodedVideoFrameBuffer>(m_capture->getWidth(), m_capture->getHeight(), encodedData);
webrtc::VideoFrame frame = webrtc::VideoFrame::Builder()
.set_video_frame_buffer(frameBuffer)
.set_rotation(webrtc::kVideoRotation_0)
Expand Down

0 comments on commit b15c7a3

Please sign in to comment.