AudioFilter
- creates plugin with reverb filter
- adjusts HelloWorld and GreenScreen to fit audio/video handling from daemon
- some code cleanup
Change-Id: If4fda4dc67b9b3db14fc7395ebf3d510923b454b
GitLab: #3
diff --git a/HelloWorld/CoinCircleVideoSubscriber.cpp b/HelloWorld/CoinCircleVideoSubscriber.cpp
index 6b4a94e..5e963cb 100644
--- a/HelloWorld/CoinCircleVideoSubscriber.cpp
+++ b/HelloWorld/CoinCircleVideoSubscriber.cpp
@@ -24,10 +24,8 @@
#include <libavutil/display.h>
}
#include <accel.h>
-
-// LOGGING
+#include <frameUtils.h>
#include <pluglog.h>
-
#include <stdio.h>
#include <opencv2/imgproc.hpp>
@@ -48,21 +46,21 @@
}
void
-CoinCircleVideoSubscriber::update(jami::Observable<AVFrame*>*, AVFrame* const& iFrame)
+CoinCircleVideoSubscriber::update(jami::Observable<AVFrame*>*, AVFrame* const& pluginFrame)
{
- if (!iFrame)
+ if (!pluginFrame)
return;
- AVFrame* pluginFrame = const_cast<AVFrame*>(iFrame);
//======================================================================================
// GET FRAME ROTATION
- AVFrameSideData* side_data = av_frame_get_side_data(iFrame, AV_FRAME_DATA_DISPLAYMATRIX);
+ AVFrameSideData* side_data = av_frame_get_side_data(pluginFrame, AV_FRAME_DATA_DISPLAYMATRIX);
int angle {0};
if (side_data) {
auto matrix_rotation = reinterpret_cast<int32_t*>(side_data->data);
angle = static_cast<int>(av_display_rotation_get(matrix_rotation));
}
+ delete side_data;
//======================================================================================
// GET RAW FRAME
@@ -70,10 +68,12 @@
// Convert input frame to RGB
int inputHeight = pluginFrame->height;
int inputWidth = pluginFrame->width;
- FrameUniquePtr bgrFrame = scaler.convertFormat(transferToMainMemory(pluginFrame,
- AV_PIX_FMT_NV12),
- AV_PIX_FMT_RGB24);
-
+ AVFrame* temp = transferToMainMemory(pluginFrame, AV_PIX_FMT_NV12);
+ AVFrame* bgrFrame = scaler.convertFormat(temp, AV_PIX_FMT_RGB24);
+ av_frame_unref(temp);
+ av_frame_free(&temp);
+ if (!bgrFrame)
+ return;
resultFrame = cv::Mat {bgrFrame->height,
bgrFrame->width,
CV_8UC3,
@@ -99,7 +99,7 @@
//======================================================================================
// REPLACE AVFRAME DATA WITH FRAME DATA
- if (bgrFrame && bgrFrame->data[0]) {
+ if (bgrFrame->data[0]) {
uint8_t* frameData = bgrFrame->data[0];
if (angle == 90 || angle == -90) {
std::memmove(frameData,
@@ -107,15 +107,12 @@
static_cast<size_t>(pluginFrame->width * pluginFrame->height * 3)
* sizeof(uint8_t));
}
- }
- // Copy Frame meta data
- if (bgrFrame && pluginFrame) {
- av_frame_copy_props(bgrFrame.get(), pluginFrame);
- scaler.moveFrom(pluginFrame, bgrFrame.get());
- }
- // Remove the pointer
- pluginFrame = nullptr;
+ av_frame_copy_props(bgrFrame, pluginFrame);
+ moveFrom(pluginFrame, bgrFrame);
+ }
+ av_frame_unref(bgrFrame);
+ av_frame_free(&bgrFrame);
}
void