├── .circleci └── config.yml ├── .clang-format ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── NFSmartPlayer.png ├── NFSmartPlayer.pxm ├── README.md ├── SCRIPTING.md ├── ci ├── Dockerfile ├── README.md ├── androidlinux.py ├── androidosx.py ├── build_options.py ├── ci.yaml ├── ios.py ├── linux.py ├── linux.sh ├── llvm-run.sh ├── nfbuild.py ├── nfbuildlinux.py ├── nfbuildosx.py ├── osx.py ├── osx.sh ├── requirements.txt └── validate_logging.py ├── include └── NFSmartPlayer │ ├── CallbackTypes.h │ ├── Client.h │ ├── Content.h │ ├── Edge.h │ ├── ErrorCode.h │ ├── Factory.h │ ├── GlobalLogger.h │ ├── Graph.h │ ├── Node.h │ ├── Plugin.h │ ├── Registry.h │ ├── Script.h │ └── nf_smart_player.h ├── interfaces ├── CMakeLists.txt ├── NFSmartPlayer.i ├── csharp │ └── CMakeLists.txt ├── java │ ├── CMakeLists.txt │ ├── Player.cpp │ └── com │ │ └── spotify │ │ └── nativeformat │ │ ├── DriverType.java │ │ ├── MessageType.java │ │ ├── NativeUtils.java │ │ ├── OSValidator.java │ │ ├── Player.java │ │ └── PlayerListener.java ├── objc │ ├── CMakeLists.txt │ ├── NFSmartPlayerEdge+Private.h │ ├── NFSmartPlayerEdge.m │ ├── NFSmartPlayerGraph+Private.h │ ├── NFSmartPlayerGraph.m │ ├── NFSmartPlayerNode+Private.h │ ├── NFSmartPlayerNode.m │ ├── NFSmartPlayerObjC.m │ ├── NFSmartPlayerParam+Private.h │ ├── NFSmartPlayerParam.m │ ├── NFSmartPlayerScript+Private.h │ ├── NFSmartPlayerScript.m │ ├── check-lib-pre.sh │ ├── include │ │ └── NFSmartPlayerObjC │ │ │ ├── NFSmartPlayerEdge.h │ │ │ ├── NFSmartPlayerGraph.h │ │ │ ├── NFSmartPlayerNode.h │ │ │ ├── NFSmartPlayerObjC.h │ │ │ ├── NFSmartPlayerParam.h │ │ │ └── NFSmartPlayerScript.h │ └── tests │ │ ├── CMakeLists.txt │ │ ├── NFSmartPlayerGraphDelegateMock.h │ │ ├── NFSmartPlayerGraphDelegateMock.m │ │ ├── NFSmartPlayerGraphTest.mm │ │ ├── NFSmartPlayerObjCDelegateMock.h │ │ ├── NFSmartPlayerObjCDelegateMock.m │ │ ├── NFSmartPlayerObjCTest.mm │ │ └── NFSmartPlayerObjCTestRunner.cpp └── python │ └── CMakeLists.txt ├── libraries └── CMakeLists.txt ├── resources ├── compand-sine.json ├── compress-expand-sine.json ├── compress-mb.json ├── compress-sine.json ├── nf-logging │ └── expected │ │ ├── example2.json │ │ ├── loop-graph.json │ │ ├── simple-graph.json │ │ └── stretch-graph.json ├── ogg-graph.json ├── ogg-loop-4x.json ├── scripting.json ├── sidechain-sine-delayed-sidechain.json ├── sidechain-sine.json ├── sine-bpf.json └── smart-player-test-audio │ ├── 2478c8c11b7a1eff5f401393a1a4bf5f.flac │ ├── 253b8e6458fbe5a46ed18d114e6e1f60.flac │ ├── 2a83716e9bfabca2e22c10bdc8f9780a.flac │ ├── 5d2d42c9e3baec1a5605ceb947c9a028.flac │ ├── 7ca6385ed2e09e89691d10cb683748dd.flac │ ├── 8a30808c97573e87f4bccbafbc71a2cc.flac │ ├── 90e05f78e8ff35739443d0c926bde602.flac │ ├── a95d4efdea46762fa5fc525e9ee181f0.flac │ ├── b458ac690dc515a160b9c24481cd592e.flac │ └── e8256968a885259b4516eef2e0b095b0.flac ├── source ├── Authoriser.h ├── CMakeLists.txt ├── CallbackTypes.cpp ├── Client.cpp ├── ClientImplementation.cpp ├── ClientImplementation.h ├── Edge.cpp ├── EdgeImplementation.cpp ├── EdgeImplementation.h ├── ErrorCode.cpp ├── GlobalLogger.cpp ├── Graph.cpp ├── GraphDelegate.h ├── GraphImplementation.cpp ├── GraphImplementation.h ├── HTTPLogSink.cpp ├── HTTPLogSink.h ├── Limiter.cpp ├── Limiter.h ├── MixerPlugin.cpp ├── MixerPlugin.h ├── NFOSCHandler.cpp ├── NFOSCHandler.h ├── Node.cpp ├── NodeImplementation.cpp ├── NodeImplementation.h ├── Notification.cpp ├── Notification.h ├── Player.cpp ├── Player.h ├── README.md ├── Registry.cpp ├── ScriptDelegate.h ├── ScriptImplementation.cpp ├── ScriptImplementation.h ├── cli │ ├── CMakeLists.txt │ └── main.cpp ├── nf_smart_player.cpp ├── plugins │ ├── CMakeLists.txt │ ├── channel │ │ ├── CMakeLists.txt │ │ ├── ChannelPlugin.cpp │ │ ├── ChannelPlugin.h │ │ ├── PluginFactory.cpp │ │ ├── PluginFactory.h │ │ ├── README.md │ │ └── tests │ │ │ ├── CMakeLists.txt │ │ │ ├── ChannelPluginTest.cpp │ │ │ └── ChannelPluginTestRunner.cpp │ ├── compressor │ │ ├── CMakeLists.txt │ │ ├── CompanderPlugin.cpp │ │ ├── CompanderPlugin.h │ │ ├── CompressorPlugin.cpp │ │ ├── CompressorPlugin.h │ │ ├── CompressorPluginFactory.cpp │ │ ├── CompressorPluginFactory.h │ │ ├── Detector.h │ │ ├── Drc.h │ │ ├── ExpanderPlugin.cpp │ │ ├── ExpanderPlugin.h │ │ ├── Knee.h │ │ ├── PeakDetector.h │ │ ├── README.md │ │ ├── RmsDetector.h │ │ ├── tests │ │ │ ├── CMakeLists.txt │ │ │ ├── CompressorPluginTest.cpp │ │ │ └── CompressorPluginTestRunner.cpp │ │ └── types.h │ ├── eq │ │ ├── CMakeLists.txt │ │ ├── EQPlugin.cpp │ │ ├── EQPlugin.h │ │ ├── EQPluginFactory.cpp │ │ ├── EQPluginFactory.h │ │ ├── FilterPlugin.cpp │ │ ├── FilterPlugin.h │ │ ├── README.md │ │ └── tests │ │ │ ├── CMakeLists.txt │ │ │ ├── EQPluginTest.cpp │ │ │ └── EQPluginTestRunner.cpp │ ├── file │ │ ├── CMakeLists.txt │ │ ├── FilePlugin.cpp │ │ ├── FilePlugin.h │ │ ├── FilePluginFactory.cpp │ │ ├── FilePluginFactory.h │ │ ├── README.md │ │ └── tests │ │ │ ├── CMakeLists.txt │ │ │ └── FilePluginTestRunner.cpp │ ├── noise │ │ ├── CMakeLists.txt │ │ ├── NoisePlugin.cpp │ │ ├── NoisePlugin.h │ │ ├── NoisePluginFactory.cpp │ │ ├── NoisePluginFactory.h │ │ ├── README.md │ │ ├── SilencePlugin.cpp │ │ ├── SilencePlugin.h │ │ └── tests │ │ │ ├── CMakeLists.txt │ │ │ ├── NoisePluginTest.cpp │ │ │ └── NoisePluginTestRunner.cpp │ ├── time │ │ ├── CMakeLists.txt │ │ ├── LoopPlugin.cpp │ │ ├── LoopPlugin.h │ │ ├── README.md │ │ ├── StretchPlugin.cpp │ │ ├── StretchPlugin.h │ │ ├── TimePluginFactory.cpp │ │ ├── TimePluginFactory.h │ │ └── tests │ │ │ ├── CMakeLists.txt │ │ │ ├── LoopPluginTest.cpp │ │ │ └── TimePluginTestRunner.cpp │ ├── util │ │ ├── BandSplitter.cpp │ │ ├── BandSplitter.h │ │ ├── ButterFilter.cpp │ │ ├── ButterFilter.h │ │ ├── CMakeLists.txt │ │ └── tests │ │ │ ├── CMakeLists.txt │ │ │ ├── PluginUtilTestRunner.cpp │ │ │ └── PluginUtilTests.cpp │ ├── waa │ │ ├── CMakeLists.txt │ │ ├── DelayPlugin.cpp │ │ ├── DelayPlugin.h │ │ ├── GainPlugin.cpp │ │ ├── GainPlugin.h │ │ ├── README.md │ │ ├── ReverbAccumulationBuffer.cpp │ │ ├── ReverbAccumulationBuffer.h │ │ ├── WAAPluginFactory.cpp │ │ ├── WAAPluginFactory.h │ │ └── tests │ │ │ ├── CMakeLists.txt │ │ │ ├── DelayPluginTest.cpp │ │ │ ├── GainPluginTest.cpp │ │ │ └── WAAPluginTestRunner.cpp │ └── wave │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── SineWavePlugin.cpp │ │ ├── SineWavePlugin.h │ │ ├── WavePluginFactory.cpp │ │ ├── WavePluginFactory.h │ │ └── tests │ │ ├── CMakeLists.txt │ │ ├── SineWavePluginTest.cpp │ │ └── WavePluginTestRunner.cpp └── tests │ ├── CMakeLists.txt │ ├── CallbackTypesTest.cpp │ ├── ClientImplementationTest.cpp │ ├── ClientTest.cpp │ ├── EdgeImplementationTest.cpp │ ├── EdgeTest.cpp │ ├── ErrorCodeTest.cpp │ ├── GraphImplementationTest.cpp │ ├── GraphTest.cpp │ ├── NFSmartPlayerTestRunner.cpp │ └── nf_smart_player_test.cpp └── tools ├── generate-integration-audio.py └── generate-version.py /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Please answer the following: 2 | 3 | ### Enviroment details: 4 | 5 | - [ ] Component (CLI, NF Playground, iOS Framework, etc): XXXXX 6 | - [ ] Player build (something like `9999-abcdef`, or version if using nodejs): XXXXX 7 | - [ ] OS & OS Version (e.g. Mac 10.12.6, Windows 10): XXXXX 8 | 9 | ### Issue Detail: 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Environment normalization: 2 | /.bundle 3 | /vendor/bundle 4 | 5 | # Xcode 6 | # 7 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 8 | 9 | ## Build generated 10 | build/ 11 | DerivedData 12 | 13 | ## Various settings 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | project.xcworkspace 24 | 25 | ## Other 26 | *.xccheckout 27 | *.moved-aside 28 | *.xcuserstate 29 | *.xcscmblueprint 30 | .DS_Store 31 | .idea 32 | .vscode 33 | 34 | ## Obj-C/Swift specific 35 | *.hmap 36 | *.ipa 37 | 38 | # Carthage 39 | Carthage/Build 40 | 41 | # Ignore changes to our project.xcconfig that gets overridden by the build system 42 | project.xcconfig 43 | 44 | # Python 45 | *.egg* 46 | *.pyc 47 | smartplayer_env 48 | 49 | # SWIG generated 50 | interfaces/python/ 51 | interfaces/csharp/ 52 | 53 | # CI Artifacts 54 | /artifacts 55 | 56 | # Java Artifacts 57 | *.class 58 | interfaces/java/*.h 59 | 60 | # Directory for creating integration test packages 61 | test-creation 62 | 63 | # Boost 64 | libraries/boost* 65 | 66 | # Integration test output 67 | /input.wav 68 | /output.wav 69 | /output.flac 70 | /nfsmartplayer.wav 71 | 72 | # Android 73 | android-ndk-* -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libraries/NFDriver"] 2 | path = libraries/NFDriver 3 | url = https://github.com/spotify/NFDriver.git 4 | [submodule "libraries/NFDecoder"] 5 | path = libraries/NFDecoder 6 | url = https://github.com/spotify/NFDecoder.git 7 | [submodule "libraries/oscpack"] 8 | path = libraries/oscpack 9 | url = https://github.com/MariadeAnton/oscpack.git 10 | [submodule "libraries/duktape"] 11 | path = libraries/duktape 12 | url = https://github.com/svaarala/duktape-releases.git 13 | [submodule "tools/gyp"] 14 | path = tools/gyp 15 | url = https://chromium.googlesource.com/external/gyp 16 | [submodule "libraries/PeqBank"] 17 | path = libraries/PeqBank 18 | url = https://github.com/spotify/PeqBank.git 19 | [submodule "libraries/NFLogger"] 20 | path = libraries/NFLogger 21 | url = https://github.com/spotify/NFLogger.git 22 | [submodule "libraries/NFGrapher"] 23 | path = libraries/NFGrapher 24 | url = https://github.com/spotify/NFGrapher.git 25 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | Contributions are welcomed. Open a pull-request or an issue. 3 | 4 | ## Code of conduct 5 | This project adheres to the [Open Code of Conduct][code-of-conduct]. By participating, you are expected to honor this code. 6 | 7 | [code-of-conduct]: https://github.com/spotify/code-of-conduct/blob/master/code-of-conduct.md 8 | -------------------------------------------------------------------------------- /NFSmartPlayer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/NFSmartPlayer.png -------------------------------------------------------------------------------- /NFSmartPlayer.pxm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/NFSmartPlayer.pxm -------------------------------------------------------------------------------- /ci/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic as intermediate 2 | 3 | WORKDIR /NFSmartPlayerEnv 4 | 5 | # copy the bare minimum to get linux.sh to execute 6 | COPY ./ci ./ci 7 | COPY ./tools ./tools 8 | RUN ./ci/linux.sh --help 9 | 10 | # Rely on the copy that will be VOLUME-ed in at runtime 11 | RUN rm -rf ./ci ./tools 12 | 13 | ENV CC=clang 14 | ENV CXX=clang++ 15 | 16 | # https://pythonspeed.com/articles/activate-virtualenv-dockerfile/ 17 | ENV VIRTUAL_ENV=/NFSmartPlayerEnv/smartplayer_env 18 | ENV PATH="$VIRTUAL_ENV/bin:$PATH" -------------------------------------------------------------------------------- /ci/ci.yaml: -------------------------------------------------------------------------------- 1 | integration_tests: 2 | - time: 2 3 | graph: resources/sine-bpf.json 4 | audio: 253b8e6458fbe5a46ed18d114e6e1f60.flac 5 | error: 0.01 6 | render_time: 0.0 7 | - time: 6 8 | graph: resources/compress-sine.json 9 | audio: 2a83716e9bfabca2e22c10bdc8f9780a.flac 10 | error: 0.01 11 | render_time: 0.0 12 | - time: 6 13 | graph: resources/compress-expand-sine.json 14 | audio: 7ca6385ed2e09e89691d10cb683748dd.flac 15 | error: 0.01 16 | render_time: 0.0 17 | - time: 6 18 | graph: resources/compand-sine.json 19 | audio: 8a30808c97573e87f4bccbafbc71a2cc.flac 20 | error: 0.01 21 | render_time: 0.0 22 | - time: 8 23 | graph: resources/compress-mb.json 24 | audio: b458ac690dc515a160b9c24481cd592e.flac 25 | error: 0.01 26 | render_time: 0.0 27 | - time: 25 28 | graph: resources/ogg-graph.json 29 | audio: a95d4efdea46762fa5fc525e9ee181f0.flac 30 | error: 0.01 31 | render_time: 0.0 32 | - graph: resources/ogg-loop-4x.json 33 | time: 30 34 | audio: 5d2d42c9e3baec1a5605ceb947c9a028.flac 35 | error: 0.01 36 | render_time: 0.0 37 | - time: 5 38 | graph: resources/sidechain-sine.json 39 | audio: e8256968a885259b4516eef2e0b095b0.flac 40 | error: 0.01 41 | render_time: 0.0 42 | - time: 5 43 | graph: resources/sidechain-sine-delayed-sidechain.json 44 | audio: 90e05f78e8ff35739443d0c926bde602.flac 45 | error: 0.01 46 | render_time: 0.0 47 | - time: 5 48 | graph: resources/scripting.json 49 | audio: 2478c8c11b7a1eff5f401393a1a4bf5f.flac 50 | error: 0.01 51 | render_time: 0.0 52 | static_analyzer_exceptions: 53 | - source/plugins/waa/AudioArray.h 54 | unit_tests: 55 | - NFSmartPlayerTests 56 | - NFSmartPlayerObjCTests 57 | - ChannelPluginTests 58 | - CompressorPluginTests 59 | - EQPluginTests 60 | - NoisePluginTests 61 | - PluginUtilTests 62 | - TimePluginTests 63 | - WAAPluginTests 64 | - WavePluginTests 65 | -------------------------------------------------------------------------------- /ci/llvm-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | exec xcrun llvm-cov gcov "$@" -------------------------------------------------------------------------------- /ci/osx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2018 Spotify AB. 3 | # 4 | # Licensed to the Apache Software Foundation (ASF) under one 5 | # or more contributor license agreements. See the NOTICE file 6 | # distributed with this work for additional information 7 | # regarding copyright ownership. The ASF licenses this file 8 | # to you under the Apache License, Version 2.0 (the 9 | # "License"); you may not use this file except in compliance 10 | # with the License. You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, 15 | # software distributed under the License is distributed on an 16 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | # KIND, either express or implied. See the License for the 18 | # specific language governing permissions and limitations 19 | # under the License. 20 | 21 | # Exit on any non-zero status 22 | set -e 23 | set -x 24 | 25 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" 26 | 27 | # Homebrew on circleci consistently fails with an error like: 28 | # 29 | # ==> Checking for dependents of upgraded formulae... Error: No such file or 30 | # directory - /usr/local/Cellar/git/2.26.2_1 31 | # 32 | # Completely unpredictable, because it's just homebrew cleaning itself up and 33 | # has nothing to do with the install itself! Just continue and hope the build 34 | # fails if one of these tools is not installed. 35 | if ! HOMEBREW_NO_AUTO_UPDATE=1 brew install \ 36 | clang-format@10 \ 37 | cmake \ 38 | ninja \ 39 | wget \ 40 | ffmpeg \ 41 | x264 \ 42 | lame \ 43 | lcov \ 44 | swig ; then 45 | echo "Homebrew install had an error, review output and try manually." 46 | fi 47 | 48 | # Update submodules 49 | git submodule sync 50 | git submodule update --init --recursive 51 | 52 | # Undo homebrew's potential meddling: https://github.com/pypa/pip/issues/5048 53 | # Homebrew will upgrade python to 3.8, but virtualenv hard codes the path to 3.7 54 | # in its shebang. 55 | pip3 uninstall -y virtualenv && pip3 install virtualenv 56 | 57 | # Install virtualenv 58 | virtualenv --python=$(which python2) smartplayer_env 59 | source smartplayer_env/bin/activate 60 | 61 | # Install Python Packages 62 | pip2 install --upgrade six 63 | pip2 install --upgrade setuptools pip 64 | pip2 install -r ${DIR}/requirements.txt 65 | 66 | # Install gyp 67 | cd tools/gyp 68 | python setup.py install 69 | cd ../.. 70 | 71 | # Execute our python build tools 72 | if [ -n "$BUILD_IOS" ]; then 73 | python ci/ios.py "$@" 74 | else 75 | if [ -n "$BUILD_ANDROID" ]; then 76 | brew cask install android-ndk 77 | python ci/androidosx.py "$@" 78 | else 79 | python ci/osx.py "$@" 80 | fi 81 | fi 82 | -------------------------------------------------------------------------------- /ci/requirements.txt: -------------------------------------------------------------------------------- 1 | llvmlite==0.26.0 2 | numba==0.41.0 3 | pyyaml 4 | flake8 5 | cmakelint 6 | pycparser 7 | pysoundfile 8 | numpy 9 | requests 10 | scikit-learn==0.20.3 11 | librosa==0.6.3 12 | ffmpeg 13 | ruamel.yaml -------------------------------------------------------------------------------- /include/NFSmartPlayer/CallbackTypes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace nativeformat { 29 | 30 | typedef struct Load { 31 | typedef std::list> ERROR_INFO; 32 | bool _loaded; 33 | ERROR_INFO _info; 34 | 35 | /* 36 | * since boost futures are not compatible with stdlib rvalue 37 | * references, allow copy 38 | */ 39 | Load(const Load &l); 40 | void operator=(const Load &l); 41 | 42 | Load(bool loaded, std::string domain, std::string msg); 43 | Load(bool loaded, ERROR_INFO info = ERROR_INFO()); 44 | Load(Load &&l); 45 | } Load; 46 | 47 | typedef std::function LOAD_CALLBACK; 48 | 49 | extern std::string errorMessageFromLoad(const Load &load); 50 | 51 | } // namespace nativeformat 52 | -------------------------------------------------------------------------------- /include/NFSmartPlayer/Edge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace nativeformat { 29 | namespace smartplayer { 30 | 31 | class Edge { 32 | public: 33 | virtual std::string source() const = 0; 34 | virtual std::string target() const = 0; 35 | virtual std::string identifier() const = 0; 36 | virtual std::string json() const = 0; 37 | }; 38 | 39 | extern std::shared_ptr createEdge(const nfgrapher::Edge &edge); 40 | extern std::shared_ptr createEdge(const std::string &json); 41 | 42 | } // namespace smartplayer 43 | } // namespace nativeformat 44 | -------------------------------------------------------------------------------- /include/NFSmartPlayer/ErrorCode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace nativeformat { 26 | namespace smartplayer { 27 | 28 | typedef enum : int { 29 | ErrorCodeNone = 0, 30 | ErrorCodePluginNotFound, 31 | ErrorCodeJSONDecodeFailed, 32 | ErrorCodeGraphIsSame, 33 | ErrorCodeNoGraphsFound, 34 | ErrorCodeCommandsFailedToParse, 35 | ErrorCodeFailedToLoadPluginFactories, 36 | ErrorCodeReloadCalledBeforeLoaded, 37 | ErrorCodePluginFailedToLoad 38 | } ErrorCode; 39 | 40 | extern ErrorCode errorCodeFromString(const std::string &error_code); 41 | extern const std::string stringFromErrorCode(ErrorCode error_code); 42 | 43 | } // namespace smartplayer 44 | } // namespace nativeformat 45 | -------------------------------------------------------------------------------- /include/NFSmartPlayer/Factory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace nativeformat { 32 | namespace plugin { 33 | 34 | typedef std::function 35 | NF_PLUGIN_ERROR_CALLBACK; 36 | typedef std::function 38 | NF_PLUGIN_RESOLVE_CALLBACK; 39 | 40 | /** 41 | * The class that represents the basic interface of a plugin factory 42 | */ 43 | class Factory { 44 | public: 45 | /** 46 | * Creates a plugin from the factory 47 | * @param greapher_node The grapher object describing the behaviour of the 48 | * plugin 49 | * @param identifier The identifier describing the plugin to invoke 50 | * @param resolve_callback The callback to invoke when a plugin wants to 51 | * resolve a variable 52 | * @param load_callback The callback to invoke when the plugin has been 53 | * created 54 | */ 55 | virtual std::shared_ptr createPlugin( 56 | const nfgrapher::Node &grapher_node, const std::string &graph_id, 57 | const NF_PLUGIN_RESOLVE_CALLBACK &resolve_callback, int channels, 58 | double samplerate, const std::shared_ptr &child_plugin, 59 | const std::string &session_id) = 0; 60 | /** 61 | * The identifiers represented by this factory 62 | * @warning This should not change. 63 | */ 64 | virtual std::vector identifiers() const = 0; 65 | }; 66 | 67 | } // namespace plugin 68 | } // namespace nativeformat 69 | -------------------------------------------------------------------------------- /include/NFSmartPlayer/GlobalLogger.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | #define NF_INFO(i) INFO(nativeformat::getGlobalLogger(), i) 26 | #define NF_WARN(i) WARN(nativeformat::getGlobalLogger(), i) 27 | #define NF_ERROR(i) ERROR(nativeformat::getGlobalLogger(), i) 28 | #define NF_REPORT(i) REPORT(nativeformat::getGlobalLogger(), i) 29 | 30 | namespace nativeformat { 31 | using logger::Logger; 32 | using logger::LogInfoHandler; 33 | 34 | typedef Logger> NF_LOGGER_TYPE; 35 | 36 | void configGlobalLogger(std::string token_type, std::string token); 37 | NF_LOGGER_TYPE &getGlobalLogger(); 38 | } // namespace nativeformat 39 | -------------------------------------------------------------------------------- /include/NFSmartPlayer/Node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | namespace nativeformat { 31 | namespace smartplayer { 32 | 33 | typedef std::function &)> 34 | NF_SMART_PLAYER_NODE_PARAM_CALLBACK; 35 | 36 | class Node { 37 | friend class GraphImplementation; 38 | 39 | public: 40 | virtual std::string identifier() const = 0; 41 | virtual std::string type() const = 0; 42 | virtual bool isOutputNode() const = 0; 43 | virtual std::string toJSON() const = 0; 44 | virtual void forEachParam( 45 | NF_SMART_PLAYER_NODE_PARAM_CALLBACK param_callback) const = 0; 46 | virtual std::shared_ptr paramForIdentifier( 47 | const std::string &identifier) const = 0; 48 | virtual const nfgrapher::Node &grapherNode() const = 0; 49 | virtual std::shared_ptr plugin() const = 0; 50 | virtual nfgrapher::LoadingPolicy loadingPolicy() const = 0; 51 | virtual std::vector dependencies() const = 0; 52 | virtual void setPlugin(std::shared_ptr &plugin) = 0; 53 | 54 | protected: 55 | virtual void run(double time, const plugin::NodeTimes &node_times, 56 | double node_time) = 0; 57 | }; 58 | 59 | extern std::shared_ptr createNode(const std::string &json); 60 | 61 | } // namespace smartplayer 62 | } // namespace nativeformat 63 | -------------------------------------------------------------------------------- /include/NFSmartPlayer/Script.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | namespace nativeformat { 26 | namespace smartplayer { 27 | 28 | typedef enum : int { 29 | ScriptScopeNone, 30 | ScriptScopeGraph, 31 | ScriptScopeSession 32 | } ScriptScope; 33 | 34 | class Script { 35 | public: 36 | virtual std::string name() const = 0; 37 | virtual ScriptScope scope() const = 0; 38 | virtual void run() = 0; 39 | virtual void close() = 0; 40 | virtual std::string code() const = 0; 41 | virtual bool isRunning() const = 0; 42 | }; 43 | 44 | } // namespace smartplayer 45 | } // namespace nativeformat 46 | -------------------------------------------------------------------------------- /interfaces/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(NATIVEFORMAT_INTERFACE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") 2 | 3 | # temporary, haven't dealt with these on Linux yet 4 | if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 5 | find_package(SWIG REQUIRED) 6 | 7 | add_subdirectory(csharp) 8 | 9 | add_subdirectory(python) 10 | add_subdirectory(objc) 11 | endif() 12 | 13 | if((NOT IOS) OR (NOT ANDROID)) 14 | add_subdirectory(java) 15 | endif() 16 | -------------------------------------------------------------------------------- /interfaces/NFSmartPlayer.i: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | %module smartplayer 22 | %{ 23 | #include "../include/NFSmartPlayer/nf_smart_player.h" 24 | %} 25 | %include "../include/NFSmartPlayer/nf_smart_player.h" 26 | -------------------------------------------------------------------------------- /interfaces/csharp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(${SWIG_USE_FILE}) 2 | set(CMAKE_SWIG_FLAGS "") 3 | 4 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 5 | 6 | # Generate C# interfaces 7 | set(CMAKE_SWIG_FLAGS -w451) 8 | set(CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_SOURCE_DIR}") 9 | set_source_files_properties( 10 | "${NATIVEFORMAT_INTERFACE_DIRECTORY}/NFSmartPlayer.i" 11 | PROPERTIES 12 | CPLUSPLUS ON) 13 | swig_add_module( 14 | NFSmartPlayerCS 15 | csharp 16 | "${NATIVEFORMAT_INTERFACE_DIRECTORY}/NFSmartPlayer.i") 17 | swig_link_libraries(NFSmartPlayerCS NFSmartPlayer ${CSHARP_LIBRARIES}) 18 | -------------------------------------------------------------------------------- /interfaces/java/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generate Java interfaces 2 | message("Generating JNI Interface") 3 | 4 | if(ANDROID) 5 | # https://stackoverflow.com/a/51764145 6 | set(JAVA_AWT_LIBRARY NotNeeded) 7 | set(JAVA_JVM_LIBRARY NotNeeded) 8 | set(JAVA_INCLUDE_PATH2 NotNeeded) 9 | set(JAVA_AWT_INCLUDE_PATH NotNeeded) 10 | endif() 11 | 12 | find_package(Java REQUIRED COMPONENTS Runtime Development) 13 | find_package(JNI REQUIRED) 14 | execute_process(COMMAND 15 | ${Java_JAVAC_EXECUTABLE} -h . com/spotify/nativeformat/Player.java 16 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 17 | RESULT_VARIABLE JAVAC_CODE) 18 | if(NOT JAVAC_CODE STREQUAL "0") 19 | message(FATAL_ERROR "JNI Generation Error: Exited with code ${JAVAC_CODE}") 20 | endif() 21 | add_library(NFSmartPlayerJava 22 | SHARED 23 | Player.cpp) 24 | target_link_libraries(NFSmartPlayerJava 25 | NFSmartPlayer 26 | ${JNI_LIBRARIES}) 27 | target_include_directories(NFSmartPlayerJava 28 | PRIVATE 29 | ${JNI_INCLUDE_DIRS}) 30 | 31 | message("End of Generating JNI Interface") -------------------------------------------------------------------------------- /interfaces/java/com/spotify/nativeformat/DriverType.java: -------------------------------------------------------------------------------- 1 | package com.spotify.nativeformat; 2 | 3 | public enum DriverType { 4 | Soundcard(0), 5 | File(1); 6 | 7 | private int numVal; 8 | 9 | DriverType(int numVal) { 10 | this.numVal = numVal; 11 | } 12 | 13 | public int getNumVal() { 14 | return numVal; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /interfaces/java/com/spotify/nativeformat/MessageType.java: -------------------------------------------------------------------------------- 1 | package com.spotify.nativeformat; 2 | 3 | public enum MessageType { 4 | None(0), 5 | Generic(1); 6 | 7 | private int numVal; 8 | 9 | MessageType(int numVal) { 10 | this.numVal = numVal; 11 | } 12 | 13 | public int getNumVal() { 14 | return numVal; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /interfaces/java/com/spotify/nativeformat/OSValidator.java: -------------------------------------------------------------------------------- 1 | package com.spotify.nativeformat; 2 | 3 | public class OSValidator { 4 | 5 | private static String OS = System.getProperty("os.name").toLowerCase(); 6 | 7 | public static boolean isWindows() { 8 | 9 | return (OS.indexOf("win") >= 0); 10 | 11 | } 12 | 13 | public static boolean isMac() { 14 | 15 | return (OS.indexOf("mac") >= 0); 16 | 17 | } 18 | 19 | public static boolean isUnix() { 20 | 21 | return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0 ); 22 | 23 | } 24 | 25 | public static boolean isSolaris() { 26 | 27 | return (OS.indexOf("sunos") >= 0); 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /interfaces/java/com/spotify/nativeformat/Player.java: -------------------------------------------------------------------------------- 1 | package com.spotify.nativeformat; 2 | 3 | import java.io.IOException; 4 | 5 | public class Player { 6 | private boolean closed; 7 | private final DriverType driverType; 8 | private final String outputPath; 9 | private final PlayerListener listener; 10 | private long nPlayerPointer; 11 | 12 | static { 13 | try { 14 | if (OSValidator.isWindows()) { 15 | NativeUtils.loadLibraryFromJar("/resources/NFSmartPlayerJava.dll"); 16 | } else if (OSValidator.isMac()) { 17 | NativeUtils.loadLibraryFromJar("/resources/libNFSmartPlayerJava.dylib"); 18 | } else if (OSValidator.isUnix()) { 19 | NativeUtils.loadLibraryFromJar("/resources/libNFSmartPlayerJava.so"); 20 | } else { 21 | NativeUtils.loadLibraryFromJar("/resources/libNFSmartPlayerJava"); 22 | } 23 | } catch (IOException e) { 24 | e.printStackTrace(); 25 | } 26 | } 27 | 28 | public Player(PlayerListener listener, DriverType driverType, String outputPath) { 29 | this.closed = false; 30 | this.driverType = driverType; 31 | this.outputPath = outputPath; 32 | this.listener = listener; 33 | init(); 34 | } 35 | 36 | public native boolean getPlaying(); 37 | public native void setPlaying(boolean playing); 38 | public native double getTime(); 39 | public native void setTime(double time); 40 | public native boolean getLoaded(); 41 | public native float getValueForPath(String path); 42 | public native void setValueForPath(String path, float... values); 43 | public native void setJson(String json); 44 | public native void sendMessage(String messageIdentifier, MessageType messageType, Object payload); 45 | 46 | public static native String getSpotifyPluginFactoryAccessTokenVariable(); 47 | public static native String getSpotifyPluginFactoryTokenTypeVariable(); 48 | public static native String getPlayerVersion(); 49 | 50 | private native void init(); 51 | public native void close(); 52 | 53 | public boolean isClosed() { 54 | return this.closed; 55 | } 56 | 57 | protected void finalize() { 58 | close(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /interfaces/java/com/spotify/nativeformat/PlayerListener.java: -------------------------------------------------------------------------------- 1 | package com.spotify.nativeformat; 2 | 3 | interface PlayerListener { 4 | String nativeFormatResolveVariable(String pluginNamespace, String variableIdentifier); 5 | void nativeFormatDidLoad(boolean success, String errorMessage); 6 | void nativeFormatReceivedMessage(String messageIdentifier, String senderIdentifier, MessageType messageType, Object payload); 7 | } -------------------------------------------------------------------------------- /interfaces/objc/NFSmartPlayerEdge+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #include 24 | 25 | @interface NFSmartPlayerEdge (Private) 26 | 27 | @property(nonatomic, assign, readonly) NF_SMART_PLAYER_EDGE_HANDLE edgeHandle; 28 | 29 | - (instancetype)initWithEdge:(NF_SMART_PLAYER_EDGE_HANDLE)edge; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /interfaces/objc/NFSmartPlayerEdge.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #import "NFSmartPlayerEdge+Private.h" 24 | 25 | @interface NFSmartPlayerEdge () 26 | 27 | @property(nonatomic, assign, readonly) NF_SMART_PLAYER_EDGE_HANDLE edgeHandle; 28 | 29 | @end 30 | 31 | @implementation NFSmartPlayerEdge 32 | 33 | #pragma mark NFSmartPlayerEdge 34 | 35 | - (instancetype)initWithEdge:(NF_SMART_PLAYER_EDGE_HANDLE)edge { 36 | self = [super init]; 37 | if (self) { 38 | _edgeHandle = edge; 39 | } 40 | return self; 41 | } 42 | 43 | - (instancetype)initWithSource:(NSString *)source target:(NSString *)target { 44 | self = [super init]; 45 | if (self) { 46 | _edgeHandle = smartplayer_create_edge(source.UTF8String, target.UTF8String); 47 | } 48 | return self; 49 | } 50 | 51 | - (instancetype)initWithJSON:(NSString *)json { 52 | self = [super init]; 53 | if (self) { 54 | _edgeHandle = smartplayer_create_edge_json(json.UTF8String); 55 | } 56 | return self; 57 | } 58 | 59 | - (NSString *)source { 60 | return [NSString stringWithUTF8String:smartplayer_edge_get_source(self.edgeHandle)]; 61 | } 62 | 63 | - (NSString *)target { 64 | return [NSString stringWithUTF8String:smartplayer_edge_get_target(self.edgeHandle)]; 65 | } 66 | 67 | - (NSString *)json { 68 | return [NSString stringWithUTF8String:smartplayer_edge_get_json(self.edgeHandle)]; 69 | } 70 | 71 | - (NSString *)identifier { 72 | return [NSString stringWithUTF8String:smartplayer_edge_get_identifier(self.edgeHandle)]; 73 | } 74 | 75 | #pragma mark NSObject 76 | 77 | - (void)dealloc { 78 | smartplayer_edge_close(self.edgeHandle); 79 | } 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /interfaces/objc/NFSmartPlayerGraph+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #include 24 | 25 | @interface NFSmartPlayerGraph (Private) 26 | 27 | @property(nonatomic, assign, readonly) NF_SMART_PLAYER_GRAPH_HANDLE graphHandle; 28 | 29 | - (instancetype)initWithGraph:(NF_SMART_PLAYER_GRAPH_HANDLE)graph; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /interfaces/objc/NFSmartPlayerNode+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #include 24 | 25 | @interface NFSmartPlayerNode (Private) 26 | 27 | @property(nonatomic, assign, readonly) NF_SMART_PLAYER_NODE_HANDLE nodeHandle; 28 | 29 | - (instancetype)initWithNode:(NF_SMART_PLAYER_NODE_HANDLE)node; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /interfaces/objc/NFSmartPlayerParam+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #include 24 | 25 | @interface NFSmartPlayerParam (Private) 26 | 27 | @property(nonatomic, assign, readonly) NF_SMART_PLAYER_PARAM_HANDLE paramHandle; 28 | 29 | - (instancetype)initWithParam:(NF_SMART_PLAYER_PARAM_HANDLE)param; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /interfaces/objc/NFSmartPlayerParam.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #import "NFSmartPlayerParam+Private.h" 24 | 25 | @interface NFSmartPlayerParam () 26 | 27 | @property(nonatomic, assign, readonly) NF_SMART_PLAYER_PARAM_HANDLE paramHandle; 28 | 29 | @end 30 | 31 | @implementation NFSmartPlayerParam 32 | 33 | #pragma mark NFSmartPlayerParam 34 | 35 | - (instancetype)initWithParam:(NF_SMART_PLAYER_PARAM_HANDLE)param { 36 | self = [super init]; 37 | if (self) { 38 | _paramHandle = param; 39 | } 40 | return self; 41 | } 42 | 43 | #pragma mark NSObject 44 | 45 | - (void)dealloc { 46 | smartplayer_param_close(self.paramHandle); 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /interfaces/objc/NFSmartPlayerScript+Private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #include 24 | 25 | @interface NFSmartPlayerScript (Private) 26 | 27 | @property(nonatomic, assign, readonly) NF_SMART_PLAYER_SCRIPT_HANDLE scriptHandle; 28 | 29 | - (instancetype)initWithScript:(NF_SMART_PLAYER_SCRIPT_HANDLE)script; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /interfaces/objc/NFSmartPlayerScript.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #import "NFSmartPlayerScript+Private.h" 24 | 25 | @interface NFSmartPlayerScript () 26 | 27 | @property(nonatomic, assign, readonly) NF_SMART_PLAYER_SCRIPT_HANDLE scriptHandle; 28 | 29 | @end 30 | 31 | @implementation NFSmartPlayerScript 32 | 33 | #pragma mark NFSmartPlayerScript 34 | 35 | - (instancetype)initWithScript:(NF_SMART_PLAYER_SCRIPT_HANDLE)script { 36 | self = [super init]; 37 | if (self) { 38 | _scriptHandle = script; 39 | } 40 | return self; 41 | } 42 | 43 | - (NSString *)name { 44 | return [NSString stringWithUTF8String:smartplayer_script_name(self.scriptHandle)]; 45 | } 46 | 47 | - (NFSmartPlayerScriptScope)scope { 48 | return (NFSmartPlayerScriptScope)smartplayer_script_scope(self.scriptHandle); 49 | } 50 | 51 | #pragma mark NSObject 52 | 53 | - (void)dealloc { 54 | smartplayer_script_close(self.scriptHandle); 55 | } 56 | 57 | @end 58 | 59 | static_assert(NFSmartPlayerScriptScopeNone == NF_SMART_PLAYER_SCRIPT_SCOPE_NONE, 60 | "The ObjC enumeration must match the C enumeration"); 61 | static_assert(NFSmartPlayerScriptScopeGraph == NF_SMART_PLAYER_SCRIPT_SCOPE_GRAPH, 62 | "The ObjC enumeration must match the C enumeration"); 63 | static_assert(NFSmartPlayerScriptScopeSession == NF_SMART_PLAYER_SCRIPT_SCOPE_SESSION, 64 | "The ObjC enumeration must match the C enumeration"); 65 | -------------------------------------------------------------------------------- /interfaces/objc/check-lib-pre.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | #mainlib=$1 5 | #shift 6 | while [[ $# > 0 ]] ; do 7 | dep=$1 8 | if [ "$dep" -nt "$mainlib" ]; then 9 | # echo "'$dep' is newer than '$mainlib'" 10 | # rm -f $mainlib 11 | find $TEMP_DIR -name "*-master.o" -print -delete 12 | exit 0 13 | fi 14 | shift 15 | done 16 | -------------------------------------------------------------------------------- /interfaces/objc/include/NFSmartPlayerObjC/NFSmartPlayerEdge.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | @interface NFSmartPlayerEdge : NSObject 24 | 25 | @property(nonatomic, strong, readonly, nonnull) NSString *source; 26 | @property(nonatomic, strong, readonly, nonnull) NSString *target; 27 | @property(nonatomic, strong, readonly, nonnull) NSString *json; 28 | @property(nonatomic, strong, readonly, nonnull) NSString *identifier; 29 | 30 | - (nonnull instancetype)initWithSource:(nonnull NSString *)source target:(nonnull NSString *)target; 31 | - (nonnull instancetype)initWithJSON:(nonnull NSString *)json; 32 | - (nonnull instancetype)init NS_UNAVAILABLE; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /interfaces/objc/include/NFSmartPlayerObjC/NFSmartPlayerGraph.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #import 24 | #import 25 | #import 26 | 27 | typedef void (^NFSmartPlayerGraphLoad)(BOOL, NSString *_Nonnull); 28 | 29 | @class NFSmartPlayerGraph; 30 | 31 | @protocol NFSmartPlayerGraphDelegate 32 | 33 | - (void)graphDidLoad:(nonnull NFSmartPlayerGraph *)graph 34 | errorMessage:(nonnull NSString *)errorMessage; 35 | 36 | @end 37 | 38 | @interface NFSmartPlayerGraph : NSObject 39 | 40 | @property(nonatomic, strong, readonly, nonnull) NSString *identifier; 41 | @property(nonatomic, assign, readwrite) NSTimeInterval renderTime; 42 | @property(nonatomic, strong, readonly, nonnull) NSString *type; 43 | @property(nonatomic, weak, readwrite, nullable) id delegate; 44 | @property(nonatomic, assign, readonly, getter=isLoaded) BOOL loaded; 45 | 46 | - (nonnull instancetype)init NS_UNAVAILABLE; 47 | - (nonnull instancetype)initWithJSON:(nonnull NSString *)json 48 | loadBlock:(nullable NFSmartPlayerGraphLoad)loadBlock; 49 | 50 | - (float)valueForPath:(nonnull NSString *)path; 51 | - (void)setValueForPath:(nonnull NSString *)path, ...; 52 | - (nullable NFSmartPlayerParam *)paramForPath:(nonnull NSString *)path; 53 | - (void)setJson:(nonnull NSString *)json; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /interfaces/objc/include/NFSmartPlayerObjC/NFSmartPlayerNode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #import 24 | 25 | @interface NFSmartPlayerNode : NSObject 26 | 27 | @property(nonatomic, strong, readonly, nonnull) NSString *identifier; 28 | @property(nonatomic, strong, readonly, nonnull) NSString *type; 29 | @property(nonatomic, assign, readonly, getter=isOutputNode) BOOL outputNode; 30 | @property(nonatomic, strong, readonly, nonnull) NSString *json; 31 | @property(nonatomic, strong, readonly, nonnull) NSArray *params; 32 | 33 | - (nonnull instancetype)initWithJSON:(nonnull NSString *)json; 34 | - (nonnull instancetype)init NS_UNAVAILABLE; 35 | - (nullable NFSmartPlayerParam *)paramForIdentifier:(nonnull NSString *)identifier; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /interfaces/objc/include/NFSmartPlayerObjC/NFSmartPlayerParam.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | @interface NFSmartPlayerParam : NSObject 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /interfaces/objc/include/NFSmartPlayerObjC/NFSmartPlayerScript.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | typedef NS_ENUM(NSInteger, NFSmartPlayerScriptScope) { 24 | NFSmartPlayerScriptScopeNone, 25 | NFSmartPlayerScriptScopeGraph, 26 | NFSmartPlayerScriptScopeSession 27 | }; 28 | 29 | @interface NFSmartPlayerScript : NSObject 30 | 31 | @property(nonatomic, strong, readonly, nonnull) NSString *name; 32 | @property(nonatomic, assign, readonly) NFSmartPlayerScriptScope scope; 33 | 34 | - (nonnull instancetype)init NS_UNAVAILABLE; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /interfaces/objc/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(NFSmartPlayerObjCTests 2 | NFSmartPlayerObjCTestRunner.cpp 3 | NFSmartPlayerGraphTest.mm 4 | NFSmartPlayerObjCTest.mm 5 | NFSmartPlayerObjCDelegateMock.h 6 | NFSmartPlayerObjCDelegateMock.m 7 | NFSmartPlayerGraphDelegateMock.h 8 | NFSmartPlayerGraphDelegateMock.m) 9 | target_link_libraries(NFSmartPlayerObjCTests 10 | NFSmartPlayerObjC 11 | NFGrapher 12 | ${Boost_LIBRARIES}) 13 | target_include_directories( 14 | NFSmartPlayerObjCTests 15 | PUBLIC 16 | "${NFSMARTPLAYEROBJC_INCLUDE_DIR}") 17 | -------------------------------------------------------------------------------- /interfaces/objc/tests/NFSmartPlayerGraphDelegateMock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | typedef void (^NFSmartPlayerGraphDelegateMockLoadedBlock)(BOOL); 24 | 25 | @interface NFSmartPlayerGraphDelegateMock : NSObject 26 | 27 | @property(nonatomic, strong, readwrite) NFSmartPlayerGraphDelegateMockLoadedBlock loadedBlock; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /interfaces/objc/tests/NFSmartPlayerGraphDelegateMock.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import "NFSmartPlayerGraphDelegateMock.h" 22 | 23 | @implementation NFSmartPlayerGraphDelegateMock 24 | 25 | - (void)graphDidLoad:(NFSmartPlayerGraph *)graph errorMessage:(NSString *)errorMessage { 26 | if (self.loadedBlock) { 27 | self.loadedBlock(YES); 28 | } 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /interfaces/objc/tests/NFSmartPlayerGraphTest.mm: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | #include 24 | 25 | #include 26 | 27 | #import "NFSmartPlayerGraphDelegateMock.h" 28 | 29 | BOOST_AUTO_TEST_SUITE(NFSmartPlayerGraphTests) 30 | 31 | BOOST_AUTO_TEST_CASE(testInitWithJson) { 32 | NFSmartPlayerGraph *graph = [[NFSmartPlayerGraph alloc] 33 | initWithJSON:@"{\"id\":\"com.nativeformat.graph:67352cd747ca928eccf57b5b29727068\",\"type\":" 34 | @"\"com.nativeformat.graph\",\"nodes\":[{\"id\":\"node-0\",\"type\":\"com." 35 | @"nativeformat.plugin.spotify.spotify\",\"label\":\"A New " 36 | @"Error\",\"commands\":[[\"setTrackUri\",\"spotify:track:" 37 | @"6OGRM4MAOlyOdhHuX0OJ6P\"],[\"setStartTime\",\"time:0\"],[\"setDuration\"," 38 | @"\"rtime:367.306\"]],\"metadata\":{\"editor.x\":65,\"editor.y\":104}},{\"id\":" 39 | @"\"node-1\",\"type\":\"com.nativeformat.plugin.waa.gain\",\"label\":\"Node " 40 | @"1\",\"commands\":[[\"gain.value\",1]],\"metadata\":{\"editor.x\":433," 41 | @"\"editor.y\":112}}],\"edges\":[{\"relation\":\"edge " 42 | @"relationship\",\"directed\":true,\"metadata\":{},\"label\":\"\",\"source\":" 43 | @"\"node-0\",\"target\":\"node-1\"}]}" 44 | loadBlock:nil]; 45 | BOOST_CHECK(graph); 46 | } 47 | 48 | BOOST_AUTO_TEST_SUITE_END() 49 | -------------------------------------------------------------------------------- /interfaces/objc/tests/NFSmartPlayerObjCDelegateMock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import 22 | 23 | typedef void (^NFSmartPlayerObjCDelegateMockLoadedBlock)(BOOL); 24 | 25 | @interface NFSmartPlayerObjCDelegateMock : NSObject 26 | 27 | @property(nonatomic, strong, readwrite) NFSmartPlayerObjCDelegateMockLoadedBlock loadedBlock; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /interfaces/objc/tests/NFSmartPlayerObjCDelegateMock.m: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #import "NFSmartPlayerObjCDelegateMock.h" 22 | 23 | @implementation NFSmartPlayerObjCDelegateMock 24 | 25 | - (NSString *)smartPlayer:(NFSmartPlayerObjC *)smartPlayer 26 | requiresResolution:(NSString *)pluginNamespace 27 | forVariable:(NSString *)variableIdentifier { 28 | return @""; 29 | } 30 | 31 | - (void)smartPlayer:(NFSmartPlayerObjC *)smartPlayer 32 | didLoad:(BOOL)success 33 | errorMessage:(NSString *)errorMessage { 34 | if (self.loadedBlock) { 35 | self.loadedBlock(success); 36 | } 37 | } 38 | 39 | - (void)smartPlayer:(NFSmartPlayerObjC *)smartPlayer 40 | receivedMessage:(NSString *)messageIdentifier 41 | messageType:(NFSmartPlayerMessageType)messageType 42 | payload:(id)payload { 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /interfaces/objc/tests/NFSmartPlayerObjCTestRunner.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #define BOOST_TEST_MODULE NFSmartPlayerObjCTests 22 | #include 23 | -------------------------------------------------------------------------------- /interfaces/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(${SWIG_USE_FILE}) 2 | 3 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 4 | 5 | # Generate Python interfaces 6 | find_package(PythonLibs) 7 | include_directories(${PYTHON_INCLUDE_PATH}) 8 | set(CMAKE_SWIG_FLAGS -w451 "-DV8_VERSION=${V8_VERSION_HEX}") 9 | set(CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_SOURCE_DIR}") 10 | set_source_files_properties( 11 | "${NATIVEFORMAT_INTERFACE_DIRECTORY}/NFSmartPlayer.i" 12 | PROPERTIES 13 | CPLUSPLUS ON) 14 | swig_add_library( 15 | NFSmartPlayerPython 16 | LANGUAGE python 17 | SOURCES "${NATIVEFORMAT_INTERFACE_DIRECTORY}/NFSmartPlayer.i") 18 | swig_link_libraries(NFSmartPlayerPython NFSmartPlayer ${PYTHON_LIBRARIES}) 19 | -------------------------------------------------------------------------------- /resources/nf-logging/expected/example2.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "clientInfo": { 4 | "playerBuildId": "2244-43324281" 5 | }, 6 | "message": [ 7 | { 8 | "partialEndSample": { 9 | "graphId": "com.nativeformat.graph:cbacd565f61fbb024d8172002f2a3871", 10 | "startTime": "2018-05-25T13:29:34Z", 11 | "renderDuration": "10s", 12 | "initiatingAction": "START", 13 | "graphOffset": "18.599s", 14 | "sourceUri": "spotify:track:54dG8htZf7qqSB6bf8RcPi", 15 | "sourceOffset": "1.3s", 16 | "sourceDuration": "10s", 17 | "scorePlaybackId": "957ddbe1-d318-47b7-bfa9-094285496fe2", 18 | "nodeId": "node-5" 19 | } 20 | } 21 | ] 22 | }, 23 | { 24 | "clientInfo": { 25 | "playerBuildId": "2244-43324281" 26 | }, 27 | "message": [ 28 | { 29 | "partialEndSample": { 30 | "graphId": "com.nativeformat.graph:cbacd565f61fbb024d8172002f2a3871", 31 | "startTime": "2018-05-25T13:29:36Z", 32 | "renderDuration": "10s", 33 | "graphOffset": "28.599s", 34 | "sourceUri": "spotify:track:54dG8htZf7qqSB6bf8RcPi", 35 | "sourceOffset": "11.299s", 36 | "sourceDuration": "10s", 37 | "scorePlaybackId": "957ddbe1-d318-47b7-bfa9-094285496fe2", 38 | "nodeId": "node-5", 39 | "sequenceNumber": "1" 40 | } 41 | } 42 | ] 43 | }, 44 | { 45 | "clientInfo": { 46 | "playerBuildId": "2244-43324281" 47 | }, 48 | "message": [ 49 | { 50 | "partialEndSample": { 51 | "graphId": "com.nativeformat.graph:cbacd565f61fbb024d8172002f2a3871", 52 | "startTime": "2018-05-25T13:29:37Z", 53 | "renderDuration": "10s", 54 | "terminatingAction": "END", 55 | "graphOffset": "38.599s", 56 | "sourceUri": "spotify:track:54dG8htZf7qqSB6bf8RcPi", 57 | "sourceOffset": "21.299s", 58 | "sourceDuration": "10s", 59 | "scorePlaybackId": "957ddbe1-d318-47b7-bfa9-094285496fe2", 60 | "nodeId": "node-5", 61 | "sequenceNumber": "2" 62 | } 63 | } 64 | ] 65 | } 66 | ] 67 | -------------------------------------------------------------------------------- /resources/ogg-graph.json: -------------------------------------------------------------------------------- 1 | { 2 | "graph": { 3 | "id": "com.nativeformat.graph:67352cd747ca928eccf57b5b29727068", 4 | "loadingPolicy": "allContentPlaythrough", 5 | "nodes": [ 6 | { 7 | "id": "node-0", 8 | "kind": "com.nativeformat.plugin.file.file", 9 | "config": { 10 | "file": "https://upload.wikimedia.org/wikipedia/en/4/45/ACDC_-_Back_In_Black-sample.ogg", 11 | "when": 0, 12 | "duration": 25000000000, 13 | "offset": 0 14 | }, 15 | "params": {}, 16 | "metadata": { 17 | "editor.x": 65, 18 | "editor.y": 104 19 | }, 20 | "label": "Back in Black" 21 | } 22 | ], 23 | "edges": [] 24 | }, 25 | "version": "0.2.0" 26 | } 27 | -------------------------------------------------------------------------------- /resources/ogg-loop-4x.json: -------------------------------------------------------------------------------- 1 | { 2 | "graph": { 3 | "id": "8fd81747-ea13-47df-99c1-6efc49262b68", 4 | "loadingPolicy": "allContentPlaythrough", 5 | "nodes": [ 6 | { 7 | "id": "751da8fc-36c6-4986-8efa-f44447392db4", 8 | "kind": "com.nativeformat.plugin.file.file", 9 | "config": { 10 | "file": "https://upload.wikimedia.org/wikipedia/en/4/45/ACDC_-_Back_In_Black-sample.ogg", 11 | "when": 0, 12 | "duration": 25000000000, 13 | "offset": 0 14 | }, 15 | "params": {} 16 | }, 17 | { 18 | "id": "35ae64c7-0321-4d55-be3f-8f67a3929b54", 19 | "kind": "com.nativeformat.plugin.time.loop", 20 | "config": { 21 | "when": 1978000000, 22 | "duration": 5277000000, 23 | "loopCount": 4 24 | }, 25 | "params": {} 26 | } 27 | ], 28 | "edges": [ 29 | { 30 | "id": "0484c617-ed37-4db9-baa9-9500af7053da", 31 | "source": "751da8fc-36c6-4986-8efa-f44447392db4", 32 | "target": "35ae64c7-0321-4d55-be3f-8f67a3929b54" 33 | } 34 | ], 35 | "scripts": [] 36 | }, 37 | "version": "1.2.24" 38 | } 39 | -------------------------------------------------------------------------------- /resources/scripting.json: -------------------------------------------------------------------------------- 1 | { 2 | "graph": { 3 | "nodes": [ 4 | { 5 | "loading_policy": "none", 6 | "kind": "com.nativeformat.plugin.wave.sine", 7 | "id": "37e715c2-2e32-460d-ba16-8551ef57bafb", 8 | "config": { 9 | "frequency": 440.0, 10 | "when": 0.0, 11 | "duration": 5000000000.0 12 | }, 13 | "params": {} 14 | } 15 | ], 16 | "loading_policy": "none", 17 | "id": "611892c1-8811-49fe-be06-d7782bbb7bcd", 18 | "scripts": [{ 19 | "name": "test-script", 20 | "code": "print('Hello from a script');\nprint(NF)" 21 | }], 22 | "edges": [] 23 | }, 24 | "version": "0.5.0" 25 | } 26 | -------------------------------------------------------------------------------- /resources/smart-player-test-audio/2478c8c11b7a1eff5f401393a1a4bf5f.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/2478c8c11b7a1eff5f401393a1a4bf5f.flac -------------------------------------------------------------------------------- /resources/smart-player-test-audio/253b8e6458fbe5a46ed18d114e6e1f60.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/253b8e6458fbe5a46ed18d114e6e1f60.flac -------------------------------------------------------------------------------- /resources/smart-player-test-audio/2a83716e9bfabca2e22c10bdc8f9780a.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/2a83716e9bfabca2e22c10bdc8f9780a.flac -------------------------------------------------------------------------------- /resources/smart-player-test-audio/5d2d42c9e3baec1a5605ceb947c9a028.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/5d2d42c9e3baec1a5605ceb947c9a028.flac -------------------------------------------------------------------------------- /resources/smart-player-test-audio/7ca6385ed2e09e89691d10cb683748dd.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/7ca6385ed2e09e89691d10cb683748dd.flac -------------------------------------------------------------------------------- /resources/smart-player-test-audio/8a30808c97573e87f4bccbafbc71a2cc.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/8a30808c97573e87f4bccbafbc71a2cc.flac -------------------------------------------------------------------------------- /resources/smart-player-test-audio/90e05f78e8ff35739443d0c926bde602.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/90e05f78e8ff35739443d0c926bde602.flac -------------------------------------------------------------------------------- /resources/smart-player-test-audio/a95d4efdea46762fa5fc525e9ee181f0.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/a95d4efdea46762fa5fc525e9ee181f0.flac -------------------------------------------------------------------------------- /resources/smart-player-test-audio/b458ac690dc515a160b9c24481cd592e.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/b458ac690dc515a160b9c24481cd592e.flac -------------------------------------------------------------------------------- /resources/smart-player-test-audio/e8256968a885259b4516eef2e0b095b0.flac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nativeformat/NFSmartPlayer/0387d2fef1f7481b457acb04c7e3dc339806152c/resources/smart-player-test-audio/e8256968a885259b4516eef2e0b095b0.flac -------------------------------------------------------------------------------- /source/Authoriser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | namespace nativeformat { 30 | namespace smartplayer { 31 | 32 | class Authoriser { 33 | public: 34 | virtual bool requiresAuthorisation( 35 | const std::shared_ptr &request) = 0; 36 | virtual void authoriseRequest( 37 | std::function &request)> 38 | callback, 39 | const std::shared_ptr &request) = 0; 40 | virtual bool isAuthorised(const std::shared_ptr &request) = 0; 41 | virtual bool shouldRetryFailedAuthorisation( 42 | const std::shared_ptr &request) = 0; 43 | }; 44 | 45 | } // namespace smartplayer 46 | } // namespace nativeformat 47 | -------------------------------------------------------------------------------- /source/CallbackTypes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #include 22 | #include 23 | 24 | namespace nativeformat { 25 | 26 | Load::Load(const Load &l) : _loaded(l._loaded) { 27 | for (auto &info : l._info) { 28 | _info.push_back(info); 29 | } 30 | } 31 | 32 | void Load::operator=(const Load &l) { 33 | _loaded = l._loaded; 34 | for (auto &info : l._info) { 35 | _info.push_back(info); 36 | } 37 | } 38 | 39 | Load::Load(bool loaded, std::string domain, std::string msg) : _loaded(loaded) { 40 | // Forward domain and message string to LogInfo ctor 41 | _info.emplace_back(msg, logger::Severity::ERROR, domain); 42 | } 43 | 44 | Load::Load(bool loaded, ERROR_INFO info /* = ERROR_INFO() */) 45 | : _loaded(loaded), _info(std::move(info)) {} 46 | 47 | Load::Load(Load &&l) : _loaded(l._loaded), _info(std::move(l._info)) {} 48 | 49 | std::string errorMessageFromLoad(const Load &load) { 50 | std::stringstream ss; 51 | if (!load._loaded) { 52 | for (auto &info : load._info) { 53 | ss << info.toString(); 54 | } 55 | } 56 | return ss.str(); 57 | } 58 | 59 | } // namespace nativeformat 60 | -------------------------------------------------------------------------------- /source/Client.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #include 22 | #include 23 | 24 | #include "ClientImplementation.h" 25 | 26 | namespace nativeformat { 27 | namespace smartplayer { 28 | 29 | const std::string PlayerErrorDomain("com.nativeformat.smartplayer"); 30 | 31 | const char *PlayerMessageIdentifierEnd = "com.nativeformat.player.end"; 32 | const char *PlayerSenderIdentifier = "com.nativeformat.client"; 33 | const char *Version = SMARTPLAYER_VERSION; 34 | 35 | std::shared_ptr createClient( 36 | NF_SMART_PLAYER_RESOLVE_CALLBACK resolve_callback, 37 | NF_SMART_PLAYER_ERROR_CALLBACK error_callback, DriverType driver_type, 38 | std::string output_destination, int osc_read_port, int osc_write_port, 39 | const std::string osc_address, int localhost_write_port) { 40 | return std::make_shared( 41 | resolve_callback, error_callback, driver_type, output_destination, 42 | osc_read_port, osc_write_port, osc_address, localhost_write_port); 43 | } 44 | 45 | } // namespace smartplayer 46 | } // namespace nativeformat 47 | -------------------------------------------------------------------------------- /source/Edge.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #include 22 | #include 23 | 24 | #include "EdgeImplementation.h" 25 | 26 | namespace nativeformat { 27 | namespace smartplayer { 28 | 29 | std::shared_ptr createEdge(const nfgrapher::Edge &edge) { 30 | return std::make_shared(edge); 31 | } 32 | 33 | std::shared_ptr createEdge(const std::string &json) { 34 | nlohmann::json j = nlohmann::json::parse(json); 35 | nfgrapher::Edge e = j; 36 | return createEdge(e); 37 | } 38 | 39 | } // namespace smartplayer 40 | } // namespace nativeformat 41 | -------------------------------------------------------------------------------- /source/EdgeImplementation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #include "EdgeImplementation.h" 22 | 23 | #include 24 | 25 | namespace nativeformat { 26 | namespace smartplayer { 27 | 28 | EdgeImplementation::EdgeImplementation(const nfgrapher::Edge& e) 29 | : _id(e.id), _source(e.source), _target(e.target) {} 30 | 31 | EdgeImplementation::~EdgeImplementation() {} 32 | 33 | std::string EdgeImplementation::source() const { return _source; } 34 | 35 | std::string EdgeImplementation::target() const { return _target; } 36 | 37 | std::string EdgeImplementation::identifier() const { return _id; } 38 | 39 | std::string EdgeImplementation::json() const { 40 | nfgrapher::Edge e; 41 | e.id = _id; 42 | e.source = _source; 43 | e.target = _target; 44 | nlohmann::json j = e; 45 | return j.dump(); 46 | } 47 | 48 | } // namespace smartplayer 49 | } // namespace nativeformat 50 | -------------------------------------------------------------------------------- /source/EdgeImplementation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace nativeformat { 29 | namespace smartplayer { 30 | 31 | class EdgeImplementation : public Edge { 32 | public: 33 | EdgeImplementation(const nfgrapher::Edge& e); 34 | virtual ~EdgeImplementation(); 35 | 36 | // Edge 37 | std::string source() const override; 38 | std::string target() const override; 39 | std::string identifier() const override; 40 | std::string json() const override; 41 | 42 | private: 43 | const std::string _id; 44 | const std::string _source; 45 | const std::string _target; 46 | }; 47 | 48 | } // namespace smartplayer 49 | } // namespace nativeformat 50 | -------------------------------------------------------------------------------- /source/GlobalLogger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include "HTTPLogSink.h" 28 | 29 | // TODO don't run this more than once with the same sinks 30 | void nativeformat::configGlobalLogger(std::string token_type, 31 | std::string token) { 32 | auto &gl = getGlobalLogger(); 33 | 34 | auto stream_sink = std::make_shared( 35 | "String StdStreamSink"); 36 | gl.addSink(stream_sink, 37 | nativeformat::logger::LogInfoFormat::STRING); 38 | } 39 | 40 | nativeformat::NF_LOGGER_TYPE &nativeformat::getGlobalLogger() { 41 | static nativeformat::NF_LOGGER_TYPE global_logger; 42 | return global_logger; 43 | } 44 | -------------------------------------------------------------------------------- /source/Graph.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "GraphImplementation.h" 28 | 29 | namespace nativeformat { 30 | namespace smartplayer { 31 | 32 | const char *GraphMessageIdentifierEnd = "com.nativeformat.graph.end"; 33 | 34 | std::shared_ptr createGraph(const std::string &json, 35 | LOAD_CALLBACK load_callback, int channels, 36 | double samplerate) { 37 | const auto session_id = createGraphSessionId(); 38 | std::shared_ptr graph = 39 | std::make_shared(channels, samplerate, session_id); 40 | graph->setJson(json, load_callback); 41 | return graph; 42 | } 43 | 44 | std::string createGraphSessionId() { 45 | static boost::uuids::random_generator uuid_generator; 46 | static std::mutex uuid_generator_mutex; 47 | std::lock_guard uuid_generator_lock(uuid_generator_mutex); 48 | auto uuid = uuid_generator(); 49 | return boost::uuids::to_string(uuid); 50 | } 51 | 52 | } // namespace smartplayer 53 | } // namespace nativeformat 54 | -------------------------------------------------------------------------------- /source/GraphDelegate.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Spotify AB. 3 | * 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | #pragma once 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace nativeformat { 29 | namespace smartplayer { 30 | 31 | class GraphDelegate { 32 | public: 33 | virtual std::shared_ptr