-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial Port of phonon-vlc for libmpv. Audio and Video-Playback works (tested with juk and dragon).
- Loading branch information
0 parents
commit 6913621
Showing
32 changed files
with
5,254 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.svn | ||
Makefile | ||
CMakeTmp | ||
CMakeCache.txt | ||
CMakeFiles/ | ||
cmake_install.cmake | ||
cmake_uninstall.cmake | ||
lib/ | ||
*.o | ||
*.so | ||
*.user | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
The phonon-VLC authors are: | ||
--------------------------- | ||
|
||
Harald Sitter | ||
Casian Andrei | ||
Ben Cooksley | ||
Jean-Baptiste Kempf | ||
Mark Kretschmann | ||
Martin T. H. Sandsmark | ||
Patrick von Reth | ||
Andreas Hartmetz | ||
Rémi Duraffort | ||
Colin Guthrie | ||
Fathi Boudra | ||
Patrick Spendrin | ||
Rémi Denis-Courmont | ||
Arno Rehn | ||
Kamil Klimek | ||
Michael Forney | ||
Raphael Kubo da Costa | ||
Alex Neundorf | ||
Benoit Calvez | ||
Myriam Schweingruber | ||
Romain Perier | ||
Valentin Rusu | ||
Albert Astals Cid | ||
Alejandro Wainzinger | ||
Alexander Potashev | ||
Andrius da Costa Ribas | ||
Arnaud Le Roy | ||
Locke Shinseiko | ||
Pino Toscano | ||
Ralf Habacker | ||
Thiago Macieira |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
cmake_minimum_required(VERSION 2.8.9) | ||
project(PhononMPV) | ||
|
||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") | ||
set(PHONON_BUILD_PHONON4QT5 ON) | ||
|
||
# Phonon | ||
find_package(Phonon REQUIRED) | ||
macro_ensure_version("4.7.0" ${PHONON_VERSION} PHONON_FOUND) | ||
macro_log_feature(PHONON_FOUND "Phonon" "Core Library" "git://anongit.kde.org/phonon.git" TRUE "4.7.0") | ||
|
||
#LibMPV | ||
find_package(PkgConfig) | ||
pkg_check_modules(MPV REQUIRED mpv>=0.29.0) | ||
macro_log_feature(MPV_FOUND "LibMPV" "MPV C API Library" "http://github.com/mpv-player/mpv" TRUE "0.29.0") | ||
|
||
if(PHONON_FOUND_EXPERIMENTAL) | ||
add_definitions(-DPHONON_EXPERIMENTAL) | ||
else(PHONON_FOUND_EXPERIMENTAL) | ||
add_definitions(-DPHONON_NO_EXPERIMENTAL) | ||
endif(PHONON_FOUND_EXPERIMENTAL) | ||
|
||
add_definitions(${QT_DEFINITIONS}) | ||
|
||
include_directories(${PHONON_INCLUDES} ${QT_INCLUDES} ${MPV_INCLUDE_DIR}) | ||
|
||
set(PHONON_MPV_MAJOR_VERSION "0") | ||
set(PHONON_MPV_MINOR_VERSION "0") | ||
set(PHONON_MPV_PATCH_VERSION "2") | ||
set(PHONON_MPV_VERSION "${PHONON_MPV_MAJOR_VERSION}.${PHONON_MPV_MINOR_VERSION}.${PHONON_MPV_PATCH_VERSION}") | ||
add_definitions(-DPHONON_MPV_VERSION="${PHONON_MPV_VERSION}") | ||
|
||
add_subdirectory(src) | ||
|
||
macro_display_feature_log() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
1. Redistributions of source code must retain the copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. The name of the author may not be used to endorse or promote products | ||
derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Find Phonon | ||
|
||
# Copyright (c) 2010-2013, Harald Sitter <[email protected]> | ||
# Copyright (c) 2011, Alexander Neundorf <[email protected]> | ||
# | ||
# Redistribution and use is allowed according to the terms of the BSD license. | ||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
|
||
set(PKG UndefinedPhononPackage) | ||
if(PHONON_BUILD_PHONON4QT5) | ||
set(PKG Phonon4Qt5) | ||
else() | ||
set(PKG Phonon) | ||
endif() | ||
|
||
find_package(${PKG} NO_MODULE) | ||
|
||
if(PHONON_BUILDSYSTEM_DIR) | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PHONON_BUILDSYSTEM_DIR}) | ||
# Prevent double-include of internals, and make sure they are included | ||
# In Phonon <4.7 the internals were auto-included, in >=4.7 they are not. | ||
if(NOT COMMAND phonon_add_executable) | ||
include(${PHONON_BUILDSYSTEM_DIR}/FindPhononInternal.cmake ) | ||
endif() | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
find_package_handle_standard_args(${PKG} DEFAULT_MSG ${PKG}_DIR ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.svn | ||
Makefile | ||
moc_* | ||
phonon_mpv_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
add_definitions(-DPHONON_LIB_INSTALL_DIR="${LIB_INSTALL_DIR}") | ||
|
||
if(${PHONON_VERSION} VERSION_GREATER "4.9.50") | ||
message(STATUS "Building against Phonon 4.10 API") | ||
set(BACKEND_VERSION_DEFINE -DPHONON_BACKEND_VERSION_4_10) | ||
elseif(${PHONON_VERSION} VERSION_GREATER "4.8.50") | ||
message(STATUS "Building against Phonon 4.9 API") | ||
set(BACKEND_VERSION_DEFINE -DPHONON_BACKEND_VERSION_4_9) | ||
elseif(${PHONON_VERSION} VERSION_GREATER "4.6.50") | ||
message(STATUS "Building against Phonon 4.7 API") | ||
set(BACKEND_VERSION_DEFINE -DPHONON_BACKEND_VERSION_4_7) | ||
elseif(${PHONON_VERSION} VERSION_GREATER "4.1.99") | ||
message(STATUS "Building against Phonon 4.2 API") | ||
set(BACKEND_VERSION_DEFINE -DPHONON_BACKEND_VERSION_4_2) | ||
else() | ||
message(STATUS "Building against Phonon 4.0 API") | ||
set(BACKEND_VERSION_DEFINE) | ||
endif() | ||
|
||
add_definitions(${BACKEND_VERSION_DEFINE}) | ||
set(AUTOMOC_MOC_OPTIONS ${BACKEND_VERSION_DEFINE}) | ||
|
||
set(phonon_mpv_SRCS | ||
audio/audiooutput.cpp | ||
audio/audiodataoutput.cpp | ||
audio/volumefadereffect.cpp | ||
backend.cpp | ||
effect.cpp | ||
effectmanager.cpp | ||
mediacontroller.cpp | ||
mediaobject.cpp | ||
sinknode.cpp | ||
video/videowidget.cpp | ||
utils/debug.cpp | ||
) | ||
|
||
add_definitions(-DPHONON_NO_GRAPHICSVIEW) | ||
|
||
automoc4_add_library(phonon_mpv MODULE ${phonon_mpv_SRCS}) | ||
qt5_use_modules(phonon_mpv Core Gui Widgets) | ||
|
||
set_target_properties(phonon_mpv PROPERTIES | ||
PREFIX "" | ||
AUTOMOC_MOC_OPTIONS ${AUTOMOC_MOC_OPTIONS} | ||
) | ||
target_link_libraries(phonon_mpv | ||
${PHONON_LIBRARY} | ||
${MPV_LIBRARIES} | ||
) | ||
|
||
install(TARGETS phonon_mpv DESTINATION ${BACKEND_INSTALL_DIR}) | ||
|
||
if(PHONON_BUILD_PHONON4QT5) | ||
# Instead of desktop files we are embedding the information into the plugin itself. | ||
# We have no KDE technology to help with finding the actual libraries anyway, so | ||
# we need to have the library path anyway. | ||
# Also see qtplugin/Q_PLUGIN_METADATA documentation. | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/phonon-mpv.json.in | ||
${CMAKE_CURRENT_BINARY_DIR}/phonon-mpv.json @ONLY) | ||
else() | ||
message(FATAL_ERROR "Only Qt5 is supported") | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
Copyright (C) 2006 Matthias Kretz <[email protected]> | ||
Copyright (C) 2009 Martin Sandsmark <[email protected]> | ||
Copyright (C) 2010 Ben Cooksley <[email protected]> | ||
Copyright (C) 2011 Harald Sitter <[email protected]> | ||
This library is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) version 3, or any | ||
later version accepted by the membership of KDE e.V. (or its | ||
successor approved by the membership of KDE e.V.), Nokia Corporation | ||
(or its successors, if any) and the KDE Free Qt Foundation, which shall | ||
act as a proxy defined in Section 6 of version 3 of the license. | ||
This library is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "audiodataoutput.h" | ||
|
||
using namespace Phonon::MPV; | ||
|
||
AudioDataOutput::AudioDataOutput(QObject* parent): QObject(parent) { | ||
m_sampleRate = 44100; | ||
connect(this, SIGNAL(sampleReadDone()), this, SLOT(sendData())); | ||
|
||
// Register channels | ||
m_channels.append(Phonon::AudioDataOutput::LeftChannel); | ||
m_channels.append(Phonon::AudioDataOutput::RightChannel); | ||
m_channels.append(Phonon::AudioDataOutput::CenterChannel); | ||
m_channels.append(Phonon::AudioDataOutput::LeftSurroundChannel); | ||
m_channels.append(Phonon::AudioDataOutput::RightSurroundChannel); | ||
m_channels.append(Phonon::AudioDataOutput::SubwooferChannel); | ||
} | ||
|
||
AudioDataOutput::~AudioDataOutput() { | ||
} | ||
|
||
int AudioDataOutput::dataSize() const { | ||
return m_dataSize; | ||
} | ||
|
||
int AudioDataOutput::sampleRate() const { | ||
return m_sampleRate; | ||
} | ||
|
||
void AudioDataOutput::setDataSize(int size) { | ||
m_dataSize = size; | ||
} | ||
|
||
void AudioDataOutput::lock(AudioDataOutput* cw, quint8** pcm_buffer , quint32 size) { | ||
cw->m_locker.lock(); | ||
*pcm_buffer = new quint8[size]; | ||
} | ||
|
||
void AudioDataOutput::unlock(AudioDataOutput* cw, quint8* pcm_buffer, | ||
quint32 channelCount, quint32 rate, | ||
quint32 sampleCount, quint32 bits_per_sample, | ||
quint32 size, qint64 pts) { | ||
Q_UNUSED(size); | ||
Q_UNUSED(pts); | ||
|
||
// (bytesPerChannelPerSample * channels * read_samples) + (bytesPerChannelPerSample * read_channels) | ||
auto bytesPerChannelPerSample{bits_per_sample / 8}; | ||
cw->m_sampleRate = rate; | ||
cw->m_channelCount = channelCount; | ||
|
||
for(quint32 readSamples = 0; readSamples < sampleCount; ++readSamples) { | ||
// Prepare a sample buffer, and initialise it | ||
quint16 sampleBuffer[6]; | ||
for(auto initialised{0}; initialised < 6; ++initialised) | ||
sampleBuffer[initialised] = 0; | ||
|
||
auto bufferPosition{bytesPerChannelPerSample * channelCount * readSamples}; | ||
|
||
for(quint32 readChannels = 0; readChannels < channelCount; ++readChannels) { | ||
quint32 complet{0}; | ||
for(auto readBytes{0u}; readBytes < bytesPerChannelPerSample; ++readBytes) { | ||
// Read from the pcm_buffer into the per channel internal buffer | ||
|
||
quint32 complet_temp{0}; | ||
complet_temp = pcm_buffer[bufferPosition]; | ||
complet_temp <<= (8 * readBytes); | ||
|
||
complet += complet_temp; | ||
++bufferPosition; | ||
} | ||
|
||
sampleBuffer[readChannels] = complet; | ||
} | ||
|
||
if(channelCount == 1) | ||
cw->m_channelSamples[1].append(qint16(sampleBuffer[0])); | ||
|
||
for(quint32 readChannels{0}; readChannels < channelCount; ++readChannels) | ||
cw->m_channelSamples[readChannels].append(qint16(sampleBuffer[readChannels])); | ||
// Finished reading one sample | ||
} | ||
|
||
delete pcm_buffer; | ||
|
||
cw->m_locker.unlock(); | ||
emit cw->sampleReadDone(); | ||
} | ||
|
||
void AudioDataOutput::sendData() { | ||
m_locker.lock(); | ||
|
||
auto chan_count{m_channelCount}; | ||
if(m_channelCount == 1) | ||
chan_count = 2; | ||
|
||
while(m_channelSamples[0].count() > m_dataSize) { | ||
QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > m_data; | ||
for(auto position{0}; position < chan_count; position++) { | ||
Phonon::AudioDataOutput::Channel chan = m_channels.value(position); | ||
QVector<qint16> data{m_channelSamples[position].mid(0, m_dataSize)}; | ||
m_channelSamples[position].remove(0, data.count()); | ||
m_data.insert(chan, data); | ||
} | ||
emit dataReady(m_data); | ||
} | ||
m_locker.unlock(); | ||
} | ||
|
||
#include "moc_audiodataoutput.cpp" |
Oops, something went wrong.