Permalink
Browse files

Initial commit to the repository

  • Loading branch information...
0 parents commit 2340bcd3ce772d058bbeddcadd7a8301f7b18747 @juhovh committed Mar 9, 2012
Showing with 16,168 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. BIN AirTV-Qt/AirTV.icns
  3. BIN AirTV-Qt/AirTV.ico
  4. +104 −0 AirTV-Qt/AirTV.pro
  5. +5 −0 AirTV-Qt/AirTV.qrc
  6. +1 −0 AirTV-Qt/AirTV.rc
  7. +184 −0 AirTV-Qt/audiooutput.cpp
  8. +51 −0 AirTV-Qt/audiooutput.h
  9. +98 −0 AirTV-Qt/images/airtv.svg
  10. +30 −0 AirTV-Qt/main.cpp
  11. +46 −0 AirTV-Qt/mainapplication.cpp
  12. +36 −0 AirTV-Qt/mainapplication.h
  13. +24 −0 AirTV-Qt/mainwindow.ui
  14. +254 −0 AirTV-Qt/qtsingleapplication/INSTALL.TXT
  15. +33 −0 AirTV-Qt/qtsingleapplication/README.TXT
  16. +13 −0 AirTV-Qt/qtsingleapplication/buildlib/buildlib.pro
  17. +6 −0 AirTV-Qt/qtsingleapplication/common.pri
  18. +25 −0 AirTV-Qt/qtsingleapplication/configure
  19. +39 −0 AirTV-Qt/qtsingleapplication/configure.bat
  20. +284 −0 AirTV-Qt/qtsingleapplication/doc/html/classic.css
  21. BIN AirTV-Qt/qtsingleapplication/doc/html/images/qt-logo.png
  22. +48 −0 AirTV-Qt/qtsingleapplication/doc/html/index.html
  23. +177 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsingleapplication-example-loader.html
  24. +103 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsingleapplication-example-trivial.html
  25. +235 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsingleapplication-members.html
  26. +31 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsingleapplication-obsolete.html
  27. +40 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsingleapplication.dcf
  28. +162 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsingleapplication.html
  29. +90 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsingleapplication.index
  30. +53 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsingleapplication.qhp
  31. +120 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsinglecoreapplication-example-console.html
  32. +126 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsinglecoreapplication-members.html
  33. +98 −0 AirTV-Qt/qtsingleapplication/doc/html/qtsinglecoreapplication.html
  34. BIN AirTV-Qt/qtsingleapplication/doc/images/qt-logo.png
  35. +47 −0 AirTV-Qt/qtsingleapplication/doc/index.qdoc
  36. +5 −0 AirTV-Qt/qtsingleapplication/examples/console/console.pro
  37. +64 −0 AirTV-Qt/qtsingleapplication/examples/console/console.qdoc
  38. +88 −0 AirTV-Qt/qtsingleapplication/examples/console/main.cpp
  39. +4 −0 AirTV-Qt/qtsingleapplication/examples/examples.pro
  40. +1 −0 AirTV-Qt/qtsingleapplication/examples/loader/file1.qsl
  41. +1 −0 AirTV-Qt/qtsingleapplication/examples/loader/file2.qsl
  42. +5 −0 AirTV-Qt/qtsingleapplication/examples/loader/loader.pro
  43. +80 −0 AirTV-Qt/qtsingleapplication/examples/loader/loader.qdoc
  44. +151 −0 AirTV-Qt/qtsingleapplication/examples/loader/main.cpp
  45. +77 −0 AirTV-Qt/qtsingleapplication/examples/trivial/main.cpp
  46. +5 −0 AirTV-Qt/qtsingleapplication/examples/trivial/trivial.pro
  47. +75 −0 AirTV-Qt/qtsingleapplication/examples/trivial/trivial.qdoc
  48. +5 −0 AirTV-Qt/qtsingleapplication/qtsingleapplication.pro
  49. +1 −0 AirTV-Qt/qtsingleapplication/src/QtLockedFile
  50. +1 −0 AirTV-Qt/qtsingleapplication/src/QtSingleApplication
  51. +199 −0 AirTV-Qt/qtsingleapplication/src/qtlocalpeer.cpp
  52. +76 −0 AirTV-Qt/qtsingleapplication/src/qtlocalpeer.h
  53. +192 −0 AirTV-Qt/qtsingleapplication/src/qtlockedfile.cpp
  54. +96 −0 AirTV-Qt/qtsingleapplication/src/qtlockedfile.h
  55. +114 −0 AirTV-Qt/qtsingleapplication/src/qtlockedfile_unix.cpp
  56. +206 −0 AirTV-Qt/qtsingleapplication/src/qtlockedfile_win.cpp
  57. +344 −0 AirTV-Qt/qtsingleapplication/src/qtsingleapplication.cpp
  58. +102 −0 AirTV-Qt/qtsingleapplication/src/qtsingleapplication.h
  59. +16 −0 AirTV-Qt/qtsingleapplication/src/qtsingleapplication.pri
  60. +148 −0 AirTV-Qt/qtsingleapplication/src/qtsinglecoreapplication.cpp
  61. +70 −0 AirTV-Qt/qtsingleapplication/src/qtsinglecoreapplication.h
  62. +10 −0 AirTV-Qt/qtsingleapplication/src/qtsinglecoreapplication.pri
  63. +45 −0 AirTV-Qt/raopcallbackhandler.cpp
  64. +27 −0 AirTV-Qt/raopcallbackhandler.h
  65. +145 −0 AirTV-Qt/raopservice.cpp
  66. +36 −0 AirTV-Qt/raopservice.h
  67. +12 −0 Makefile
  68. +1 −0 README
  69. +23 −0 airport.key
  70. +27 −0 include/dnssd.h
  71. +30 −0 include/raop.h
  72. +1,172 −0 src/alac/alac.c
  73. +13 −0 src/alac/alac.h
  74. +14 −0 src/alac/stdint_win.h
  75. +268 −0 src/base64.c
  76. +15 −0 src/base64.h
  77. +24 −0 src/compat.h
  78. +457 −0 src/crypto/aes.c
  79. +1,512 −0 src/crypto/bigint.c
  80. +99 −0 src/crypto/bigint.h
  81. +131 −0 src/crypto/bigint_impl.h
  82. +6 −0 src/crypto/config.h
  83. +146 −0 src/crypto/crypto.h
  84. +105 −0 src/crypto/hmac.c
  85. +294 −0 src/crypto/md5.c
  86. +160 −0 src/crypto/os_port.h
  87. +92 −0 src/crypto/rc4.c
  88. +249 −0 src/crypto/sha1.c
  89. +285 −0 src/dnssd.c
  90. +164 −0 src/dnssd.m
  91. +19 −0 src/dnssdint.h
  92. +10 −0 src/global.h
  93. +1,820 −0 src/http_parser.c
  94. +290 −0 src/http_parser.h
  95. +238 −0 src/http_request.c
  96. +22 −0 src/http_request.h
  97. +133 −0 src/http_response.c
  98. +15 −0 src/http_response.h
  99. +339 −0 src/httpd.c
  100. +27 −0 src/httpd.h
  101. +90 −0 src/logger.c
  102. +28 −0 src/logger.h
  103. +39 −0 src/memalign.h
  104. +139 −0 src/netutils.c
  105. +10 −0 src/netutils.h
  106. +340 −0 src/raop.c
  107. +380 −0 src/raop_buffer.c
  108. +35 −0 src/raop_buffer.h
  109. +521 −0 src/raop_rtp.c
  110. +23 −0 src/raop_rtp.h
  111. +371 −0 src/rsakey.c
  112. +25 −0 src/rsakey.h
  113. +148 −0 src/rsapem.c
  114. +10 −0 src/rsapem.h
  115. +228 −0 src/sdp.c
  116. +22 −0 src/sdp.h
  117. +35 −0 src/sockets.h
  118. +46 −0 src/threads.h
  119. +130 −0 src/utils.c
  120. +9 −0 src/utils.h
  121. +48 −0 test/dnssd_test.c
  122. +32 −0 test/dnssd_test.m
  123. +213 −0 test/main.c
  124. +75 −0 test/shairport.c
@@ -0,0 +1,7 @@
+*-build-*
+*.user
+*.o
+*.DS_Store
+*.swp
+project.xcworkspace
+xcuserdata
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,104 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2011-12-04T00:47:51
+#
+#-------------------------------------------------
+
+QT += core gui multimedia phonon svg
+
+include(qtsingleapplication/src/qtsingleapplication.pri)
+
+TARGET = AirTV
+TEMPLATE = app
+ICON = AirTV.icns
+RC_FILE = AirTV.rc
+
+win32 {
+ LIBS += C:\\QtSDK\\mingw\\lib\\libws2_32.a
+ QMAKE_LFLAGS += -static-libgcc
+}
+unix:!macx {
+ LIBS += -ldns_sd
+}
+macx {
+ QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.5
+}
+
+INCLUDEPATH += ../include/
+SOURCES += main.cpp\
+ ../src/utils.c \
+ ../src/sdp.c \
+ ../src/rsapem.c \
+ ../src/rsakey.c \
+ ../src/raop.c \
+ ../src/raop_rtp.c \
+ ../src/raop_buffer.c \
+ ../src/netutils.c \
+ ../src/httpd.c \
+ ../src/http_response.c \
+ ../src/http_request.c \
+ ../src/http_parser.c \
+ ../src/dnssd.c \
+ ../src/base64.c \
+ ../src/alac/alac.c \
+ ../src/crypto/sha1.c \
+ ../src/crypto/rc4.c \
+ ../src/crypto/md5.c \
+ ../src/crypto/hmac.c \
+ ../src/crypto/bigint.c \
+ ../src/crypto/aes.c \
+ audiooutput.cpp \
+ raopservice.cpp \
+ mainapplication.cpp \
+ raopcallbackhandler.cpp \
+ ../src/logger.c
+
+HEADERS += \
+ audiooutput.h \
+ raopservice.h \
+ mainapplication.h \
+ raopcallbackhandler.h
+
+FORMS += mainwindow.ui
+
+RESOURCES += \
+ AirTV.qrc
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/icons">
+ <file alias="airtv.svg">images/airtv.svg</file>
+ </qresource>
+</RCC>
@@ -0,0 +1 @@
+IDI_ICON1 ICON DISCARDABLE "AirTV.ico"
@@ -0,0 +1,184 @@
+#include "audiooutput.h"
+
+#include <QDebug>
+#include <QtEndian>
+#include <math.h>
+
+#define BUFFER_SIZE (64*1024)
+
+AudioOutput::AudioOutput(QObject *parent) :
+ QIODevice(parent),
+ m_initialized(false),
+ m_output(0),
+ m_volume(0.0f)
+{
+}
+
+bool AudioOutput::init(int bits, int channels, int samplerate)
+{
+ if (m_initialized) {
+ return false;
+ }
+ if (bits != 16) {
+ return false;
+ }
+
+ m_format.setSampleSize(bits);
+ m_format.setChannels(channels);
+ m_format.setFrequency(samplerate);
+ m_format.setCodec("audio/pcm");
+ m_format.setByteOrder(QAudioFormat::LittleEndian);
+ m_format.setSampleType(QAudioFormat::SignedInt);
+
+ m_initialized = setDevice(QAudioDeviceInfo::defaultOutputDevice());
+ return m_initialized;
+}
+
+bool AudioOutput::setDevice(QAudioDeviceInfo deviceInfo)
+{
+ if (!deviceInfo.isFormatSupported(m_format)) {
+ qDebug() << "Format not supported!";
+ return false;
+ }
+ m_deviceInfo = deviceInfo;
+ this->reinit();
+ return true;
+}
+
+void AudioOutput::reinit()
+{
+ bool running = false;
+ if (m_output && m_output->state() != QAudio::StoppedState) {
+ running = true;
+ }
+ this->stop();
+
+ // Reinitialize audio output
+ delete m_output;
+ m_output = 0;
+ m_output = new QAudioOutput(m_deviceInfo, m_format, this);
+
+ // Set constant values to new audio output
+ connect(m_output, SIGNAL(notify()), SLOT(notified()));
+ connect(m_output, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State)));
+ if (running) {
+ this->start();
+ }
+}
+
+void AudioOutput::start()
+{
+ if (m_output == 0 || m_output->state() != QAudio::StoppedState) {
+ return;
+ }
+ this->open(QIODevice::ReadOnly);
+ m_buffer.clear();
+ m_output->start(this);
+ m_output->suspend();
+}
+
+void AudioOutput::setVolume(float volume)
+{
+ m_volume = volume;
+}
+
+void AudioOutput::output(const char *data, int datalen)
+{
+ if (m_output && m_output->state() != QAudio::StoppedState) {
+ // Append input data to the end of buffer
+ m_buffer.append(data, datalen);
+
+ // Check if our buffer has grown too large
+ if (m_buffer.length() > 2*BUFFER_SIZE) {
+ // There could be a better way to handle this
+ this->flush();
+ }
+
+ // If audio is suspended and buffer is full, resume
+ if (m_output->state() == QAudio::SuspendedState) {
+ if (m_buffer.length() >= BUFFER_SIZE) {
+ qDebug() << "Resuming...";
+ m_output->resume();
+ }
+ }
+ }
+}
+
+void AudioOutput::flush()
+{
+ // Flushing buffers is a bit tricky...
+ // Don't modify this unless you're sure
+ this->stop();
+ m_output->reset();
+ this->start();
+}
+
+void AudioOutput::stop()
+{
+ if (m_output && m_output->state() != QAudio::StoppedState) {
+ // Stop audio output
+ m_output->stop();
+ m_buffer.clear();
+ this->close();
+ }
+}
+
+static void apply_s16le_volume(float volume, uchar *data, int datalen)
+{
+ int samples = datalen/2;
+ float mult = pow(10.0,0.05*volume);
+
+ for (int i=0; i<samples; i++) {
+ qint16 val = qFromLittleEndian<qint16>(data+i*2)*mult;
+ qToLittleEndian<qint16>(val, data+i*2);
+ }
+}
+
+qint64 AudioOutput::readData(char *data, qint64 maxlen)
+{
+ // Calculate output length, always full samples
+ int outlen = qMin(m_buffer.length(), (int)maxlen);
+ if (outlen%2 != 0) {
+ outlen += 1;
+ }
+
+ memcpy(data, m_buffer.data(), outlen);
+ apply_s16le_volume(m_volume, (uchar *)data, outlen);
+ m_buffer.remove(0, outlen);
+ return outlen;
+}
+
+qint64 AudioOutput::writeData(const char *data, qint64 len)
+{
+ Q_UNUSED(data);
+ Q_UNUSED(len);
+
+ return 0;
+}
+
+qint64 AudioOutput::bytesAvailable() const
+{
+ return m_buffer.length() + QIODevice::bytesAvailable();
+}
+
+bool AudioOutput::isSequential() const
+{
+ return true;
+}
+
+void AudioOutput::notified()
+{
+}
+
+void AudioOutput::stateChanged(QAudio::State state)
+{
+ // Start buffering again in case of underrun...
+ // Required on Windows, otherwise it stalls idle
+ if (state == QAudio::IdleState && m_output->error() == QAudio::UnderrunError) {
+ // This check is required, because Mac OS X underruns often
+ if (m_buffer.length() < BUFFER_SIZE) {
+ m_output->suspend();
+ }
+ }
+ qWarning() << "state = " << state;
+}
@@ -0,0 +1,51 @@
+#ifndef AUDIOOUTPUT_H
+#define AUDIOOUTPUT_H
+
+#include <QObject>
+#include <QIODevice>
+#include <QByteArray>
+#include <QAudioFormat>
+#include <QAudioDeviceInfo>
+#include <QAudioOutput>
+#include <QIODevice>
+
+class AudioOutput : public QIODevice
+{
+ Q_OBJECT
+public:
+ explicit AudioOutput(QObject *parent = 0);
+ bool init(int bits, int channels, int samplerate);
+ bool setDevice(QAudioDeviceInfo deviceInfo);
+
+ void start();
+ void setVolume(float volume);
+ void output(const char *data, int datalen);
+ void flush();
+ void stop();
+
+ qint64 readData(char *data, qint64 maxlen);
+ qint64 writeData(const char *data, qint64 len);
+ qint64 bytesAvailable() const;
+ bool isSequential() const;
+
+private:
+ void reinit();
+
+private:
+ bool m_initialized;
+ QByteArray m_buffer;
+ QAudioFormat m_format;
+ QAudioDeviceInfo m_deviceInfo;
+ QAudioOutput* m_output;
+ float m_volume;
+
+signals:
+
+public slots:
+
+private slots:
+ void notified();
+ void stateChanged(QAudio::State state);
+};
+
+#endif // AUDIOOUTPUT_H
Oops, something went wrong.

0 comments on commit 2340bcd

Please sign in to comment.