mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 03:50:16 +02:00
added support for external hificodec and hifi codec plugin
This commit is contained in:
parent
7d608ba592
commit
f5b693cebb
6 changed files with 232 additions and 0 deletions
50
cmake/externals/hifiAudioCodec/CMakeLists.txt
vendored
Normal file
50
cmake/externals/hifiAudioCodec/CMakeLists.txt
vendored
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
include(ExternalProject)
|
||||||
|
include(SelectLibraryConfigurations)
|
||||||
|
|
||||||
|
set(EXTERNAL_NAME HiFiAudioCodec)
|
||||||
|
|
||||||
|
string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER)
|
||||||
|
|
||||||
|
ExternalProject_Add(
|
||||||
|
${EXTERNAL_NAME}
|
||||||
|
URL https://s3.amazonaws.com/hifi-public/dependencies/codecSDK.zip
|
||||||
|
URL_MD5 4add25b7cc5dfdb3cbfc1156b95cfff7
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
LOG_DOWNLOAD 1
|
||||||
|
)
|
||||||
|
|
||||||
|
# Hide this external target (for ide users)
|
||||||
|
set_target_properties(${EXTERNAL_NAME} PROPERTIES FOLDER "hidden/externals")
|
||||||
|
|
||||||
|
ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR)
|
||||||
|
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include CACHE TYPE INTERNAL)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/Release/audio.lib CACHE TYPE INTERNAL)
|
||||||
|
|
||||||
|
# FIXME need to account for different architectures
|
||||||
|
#if ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||||
|
# set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/lib/win64/audio.lib CACHE TYPE INTERNAL)
|
||||||
|
# add_paths_to_fixup_libs(${SOURCE_DIR}/bin/win64)
|
||||||
|
#else()
|
||||||
|
# set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/lib/win32/audio.lib CACHE TYPE INTERNAL)
|
||||||
|
# add_paths_to_fixup_libs(${SOURCE_DIR}/bin/win32)
|
||||||
|
#endif()
|
||||||
|
|
||||||
|
elseif(APPLE)
|
||||||
|
|
||||||
|
# FIXME need to account for different architectures
|
||||||
|
#set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/lib/osx32/audio.dylib CACHE TYPE INTERNAL)
|
||||||
|
#add_paths_to_fixup_libs(${SOURCE_DIR}/bin/osx32)
|
||||||
|
|
||||||
|
elseif(NOT ANDROID)
|
||||||
|
|
||||||
|
# FIXME need to account for different architectures
|
||||||
|
#set(${EXTERNAL_NAME_UPPER}_LIBRARIES ${SOURCE_DIR}/lib/linux64/audio.so CACHE TYPE INTERNAL)
|
||||||
|
#add_paths_to_fixup_libs(${SOURCE_DIR}/bin/linux64)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
21
plugins/hifiCodec/CMakeLists.txt
Normal file
21
plugins/hifiCodec/CMakeLists.txt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#
|
||||||
|
# Created by Brad Hefta-Gaub on 7/10/2016
|
||||||
|
# Copyright 2016 High Fidelity, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the Apache License, Version 2.0.
|
||||||
|
# See the accompanying file LICENSE or http:#www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
set(TARGET_NAME hifiCodec)
|
||||||
|
setup_hifi_client_server_plugin()
|
||||||
|
|
||||||
|
link_hifi_libraries(shared plugins)
|
||||||
|
|
||||||
|
add_dependency_external_projects(HiFiAudioCodec)
|
||||||
|
target_include_directories(${TARGET_NAME} PRIVATE ${HIFIAUDIOCODEC_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(${TARGET_NAME} ${HIFIAUDIOCODEC_LIBRARIES})
|
||||||
|
endif()
|
||||||
|
|
72
plugins/hifiCodec/src/HiFiCodec.cpp
Normal file
72
plugins/hifiCodec/src/HiFiCodec.cpp
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
//
|
||||||
|
// HiFiCodec.cpp
|
||||||
|
// plugins/hifiCodec/src
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub on 7/10/2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <qapplication.h>
|
||||||
|
|
||||||
|
#include <AudioCodec.h> // should be from the external...
|
||||||
|
|
||||||
|
#include <PerfStat.h>
|
||||||
|
|
||||||
|
#include "HiFiCodec.h"
|
||||||
|
|
||||||
|
const QString HiFiCodec::NAME = "hifiAC";
|
||||||
|
|
||||||
|
void HiFiCodec::init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void HiFiCodec::deinit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HiFiCodec::activate() {
|
||||||
|
CodecPlugin::activate();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HiFiCodec::deactivate() {
|
||||||
|
CodecPlugin::deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool HiFiCodec::isSupported() const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
class HiFiEncoder : public Encoder {
|
||||||
|
public:
|
||||||
|
virtual void encode(const QByteArray& decodedBuffer, QByteArray& encodedBuffer) override {
|
||||||
|
encodedBuffer = decodedBuffer;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class HiFiDecoder : public Decoder {
|
||||||
|
public:
|
||||||
|
virtual void decode(const QByteArray& encodedBuffer, QByteArray& decodedBuffer) override {
|
||||||
|
decodedBuffer = encodedBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void trackLostFrames(int numFrames) override { }
|
||||||
|
};
|
||||||
|
|
||||||
|
Encoder* HiFiCodec::createEncoder(int sampleRate, int numChannels) {
|
||||||
|
return new HiFiEncoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
Decoder* HiFiCodec::createDecoder(int sampleRate, int numChannels) {
|
||||||
|
return new HiFiDecoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HiFiCodec::releaseEncoder(Encoder* encoder) {
|
||||||
|
delete encoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
void HiFiCodec::releaseDecoder(Decoder* decoder) {
|
||||||
|
delete decoder;
|
||||||
|
}
|
42
plugins/hifiCodec/src/HiFiCodec.h
Normal file
42
plugins/hifiCodec/src/HiFiCodec.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
//
|
||||||
|
// HiFiCodec.h
|
||||||
|
// plugins/hifiCodec/src
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub on 7/10/2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_HiFiCodec_h
|
||||||
|
#define hifi_HiFiCodec_h
|
||||||
|
|
||||||
|
#include <plugins/CodecPlugin.h>
|
||||||
|
|
||||||
|
class HiFiCodec : public CodecPlugin {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Plugin functions
|
||||||
|
bool isSupported() const override;
|
||||||
|
const QString& getName() const override { return NAME; }
|
||||||
|
|
||||||
|
void init() override;
|
||||||
|
void deinit() override;
|
||||||
|
|
||||||
|
/// Called when a plugin is being activated for use. May be called multiple times.
|
||||||
|
bool activate() override;
|
||||||
|
/// Called when a plugin is no longer being used. May be called multiple times.
|
||||||
|
void deactivate() override;
|
||||||
|
|
||||||
|
virtual Encoder* createEncoder(int sampleRate, int numChannels) override;
|
||||||
|
virtual Decoder* createDecoder(int sampleRate, int numChannels) override;
|
||||||
|
virtual void releaseEncoder(Encoder* encoder) override;
|
||||||
|
virtual void releaseDecoder(Decoder* decoder) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const QString NAME;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_HiFiCodec_h
|
46
plugins/hifiCodec/src/HiFiCodecProvider.cpp
Normal file
46
plugins/hifiCodec/src/HiFiCodecProvider.cpp
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub on 7/10/2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QtPlugin>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
|
#include <plugins/RuntimePlugin.h>
|
||||||
|
#include <plugins/CodecPlugin.h>
|
||||||
|
|
||||||
|
#include "HiFiCodec.h"
|
||||||
|
|
||||||
|
class HiFiCodecProvider : public QObject, public CodecProvider {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID CodecProvider_iid FILE "plugin.json")
|
||||||
|
Q_INTERFACES(CodecProvider)
|
||||||
|
|
||||||
|
public:
|
||||||
|
HiFiCodecProvider(QObject* parent = nullptr) : QObject(parent) {}
|
||||||
|
virtual ~HiFiCodecProvider() {}
|
||||||
|
|
||||||
|
virtual CodecPluginList getCodecPlugins() override {
|
||||||
|
static std::once_flag once;
|
||||||
|
std::call_once(once, [&] {
|
||||||
|
|
||||||
|
CodecPluginPointer hiFiCodec(new HiFiCodec());
|
||||||
|
if (hiFiCodec->isSupported()) {
|
||||||
|
_codecPlugins.push_back(hiFiCodec);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
return _codecPlugins;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CodecPluginList _codecPlugins;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "HiFiCodecProvider.moc"
|
1
plugins/hifiCodec/src/plugin.json
Normal file
1
plugins/hifiCodec/src/plugin.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{"name":"HiFi 4:1 Audio Codec"}
|
Loading…
Reference in a new issue