GreenScreen: add process test

GitLab: https://git.jami.net/savoirfairelinux/jami-daemon/-/issues/745

Change-Id: Iad3ce60555f8cff81b3e0b49bfc4fc164e2bbb37
diff --git a/AutoAnswer/main.cpp b/AutoAnswer/main.cpp
index dfed25f..ad6a79e 100644
--- a/AutoAnswer/main.cpp
+++ b/AutoAnswer/main.cpp
@@ -99,12 +99,8 @@
     std::cout << "Version " << AutoAnswer_VERSION_MAJOR << "." << AutoAnswer_VERSION_MINOR << "."
               << AutoAnswer_VERSION_PATCH << std::endl << std::endl;
 
-
-#ifdef _WIN32
-    std::ifstream file = std::ifstream(string_utils::to_wstring("testPreferences.yml"));
-#else
-    std::ifstream file = std::ifstream("testPreferences.yml", std::ios_base::in);
-#endif
+    std::ifstream file;
+    file_utils::openStream(file, "testPreferences.yml");
 
     assert(file.is_open());
     YAML::Node node = YAML::Load(file);
diff --git a/GreenScreen/.gitignore b/GreenScreen/.gitignore
new file mode 100644
index 0000000..cc42585
--- /dev/null
+++ b/GreenScreen/.gitignore
@@ -0,0 +1,5 @@
+/GreenScreen
+/libonnxruntime.so.1.6.0
+*.mp4
+GreenScreen*
+/libonnxruntime.dylib
diff --git a/GreenScreen/CMakeLists.txt b/GreenScreen/CMakeLists.txt
index 3a65bd2..db5ad07 100644
--- a/GreenScreen/CMakeLists.txt
+++ b/GreenScreen/CMakeLists.txt
@@ -25,6 +25,8 @@
     set (CONTRIB_PLATFORM ${CONTRIB_PLATFORM_CURT}-windows)
     set (LIBRARY_FILE_NAME ${ProjectName}.dll)
     set (FFMPEG ${CONTRIB_PATH}/build/ffmpeg/Build/win32/x64)
+else()
+    message( FATAL_ERROR "\nUse CMake only for Windows! For linux or Android (linux host), use our bash scripts." )
 endif()
 
 message(Building:\   ${ProjectName}\   ${Version})
@@ -46,8 +48,14 @@
 
 set(CMAKE_CXX_STANDARD 17)
 set(CMAKE_CXX_STANDARD_REQUIRED True)
-set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
-set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
+
+if(TESTPROCESS)
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D__DEBUG__ /MT")
+    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /D__DEBUG__ /MT")
+else()
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MT")
+    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
+endif()
 
 set(plugin_SRC main.cpp
                pluginMediaHandler.cpp
@@ -56,6 +64,7 @@
                ./../lib/accel.cpp
                ./../lib/frameUtils.cpp
                ./../lib/frameFilter.cpp
+               ./../lib/common.cpp
                )
 
 set(plugin_HDR pluginMediaHandler.h
@@ -64,16 +73,19 @@
                ./../lib/pluglog.h
                ./../lib/mediaStream.h
                ./../lib/audioFormat.h
+               ./../lib/common.h
                )
 
+if(TESTPROCESS)
+    add_executable(${ProjectName} ${plugin_SRC}
+                                    ${plugin_HDR}
+                                    )
+else()
+    add_library(${ProjectName} SHARED ${plugin_SRC}
+                                        ${plugin_HDR}
+                                        )
+endif()
 
-
-# add the library
-add_library(${ProjectName} SHARED ${plugin_SRC}
-                                  ${plugin_HDR}
-                                  )
-
-if (WIN32)
 target_include_directories(${ProjectName} PUBLIC ${PROJECT_BINARY_DIR}
                                                  ${PROJECT_SOURCE_DIR}
                                                  ${PLUGINS_LIB}
@@ -84,6 +96,7 @@
                                                  ${CONTRIB_PATH}/build/opencv/build/install/include
                                                  ${ONNX_DIR}/../include/session
                                                  ${ONNX_DIR}/../include/providers/cuda
+                                                 ${CONTRIB_PATH}/build/yaml-cpp/include
                                                  )
 target_link_directories(${ProjectName} PUBLIC ${CONTRIB_PATH}
                                         ${CONTRIB_PATH}/build/fmt/msvc/Release
@@ -93,29 +106,47 @@
                                         ${ONNX_DIR}
                                         ${CONTRIB_PATH}/msvc/lib/x64
                                         ${CONTRIB_PATH}/build/fmt/msvc/Release
+                                        ${CONTRIB_PATH}/build/yaml-cpp/msvc/Release
                                         )
 
-target_link_libraries(${ProjectName} PUBLIC libavfilter libswscale libavformat libavcodec libavutil libvpx libx264 libopus libmfx
+target_link_libraries(${ProjectName} PUBLIC libyaml-cppmd libavfilter libswscale libavformat libavcodec libavutil libvpx libx264 libopus libmfx
                                             libzlib ws2_32 Bcrypt Secur32 opencv_imgproc460 opencv_core460 onnxruntime msvcrt)
-endif()
 
 add_custom_command(
     TARGET ${ProjectName}
     PRE_BUILD
     COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/zlib ${CONTRIB_PATH}/src/zlib
     COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/ffmpeg/ ${CONTRIB_PATH}/src/ffmpeg
+    COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/../contrib/yaml-cpp ${CONTRIB_PATH}/src/yaml-cpp
+    COMMAND python ${DAEMON}/compat/msvc/winmake.py -fb yaml-cpp
     COMMAND python ${DAEMON}/compat/msvc/winmake.py -fb zlib
     COMMAND python ${DAEMON}/compat/msvc/winmake.py -fb ffmpeg
-    COMMAND python ${PROJECT_SOURCE_DIR}/../SDK/jplManipulation.py --preassemble --plugin=${ProjectName}
-    COMMAND ${CMAKE_COMMAND} -E copy ${ONNX_DIR}/onnxruntime.lib ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM}
-    COMMAND ${CMAKE_COMMAND} -E copy ${ONNX_DIR}/onnxruntime.dll ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM}
-    COMMAND ${CMAKE_COMMAND} -E make_directory ${JPL_DIRECTORY}/data/model
-    COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/modelSRC/mModel.onnx ${JPL_DIRECTORY}/data/model
-    COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/${PREFERENCESFILENAME}.json ${JPL_DIRECTORY}/data/preferences.json
-    COMMENT "Assembling Plugin files"
+    COMMAND cd ${CONTRIB_PATH}/src/
+    COMMAND git checkout *
 )
-
-if (WIN32)
+if(TESTPROCESS)
+    add_custom_command(
+        TARGET ${ProjectName}
+        PRE_BUILD
+        COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/testPreferences.yml ${PROJECT_BINARY_DIR}/
+        COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/sample.mp4 ${PROJECT_BINARY_DIR}/
+        COMMAND ${CMAKE_COMMAND} -E copy ${ONNX_DIR}/onnxruntime.lib ${PROJECT_BINARY_DIR}/Debug
+        COMMAND ${CMAKE_COMMAND} -E copy ${ONNX_DIR}/onnxruntime.dll ${PROJECT_BINARY_DIR}/Debug
+        COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_SOURCE_DIR}/data/model
+        COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/modelSRC/mModel.onnx ${PROJECT_SOURCE_DIR}/data/model
+    )
+else()
+    add_custom_command(
+        TARGET ${ProjectName}
+        PRE_BUILD
+        COMMAND python ${PROJECT_SOURCE_DIR}/../SDK/jplManipulation.py --preassemble --plugin=${ProjectName}
+        COMMAND ${CMAKE_COMMAND} -E copy ${ONNX_DIR}/onnxruntime.lib ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM}
+        COMMAND ${CMAKE_COMMAND} -E copy ${ONNX_DIR}/onnxruntime.dll ${JPL_DIRECTORY}/lib/${CONTRIB_PLATFORM}
+        COMMAND ${CMAKE_COMMAND} -E make_directory ${JPL_DIRECTORY}/data/model
+        COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/modelSRC/mModel.onnx ${JPL_DIRECTORY}/data/model
+        COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/${PREFERENCESFILENAME}.json ${JPL_DIRECTORY}/data/preferences.json
+        COMMENT "Assembling Plugin files"
+    )
     add_custom_command(
         TARGET ${ProjectName}
         POST_BUILD
@@ -124,5 +155,4 @@
         COMMAND python ${PROJECT_SOURCE_DIR}/../SDK/jplManipulation.py --assemble --plugin=${ProjectName} --extraPath=${EXTRA_PATH}
         COMMENT "Generating JPL archive"
     )
-
 endif()
diff --git a/GreenScreen/build.sh b/GreenScreen/build.sh
index 5118613..725334d 100755
--- a/GreenScreen/build.sh
+++ b/GreenScreen/build.sh
@@ -6,9 +6,10 @@
 EXTRAPATH=''
 # Flags:
 
-  # -p: number of processors to use
-  # -c: Runtime plugin cpu/gpu setting.
-  # -t: target platform.
+# -p: number of processors to use.
+# -c: Runtime plugin cpu/gpu setting.
+# -t: target platform.
+# -d: debug program.
 
 if [ -z "${DAEMON}" ]; then
     DAEMON="./../../daemon"
@@ -50,8 +51,12 @@
     PREFERENCESFILENAME="${PREFERENCESFILENAME}-accel"
 fi
 
-while getopts t:c:p OPT; do
+while getopts t:c:p:d OPT; do
   case "$OPT" in
+    d)
+      DEBUG=true
+      export __DEBUG__=true
+    ;;
     t)
       PLATFORM="${OPTARG}"
       if [ ${PLATFORM} = "android" ]; then
@@ -69,6 +74,7 @@
 done
 
 cp -r ffmpeg ${CONTRIB_PATH}/src/
+cp -r ../contrib/rav1e ${CONTRIB_PATH}/src/
 
 if [ "${PLATFORM}" = "linux-gnu" ] || [ "${PLATFORM}" = "redhat-linux" ]
 then
@@ -81,8 +87,6 @@
     rm .ffmpeg
     cd ${WORKPATH}
 
-    python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME}
-
     CONTRIB_PLATFORM=${CONTRIB_PLATFORM_CURT}-${PLATFORM}
     ONNX_PATH=${EXTRALIBS_PATH}
     if [ -z "${EXTRALIBS_PATH}" ]
@@ -90,13 +94,23 @@
       ONNX_PATH="${CONTRIB_PATH}/${CONTRIB_PLATFORM}"
     fi
 
+    if [ ${DEBUG} ]; then
+      OUTPUT="${PLUGIN_NAME}"
+      CLANG_OPTS="-g -fsanitize=address"
+      EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lvdpau -lX11 -lva-drm -lva-x11 -lrav1e"
+      EXTRA_DEFINES="-D__DEBUG__"
+    else
+      python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME}
+      CLANG_OPTS="-O3 -shared"
+      OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
+    fi
+
     # Compile
-    clang++ -std=c++17 -shared -fPIC \
+    clang++ -std=c++17 -fPIC ${CLANG_OPTS} \
     -Wl,-Bsymbolic,-rpath,"\${ORIGIN}" \
     -Wall -Wextra \
-    -Wno-unused-variable \
-    -Wno-unused-function \
     -Wno-unused-parameter \
+    ${EXTRA_DEFINES} \
     -D${PROCESSOR} \
     -I"." \
     -I"${DAEMON_SRC}" \
@@ -105,6 +119,7 @@
     -I"${ONNX_PATH}/include/onnxruntime/session" \
     -I"${ONNX_PATH}/include/onnxruntime/providers/cuda" \
     -I"${PLUGINS_LIB}" \
+    ./../lib/common.cpp \
     ./../lib/accel.cpp \
     ./../lib/frameUtils.cpp \
     ./../lib/frameFilter.cpp \
@@ -125,11 +140,26 @@
     -l:libx264.a \
     -lopencv_imgproc \
     -lopencv_core \
-    -lva ${CUBLASLT} \
-    -lonnxruntime \
-    -o "build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
+    -lvpx \
+    -lx264 \
+    -lspeex \
+    -lopus \
+    -lz \
+    -lva \
+    ${CUBLASLT} -lonnxruntime \
+    ${EXTRA_DEBUG_LIBRARIES} \
+    -o "${OUTPUT}"
 
-    cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.so" "build-local/jpl/lib/$CONTRIB_PLATFORM/libonnxruntime.so.1.6.0"
+    if [ ${DEBUG} ]; then
+      cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.so" "libonnxruntime.so.1.6.0"
+      mkdir -p "./data/model"
+      cp "./modelSRC/mModel.onnx" "./data/model/mModel.onnx"
+    else
+      cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.so" "build-local/jpl/lib/$CONTRIB_PLATFORM/libonnxruntime.so.1.6.0"
+      mkdir -p "./build-local/jpl/data/model"
+      cp "./modelSRC/mModel.onnx" "./build-local/jpl/data/model/mModel.onnx"
+      cp "./${PREFERENCESFILENAME}.json" "./build-local/jpl/data/preferences.json"
+    fi
     if [ "${PROCESSOR}" = "NVIDIA" ]
     then
       cp "${CUDA_HOME}/lib64/libcudart.so.10.2.89" "build-local/jpl/lib/$CONTRIB_PLATFORM/libcudart.so.10.2"
@@ -141,12 +171,8 @@
       cp "${CUDNN_HOME}/libcudnn_ops_infer.so.8" "build-local/jpl/lib/$CONTRIB_PLATFORM/libcudnn_ops_infer.so.8"
     fi
 
-    mkdir "./build-local/jpl/data/model"
-    cp "./modelSRC/mModel.onnx" "./build-local/jpl/data/model/mModel.onnx"
-    cp "./${PREFERENCESFILENAME}.json" "./build-local/jpl/data/preferences.json"
-
 elif [ "${PLATFORM}" = "darwin" ]
-then  
+then
     if [ -f "${CONTRIB_PATH}/native/.ffmpeg" ]; then
         rm "${CONTRIB_PATH}/native/.ffmpeg"
     fi
@@ -156,8 +182,6 @@
     rm .ffmpeg
     cd ${WORKPATH}
 
-    python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME}
-  
     CONTRIB_PLATFORM=${CONTRIB_PLATFORM_CURT}-${PLATFORM}
     ONNX_PATH=${EXTRALIBS_PATH}
     if [ -z "${EXTRALIBS_PATH}" ]
@@ -165,17 +189,27 @@
       ONNX_PATH="${CONTRIB_PATH}/${CONTRIB_PLATFORM}${CONTRIB_PLATFORM_EXTRA}"
     fi
 
+    if [ ${DEBUG} ]; then
+      OUTPUT="${PLUGIN_NAME}"
+      CLANG_OPTS="-g -fsanitize=address"
+      EXTRA_DEBUG_LIBRARIES="-lyaml-cpp -lrav1e"
+      EXTRA_DEFINES="-D__DEBUG__"
+    else
+      python3 ./../SDK/jplManipulation.py --preassemble --plugin=${PLUGIN_NAME}
+      CLANG_OPTS="-O3 -shared"
+      OUTPUT="build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
+    fi
+
     # Compile
-    clang++ -std=c++17 -shared -fPIC \
+    clang++ -std=c++17 -fPIC ${CLANG_OPTS} \
     -Wl,-no_compact_unwind -Wl,-framework,CoreFoundation \
     -Wl,-framework,Security -Wl,-framework,VideoToolbox \
     -Wl,-framework,CoreMedia -Wl,-framework,CoreVideo \
     -Wl,-framework,OpenCl -Wl,-framework,Accelerate \
     -Wl,-rpath,"\${ORIGIN}" \
     -Wall -Wextra \
-    -Wno-unused-variable \
-    -Wno-unused-function \
     -Wno-unused-parameter \
+    ${EXTRA_DEFINES} \
     -D${PROCESSOR} \
     -I"." \
     -I"${DAEMON_SRC}" \
@@ -183,6 +217,7 @@
     -I"${CONTRIB_PATH}/${CONTRIB_PLATFORM}${CONTRIB_PLATFORM_EXTRA}/include/opencv4" \
     -I"${ONNX_PATH}/include/onnxruntime/session" \
     -I"${PLUGINS_LIB}" \
+    ./../lib/common.cpp \
     ./../lib/accel.cpp \
     ./../lib/frameUtils.cpp \
     ./../lib/frameFilter.cpp \
@@ -202,18 +237,26 @@
     -lopencv_imgproc \
     -lopencv_core \
     -lonnxruntime \
-    "/usr/local/opt/speex/lib/libspeex.a" \
-    "/usr/local/opt/opus/lib/libopus.a" \
-    -o "build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
+    -lspeex \
+    -lopus \
+    ${EXTRA_DEBUG_LIBRARIES} \
+    -o "${OUTPUT}"
 
-    cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.dylib" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib"
-    install_name_tool -id "@loader_path/libonnxruntime.1.6.0.dylib" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib"
-    install_name_tool -id "@loader_path/${SO_FILE_NAME}" "build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
-    install_name_tool -change "@rpath/libonnxruntime.1.6.0.dylib" "@loader_path/libonnxruntime.dylib" "build-local/jpl/lib/${CONTRIB_PLATFORM}/${SO_FILE_NAME}"
-
-    mkdir "./build-local/jpl/data/model"
-    cp "./modelSRC/mModel.onnx" "./build-local/jpl/data/model/mModel.onnx"
-    cp "./${PREFERENCESFILENAME}.json" "./build-local/jpl/data/preferences.json"
+    if [ ${DEBUG} ]; then
+      mkdir -p "./data/model"
+      cp "./modelSRC/mModel.onnx" "./data/model/mModel.onnx"
+      cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.dylib" "libonnxruntime.dylib"
+      install_name_tool -id "@loader_path/libonnxruntime.1.6.0.dylib" "libonnxruntime.dylib"
+      install_name_tool -id "@loader_path/${PLUGIN_NAME}" "${OUTPUT}"
+    else
+      mkdir -p "./build-local/jpl/data/model"
+      cp "./modelSRC/mModel.onnx" "./build-local/jpl/data/model/mModel.onnx"
+      cp "./${PREFERENCESFILENAME}.json" "./build-local/jpl/data/preferences.json"
+      cp "${ONNX_PATH}/lib/onnxruntime/${ONNX_LIBS}/libonnxruntime.dylib" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib"
+      install_name_tool -id "@loader_path/libonnxruntime.1.6.0.dylib" "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib"
+      install_name_tool -id "@loader_path/${SO_FILE_NAME}" "${OUTPUT}"
+    fi
+    install_name_tool -change "@rpath/libonnxruntime.1.6.0.dylib" "@loader_path/libonnxruntime.dylib" "${OUTPUT}"
 
     if [ -n "${APPLE_SIGN_CERTIFICATE}" ]; then
       codesign --force --verify --timestamp -o runtime --sign "${APPLE_SIGN_CERTIFICATE}"  "build-local/jpl/lib/${CONTRIB_PLATFORM}/libonnxruntime.dylib"
@@ -407,12 +450,14 @@
         buildlib
     done
 
-    mkdir "./build-local/jpl/data/model"
+    mkdir -p "./build-local/jpl/data/model"
     cp "./modelSRC/mModel.ort" "./build-local/jpl/data/model/mModel.ort"
     cp "./${PREFERENCESFILENAME}-accel.json" "./build-local/jpl/data/preferences.json"
 fi
 
-python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${ONNX_LIBS}
+if [ ! ${DEBUG} ]; then
+  python3 ./../SDK/jplManipulation.py --assemble --plugin=${PLUGIN_NAME} --distribution=${PLATFORM} --extraPath=${ONNX_LIBS}
+fi
 cd ${CONTRIB_PATH}/src/ffmpeg/
 # ffmpeg build configuration files were changed during plugin build
 # this git checkout will remove these changes
diff --git a/GreenScreen/data/model/.gitignore b/GreenScreen/data/model/.gitignore
new file mode 100644
index 0000000..9898231
--- /dev/null
+++ b/GreenScreen/data/model/.gitignore
@@ -0,0 +1 @@
+/mModel.onnx
diff --git a/GreenScreen/ffmpeg/rules.mak b/GreenScreen/ffmpeg/rules.mak
index c97236a..372c048 100644
--- a/GreenScreen/ffmpeg/rules.mak
+++ b/GreenScreen/ffmpeg/rules.mak
@@ -3,7 +3,15 @@
 
 PKGS+=ffmpeg
 
+ifdef HAVE_ANDROID
 DEPS_ffmpeg = iconv zlib vpx opus speex x264
+else
+ifdef __DEBUG__
+DEPS_ffmpeg = iconv zlib vpx opus speex x264 rav1e
+else
+DEPS_ffmpeg = iconv zlib vpx opus speex x264
+endif
+endif
 
 FFMPEGCONF = \
 	--cc="$(CC)" \
@@ -169,6 +177,12 @@
 	--enable-filter=colorkey \
 	--enable-filter=split
 
+ifdef __DEBUG__
+FFMPEGCONF += \
+	--enable-librav1e\
+	--enable-encoder=librav1e \
+	--enable-muxer=mp4
+endif
 
 #platform specific options
 
diff --git a/GreenScreen/ffmpeg/windows-configure-make.sh b/GreenScreen/ffmpeg/windows-configure-make.sh
index b6ec0d9..f288dc5 100644
--- a/GreenScreen/ffmpeg/windows-configure-make.sh
+++ b/GreenScreen/ffmpeg/windows-configure-make.sh
@@ -109,6 +109,9 @@
             --enable-encoder=png
             --enable-decoder=png'
 
+FFMPEGCONF+='
+	--enable-muxer=mp4'
+
 #filters
 FFMPEGCONF+='
             --enable-filter=scale
diff --git a/GreenScreen/main.cpp b/GreenScreen/main.cpp
index eef75af..156bf69 100644
--- a/GreenScreen/main.cpp
+++ b/GreenScreen/main.cpp
@@ -26,6 +26,14 @@
 #include <plugin/jamiplugin.h>
 #include "pluginMediaHandler.h"
 
+#ifdef __DEBUG__
+#include <assert.h>
+#include <yaml-cpp/yaml.h>
+#include <fstream>
+#include <AVFrameIO.h>
+#include <common.h>
+#endif
+
 #ifdef WIN32
 #define EXPORT_PLUGIN __declspec(dllexport)
 #else
@@ -45,7 +53,7 @@
 JAMI_dynPluginInit(const JAMI_PluginAPI* api)
 {
     std::cout << "*******************" << std::endl;
-    std::cout << "**  GREENSCREEN  **" << std::endl;
+    std::cout << "**  GreenScreen  **" << std::endl;
     std::cout << "*******************" << std::endl << std::endl;
     std::cout << "Version " << GreenScreen_VERSION_MAJOR << "." << GreenScreen_VERSION_MINOR << "."
               << GreenScreen_VERSION_PATCH << std::endl;
@@ -66,3 +74,47 @@
     return nullptr;
 }
 }
+
+#ifdef __DEBUG__
+
+int
+main ()
+{
+    std::cout << "*********************************" << std::endl;
+    std::cout << "**  GreenScreen Debug Version  **" << std::endl;
+    std::cout << "*********************************" << std::endl;
+    std::cout << "Version " << GreenScreen_VERSION_MAJOR << "." << GreenScreen_VERSION_MINOR << "."
+              << GreenScreen_VERSION_PATCH << std::endl << std::endl;
+
+    std::ifstream file;
+    file_utils::openStream(file, "testPreferences.yml");
+
+    assert(file.is_open());
+    YAML::Node node = YAML::Load(file);
+
+    assert(node.IsMap());
+    std::map<std::string, std::string> preferences;
+    for (const auto& kv : node) {
+        preferences[kv.first.as<std::string>()] = kv.second.as<std::string>();
+        std::cout << "Key: " << kv.first.as<std::string>() << "; Value: " << kv.second.as<std::string>() << std::endl;
+    }
+
+#ifdef _WIN32
+    std::string dataPath = "../data";
+#else
+    std::string dataPath = "data";
+#endif
+    preferences["background"] = dataPath + separator() + preferences["background"];
+
+    auto fmp = std::make_unique<jami::PluginMediaHandler>(std::move(preferences), std::move(dataPath));
+
+    auto subject = std::make_shared<jami::PublishObservable<AVFrame*>>();
+
+    // Valid Read frames from sample file and send to subscriber
+    std::cout << "Test 1" << std::endl << "Sent video: " << preferences["sample"] << std::endl;
+    fmp->notifyAVFrameSubject(StreamData("testCall", false, StreamType::video, "origin", "destiny"), subject);
+    av_utils::readAndNotifyAVFrame(preferences["sample"], subject.get(), preferences["output"], AVMEDIA_TYPE_VIDEO);
+
+    return 0;
+}
+#endif
diff --git a/GreenScreen/package.json b/GreenScreen/package.json
index c4773e6..13f516d 100644
--- a/GreenScreen/package.json
+++ b/GreenScreen/package.json
@@ -4,11 +4,11 @@
     "extractLibs": false,
     "deps": [
         "fmt",
-        "ffmpeg",
         "opencv"
     ],
     "defines": [
-        "NVIDIA=False"
+        "NVIDIA=False",
+        "TESTPROCESS=False"
     ],
     "custom_scripts": {
         "pre_build": [
diff --git a/GreenScreen/pluginProcessor.cpp b/GreenScreen/pluginProcessor.cpp
index 52b7d17..ff189f1 100644
--- a/GreenScreen/pluginProcessor.cpp
+++ b/GreenScreen/pluginProcessor.cpp
@@ -27,10 +27,7 @@
 }
 #include <frameUtils.h>
 #include <pluglog.h>
-
-#ifdef WIN32
 #include <common.h>
-#endif
 
 const char sep = separator();
 
@@ -321,7 +318,6 @@
     if (mainFilter_.initialize(mainFilterDescription_, {maskms_, bgStream_, ims2_}) < 0)
         return;
 
-    int got_frame;
     AVCodecContext* pCodecCtx;
     AVPacket* packet;
 
@@ -376,6 +372,8 @@
 
     frameFree(bgImage);
     avcodec_close(pCodecCtx);
+    avcodec_free_context(&pCodecCtx);
+    av_packet_unref(packet);
     av_packet_free(&packet);
     pFormatCtx_.reset();
 }
diff --git a/GreenScreen/sample.mp4 b/GreenScreen/sample.mp4
new file mode 100644
index 0000000..f71fcb8
--- /dev/null
+++ b/GreenScreen/sample.mp4
Binary files differ
diff --git a/GreenScreen/testPreferences.yml b/GreenScreen/testPreferences.yml
new file mode 100644
index 0000000..32a64ab
--- /dev/null
+++ b/GreenScreen/testPreferences.yml
@@ -0,0 +1,6 @@
+background: "backgrounds/background2.jpeg"
+blur: "0"
+blurlevel: "8"
+streamslist: "out"
+sample: "sample.mp4"
+output: "processed.mp4"
\ No newline at end of file
diff --git a/contrib/yaml-cpp/package.json b/contrib/yaml-cpp/package.json
new file mode 100644
index 0000000..fba0139
--- /dev/null
+++ b/contrib/yaml-cpp/package.json
@@ -0,0 +1,17 @@
+{
+    "name": "yaml-cpp",
+    "version": "24fa1b33805c9a91df0f32c46c28e314dd7ad96f",
+    "url": "https://github.com/jbeder/yaml-cpp/archive/__VERSION__.tar.gz",
+    "deps": [],
+    "patches": [],
+    "win_patches": [],
+    "project_paths": ["msvc/yaml-cpp.vcxproj"],
+    "with_env" : "",
+    "custom_scripts": {
+        "pre_build": [
+            "mkdir msvc & cd msvc & cmake .. -G %CMAKE_GENERATOR% -DCMAKE_CXX_FLAGS_RELEASE='/MT'"
+        ],
+        "build": [],
+        "post_build": []
+    }
+}
\ No newline at end of file
diff --git a/lib/AVFrameIO.h b/lib/AVFrameIO.h
index 867ffa8..6845d33 100644
--- a/lib/AVFrameIO.h
+++ b/lib/AVFrameIO.h
@@ -1,3 +1,22 @@
+/**
+ *  Copyright (C) 2022 Savoir-faire Linux Inc.
+ *
+ *  Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.
+ */
 
 extern "C" {
 #include <libavcodec/avcodec.h>