From a4593fc1ef077d329edde79a40fe27155384a1d7 Mon Sep 17 00:00:00 2001 From: Daniel Walz Date: Sat, 25 Nov 2023 16:44:42 +0100 Subject: [PATCH] Fixed MacOS build and merged addons into base --- examples/MultiCamTest/MultiCamTest.jucer | 121 ------ examples/VideoPlayer/Source/MainComponent.cpp | 137 +++---- examples/VideoPlayer/Source/OSDComponent.h | 4 +- modules/CMakeLists.txt | 2 +- .../Tests/VideoPlayer/CMakeLists.txt | 61 --- .../Tests/VideoPlayer/Source/Main.cpp | 107 ------ .../VideoPlayer/Source/MainComponent.cpp | 359 ------------------ .../Tests/VideoPlayer/Source/OSDComponent.h | 180 --------- .../Tests/VideoPlayer/VideoPlayer.jucer | 90 ----- .../foleys_video_addons.cpp | 32 -- .../foleys_video_addons/foleys_video_addons.h | 73 ---- .../foleys_video_addons.mm | 25 -- .../Basics/foleys_VideoEngine.h | 9 +- .../Camera/foleys_CameraClip.h | 3 + .../Camera/foleys_CameraManager.h | 2 + .../Camera/foleys_CameraManager_OSX.mm | 2 +- .../foleys_video_engine/Clips/foleys_AVClip.h | 3 + .../Clips/foleys_ClipDescriptor.h | 2 + .../Clips/foleys_ComposedClip.h | 2 + .../Plugins/foleys_VideoPluginManager.h | 2 + .../Processing/foleys_ParameterAutomation.h | 5 + .../ReadWrite/foleys_AVFormatManager.h | 1 - .../Widgets/foleys_SoftwareView.h | 2 + .../foleys_video_engine.cpp | 1 + .../foleys_video_engine/foleys_video_engine.h | 89 ++--- .../foleys_video_engine_types.h | 29 ++ 26 files changed, 158 insertions(+), 1185 deletions(-) delete mode 100644 examples/MultiCamTest/MultiCamTest.jucer delete mode 100644 modules/foleys_video_addons/Tests/VideoPlayer/CMakeLists.txt delete mode 100755 modules/foleys_video_addons/Tests/VideoPlayer/Source/Main.cpp delete mode 100755 modules/foleys_video_addons/Tests/VideoPlayer/Source/MainComponent.cpp delete mode 100644 modules/foleys_video_addons/Tests/VideoPlayer/Source/OSDComponent.h delete mode 100644 modules/foleys_video_addons/Tests/VideoPlayer/VideoPlayer.jucer delete mode 100644 modules/foleys_video_addons/foleys_video_addons.cpp delete mode 100644 modules/foleys_video_addons/foleys_video_addons.h delete mode 100644 modules/foleys_video_addons/foleys_video_addons.mm create mode 100644 modules/foleys_video_engine/foleys_video_engine_types.h diff --git a/examples/MultiCamTest/MultiCamTest.jucer b/examples/MultiCamTest/MultiCamTest.jucer deleted file mode 100644 index c966156e..00000000 --- a/examples/MultiCamTest/MultiCamTest.jucer +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/VideoPlayer/Source/MainComponent.cpp b/examples/VideoPlayer/Source/MainComponent.cpp index 36c8a48c..798b3eb0 100755 --- a/examples/VideoPlayer/Source/MainComponent.cpp +++ b/examples/VideoPlayer/Source/MainComponent.cpp @@ -33,7 +33,6 @@ #include "../JuceLibraryCode/JuceHeader.h" - #include "OSDComponent.h" //============================================================================== @@ -41,13 +40,14 @@ The display plus drop target to allow movies dragged into */ #if FOLEYS_USE_OPENGL -using ViewType=foleys::OpenGLView; +using ViewType = foleys::OpenGLView; #else -using ViewType=foleys::SoftwareView; +using ViewType = foleys::SoftwareView; #endif -class VideoComponentWithDropper : public ViewType, - public juce::FileDragAndDropTarget +class VideoComponentWithDropper + : public ViewType + , public juce::FileDragAndDropTarget { public: VideoComponentWithDropper() @@ -58,20 +58,18 @@ class VideoComponentWithDropper : public ViewType, setContinuousRepaint (30); } - bool isInterestedInFileDrag (const juce::StringArray &) override - { - return true; - } + bool isInterestedInFileDrag (const juce::StringArray&) override { return true; } - void filesDropped (const juce::StringArray &files, int, int) override + void filesDropped (const juce::StringArray& files, int, int) override { if (onFileDropped) - onFileDropped (files [0]); + onFileDropped (files[0]); juce::Process::makeForegroundProcess(); } - std::function onFileDropped; + std::function onFileDropped; + private: JUCE_DECLARE_NON_COPYABLE (VideoComponentWithDropper) }; @@ -81,8 +79,9 @@ class VideoComponentWithDropper : public ViewType, This component lives inside our window, and this is where you should put all your controls and content. */ -class MainContentComponent : public juce::AudioAppComponent, - public foleys::TimeCodeAware::Listener +class MainContentComponent + : public juce::AudioAppComponent + , public foleys::TimeCodeAware::Listener { public: //============================================================================== @@ -90,9 +89,11 @@ class MainContentComponent : public juce::AudioAppComponent, { setWantsKeyboardFocus (true); + videoEngine.getFormatManager().registerFormat (std::make_unique()); + dummy.setBounds (0, 0, 1, 1); addAndMakeVisible (dummy); - + addAndMakeVisible (videoComponent); videoComponent.addAndMakeVisible (osdComponent); @@ -100,7 +101,8 @@ class MainContentComponent : public juce::AudioAppComponent, setAudioChannels (0, 2); #ifdef DEBUG - if (auto* device = deviceManager.getCurrentAudioDevice()) { + if (auto* device = deviceManager.getCurrentAudioDevice()) + { DBG ("Current Samplerate: " + juce::String (device->getCurrentSampleRate())); DBG ("Current Buffersize: " + juce::String (device->getCurrentBufferSizeSamples())); DBG ("Current Bitdepth: " + juce::String (device->getCurrentBitDepth())); @@ -109,16 +111,12 @@ class MainContentComponent : public juce::AudioAppComponent, #if USE_FF_AUDIO_METERS meter = std::make_unique(); - meter->getLookAndFeel().setColour (foleys::LevelMeter::ColourIds::lmBackgroundColour, - juce::Colour::fromFloatRGBA (0.0f, 0.0f, 0.0f, 0.6f)); + meter->getLookAndFeel().setColour (foleys::LevelMeter::ColourIds::lmBackgroundColour, juce::Colour::fromFloatRGBA (0.0f, 0.0f, 0.0f, 0.6f)); meter->setMeterSource (&meterSource); addAndMakeVisible (*meter); #endif - osdComponent.open.onClick = [this] - { - openFile(); - }; + osdComponent.open.onClick = [this] { openFile(); }; osdComponent.stop.onClick = [this] { @@ -127,10 +125,7 @@ class MainContentComponent : public juce::AudioAppComponent, clip->setNextReadPosition (0); }; - osdComponent.pause.onClick = [this] - { - transportSource.stop(); - }; + osdComponent.pause.onClick = [this] { transportSource.stop(); }; osdComponent.play.onClick = [this] { @@ -140,8 +135,8 @@ class MainContentComponent : public juce::AudioAppComponent, if (ffwdSpeed != 2) { auto lastPos = clip->getNextReadPosition(); - ffwdSpeed = 2; - auto factor = 0.5 + (ffwdSpeed / 4.0); + ffwdSpeed = 2; + auto factor = 0.5 + (ffwdSpeed / 4.0); transportSource.setSource (clip.get(), 0, nullptr, factor, 2); clip->setNextReadPosition (lastPos); } @@ -154,11 +149,11 @@ class MainContentComponent : public juce::AudioAppComponent, return; auto lastPos = clip->getNextReadPosition(); - ffwdSpeed = (ffwdSpeed + 1) % 7; - auto factor = 0.5 + (ffwdSpeed / 4.0); + ffwdSpeed = (ffwdSpeed + 1) % 7; + auto factor = 0.5 + (ffwdSpeed / 4.0); transportSource.setSource (clip.get(), 0, nullptr, factor, 2); clip->setNextReadPosition (lastPos); - transportSource.start (); + transportSource.start(); }; osdComponent.seekBar.onValueChange = [this] @@ -167,25 +162,16 @@ class MainContentComponent : public juce::AudioAppComponent, clip->setNextReadPosition (juce::int64 (osdComponent.seekBar.getValue() * sampleRate)); }; -#if FOLEYS_HAS_ADDONS - osdComponent.camera.onClick = [this] - { - openCamera(); - }; +#if FOLEYS_CAMERA_SUPPORT + osdComponent.camera.onClick = [this] { openCamera(); }; #endif - videoComponent.onFileDropped = [this](juce::File file) - { - openFile (file); - }; + videoComponent.onFileDropped = [this] (juce::File file) { openFile (file); }; setSize (800, 600); } - ~MainContentComponent() override - { - shutdownAudio(); - } + ~MainContentComponent() override { shutdownAudio(); } //============================================================================== void prepareToPlay (int samplesPerBlockExpected, double newSampleRate) override @@ -205,11 +191,9 @@ class MainContentComponent : public juce::AudioAppComponent, void getNextAudioBlock (const juce::AudioSourceChannelInfo& bufferToFill) override { - auto numInputChannels = 2; //movieClip->getVideoChannels(); + auto numInputChannels = 2; // movieClip->getVideoChannels(); - juce::AudioSourceChannelInfo info (&readBuffer, - bufferToFill.startSample, - bufferToFill.numSamples); + juce::AudioSourceChannelInfo info (&readBuffer, bufferToFill.startSample, bufferToFill.numSamples); // the AudioTransportSource takes care of start, stop and resample transportSource.getNextAudioBlock (info); @@ -219,17 +203,14 @@ class MainContentComponent : public juce::AudioAppComponent, if (numInputChannels > 0) { - for (int i=0; i < bufferToFill.buffer->getNumChannels(); ++i) { + for (int i = 0; i < bufferToFill.buffer->getNumChannels(); ++i) + { - bufferToFill.buffer->copyFrom (i, bufferToFill.startSample, - readBuffer.getReadPointer (i % numInputChannels), - bufferToFill.numSamples); - if (bufferToFill.buffer->getNumChannels() == 2 && - readBuffer.getNumChannels() > 2) { + bufferToFill.buffer->copyFrom (i, bufferToFill.startSample, readBuffer.getReadPointer (i % numInputChannels), bufferToFill.numSamples); + if (bufferToFill.buffer->getNumChannels() == 2 && readBuffer.getNumChannels() > 2) + { // add center to left and right - bufferToFill.buffer->addFrom (i, bufferToFill.startSample, - readBuffer.getReadPointer (2), - bufferToFill.numSamples, 0.7f); + bufferToFill.buffer->addFrom (i, bufferToFill.startSample, readBuffer.getReadPointer (2), bufferToFill.numSamples, 0.7f); } } } @@ -241,15 +222,12 @@ class MainContentComponent : public juce::AudioAppComponent, void releaseResources() override { - transportSource.releaseResources (); + transportSource.releaseResources(); if (clip.get() != nullptr) - clip->releaseResources (); + clip->releaseResources(); } - void timecodeChanged (int64_t, double seconds) override - { - osdComponent.seekBar.setValue (seconds, juce::dontSendNotification); - } + void timecodeChanged (int64_t, double seconds) override { osdComponent.seekBar.setValue (seconds, juce::dontSendNotification); } void openFile (juce::File name) { @@ -286,14 +264,15 @@ class MainContentComponent : public juce::AudioAppComponent, } } -#if FOLEYS_HAS_ADDONS +#if FOLEYS_CAMERA_SUPPORT void openCamera() { osdComponent.setClip ({}); transportSource.stop(); transportSource.setSource (nullptr); - auto newClip = cameraManager.createCameraClip (1); + auto camera = cameraManager.openCamera (0); + auto newClip = cameraManager.createCameraClip (std::move (camera)); videoEngine.manageLifeTime (newClip); newClip->prepareToPlay (blockSize, sampleRate); clip = newClip; @@ -303,10 +282,7 @@ class MainContentComponent : public juce::AudioAppComponent, } #endif - void paint (juce::Graphics& g) override - { - g.fillAll (juce::Colours::black); - } + void paint (juce::Graphics& g) override { g.fillAll (juce::Colours::black); } void resized() override { @@ -314,12 +290,12 @@ class MainContentComponent : public juce::AudioAppComponent, osdComponent.setBounds (getBounds()); #if USE_FF_AUDIO_METERS - const int w = 30 + 20 * meterSource.getNumChannels(); + const int w = 30 + 20 * meterSource.getNumChannels(); meter->setBounds (getWidth() - w, getHeight() - 240, w, 200); #endif } - bool keyPressed (const juce::KeyPress &key) override + bool keyPressed (const juce::KeyPress& key) override { if (key == juce::KeyPress::spaceKey) { @@ -346,24 +322,27 @@ class MainContentComponent : public juce::AudioAppComponent, std::shared_ptr clip; - juce::AudioTransportSource transportSource; - double sampleRate = 0.0; - int blockSize = 0; - int ffwdSpeed = 2; + juce::AudioTransportSource transportSource; + double sampleRate = 0.0; + int blockSize = 0; + int ffwdSpeed = 2; - VideoComponentWithDropper videoComponent; - OSDComponent osdComponent; + VideoComponentWithDropper videoComponent; + OSDComponent osdComponent; #if USE_FF_AUDIO_METERS std::unique_ptr meter; foleys::LevelMeterSource meterSource; #endif - juce::AudioBuffer readBuffer; + juce::AudioBuffer readBuffer; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent) }; // (This function is called by the app startup code to create our main component) -juce::Component* createMainContentComponent() { return new MainContentComponent(); } +juce::Component* createMainContentComponent() +{ + return new MainContentComponent(); +} diff --git a/examples/VideoPlayer/Source/OSDComponent.h b/examples/VideoPlayer/Source/OSDComponent.h index 5a1130e7..572c48f8 100644 --- a/examples/VideoPlayer/Source/OSDComponent.h +++ b/examples/VideoPlayer/Source/OSDComponent.h @@ -51,7 +51,7 @@ class OSDComponent : public juce::Component addAndMakeVisible (open); flexBox.items.add (juce::FlexItem (open).withFlex (1.0, 1.0, 0.5).withHeight (20.0)); -#if FOLEYS_HAS_ADDONS +#if FOLEYS_CAMERA_SUPPORT camera.setWantsKeyboardFocus (false); addAndMakeVisible (camera); flexBox.items.add (juce::FlexItem (camera).withFlex (1.0, 1.0, 0.5).withHeight (20.0)); @@ -77,7 +77,7 @@ class OSDComponent : public juce::Component addAndMakeVisible (ffwd); flexBox.items.add (juce::FlexItem (ffwd).withFlex (1.0, 1.0, 0.5).withHeight (20.0)); -#if FOLEYS_HAS_ADDONS +#if FOLEYS_CAMERA_SUPPORT open.setConnectedEdges (juce::TextButton::ConnectedOnRight); camera.setConnectedEdges (juce::TextButton::ConnectedOnLeft); #endif diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 67f86eeb..9dac7125 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -1,5 +1,5 @@ -juce_add_modules(foleys_video_engine foleys_video_addons ff_meters +juce_add_modules(foleys_video_engine ff_meters ALIAS_NAMESPACE Foleys) add_subdirectory(ffmpeg) diff --git a/modules/foleys_video_addons/Tests/VideoPlayer/CMakeLists.txt b/modules/foleys_video_addons/Tests/VideoPlayer/CMakeLists.txt deleted file mode 100644 index 7a4acc5f..00000000 --- a/modules/foleys_video_addons/Tests/VideoPlayer/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ -cmake_minimum_required(VERSION 3.17) - -set(PROJECT_NAME VideoPlayer) - -set(PROJECT_SOURCES - Sources/main.cpp - Sources/mainwindow.cpp - Sources/mainwindow.h - Sources/mainwindow.ui - Sources/AudioPluginManager.cpp - Sources/AudioPluginManager.h -) - -project("${PROJECT_NAME}" LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -set_property(GLOBAL PROPERTY USE_FOLDERS YES) - -# Configure JUCE sources -set(JUCE_ENABLE_MODULE_SOURCE_GROUPS ON) -option(JUCE_ENABLE_MODULE_SOURCE_GROUPS "Enable Module Source Groups" ON) - -# The source tree should uhhh, still look like the source tree, yo -source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/Source PREFIX "" FILES ${SourceFiles}) - - -add_subdirectory(JUCE) - -juce_add_gui_app("${PROJECT_NAME}" - PRODUCT_NAME "${PROJECT_NAME}" - VERSION 1.0.0) - -juce_add_modules( - ../modules/) - -target_compile_definitions(${PROJECT_NAME} - PUBLIC - JUCE_PLUGINHOST_AU=1 - JUCE_PLUGINHOST_VST3=1) - -target_link_libraries(${PROJECT_NAME} - PUBLIC - juce::juce_core - juce::juce_audio_basics - juce::juce_audio_devices - juce::juce_audio_utils - juce::juce_audio_formats - juce::juce_audio_processors - foleys::foleys_video_engine - foleys::foleys_video_addons - juce::juce_recommended_config_flags - juce::juce_recommended_warning_flags -) diff --git a/modules/foleys_video_addons/Tests/VideoPlayer/Source/Main.cpp b/modules/foleys_video_addons/Tests/VideoPlayer/Source/Main.cpp deleted file mode 100755 index e365e01a..00000000 --- a/modules/foleys_video_addons/Tests/VideoPlayer/Source/Main.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - ============================================================================== - - Copyright (c) 2019 - 2023, Foleys Finest Audio - Daniel Walz - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. - ============================================================================== - - This contains the basic startup code for a Juce application. - - ============================================================================== -*/ - -#include "../JuceLibraryCode/JuceHeader.h" - -juce::Component* createMainContentComponent(); - -//============================================================================== -class VideoPlayerApplication : public juce::JUCEApplication -{ -public: - //============================================================================== - VideoPlayerApplication() {} - - const juce::String getApplicationName() override { return ProjectInfo::projectName; } - const juce::String getApplicationVersion() override { return ProjectInfo::versionString; } - bool moreThanOneInstanceAllowed() override { return true; } - - //============================================================================== - void initialise (const juce::String& commandLine) override - { - juce::ignoreUnused (commandLine); - mainWindow = std::make_unique (getApplicationName()); - } - - void shutdown() override - { - } - - //============================================================================== - void systemRequestedQuit() override - { - quit(); - } - - void anotherInstanceStarted (const juce::String& commandLine) override - { - juce::ignoreUnused (commandLine); - } - - //============================================================================== - /* - This class implements the desktop window that contains an instance of - our MainContentComponent class. - */ - class MainWindow : public juce::DocumentWindow - { - public: - MainWindow (juce::String name) : DocumentWindow (name, - juce::Colours::lightgrey, - juce::DocumentWindow::allButtons) - { - setUsingNativeTitleBar (true); - setContentOwned (createMainContentComponent(), true); - setResizable (true, true); - - centreWithSize (getWidth(), getHeight()); - setVisible (true); - } - - void closeButtonPressed() override - { - juce::JUCEApplication::getInstance()->systemRequestedQuit(); - } - - private: - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow) - }; - -private: - std::unique_ptr mainWindow; -}; - -//============================================================================== -// This macro generates the main() routine that launches the app. -START_JUCE_APPLICATION (VideoPlayerApplication) diff --git a/modules/foleys_video_addons/Tests/VideoPlayer/Source/MainComponent.cpp b/modules/foleys_video_addons/Tests/VideoPlayer/Source/MainComponent.cpp deleted file mode 100755 index a99dcb0b..00000000 --- a/modules/foleys_video_addons/Tests/VideoPlayer/Source/MainComponent.cpp +++ /dev/null @@ -1,359 +0,0 @@ -/* - ============================================================================== - Copyright (c) 2019-2020, Foleys Finest Audio - Daniel Walz - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. - ============================================================================== - - Demo to play back a movie using ffmpeg and JUCE - - ============================================================================== - */ - - -#include "../JuceLibraryCode/JuceHeader.h" -#include "OSDComponent.h" - -//============================================================================== -/* - The display plus drop target to allow movies dragged into - */ -#if FOLEYS_USE_OPENGL -using ViewType = foleys::OpenGLView; -#else -using ViewType = foleys::SoftwareView; -#endif - -class VideoComponentWithDropper - : public ViewType - , public juce::FileDragAndDropTarget -{ - public: - VideoComponentWithDropper() - { - setInterceptsMouseClicks (true, true); - setWantsKeyboardFocus (false); - - setContinuousRepaint (30); - } - - bool isInterestedInFileDrag (const juce::StringArray&) override - { - return true; - } - - void filesDropped (const juce::StringArray& files, int, int) override - { - if (onFileDropped) onFileDropped (files[0]); - - juce::Process::makeForegroundProcess(); - } - - std::function onFileDropped; - - private: - JUCE_DECLARE_NON_COPYABLE (VideoComponentWithDropper) -}; - -//============================================================================== -/* - This component lives inside our window, and this is where you should put all - your controls and content. -*/ -class MainContentComponent - : public juce::AudioAppComponent - , public foleys::TimeCodeAware::Listener -{ - public: - //============================================================================== - MainContentComponent() - { - setWantsKeyboardFocus (true); - -#if JUCE_WINDOWS - videoEngine.getFormatManager().registerFormat (std::make_unique()); -#endif - -#if FOLEYS_USE_FFMPEG - videoEngine.getFormatManager().registerFormat (std::make_unique()); -#endif - addAndMakeVisible (filmStrip); - - addAndMakeVisible (videoComponent); - videoComponent.addAndMakeVisible (osdComponent); - - // specify the number of input and output channels that we want to open - setAudioChannels (0, 2); - -#ifdef DEBUG - if (auto* device = deviceManager.getCurrentAudioDevice()) - { - DBG ("Current Samplerate: " + juce::String (device->getCurrentSampleRate())); - DBG ("Current Buffersize: " + juce::String (device->getCurrentBufferSizeSamples())); - DBG ("Current Bitdepth: " + juce::String (device->getCurrentBitDepth())); - } -#endif /* DEBUG */ - -#ifdef USE_FF_AUDIO_METERS - meter = std::make_unique(); - meter->getLookAndFeel()->setMeterColour (foleys::LevelMeterLookAndFeel::lmBackgroundColour, juce::Colour::fromFloatRGBA (0.0f, 0.0f, 0.0f, 0.6f)); - meter->setMeterSource (&meterSource); - addAndMakeVisible (meter); -#endif - - osdComponent.open.onClick = [this] { openFile(); }; - - osdComponent.stop.onClick = [this] { - transportSource.stop(); - if (clip) clip->setNextReadPosition (0); - }; - - osdComponent.pause.onClick = [this] { transportSource.stop(); }; - - osdComponent.play.onClick = [this] { - if (clip.get() == nullptr) return; - - if (ffwdSpeed != 2) - { - auto lastPos = clip->getNextReadPosition(); - ffwdSpeed = 2; - auto factor = 0.5 + (ffwdSpeed / 4.0); - transportSource.setSource (clip.get(), 0, nullptr, factor, 2); - clip->setNextReadPosition (lastPos); - } - transportSource.start(); - }; - - osdComponent.ffwd.onClick = [this] { - if (clip.get() == nullptr) return; - - auto lastPos = clip->getNextReadPosition(); - ffwdSpeed = (ffwdSpeed + 1) % 7; - auto factor = 0.5 + (ffwdSpeed / 4.0); - transportSource.setSource (clip.get(), 0, nullptr, factor, 2); - clip->setNextReadPosition (lastPos); - transportSource.start(); - }; - - osdComponent.seekBar.onValueChange = [this] { - if (clip.get()) clip->setNextReadPosition (juce::int64 (osdComponent.seekBar.getValue() * sampleRate)); - }; - -#if FOLEYS_HAS_ADDONS - osdComponent.camera.onClick = [this] { openCamera(); }; -#endif - - videoComponent.onFileDropped = [this] (juce::File file) { openFile (file); }; - - setSize (800, 600); - } - - ~MainContentComponent() override - { - shutdownAudio(); - } - - //============================================================================== - void prepareToPlay (int samplesPerBlockExpected, double newSampleRate) override - { - // This function will be called when the audio device is started, or when - // its settings (i.e. sample rate, block size, etc) are changed. - sampleRate = newSampleRate; - blockSize = samplesPerBlockExpected; - - if (clip.get() != nullptr) clip->prepareToPlay (blockSize, sampleRate); - - transportSource.prepareToPlay (blockSize, sampleRate); - - readBuffer.setSize (2, blockSize); - } - - void getNextAudioBlock (const juce::AudioSourceChannelInfo& bufferToFill) override - { - auto numInputChannels = 2; // movieClip->getVideoChannels(); - - juce::AudioSourceChannelInfo info (&readBuffer, bufferToFill.startSample, bufferToFill.numSamples); - // the AudioTransportSource takes care of start, stop and resample - transportSource.getNextAudioBlock (info); - -#ifdef USE_FF_AUDIO_METERS - meterSource.measureBlock (readBuffer); -#endif - - if (numInputChannels > 0) - { - for (int i = 0; i < bufferToFill.buffer->getNumChannels(); ++i) - { - - bufferToFill.buffer->copyFrom (i, bufferToFill.startSample, readBuffer.getReadPointer (i % numInputChannels), bufferToFill.numSamples); - if (bufferToFill.buffer->getNumChannels() == 2 && readBuffer.getNumChannels() > 2) - { - // add center to left and right - bufferToFill.buffer->addFrom (i, bufferToFill.startSample, readBuffer.getReadPointer (2), bufferToFill.numSamples, 0.7f); - } - } - } - else - { - bufferToFill.clearActiveBufferRegion(); - } - } - - void releaseResources() override - { - transportSource.releaseResources(); - if (clip.get() != nullptr) clip->releaseResources(); - } - - void timecodeChanged (int64_t, double seconds) override - { - osdComponent.seekBar.setValue (seconds, juce::dontSendNotification); - } - - void openFile (juce::File name) - { - if (clip.get() != nullptr) clip->removeTimecodeListener (this); - - osdComponent.setClip ({}); - auto newClip = videoEngine.createClipFromFile (juce::URL (name)); - - if (newClip.get() == nullptr) return; - - newClip->prepareToPlay (blockSize, sampleRate); - - clip = newClip; - - osdComponent.setClip (clip); - videoComponent.setClip (clip); - clip->addTimecodeListener (this); - osdComponent.seekBar.setRange (0.0, clip->getLengthInSeconds()); - transportSource.setSource (clip.get(), 0, nullptr); - - filmStrip.setClip (clip); - filmStrip.setStartAndEnd (0.0, clip->getLengthInSeconds()); - } - - void openFile() - { - transportSource.stop(); - transportSource.setSource (nullptr); - - juce::FileChooser chooser ("Open Video File"); - if (chooser.browseForFileToOpen()) - { - auto video = chooser.getResult(); - openFile (chooser.getResult()); - } - } - -#if FOLEYS_HAS_ADDONS - void openCamera() - { - osdComponent.setClip ({}); - transportSource.stop(); - transportSource.setSource (nullptr); - - auto camera = cameraManager.openCamera (0); - camera->onCaptureEngineInitialized = [c = camera.get()]() { c->start(); }; - - auto newClip = cameraManager.createCameraClip (std::move (camera)); - videoEngine.manageLifeTime (newClip); - newClip->prepareToPlay (blockSize, sampleRate); - clip = newClip; - videoComponent.setClip (clip); - clip->addTimecodeListener (this); - transportSource.setSource (clip.get(), 0, nullptr); - } -#endif - - void paint (juce::Graphics& g) override - { - g.fillAll (juce::Colours::black); - } - - void resized() override - { - auto bounds = getBounds(); - filmStrip.setBounds (bounds.removeFromBottom (100)); - - videoComponent.setBounds (bounds); - osdComponent.setBounds (bounds); - -#ifdef USE_FF_AUDIO_METERS - const int w = 30 + 20 * videoReader->getVideoChannels(); - meter->setBounds (getWidth() - w, getHeight() - 240, w, 200); -#endif - } - - bool keyPressed (const juce::KeyPress& key) override - { - if (key == juce::KeyPress::spaceKey) - { - if (transportSource.isPlaying()) - { - transportSource.stop(); - return true; - } - transportSource.start(); - return true; - } - return false; - } - - private: - //============================================================================== - - foleys::VideoEngine videoEngine; - -#if FOLEYS_CAMERA_SUPPORT - foleys::CameraManager cameraManager { videoEngine }; -#endif - - std::shared_ptr clip; - - juce::AudioTransportSource transportSource; - double sampleRate = 0.0; - int blockSize = 0; - int ffwdSpeed = 2; - - VideoComponentWithDropper videoComponent; - OSDComponent osdComponent; - foleys::FilmStrip filmStrip; - -#ifdef USE_FF_AUDIO_METERS - std::unique_ptr meter; - LevelMeterSource meterSource; -#endif - - juce::AudioBuffer readBuffer; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent) -}; - - -// (This function is called by the app startup code to create our main component) -juce::Component* createMainContentComponent() -{ - return new MainContentComponent(); -} diff --git a/modules/foleys_video_addons/Tests/VideoPlayer/Source/OSDComponent.h b/modules/foleys_video_addons/Tests/VideoPlayer/Source/OSDComponent.h deleted file mode 100644 index 5a1130e7..00000000 --- a/modules/foleys_video_addons/Tests/VideoPlayer/Source/OSDComponent.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - ============================================================================== - Copyright (c) 2019, Foleys Finest Audio - Daniel Walz - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - 3. Neither the name of the copyright holder nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. - ============================================================================== - - Overlay component - - ============================================================================== - */ - -#pragma once - -#include "../JuceLibraryCode/JuceHeader.h" - -//============================================================================== -/* -*/ -class OSDComponent : public juce::Component -{ -public: - OSDComponent() - { - setOpaque (false); - setInterceptsMouseClicks (false, true); - setWantsKeyboardFocus (false); - - open.setWantsKeyboardFocus (false); - addAndMakeVisible (open); - flexBox.items.add (juce::FlexItem (open).withFlex (1.0, 1.0, 0.5).withHeight (20.0)); - -#if FOLEYS_HAS_ADDONS - camera.setWantsKeyboardFocus (false); - addAndMakeVisible (camera); - flexBox.items.add (juce::FlexItem (camera).withFlex (1.0, 1.0, 0.5).withHeight (20.0)); -#endif - - addAndMakeVisible (seekBar); - seekBar.setWantsKeyboardFocus (false); - flexBox.items.add (juce::FlexItem (seekBar).withFlex (6.0, 1.0, 0.5).withHeight (20.0)); - - stop.setWantsKeyboardFocus (false); - addAndMakeVisible (stop); - flexBox.items.add (juce::FlexItem (stop).withFlex (1.0, 1.0, 0.5).withHeight (20.0)); - - pause.setWantsKeyboardFocus (false); - addAndMakeVisible (pause); - flexBox.items.add (juce::FlexItem (pause).withFlex (1.0, 1.0, 0.5).withHeight (20.0)); - - play.setWantsKeyboardFocus (false); - addAndMakeVisible (play); - flexBox.items.add (juce::FlexItem (play).withFlex (1.0, 1.0, 0.5).withHeight (20.0)); - - ffwd.setWantsKeyboardFocus (false); - addAndMakeVisible (ffwd); - flexBox.items.add (juce::FlexItem (ffwd).withFlex (1.0, 1.0, 0.5).withHeight (20.0)); - -#if FOLEYS_HAS_ADDONS - open.setConnectedEdges (juce::TextButton::ConnectedOnRight); - camera.setConnectedEdges (juce::TextButton::ConnectedOnLeft); -#endif - - stop.setConnectedEdges (juce::TextButton::ConnectedOnRight); - pause.setConnectedEdges (juce::TextButton::ConnectedOnRight | juce::TextButton::ConnectedOnLeft); - play.setConnectedEdges (juce::TextButton::ConnectedOnRight | juce::TextButton::ConnectedOnLeft); - ffwd.setConnectedEdges (juce::TextButton::ConnectedOnLeft); - } - - void paint (juce::Graphics& g) override - { - if (clip && clip->getLengthInSeconds() > 0) - { - g.setColour (juce::Colours::white); - g.setFont (24); - auto size = clip->getVideoSize(); - auto dim = juce::String (size.width) + " x " + juce::String (size.height); - g.drawFittedText (dim, getLocalBounds(), juce::Justification::topLeft, 1); - g.drawFittedText (foleys::timecodeToString (clip->getCurrentTimeInSeconds()), - getLocalBounds(), juce::Justification::topRight, 1); - } - } - - void resized() override - { - auto bounds = getBounds().withTop (getHeight() - 50).reduced (10); - flexBox.performLayout (bounds); - } - - void setClip (std::shared_ptr newClip) - { - clip = newClip; - } - - class MouseIdle : public juce::MouseListener, public juce::Timer - { - public: - MouseIdle (Component& c) : - component (c), - lastMovement (juce::Time::getMillisecondCounter()) - { - juce::Desktop::getInstance().addGlobalMouseListener (this); - startTimerHz (20); - } - - void timerCallback () override - { - const auto relTime = juce::Time::getMillisecondCounter() - lastMovement; - if (relTime < 2000) - { - component.setVisible (true); - component.setAlpha (1.0); - if (auto* parent = component.getParentComponent()) - parent->setMouseCursor (juce::MouseCursor::StandardCursorType::NormalCursor); - } - else if (relTime < 2300) - { - component.setAlpha (1.0f - std::max (0.0f, (relTime - 2000.0f) / 300.0f)); - } - else - { - component.setVisible (false); - if (auto* parent = component.getParentComponent()) - { - parent->setMouseCursor (juce::MouseCursor::StandardCursorType::NoCursor); - juce::Desktop::getInstance().getMainMouseSource().forceMouseCursorUpdate(); - } - } - } - - void mouseMove (const juce::MouseEvent &event) override - { - if (event.position.getDistanceFrom (lastPosition) > 3.0) { - lastMovement = juce::Time::getMillisecondCounter(); - lastPosition = event.position; - } - } - private: - juce::Component& component; - juce::int64 lastMovement; - juce::Point lastPosition; - }; - - juce::Slider seekBar { juce::Slider::LinearHorizontal, juce::Slider::NoTextBox }; - juce::TextButton camera { TRANS ("Camera") }; - juce::TextButton open { TRANS ("Open") }; - juce::TextButton play { TRANS ("Play") }; - juce::TextButton pause { TRANS ("Pause") }; - juce::TextButton stop { TRANS ("Stop") }; - juce::TextButton ffwd { TRANS ("FWD") }; - -private: - MouseIdle idle { *this }; - juce::FlexBox flexBox; - - std::shared_ptr clip; - - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (OSDComponent) -}; diff --git a/modules/foleys_video_addons/Tests/VideoPlayer/VideoPlayer.jucer b/modules/foleys_video_addons/Tests/VideoPlayer/VideoPlayer.jucer deleted file mode 100644 index 222ea439..00000000 --- a/modules/foleys_video_addons/Tests/VideoPlayer/VideoPlayer.jucer +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/modules/foleys_video_addons/foleys_video_addons.cpp b/modules/foleys_video_addons/foleys_video_addons.cpp deleted file mode 100644 index 3eb3e660..00000000 --- a/modules/foleys_video_addons/foleys_video_addons.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* -============================================================================== - -Copyright (c) 2019-2021, Foleys Finest Audio - Daniel Walz -All rights reserved. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. - -============================================================================== -*/ - -#include "foleys_video_addons.h" - - -#if JUCE_WINDOWS -#include "Native/foleys_Helpers_Win.h" -#include "Camera/foleys_CameraManager_Win.cpp" -#include "ReadWrite/foleys_MediaFoundation_Win.cpp" -#endif - -#include "Camera/foleys_CameraManager.cpp" -#include "Camera/foleys_CameraClip.cpp" - diff --git a/modules/foleys_video_addons/foleys_video_addons.h b/modules/foleys_video_addons/foleys_video_addons.h deleted file mode 100644 index b59732a1..00000000 --- a/modules/foleys_video_addons/foleys_video_addons.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - ============================================================================== - - Copyright (c) 2019-2021, Foleys Finest Audio - Daniel Walz - All rights reserved. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE - OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. - - ============================================================================== - - BEGIN_JUCE_MODULE_DECLARATION - - ID: foleys_video_addons - vendor: Foleys Finest Audio UG - version: 0.1.0 - name: Video engine to read, process, display and write video in JUCE - description: Provides classes to read audio streams from video files or to - mux audio into an existing video - dependencies: foleys_video_engine - OSXFrameworks: AVFoundation CoreMedia - iOSFrameworks: AVFoundation CoreMedia - minimumCppStandard: 17 - - website: https://foleysfinest.com/ - - END_JUCE_MODULE_DECLARATION - - ============================================================================== - */ - -#pragma once - - -/** Config: FOLEYS_CAMERA_SUPPORT - Set this flag to access the cameras attached to the system - */ -#ifndef FOLEYS_CAMERA_SUPPORT -#define FOLEYS_CAMERA_SUPPORT 1 -#endif - - -#include -#include -#include -#include -#include -#include -#include - -#if JUCE_WINDOWS - #pragma comment(lib, "d3d11.lib") - #pragma comment(lib, "mfplat.lib") - #pragma comment(lib, "mf.lib") - #pragma comment(lib, "mfreadwrite.lib") - #pragma comment(lib, "mfuuid.lib") - #pragma comment(lib, "propsys.lib") -#endif - -#include "Camera/foleys_CameraManager.h" -#include "Camera/foleys_CameraClip.h" - -#if JUCE_WINDOWS -#include "ReadWrite/foleys_MediaFoundation_Win.h" -#endif diff --git a/modules/foleys_video_addons/foleys_video_addons.mm b/modules/foleys_video_addons/foleys_video_addons.mm deleted file mode 100644 index af9af3dc..00000000 --- a/modules/foleys_video_addons/foleys_video_addons.mm +++ /dev/null @@ -1,25 +0,0 @@ -/* -============================================================================== - -Copyright (c) 2019-2021, Foleys Finest Audio - Daniel Walz -All rights reserved. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. - -============================================================================== -*/ - -#include "foleys_video_addons.h" - -#include "Camera/foleys_CameraManager_OSX.mm" - -#include "foleys_video_addons.cpp" diff --git a/modules/foleys_video_engine/Basics/foleys_VideoEngine.h b/modules/foleys_video_engine/Basics/foleys_VideoEngine.h index b8c9177f..87fcbca5 100644 --- a/modules/foleys_video_engine/Basics/foleys_VideoEngine.h +++ b/modules/foleys_video_engine/Basics/foleys_VideoEngine.h @@ -20,14 +20,13 @@ #pragma once +#include "../Plugins/foleys_AudioPluginManager.h" +#include "../Plugins/foleys_VideoPluginManager.h" +#include "../ReadWrite/foleys_AVFormatManager.h" namespace foleys { -#if FOLEYS_HAS_ADDONS && FOLEYS_CAMERA_SUPPORT -class CameraManager; -#endif - /** @class VideoEngine @@ -141,7 +140,7 @@ class VideoEngine : private juce::Timer JUCE_DECLARE_WEAK_REFERENCEABLE (VideoEngine) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (VideoEngine) -#if FOLEYS_HAS_ADDONS && FOLEYS_CAMERA_SUPPORT +#if FOLEYS_CAMERA_SUPPORT public: void setCameraManager (CameraManager* manager) { diff --git a/modules/foleys_video_engine/Camera/foleys_CameraClip.h b/modules/foleys_video_engine/Camera/foleys_CameraClip.h index 902b01de..856cf669 100644 --- a/modules/foleys_video_engine/Camera/foleys_CameraClip.h +++ b/modules/foleys_video_engine/Camera/foleys_CameraClip.h @@ -22,9 +22,12 @@ #if FOLEYS_CAMERA_SUPPORT +#include "../Clips/foleys_AVClip.h" + namespace foleys { + class CameraClip : public AVClip { public: diff --git a/modules/foleys_video_engine/Camera/foleys_CameraManager.h b/modules/foleys_video_engine/Camera/foleys_CameraManager.h index 8273b2b8..25c57082 100644 --- a/modules/foleys_video_engine/Camera/foleys_CameraManager.h +++ b/modules/foleys_video_engine/Camera/foleys_CameraManager.h @@ -22,6 +22,8 @@ #if FOLEYS_CAMERA_SUPPORT +#include "../Basics/foleys_VideoFifo.h" + namespace foleys { diff --git a/modules/foleys_video_engine/Camera/foleys_CameraManager_OSX.mm b/modules/foleys_video_engine/Camera/foleys_CameraManager_OSX.mm index db503827..724a6644 100644 --- a/modules/foleys_video_engine/Camera/foleys_CameraManager_OSX.mm +++ b/modules/foleys_video_engine/Camera/foleys_CameraManager_OSX.mm @@ -94,7 +94,7 @@ void openCamera() return; addProtocol (@protocol (AVCaptureVideoDataOutputSampleBufferDelegate)); - addMethod (@selector (captureOutput:didOutputSampleBuffer:fromConnection:), captureOutput, "v@:@@@"); + addMethod (@selector (captureOutput:didOutputSampleBuffer:fromConnection:), captureOutput); registerClass(); videoDataOutputQueue = dispatch_queue_create ("VideoDataOutputQueue", DISPATCH_QUEUE_SERIAL); diff --git a/modules/foleys_video_engine/Clips/foleys_AVClip.h b/modules/foleys_video_engine/Clips/foleys_AVClip.h index 114bd492..cbae85d3 100644 --- a/modules/foleys_video_engine/Clips/foleys_AVClip.h +++ b/modules/foleys_video_engine/Clips/foleys_AVClip.h @@ -20,6 +20,9 @@ #pragma once +#include "../Processing/foleys_ProcessorParameter.h" +#include "../Processing/foleys_ParameterAutomation.h" + namespace foleys { diff --git a/modules/foleys_video_engine/Clips/foleys_ClipDescriptor.h b/modules/foleys_video_engine/Clips/foleys_ClipDescriptor.h index 4b1b1a34..f42aec3e 100644 --- a/modules/foleys_video_engine/Clips/foleys_ClipDescriptor.h +++ b/modules/foleys_video_engine/Clips/foleys_ClipDescriptor.h @@ -20,6 +20,8 @@ #pragma once +#include "../Processing/foleys_ControllableBase.h" + namespace foleys { diff --git a/modules/foleys_video_engine/Clips/foleys_ComposedClip.h b/modules/foleys_video_engine/Clips/foleys_ComposedClip.h index cf44c415..c229fda2 100644 --- a/modules/foleys_video_engine/Clips/foleys_ComposedClip.h +++ b/modules/foleys_video_engine/Clips/foleys_ComposedClip.h @@ -23,6 +23,8 @@ namespace foleys { +class AudioMixer; + /** @class ComposedClip diff --git a/modules/foleys_video_engine/Plugins/foleys_VideoPluginManager.h b/modules/foleys_video_engine/Plugins/foleys_VideoPluginManager.h index 49ffca97..9e40a19d 100644 --- a/modules/foleys_video_engine/Plugins/foleys_VideoPluginManager.h +++ b/modules/foleys_video_engine/Plugins/foleys_VideoPluginManager.h @@ -23,6 +23,8 @@ namespace foleys { +class VideoProcessor; + /** The VideoPluginManager is used to create VideoProcessor instances to be placed into the image processing pipeline. diff --git a/modules/foleys_video_engine/Processing/foleys_ParameterAutomation.h b/modules/foleys_video_engine/Processing/foleys_ParameterAutomation.h index b6e76704..4593b7ce 100644 --- a/modules/foleys_video_engine/Processing/foleys_ParameterAutomation.h +++ b/modules/foleys_video_engine/Processing/foleys_ParameterAutomation.h @@ -20,9 +20,14 @@ #pragma once +#include "foleys_ProcessorParameter.h" + namespace foleys { +class ControllableBase; +class ProcessorController; + /** This class allows storing and playing back automation values. It is used in the ClipDescriptor's ProcessorController. diff --git a/modules/foleys_video_engine/ReadWrite/foleys_AVFormatManager.h b/modules/foleys_video_engine/ReadWrite/foleys_AVFormatManager.h index 9a4a4fdd..acfcc240 100644 --- a/modules/foleys_video_engine/ReadWrite/foleys_AVFormatManager.h +++ b/modules/foleys_video_engine/ReadWrite/foleys_AVFormatManager.h @@ -24,7 +24,6 @@ namespace foleys { - struct AVFormat { AVFormat() = default; virtual ~AVFormat() = default; diff --git a/modules/foleys_video_engine/Widgets/foleys_SoftwareView.h b/modules/foleys_video_engine/Widgets/foleys_SoftwareView.h index a6d8935b..4dd01823 100644 --- a/modules/foleys_video_engine/Widgets/foleys_SoftwareView.h +++ b/modules/foleys_video_engine/Widgets/foleys_SoftwareView.h @@ -20,6 +20,8 @@ #pragma once +#include "foleys_VideoView.h" + namespace foleys { diff --git a/modules/foleys_video_engine/foleys_video_engine.cpp b/modules/foleys_video_engine/foleys_video_engine.cpp index 815bdcad..c91a70b8 100644 --- a/modules/foleys_video_engine/foleys_video_engine.cpp +++ b/modules/foleys_video_engine/foleys_video_engine.cpp @@ -18,6 +18,7 @@ ============================================================================== */ + #include "foleys_video_engine.h" #include "Basics/foleys_VideoFifo.cpp" diff --git a/modules/foleys_video_engine/foleys_video_engine.h b/modules/foleys_video_engine/foleys_video_engine.h index 5f2fb21f..3c83729d 100644 --- a/modules/foleys_video_engine/foleys_video_engine.h +++ b/modules/foleys_video_engine/foleys_video_engine.h @@ -1,7 +1,7 @@ /* ============================================================================== - Copyright (c) 2019-2021, Foleys Finest Audio - Daniel Walz + Copyright (c) 2019-2023, Foleys Finest Audio - Daniel Walz All rights reserved. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND @@ -21,12 +21,14 @@ ID: foleys_video_engine vendor: Foleys Finest Audio Ltd. - version: 0.2.0 + version: 0.3.0 name: Video engine to read, process, display and write video in JUCE description: Provides classes to read audio streams from video files or to mux audio into an existing video dependencies: juce_audio_basics juce_audio_formats juce_gui_basics juce_graphics juce_core juce_audio_utils + OSXFrameworks: AVFoundation CoreMedia + iOSFrameworks: AVFoundation CoreMedia minimumCppStandard: 17 website: https://foleysfinest.com/ @@ -42,7 +44,7 @@ raw OpenGL calls. */ #ifndef FOLEYS_USE_OPENGL -#define FOLEYS_USE_OPENGL 0 + #define FOLEYS_USE_OPENGL 0 #endif /** Config: FOLEYS_CAMERA_SUPPORT @@ -56,90 +58,81 @@ Set this flag to use FFmpeg as reading/writing library */ #ifndef FOLEYS_USE_FFMPEG -#define FOLEYS_USE_FFMPEG 1 + #define FOLEYS_USE_FFMPEG 1 #endif /** Config: FOLEYS_DEBUG_LOGGING Set this flag to enable logging */ #ifndef FOLEYS_DEBUG_LOGGING -#define FOLEYS_DEBUG_LOGGING 0 + #define FOLEYS_DEBUG_LOGGING 0 #endif -#define FOLEYS_ENGINE_VERSION "0.2.0" - -// foleys_video_addons is a proprietory module containing -// camera support and reading and writing using the -// platform SDKs instead of ffmpeg -#ifdef JUCE_MODULE_AVAILABLE_foleys_video_addons -#define FOLEYS_HAS_ADDONS JUCE_MODULE_AVAILABLE_foleys_video_addons -#else -#define FOLEYS_HAS_ADDONS 0 -#endif +#define FOLEYS_ENGINE_VERSION "0.3.0" #pragma once -#include #include #include +#include +#include #include #include -#include #if FOLEYS_DEBUG_LOGGING -# define FOLEYS_LOG(textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON(juce::String tempDbgBuf; tempDbgBuf << "foleys: " << textToWrite; juce::Logger::outputDebugString (tempDbgBuf);) + #define FOLEYS_LOG(textToWrite) \ + JUCE_BLOCK_WITH_FORCED_SEMICOLON (juce::String tempDbgBuf; tempDbgBuf << "foleys: " << textToWrite; juce::Logger::outputDebugString (tempDbgBuf);) #else -# define FOLEYS_LOG(textToWrite) + #define FOLEYS_LOG(textToWrite) #endif #ifdef JUCE_MODULE_AVAILABLE_juce_opengl -#include + #include #endif +#include "foleys_video_engine_types.h" + +#include "Basics/foleys_AudioFifo.h" #include "Basics/foleys_Structures.h" -#include "Basics/foleys_VideoFrame.h" #include "Basics/foleys_TimeCodeAware.h" -#include "Basics/foleys_AudioFifo.h" +#include "Camera/foleys_CameraManager.h" #include "Basics/foleys_VideoFifo.h" -#include "Processing/foleys_ProcessorParameter.h" +#include "Basics/foleys_VideoFrame.h" +#include "Camera/foleys_CameraClip.h" +#include "Basics/foleys_VideoEngine.h" +#include "Clips/foleys_AVClip.h" +#include "Clips/foleys_AudioClip.h" +#include "Clips/foleys_ClipDescriptor.h" +#include "Clips/foleys_ComposedClip.h" +#include "Clips/foleys_ImageClip.h" +#include "Clips/foleys_MovieClip.h" #include "Plugins/foleys_AudioPluginManager.h" -#include "Plugins/foleys_VideoProcessor.h" #include "Plugins/foleys_VideoPluginManager.h" +#include "Plugins/foleys_VideoProcessor.h" +#include "Processing/foleys_AudioMixer.h" +#include "Processing/foleys_ColourLookuptables.h" #include "Processing/foleys_ControllableBase.h" -#include "Processing/foleys_ProcessorController.h" +#include "Processing/foleys_DefaultAudioMixer.h" #include "Processing/foleys_ParameterAutomation.h" -#include "Clips/foleys_AVClip.h" -#include "Clips/foleys_ClipDescriptor.h" +#include "Processing/foleys_ProcessorController.h" +#include "Processing/foleys_ProcessorParameter.h" +#include "Processing/foleys_VideoMixer.h" +#include "ReadWrite/foleys_AVFormatManager.h" #include "ReadWrite/foleys_AVReader.h" #include "ReadWrite/foleys_AVWriter.h" -#include "ReadWrite/foleys_AVFormatManager.h" #include "ReadWrite/foleys_ClipRenderer.h" -#include "Processing/foleys_AudioMixer.h" -#include "Processing/foleys_VideoMixer.h" -#include "Processing/foleys_DefaultAudioMixer.h" -#include "Processing/foleys_ColourLookuptables.h" - -#include "Clips/foleys_AudioClip.h" -#include "Clips/foleys_ImageClip.h" -#include "Clips/foleys_MovieClip.h" -#include "Clips/foleys_ComposedClip.h" - -#include "Basics/foleys_VideoEngine.h" -#include "Widgets/foleys_VideoView.h" -#include "Widgets/foleys_SoftwareView.h" -#include "Widgets/foleys_FilmStrip.h" #include "Widgets/foleys_AudioStrip.h" +#include "Widgets/foleys_FilmStrip.h" #include "Widgets/foleys_OpenGLDraw.h" #include "Widgets/foleys_OpenGLView.h" - -#include "Camera/foleys_CameraManager.h" -#include "Camera/foleys_CameraClip.h" +#include "Widgets/foleys_SoftwareView.h" +#include "Widgets/foleys_VideoView.h" #if FOLEYS_USE_FFMPEG -#include "ReadWrite/FFmpeg/foleys_FFmpegReader.h" -#include "ReadWrite/FFmpeg/foleys_FFmpegWriter.h" -#include "ReadWrite/FFmpeg/foleys_FFmpegFormat.h" + #include "ReadWrite/FFmpeg/foleys_FFmpegFormat.h" + #include "ReadWrite/FFmpeg/foleys_FFmpegReader.h" + #include "ReadWrite/FFmpeg/foleys_FFmpegWriter.h" #endif #if JUCE_WINDOWS diff --git a/modules/foleys_video_engine/foleys_video_engine_types.h b/modules/foleys_video_engine/foleys_video_engine_types.h new file mode 100644 index 00000000..dafecb53 --- /dev/null +++ b/modules/foleys_video_engine/foleys_video_engine_types.h @@ -0,0 +1,29 @@ +// +// Created by Daniel Walz on 25.11.23. +// + +#pragma once + +/** + * This is adding forward declarations that might be useful + */ + +namespace foleys +{ + +class VideoEngine; +class AVClip; +class AVReader; +class AVWriter; +class VideoProcessor; +struct VideoFrame; + +#if FOLEYS_CAMERA_SUPPORT + +class CameraManager; +class CameraReceiver; + +#endif + + +} // namespace foleys