├── .gitignore
├── LICENSE
├── README.md
├── android
├── AndroidManifest.xml
├── build.gradle
└── res
│ ├── drawable-hdpi
│ └── icon.png
│ ├── drawable-ldpi
│ └── icon.png
│ ├── drawable-mdpi
│ └── icon.png
│ ├── drawable
│ ├── icon.png
│ ├── icon2.png
│ └── splash.xml
│ └── values
│ ├── apptheme.xml
│ └── libs.xml
├── czys.pro
├── czys.qm
├── czys.ts
├── deployment.pri
├── fonts
├── demo.css
├── demo.html
├── iconfont.css
├── iconfont.eot
├── iconfont.svg
├── iconfont.ttf
└── iconfont.woff
├── kxmob
├── KxBluetooth.cpp
├── KxBluetooth.h
├── KxDesktopServices.cpp
├── KxDesktopServices.h
├── KxFileDialog.qml
├── KxFilePage.qml
├── KxFileSearch.cpp
├── KxFileSearch.h
├── KxMenu.qml
├── KxMessageBox.qml
├── KxQuickView.cpp
├── KxQuickView.h
├── KxTagParser.cpp
├── KxTagParser.h
├── KxUtils.cpp
└── KxUtils.h
├── listmgr
├── AboutPlayer.qml
├── FolderList.qml
├── ListManager.qml
├── MusicBar.qml
├── PlayCenter.qml
├── PopHistory.qml
├── PopSongList.qml
├── SongList.qml
├── SongSearch.qml
└── Theme.qml
├── main.cpp
├── main.qml
├── qml.qrc
└── taglib
├── CMakeLists.txt
├── ape
├── ape-tag-format.txt
├── apefile.cpp
├── apefile.h
├── apefooter.cpp
├── apefooter.h
├── apeitem.cpp
├── apeitem.h
├── apeproperties.cpp
├── apeproperties.h
├── apetag.cpp
└── apetag.h
├── asf
├── asfattribute.cpp
├── asfattribute.h
├── asffile.cpp
├── asffile.h
├── asfpicture.cpp
├── asfpicture.h
├── asfproperties.cpp
├── asfproperties.h
├── asftag.cpp
└── asftag.h
├── audioproperties.cpp
├── audioproperties.h
├── config.h
├── fileref.cpp
├── fileref.h
├── flac
├── flacfile.cpp
├── flacfile.h
├── flacmetadatablock.cpp
├── flacmetadatablock.h
├── flacpicture.cpp
├── flacpicture.h
├── flacproperties.cpp
├── flacproperties.h
├── flacunknownmetadatablock.cpp
└── flacunknownmetadatablock.h
├── it
├── itfile.cpp
├── itfile.h
├── itproperties.cpp
└── itproperties.h
├── mod
├── modfile.cpp
├── modfile.h
├── modfilebase.cpp
├── modfilebase.h
├── modfileprivate.h
├── modproperties.cpp
├── modproperties.h
├── modtag.cpp
└── modtag.h
├── mp4
├── mp4atom.cpp
├── mp4atom.h
├── mp4coverart.cpp
├── mp4coverart.h
├── mp4file.cpp
├── mp4file.h
├── mp4item.cpp
├── mp4item.h
├── mp4properties.cpp
├── mp4properties.h
├── mp4tag.cpp
└── mp4tag.h
├── mpc
├── mpcfile.cpp
├── mpcfile.h
├── mpcproperties.cpp
└── mpcproperties.h
├── mpeg
├── id3v1
│ ├── id3v1genres.cpp
│ ├── id3v1genres.h
│ ├── id3v1tag.cpp
│ └── id3v1tag.h
├── id3v2
│ ├── frames
│ │ ├── attachedpictureframe.cpp
│ │ ├── attachedpictureframe.h
│ │ ├── commentsframe.cpp
│ │ ├── commentsframe.h
│ │ ├── generalencapsulatedobjectframe.cpp
│ │ ├── generalencapsulatedobjectframe.h
│ │ ├── ownershipframe.cpp
│ │ ├── ownershipframe.h
│ │ ├── popularimeterframe.cpp
│ │ ├── popularimeterframe.h
│ │ ├── privateframe.cpp
│ │ ├── privateframe.h
│ │ ├── relativevolumeframe.cpp
│ │ ├── relativevolumeframe.h
│ │ ├── textidentificationframe.cpp
│ │ ├── textidentificationframe.h
│ │ ├── uniquefileidentifierframe.cpp
│ │ ├── uniquefileidentifierframe.h
│ │ ├── unknownframe.cpp
│ │ ├── unknownframe.h
│ │ ├── unsynchronizedlyricsframe.cpp
│ │ ├── unsynchronizedlyricsframe.h
│ │ ├── urllinkframe.cpp
│ │ └── urllinkframe.h
│ ├── id3v2.2.0.txt
│ ├── id3v2.3.0.txt
│ ├── id3v2.4.0-frames.txt
│ ├── id3v2.4.0-structure.txt
│ ├── id3v2extendedheader.cpp
│ ├── id3v2extendedheader.h
│ ├── id3v2footer.cpp
│ ├── id3v2footer.h
│ ├── id3v2frame.cpp
│ ├── id3v2frame.h
│ ├── id3v2framefactory.cpp
│ ├── id3v2framefactory.h
│ ├── id3v2header.cpp
│ ├── id3v2header.h
│ ├── id3v2synchdata.cpp
│ ├── id3v2synchdata.h
│ ├── id3v2tag.cpp
│ └── id3v2tag.h
├── mpegfile.cpp
├── mpegfile.h
├── mpegheader.cpp
├── mpegheader.h
├── mpegproperties.cpp
├── mpegproperties.h
├── xingheader.cpp
└── xingheader.h
├── ogg
├── flac
│ ├── oggflacfile.cpp
│ └── oggflacfile.h
├── oggfile.cpp
├── oggfile.h
├── oggpage.cpp
├── oggpage.h
├── oggpageheader.cpp
├── oggpageheader.h
├── opus
│ ├── opusfile.cpp
│ ├── opusfile.h
│ ├── opusproperties.cpp
│ └── opusproperties.h
├── speex
│ ├── speexfile.cpp
│ ├── speexfile.h
│ ├── speexproperties.cpp
│ └── speexproperties.h
├── vorbis
│ ├── vorbisfile.cpp
│ ├── vorbisfile.h
│ ├── vorbisproperties.cpp
│ └── vorbisproperties.h
├── xiphcomment.cpp
└── xiphcomment.h
├── riff
├── aiff
│ ├── aifffile.cpp
│ ├── aifffile.h
│ ├── aiffproperties.cpp
│ └── aiffproperties.h
├── rifffile.cpp
├── rifffile.h
└── wav
│ ├── infotag.cpp
│ ├── infotag.h
│ ├── wavfile.cpp
│ ├── wavfile.h
│ ├── wavproperties.cpp
│ └── wavproperties.h
├── s3m
├── s3mfile.cpp
├── s3mfile.h
├── s3mproperties.cpp
└── s3mproperties.h
├── tag.cpp
├── tag.h
├── taglib_config.h
├── taglib_config.h.cmake
├── taglib_export.h
├── tagunion.cpp
├── tagunion.h
├── toolkit
├── taglib.h
├── tbytevector.cpp
├── tbytevector.h
├── tbytevectorlist.cpp
├── tbytevectorlist.h
├── tbytevectorstream.cpp
├── tbytevectorstream.h
├── tdebug.cpp
├── tdebug.h
├── tdebuglistener.cpp
├── tdebuglistener.h
├── tfile.cpp
├── tfile.h
├── tfilestream.cpp
├── tfilestream.h
├── tiostream.cpp
├── tiostream.h
├── tlist.h
├── tlist.tcc
├── tmap.h
├── tmap.tcc
├── tpropertymap.cpp
├── tpropertymap.h
├── trefcounter.cpp
├── trefcounter.h
├── tstring.cpp
├── tstring.h
├── tstringlist.cpp
├── tstringlist.h
├── tutils.h
├── unicode.cpp
└── unicode.h
├── trueaudio
├── trueaudiofile.cpp
├── trueaudiofile.h
├── trueaudioproperties.cpp
└── trueaudioproperties.h
├── wavpack
├── wavpackfile.cpp
├── wavpackfile.h
├── wavpackproperties.cpp
└── wavpackproperties.h
└── xm
├── xmfile.cpp
├── xmfile.h
├── xmproperties.cpp
└── xmproperties.h
/.gitignore:
--------------------------------------------------------------------------------
1 | # C++ objects and libs
2 |
3 | *.slo
4 | *.lo
5 | *.o
6 | *.a
7 | *.la
8 | *.lai
9 | *.so
10 | *.dll
11 | *.dylib
12 |
13 | # Qt-es
14 |
15 | /.qmake.cache
16 | /.qmake.stash
17 | *.pro.user
18 | *.pro.user.*
19 | *.qbs.user
20 | *.qbs.user.*
21 | *.moc
22 | moc_*.cpp
23 | qrc_*.cpp
24 | ui_*.h
25 | Makefile*
26 | *build-*
27 |
28 | # QtCreator
29 |
30 | *.autosave
31 |
32 | # QtCtreator Qml
33 | *.qmlproject.user
34 | *.qmlproject.user.*
35 |
36 | # QtCtreator CMake
37 | CMakeLists.txt.user
38 |
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 纯真有声
2 |
这是一款基于QML的开源播放器,任何人都可以自由拷贝及使用其代码,对QML的初学者来说,这将会是一个学习和借鉴的最好例子。
3 |
写播放器的起缘
4 |
本人喜欢佛法,手机里装有20G的高德大僧的音频,自从手机从红米换到联想后,发现联想本地播放器(联想没有播放器,它是内置网易云音乐定制版)非常不好用,它没有最近进度的记忆功能,且在5.0安卓系统上,在蓝牙模式上会经常无法播放。后来花了较长的时间在使用别的播放器,包括酷狗、QQ音乐、以及谷歌5.0原播放器以及其它个人播放器,均会发现一些特别憋屈的问题。如QQ音乐会在每次登录界面均会随机选择一首其它音乐,你很容易忘记上一次播放那一首文件,播放到那一个进度。其它第三方个人播放器会植入广告或功能支持很不好。最后实在无法找到如意的播放器,才产生开发一个适合自已的播放器。
5 |
本播放器能解决什么问题
6 |
本播放器主要是针对有声书的场景而开发,如果你有聆听有声书的习惯,将会发现它有如下几个特色功能。
7 |
1.自动记忆最近一次播放的进度。
8 |
2.可以手动保存任何一本有声书的播放进度,你可以自由在多本有声书中自由切换,而不用担心进度丢失。
9 |
3.它是一个本地播放器,没有在线听歌等功能,不用担心它会偷流量。
10 |
4.它是个人维护,不会存在商业应用的一些特色功能。
11 |
安装要求
12 |
Qt5.7
13 |
NDK-r12
14 |
JDK>1.8
15 |
安装参考http://www.kxtry.com/qtandroid
16 |
17 |
当前版本是1.1
18 |
19 |
版本1.1变更:
20 |
增加了皮肤主题,默认为绿色,也可轻松定制为其它颜色。
21 |
22 |

23 |

24 |

25 |

26 |

--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | jcenter()
4 | }
5 |
6 | dependencies {
7 | classpath 'com.android.tools.build:gradle:1.1.0'
8 | }
9 | }
10 |
11 | allprojects {
12 | repositories {
13 | jcenter()
14 | }
15 | }
16 |
17 | apply plugin: 'com.android.application'
18 |
19 | dependencies {
20 | compile fileTree(dir: 'libs', include: ['*.jar'])
21 | }
22 |
23 | android {
24 | /*******************************************************
25 | * The following variables:
26 | * - androidBuildToolsVersion,
27 | * - androidCompileSdkVersion
28 | * - qt5AndroidDir - holds the path to qt android files
29 | * needed to build any Qt application
30 | * on Android.
31 | *
32 | * are defined in gradle.properties file. This file is
33 | * updated by QtCreator and androiddeployqt tools.
34 | * Changing them manually might break the compilation!
35 | *******************************************************/
36 |
37 | compileSdkVersion androidCompileSdkVersion.toInteger()
38 |
39 | buildToolsVersion androidBuildToolsVersion
40 |
41 | sourceSets {
42 | main {
43 | manifest.srcFile 'AndroidManifest.xml'
44 | java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
45 | aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
46 | res.srcDirs = [qt5AndroidDir + '/res', 'res']
47 | resources.srcDirs = ['src']
48 | renderscript.srcDirs = ['src']
49 | assets.srcDirs = ['assets']
50 | jniLibs.srcDirs = ['libs']
51 | }
52 | }
53 |
54 | lintOptions {
55 | abortOnError false
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/android/res/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/android/res/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/android/res/drawable-ldpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/android/res/drawable-ldpi/icon.png
--------------------------------------------------------------------------------
/android/res/drawable-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/android/res/drawable-mdpi/icon.png
--------------------------------------------------------------------------------
/android/res/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/android/res/drawable/icon.png
--------------------------------------------------------------------------------
/android/res/drawable/icon2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/android/res/drawable/icon2.png
--------------------------------------------------------------------------------
/android/res/drawable/splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 | -
9 |
10 |
11 |
--------------------------------------------------------------------------------
/android/res/values/apptheme.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/android/res/values/libs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - https://download.qt-project.org/ministro/android/qt5/qt-5.4
5 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/czys.qm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/czys.qm
--------------------------------------------------------------------------------
/czys.ts:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ListManager
6 |
7 | SongSearch
8 | 歌曲搜索
9 |
10 |
11 | MUYU
12 | 木鱼
13 |
14 |
15 | Settings
16 | 设置
17 |
18 |
19 | Song
20 | 歌曲
21 |
22 |
23 | Singer
24 | 歌手
25 |
26 |
27 | Folder
28 | 文件夹
29 |
30 |
31 |
32 | SongSearch
33 |
34 | Search All Music File By One Key.
35 | 一键搜索所有音乐
36 |
37 |
38 | msgbox
39 | 消息
40 |
41 |
42 | DirSelect
43 | 目录选择
44 |
45 |
46 | Search
47 | 搜索
48 |
49 |
50 | Pause
51 | 暂停
52 |
53 |
54 | Resume
55 | 继续
56 |
57 |
58 | Stop
59 | 停止
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/deployment.pri:
--------------------------------------------------------------------------------
1 | unix:!android {
2 | isEmpty(target.path) {
3 | qnx {
4 | target.path = /tmp/$${TARGET}/bin
5 | } else {
6 | target.path = /opt/$${TARGET}/bin
7 | }
8 | export(target.path)
9 | }
10 | INSTALLS += target
11 | }
12 |
13 | export(INSTALLS)
14 |
--------------------------------------------------------------------------------
/fonts/demo.css:
--------------------------------------------------------------------------------
1 | *{margin: 0;padding: 0;list-style: none;}
2 | /*
3 | KISSY CSS Reset
4 | 理念:1. reset 的目的不是清除浏览器的默认样式,这仅是部分工作。清除和重置是紧密不可分的。
5 | 2. reset 的目的不是让默认样式在所有浏览器下一致,而是减少默认样式有可能带来的问题。
6 | 3. reset 期望提供一套普适通用的基础样式。但没有银弹,推荐根据具体需求,裁剪和修改后再使用。
7 | 特色:1. 适应中文;2. 基于最新主流浏览器。
8 | 维护:玉伯, 正淳
9 | */
10 |
11 | /** 清除内外边距 **/
12 | body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, /* structural elements 结构元素 */
13 | dl, dt, dd, ul, ol, li, /* list elements 列表元素 */
14 | pre, /* text formatting elements 文本格式元素 */
15 | form, fieldset, legend, button, input, textarea, /* form elements 表单元素 */
16 | th, td /* table elements 表格元素 */ {
17 | margin: 0;
18 | padding: 0;
19 | }
20 |
21 | /** 设置默认字体 **/
22 | body,
23 | button, input, select, textarea /* for ie */ {
24 | font: 12px/1.5 tahoma, arial, \5b8b\4f53, sans-serif;
25 | }
26 | h1, h2, h3, h4, h5, h6 { font-size: 100%; }
27 | address, cite, dfn, em, var { font-style: normal; } /* 将斜体扶正 */
28 | code, kbd, pre, samp { font-family: courier new, courier, monospace; } /* 统一等宽字体 */
29 | small { font-size: 12px; } /* 小于 12px 的中文很难阅读,让 small 正常化 */
30 |
31 | /** 重置列表元素 **/
32 | ul, ol { list-style: none; }
33 |
34 | /** 重置文本格式元素 **/
35 | a { text-decoration: none; }
36 | a:hover { text-decoration: underline; }
37 |
38 |
39 | /** 重置表单元素 **/
40 | legend { color: #000; } /* for ie6 */
41 | fieldset, img { border: 0; } /* img 搭车:让链接里的 img 无边框 */
42 | button, input, select, textarea { font-size: 100%; } /* 使得表单元素在 ie 下能继承字体大小 */
43 | /* 注:optgroup 无法扶正 */
44 |
45 | /** 重置表格元素 **/
46 | table { border-collapse: collapse; border-spacing: 0; }
47 |
48 | /* 清除浮动 */
49 | .ks-clear:after, .clear:after {
50 | content: '\20';
51 | display: block;
52 | height: 0;
53 | clear: both;
54 | }
55 | .ks-clear, .clear {
56 | *zoom: 1;
57 | }
58 |
59 | .main {padding: 30px 100px;}
60 | .main h1{font-size:36px; color:#333; text-align:left;margin-bottom:30px; border-bottom: 1px solid #eee;}
61 |
62 | .helps{margin-top:40px;}
63 | .helps pre{
64 | padding:20px;
65 | margin:10px 0;
66 | border:solid 1px #e7e1cd;
67 | background-color: #fffdef;
68 | overflow: auto;
69 | }
70 |
71 | .icon_lists li{
72 | float:left;
73 | width: 100px;
74 | height:180px;
75 | text-align: center;
76 | }
77 | .icon_lists .icon{
78 | font-size: 42px;
79 | line-height: 100px;
80 | margin: 10px 0;
81 | color:#333;
82 | -webkit-transition: font-size 0.25s ease-out 0s;
83 | -moz-transition: font-size 0.25s ease-out 0s;
84 | transition: font-size 0.25s ease-out 0s;
85 |
86 | }
87 | .icon_lists .icon:hover{
88 | font-size: 100px;
89 | }
90 |
--------------------------------------------------------------------------------
/fonts/iconfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/fonts/iconfont.eot
--------------------------------------------------------------------------------
/fonts/iconfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/fonts/iconfont.ttf
--------------------------------------------------------------------------------
/fonts/iconfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/fonts/iconfont.woff
--------------------------------------------------------------------------------
/kxmob/KxBluetooth.cpp:
--------------------------------------------------------------------------------
1 | #include "KxBluetooth.h"
2 | #include
3 | #include
4 |
5 | KxBluetooth::KxBluetooth(QObject *parent)
6 | : QObject(parent)
7 | {
8 | m_pBluetooth = new QBluetoothLocalDevice(this);
9 | QObject::connect(m_pBluetooth, SIGNAL(deviceConnected(QBluetoothAddress)), this, SLOT(onDeviceConnected(QBluetoothAddress)));
10 | QObject::connect(m_pBluetooth, SIGNAL(deviceDisconnected(QBluetoothAddress)), this, SLOT(onDeviceDisconnected(QBluetoothAddress)));
11 | }
12 |
13 | void KxBluetooth::onDeviceConnected(const QBluetoothAddress &address)
14 | {
15 | emit connected(address.toString());
16 | }
17 |
18 | void KxBluetooth::onDeviceDisconnected(const QBluetoothAddress &address)
19 | {
20 | emit disconnected(address.toString());
21 | }
22 |
--------------------------------------------------------------------------------
/kxmob/KxBluetooth.h:
--------------------------------------------------------------------------------
1 | #ifndef _KXBLUETOOTH_H_
2 | #define _KXBLUETOOTH_H_
3 |
4 | #include
5 | #include
6 |
7 | class QBluetoothLocalDevice;
8 | class QBluetoothAddress;
9 |
10 | class KxBluetooth : public QObject
11 | {
12 | Q_OBJECT
13 | public:
14 | explicit KxBluetooth(QObject *parent = NULL);
15 |
16 | Q_SIGNALS:
17 | void connected(const QString& device);
18 | void disconnected(const QString& device);
19 |
20 | private Q_SLOTS:
21 | void onDeviceConnected(const QBluetoothAddress &address);
22 | void onDeviceDisconnected(const QBluetoothAddress &address);
23 | private:
24 | QPointer m_pBluetooth;
25 | };
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/kxmob/KxDesktopServices.cpp:
--------------------------------------------------------------------------------
1 | #include "KxDesktopServices.h"
2 | #include
3 | #include
4 |
5 | KxDesktopServices::KxDesktopServices(QObject *parent)
6 | : QObject(parent)
7 | {
8 |
9 | }
10 |
11 | void KxDesktopServices::openUrl(const QString &url)
12 | {
13 | QDesktopServices::openUrl(QUrl(url));
14 | }
15 |
--------------------------------------------------------------------------------
/kxmob/KxDesktopServices.h:
--------------------------------------------------------------------------------
1 | #ifndef _KXDESKTOPSERVICES_H_
2 | #define _KXDESKTOPSERVICES_H_
3 |
4 | #include
5 |
6 | class KxDesktopServices : public QObject
7 | {
8 | Q_OBJECT
9 |
10 | public:
11 | explicit KxDesktopServices(QObject *parent = NULL);
12 |
13 | Q_INVOKABLE void openUrl(const QString& url);
14 | };
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/kxmob/KxFileSearch.cpp:
--------------------------------------------------------------------------------
1 | #include "KxFileSearch.h"
2 | #include
3 | #include
4 | #include
5 |
6 | KxFileSearch::KxFileSearch(QObject *parent)
7 | : QObject(parent)
8 | , m_isRuning(false)
9 | , m_state("init")
10 | {
11 | }
12 |
13 | QString KxFileSearch::getState() const
14 | {
15 | return m_state;
16 | }
17 |
18 | void KxFileSearch::search(const QString &path, const QStringList &nameFilters)
19 | {
20 | if(m_listPause.isEmpty()){
21 | if(!m_isRuning){
22 | QMetaObject::invokeMethod(this, "doSearch", Qt::QueuedConnection, Q_ARG(QString, path), Q_ARG(QStringList, nameFilters));
23 | m_isRuning = true;
24 | m_state = "start";
25 | emit statusChanged();
26 | }else{
27 | m_list.append(Data(path, nameFilters));
28 | }
29 | }else{
30 | m_listPause.append(Data(path, nameFilters));
31 | }
32 | }
33 |
34 | void KxFileSearch::pause()
35 | {
36 | if(!m_list.isEmpty()){
37 | m_listPause.append(m_list);
38 | m_list.clear();
39 | }
40 | }
41 |
42 | void KxFileSearch::resume()
43 | {
44 | if(!m_listPause.isEmpty())
45 | {
46 | m_list.append(m_listPause);
47 | m_listPause.clear();
48 | Data d = m_list.takeFirst();
49 | search(d.path, d.filter);
50 | }
51 | }
52 |
53 | void KxFileSearch::stop()
54 | {
55 | m_listPause.clear();
56 | m_list.clear();
57 | if(m_state != "stop"){
58 | m_state = "stop";
59 | emit statusChanged();
60 | }
61 | }
62 |
63 | void KxFileSearch::doSearch(const QString &path, const QStringList &filters)
64 | {
65 | QDir dir(path);
66 | dir.setNameFilters(filters);
67 | QFileInfoList files = dir.entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot, QDir::DirsFirst);
68 | for(int i = 0; i < files.count(); i++){
69 | QFileInfo fi = files.at(i);
70 | emit searchResult(path, fi.filePath(), fi.isDir());
71 | }
72 | if(!m_listPause.isEmpty()){
73 | m_isRuning = false;
74 | m_state = "pause";
75 | emit statusChanged();
76 | }else if(!m_list.isEmpty()){
77 | Data d = m_list.takeFirst();
78 | QMetaObject::invokeMethod(this, "doSearch", Qt::QueuedConnection, Q_ARG(QString, d.path), Q_ARG(QStringList, d.filter));
79 | }else{
80 | m_isRuning = false;
81 | m_state = "stop";
82 | emit statusChanged();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/kxmob/KxFileSearch.h:
--------------------------------------------------------------------------------
1 | #ifndef _KXFILESEARCH_H_
2 | #define _KXFILESEARCH_H_
3 |
4 | #include
5 |
6 | class KxFileSearch : public QObject
7 | {
8 | Q_OBJECT
9 | Q_PROPERTY(QString state READ getState)
10 | public:
11 | explicit KxFileSearch(QObject *parent = NULL);
12 |
13 | QString getState() const;
14 |
15 | Q_INVOKABLE void search(const QString& path, const QStringList &nameFilters=QStringList("*"));
16 | Q_INVOKABLE void pause();
17 | Q_INVOKABLE void resume();
18 | Q_INVOKABLE void stop();
19 |
20 |
21 | Q_SIGNALS:
22 | void statusChanged();
23 | void searchResult(const QString& folder, const QString& file, bool isDir);
24 |
25 | private Q_SLOTS:
26 | void doSearch(const QString& path, const QStringList& filters);
27 |
28 | private:
29 | struct Data{
30 | Data(const QString& p, const QStringList& f){
31 | path = p;
32 | filter = f;
33 | }
34 |
35 | QString path;
36 | QStringList filter;
37 | };
38 | QList m_list;
39 | QList m_listPause;
40 | bool m_isRuning;
41 | QString m_state;
42 | };
43 |
44 | #endif
45 |
--------------------------------------------------------------------------------
/kxmob/KxMenu.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.6
2 | import QtQuick.Layouts 1.3
3 | import QtQuick.Controls 2.0
4 | import QtQuick.Controls.Material 2.0
5 | import QtQml.Models 2.1
6 |
7 | Menu {
8 | property int menuWidth: 180
9 | modal:true
10 | clip: true
11 |
12 | Material.background: g_theme.alphaLv4
13 | Component.onCompleted: {
14 | //菜单必须设置背景宽度,才能正确显示文本,这应该是它的一个BUG。
15 | if(menuWidth < 100){
16 | menuWidth = 100;
17 | }
18 | }
19 |
20 | background:Rectangle{
21 | id:myback
22 | implicitWidth: menuWidth
23 | color:g_theme.themeColor
24 | Rectangle {
25 | anchors.fill: parent
26 | color:g_theme.alphaLv5
27 | }
28 | }
29 | }
30 |
31 |
32 |
--------------------------------------------------------------------------------
/kxmob/KxMessageBox.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.6
2 | import QtQuick.Layouts 1.3
3 | import QtQuick.Controls 2.0
4 | import QtQuick.Controls.Material 2.0
5 |
6 | Popup {
7 | id: msgbox
8 |
9 | property string title
10 | property string content
11 | property alias okText: okButton.text
12 | property alias cancelText: cancelButton.text
13 | modal: true
14 | focus: true
15 |
16 | signal result(int val)
17 |
18 | Component.onCompleted: {
19 | width = Math.min(g_window.width, g_window.height) / 3 * 2
20 | height = msgColumn.implicitHeight + topPadding + bottomPadding
21 | x = (g_window.width - width - leftPadding - rightPadding) / 2;
22 | y = (g_window.height - height - topPadding - bottomPadding) / 2;
23 | contentWidth = width;
24 | contentHeight = height;
25 | console.log('width:'+width+',height:'+height)
26 | }
27 |
28 | background: Rectangle{
29 | color:g_theme.themeColor
30 | radius: 5
31 | Rectangle{
32 | anchors.fill: parent
33 | color:g_theme.alphaLv4
34 | radius: 5
35 | }
36 | }
37 |
38 | contentItem: ColumnLayout {
39 | id: msgColumn
40 | spacing: 20
41 |
42 | Material.background:g_theme.themeColor
43 | Label {
44 | text: title
45 | font.bold: true
46 | }
47 |
48 | Label {
49 | text: content
50 | wrapMode: Label.WrapAnywhere
51 | verticalAlignment: Label.AlignVCenter
52 | Layout.fillWidth: true
53 | Layout.fillHeight: true
54 | }
55 |
56 | RowLayout {
57 | spacing: 10
58 |
59 | Material.background:g_theme.themeColor
60 | Button {
61 | id: okButton
62 | text: qsTr("Ok")
63 | onClicked: {
64 | msgbox.visible = false;
65 | msgbox.close()
66 | msgbox.result(1)
67 | }
68 | Layout.preferredWidth: 0
69 | Layout.fillWidth: true
70 | }
71 |
72 | Button {
73 | id: cancelButton
74 | text: qsTr("Cancel")
75 | onClicked: {
76 | msgbox.visible = false;
77 | msgbox.close();
78 | msgbox.result(0);
79 | }
80 | Layout.preferredWidth: 0
81 | Layout.fillWidth: true
82 | }
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/kxmob/KxQuickView.cpp:
--------------------------------------------------------------------------------
1 | #include "KxQuickView.h"
2 | #include
3 |
4 | KxQuickView::KxQuickView(QWindow *parent)
5 | : QQuickView(parent)
6 | {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/kxmob/KxQuickView.h:
--------------------------------------------------------------------------------
1 | #ifndef _KXAPPVIEW_H_
2 | #define _KXAPPVIEW_H_
3 |
4 | #include
5 |
6 | class KxQuickView : public QQuickView
7 | {
8 | Q_OBJECT
9 | public:
10 | explicit KxQuickView(QWindow *parent = NULL);
11 | };
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/kxmob/KxTagParser.cpp:
--------------------------------------------------------------------------------
1 | #include "KxTagParser.h"
2 | #include "taglib/tag.h"
3 | #include "taglib/mpeg/mpegfile.h"
4 | #include "taglib/fileref.h"
5 | #include
6 | #include
7 |
8 | KxTagParser::KxTagParser(QObject *parent)
9 | :QObject(parent)
10 | {
11 |
12 | }
13 |
14 | QVariant KxTagParser::get(const QString &file) const
15 | {
16 | if(!isSupportFormat(file)){
17 | return false;
18 | }
19 | TagLib::FileRef fr(file.toLocal8Bit().data(), false, TagLib::AudioProperties::Fast);
20 | if(fr.isNull())
21 | return false;
22 | QVariantMap data;
23 | TagLib::Tag* tag = fr.tag();
24 | if(tag){
25 | data.insert("title", tag->title().toCString());
26 | data.insert("artist", tag->artist().toCString());
27 | data.insert("album", tag->album().toCString());
28 | data.insert("genre", tag->genre().toCString());
29 | data.insert("comment", tag->comment().toCString());
30 | data.insert("year", tag->year());
31 | data.insert("track", tag->track());
32 | }
33 | TagLib::AudioProperties* ap = fr.audioProperties();
34 | if(ap){
35 | data.insert("bitrate", ap->bitrate());
36 | data.insert("channels", ap->channels());
37 | data.insert("playLength", ap->length() * 1000);
38 | data.insert("sampleRate", ap->sampleRate());
39 | }
40 | return QVariant(data);
41 | }
42 |
43 | bool KxTagParser::isSupportFormat(const QString &file) const
44 | {
45 | const char *exts[] = {".mp3", ".wma", ".ogg", ".wav", ".flac"};
46 | int idx = file.lastIndexOf('.');
47 | if(idx < 0){
48 | return false;
49 | }
50 | QString ext = file.mid(idx);
51 | for(int i = 0; i < (sizeof(exts) / sizeof(exts[0])); i++){
52 | if(ext.compare(exts[i], Qt::CaseInsensitive) == 0){
53 | return true;
54 | }
55 | }
56 | return false;
57 | }
58 |
--------------------------------------------------------------------------------
/kxmob/KxTagParser.h:
--------------------------------------------------------------------------------
1 | #ifndef _KXTAGPARSER_H_
2 | #define _KXTAGPARSER_H_
3 |
4 | #include
5 | #include
6 |
7 | class KxTagParser : public QObject
8 | {
9 | Q_OBJECT
10 | public:
11 | explicit KxTagParser(QObject *parent = NULL);
12 |
13 | Q_INVOKABLE QVariant get(const QString& file) const;
14 |
15 | private:
16 | bool isSupportFormat(const QString& file) const;
17 | };
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/kxmob/KxUtils.cpp:
--------------------------------------------------------------------------------
1 | #include "KxUtils.h"
2 | #include
3 |
4 | KxUtils::KxUtils(QObject *parent)
5 | : QObject(parent)
6 | {
7 |
8 | }
9 |
10 | QString KxUtils::genericPath() const
11 | {
12 | static QString dataPath;
13 | if ( dataPath.isEmpty() ) {
14 | dataPath = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation).first();
15 | }
16 | return dataPath;
17 | }
18 |
--------------------------------------------------------------------------------
/kxmob/KxUtils.h:
--------------------------------------------------------------------------------
1 | #ifndef _KXUTILS_H_
2 | #define _KXUTILS_H_
3 |
4 | #include
5 |
6 | class KxUtils : public QObject
7 | {
8 | Q_OBJECT
9 | Q_PROPERTY(QString genericPath READ genericPath)
10 |
11 | public:
12 | explicit KxUtils(QObject *parent = NULL);
13 |
14 | QString genericPath() const;
15 | };
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/listmgr/AboutPlayer.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.6
2 | import QtQuick.Layouts 1.3
3 | import QtQuick.Controls 2.0
4 | import QtQuick.Controls.Material 2.0
5 | import KxDesktopServices 1.0
6 |
7 | Page {
8 | id: pane
9 | padding: 0
10 | clip:true
11 |
12 | Component.onCompleted: {
13 | g_musicBar.visible = false;
14 | }
15 |
16 | Component.onDestruction: {
17 | g_musicBar.visible = true;
18 | }
19 |
20 | Material.background: g_theme.themeColor
21 |
22 | header: Rectangle{
23 | width:parent.width
24 | height:g_theme.topbar_height
25 | color:g_theme.topbar_background
26 |
27 | Material.foreground: g_theme.topbar_foreground
28 | RowLayout{
29 | anchors.fill: parent
30 | ToolButton {
31 | id:tbReturn
32 | text:"\ue61e"
33 | font.family: "iconfont"
34 | font.pixelSize: 24
35 | onClicked: {
36 | g_stackView.pop();
37 | }
38 | }
39 | Label{
40 | text:'关于'
41 | font.pixelSize: 20
42 | horizontalAlignment: Label.AlignHCenter
43 | verticalAlignment: Label.AlignVCenter
44 | font.bold: true
45 | Layout.fillWidth: true
46 | }
47 | Item{
48 | width: tbReturn.width
49 | }
50 | }
51 | }
52 |
53 | Pane{
54 | padding: 0
55 | anchors.fill: parent
56 | Material.background: g_theme.alphaLv4
57 | ColumnLayout{
58 | anchors.fill: parent
59 | spacing:0
60 |
61 | Label{
62 | Layout.fillHeight: true
63 | Layout.fillWidth: true
64 | Layout.leftMargin: 10
65 | Layout.rightMargin: 10
66 | wrapMode: Label.WrapAnywhere
67 | font.pixelSize: 18
68 | lineHeight:1.5
69 |
70 | Component.onCompleted: {
71 | var txt = '
如果你追求一个纯粹的本地播放器,那你可以试试这个,特别是喜欢听有声书的朋友。'
72 | txt += '
播放器主页:http://www.czysheng.com/player'
73 | txt += '
有声书主页:http://www.czysheng.com'
74 | txt += '
源码仓库:https://github.com/kxtry/czys'
75 | txt += '
版本号:1.2'
76 | text = txt;
77 | }
78 |
79 | onLinkActivated:{
80 | console.log(link + " link activated");
81 | desktopServices.openUrl(link);
82 | }
83 | }
84 | }
85 | }
86 |
87 | KxDesktopServices{
88 | id:desktopServices;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/listmgr/FolderList.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.6
2 | import QtQuick.Layouts 1.3
3 | import QtQuick.Controls 2.0
4 | import QtQuick.Controls.Material 2.0
5 |
6 | Pane {
7 | id: pane
8 | padding: 0
9 | clip:true
10 |
11 | property var musicAll
12 |
13 | signal play(string file, string name)
14 |
15 | onMusicAllChanged: {
16 | listModel.clear();
17 | for(var id in musicAll){
18 | var info ={
19 | fileName:id.substring(id.lastIndexOf('/')+1),
20 | filePath:id,
21 | fileCount:musicAll[id].length
22 | }
23 | listModel.append(info);
24 | }
25 | }
26 |
27 | Component {
28 | id: songList
29 | PopSongList{
30 | }
31 | }
32 |
33 | ListView {
34 | id:listView
35 | anchors.fill: parent
36 |
37 | model: ListModel{
38 | id:listModel
39 | }
40 |
41 | Component {
42 | id: folderDelegate
43 | Rectangle {
44 | width: listView.width
45 | height: 55
46 | color:maMouse.pressed ? g_theme.list_accent : g_theme.list_background
47 | Rectangle{
48 | x:0
49 | y:0
50 | width:parent.width
51 | height:1
52 | color:g_theme.list_line
53 | visible:index === 0 ? true : false
54 | }
55 | ColumnLayout{
56 | anchors.fill: parent
57 | Item{
58 | Layout.fillHeight: true
59 | }
60 |
61 | Text {
62 | Layout.preferredHeight: 18
63 | Layout.fillWidth: true
64 | Layout.leftMargin: 10
65 | text: model.fileName
66 | font.pixelSize: 15
67 | verticalAlignment: Qt.AlignVCenter
68 | }
69 |
70 | Text {
71 | Layout.preferredHeight: 12
72 | Layout.fillWidth: true
73 | Layout.leftMargin: 10
74 | text: '共'+model.fileCount+'首,' + model.filePath
75 | font.pixelSize: 10
76 | verticalAlignment: Qt.AlignVCenter
77 | }
78 | Item{
79 | Layout.fillHeight: true
80 | }
81 | }
82 | Rectangle{
83 | x:0
84 | y:parent.height - 1
85 | width:parent.width
86 | height:1
87 | color:g_theme.list_line
88 | }
89 | MouseArea{
90 | id:maMouse
91 | anchors.fill: parent
92 | onClicked: {
93 | var songs = pane.musicAll[model.filePath];
94 | g_stackView.push(songList, {musicAll:songs, folderName:model.fileName})
95 | }
96 | }
97 | }
98 | }
99 | delegate: folderDelegate
100 | ScrollIndicator.vertical: ScrollIndicator { }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/listmgr/MusicBar.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.6
2 | import QtQuick.Layouts 1.3
3 | import QtQuick.Controls 2.0
4 | import QtQuick.Controls.Material 2.0
5 | import QtMultimedia 5.6
6 | import KxFileSearch 1.0
7 | import KxTagParser 1.0
8 | import "../kxmob"
9 |
10 | Pane {
11 | id:musicBar
12 | padding:0
13 |
14 | readonly property int barHeight: 50
15 | property alias songName: songName.text
16 | property alias tbPlay: tbPlay
17 |
18 | signal clicked();
19 |
20 | Material.background: g_theme.musicbar_background
21 | Material.foreground: g_theme.musicbar_foreground
22 |
23 | Component.onCompleted: {
24 | g_playMusic.playing.connect(onPlaying);
25 | g_playMusic.paused.connect(onPaused);
26 | g_playMusic.stopped.connect(onStopped);
27 | }
28 |
29 | Component.onDestruction: {
30 | console.log('onDestruction');
31 | g_playMusic.playing.disconnect(onPlaying);
32 | g_playMusic.paused.disconnect(onPaused);
33 | g_playMusic.stopped.disconnect(onStopped);
34 | }
35 |
36 | function onPlaying(){
37 | tbPlay.text = '\ue609';
38 | }
39 |
40 | function onPaused(){
41 | tbPlay.text = '\ue607';
42 | }
43 |
44 | function onStopped(){
45 | tbPlay.text = '\ue607';
46 | }
47 |
48 | ColumnLayout{
49 | z:100
50 | width:parent.width
51 | height:barHeight
52 | spacing: 0
53 | Rectangle {
54 | Layout.preferredHeight: 1
55 | Layout.fillWidth: true
56 | color:g_theme.musicbar_line
57 |
58 | Rectangle {
59 | x:0
60 | y:0
61 | width: g_playMusic.position / g_playMusic.duration * parent.width
62 | height:3
63 | color:g_theme.musicbar_slider
64 | }
65 | }
66 |
67 | RowLayout {
68 | spacing: 5
69 | Layout.fillHeight: true
70 | Layout.fillWidth: true
71 | Layout.rightMargin: 20
72 |
73 | Label {
74 | id:songName
75 | font.pixelSize: 20
76 | elide: Label.ElideRight
77 | horizontalAlignment: Qt.AlignLeft
78 | verticalAlignment: Qt.AlignVCenter
79 | Layout.fillWidth: true
80 | Layout.leftMargin: 10
81 | }
82 | ToolButton {
83 | id:tbPlay
84 | text:g_playMusic.playbackState === Audio.PlayingState ? "\ue609" : '\ue607'
85 | font.family: "iconfont"
86 | font.pixelSize: 24
87 | onClicked: {
88 | if(text === '\ue607'){
89 | g_playMusic.play();
90 | }else{
91 | g_playMusic.pause();
92 | }
93 | }
94 | }
95 | }
96 |
97 | Rectangle {
98 | Layout.preferredHeight: 1
99 | Layout.fillWidth: true
100 | color:g_theme.musicbar_line
101 | }
102 | }
103 |
104 | MouseArea {
105 | z:0
106 | anchors.fill: parent
107 | onClicked: {
108 | musicBar.clicked();
109 | }
110 | }
111 | }
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/listmgr/PopSongList.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.6
2 | import QtQuick.Layouts 1.3
3 | import QtQuick.Controls 2.0
4 | import QtQuick.Controls.Material 2.0
5 |
6 | Page {
7 | id: pane
8 | padding: 0
9 | clip:true
10 |
11 | property alias musicAll:mylist.musicAll
12 | property string folderName
13 |
14 | Material.background: g_theme.themeColor
15 |
16 | header: Rectangle {
17 | width:parent.width
18 | height:g_theme.topbar_height
19 | color:g_theme.topbar_background
20 |
21 | Material.foreground: g_theme.topbar_foreground
22 |
23 | RowLayout {
24 | spacing: 20
25 | anchors.fill: parent
26 |
27 | ToolButton {
28 | id:downArrow
29 | text:"\ue62d"
30 | font.family: "iconfont"
31 | font.pixelSize: 24
32 | onClicked: {
33 | g_stackView.pop()
34 | }
35 | }
36 |
37 | Label {
38 | id: titleLabel
39 | text: folderName
40 | font.pixelSize: 20
41 | font.bold: true
42 | elide: Label.ElideRight
43 | horizontalAlignment: Qt.AlignHCenter
44 | verticalAlignment: Qt.AlignVCenter
45 | Layout.fillWidth: true
46 | }
47 |
48 | Item{
49 | width:downArrow.width
50 | }
51 | }
52 | }
53 |
54 | Pane{
55 | padding: 0
56 | anchors.fill: parent
57 |
58 | Material.background: g_theme.alphaLv4
59 |
60 | SongList{
61 | id:mylist
62 | listName:folderName
63 | anchors.fill: parent
64 | anchors.bottomMargin: g_musicBar.barHeight
65 | }
66 |
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/listmgr/SongList.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.6
2 | import QtQuick.Layouts 1.3
3 | import QtQuick.Controls 2.0
4 | import QtQuick.Controls.Material 2.0
5 |
6 | Pane {
7 | id: songList
8 | padding: 0
9 | clip:true
10 |
11 | property var musicAll
12 | property string listName: '所有音乐'
13 |
14 | onMusicAllChanged: {
15 | listModel.clear();
16 | for(var id in musicAll){
17 | var song = musicAll[id];
18 | if(song instanceof Array){
19 | for(var i = 0; i < song.length; i++){
20 | listModel.append(song[i]);
21 | }
22 | }else{
23 | listModel.append(song);
24 | }
25 | }
26 | }
27 |
28 |
29 | ListView {
30 | clip:true
31 | anchors.fill: parent
32 | id:listView
33 | currentIndex:-1
34 |
35 | model: ListModel{
36 | id:listModel
37 | }
38 |
39 | Component {
40 | id: songDelegate
41 | Rectangle {
42 | width: listView.width
43 | height: 55
44 | color:maMouse.pressed ? g_theme.list_accent : g_theme.list_background
45 | Rectangle{
46 | x:0
47 | y:0
48 | width:parent.width
49 | height:1
50 | color:g_theme.list_line
51 | visible:index === 0 ? true : false
52 | }
53 | ColumnLayout{
54 | anchors.fill: parent
55 | Item{
56 | Layout.fillHeight: true
57 | }
58 |
59 | Text {
60 | Layout.preferredHeight: 18
61 | Layout.fillWidth: true
62 | Layout.leftMargin: 10
63 | text: model.fileName
64 | font.pixelSize: 15
65 | verticalAlignment: Qt.AlignVCenter
66 | }
67 |
68 | Text {
69 | Layout.preferredHeight: 12
70 | Layout.fillWidth: true
71 | Layout.leftMargin: 10
72 | text: model.filePath
73 | font.pixelSize: 10
74 | verticalAlignment: Qt.AlignVCenter
75 | }
76 | Item{
77 | Layout.fillHeight: true
78 | }
79 | }
80 | Rectangle{
81 | x:0
82 | y:parent.height - 1
83 | width:parent.width
84 | height:1
85 | color:g_theme.list_line
86 | }
87 | MouseArea{
88 | id:maMouse
89 | anchors.fill: parent
90 | onClicked: {
91 | if (listView.currentIndex != index) {
92 | listView.currentIndex = index;
93 | var musics = []
94 | for(var i = 0; i < listModel.count; i++){
95 | var info = listModel.get(i);
96 | var param = {
97 | fileName:info.fileName
98 | }
99 | var url = encodeURI("file://" +info.filePath+'?param='+JSON.stringify(param));
100 | musics.push(url);
101 | }
102 | //console.log('musics:' + JSON.stringify(musics));
103 | g_playMusic.resetPlayList(musics, listName, true);
104 | g_playMusic.playIndex(index, 0, true);
105 | }
106 | }
107 | }
108 | }
109 | }
110 |
111 | delegate: songDelegate
112 | ScrollIndicator.vertical: ScrollIndicator { }
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/listmgr/Theme.qml:
--------------------------------------------------------------------------------
1 | import QtQuick 2.6
2 | import QtQuick.Controls 2.0
3 | import QtQuick.Controls.Material 2.0
4 |
5 | QtObject {
6 | property color themeColor:Material.color(Material.Green)
7 | property color lightThemeColor:Material.color(Material.LightGreen)
8 |
9 | property color topbar_background:alphaLv1
10 | property color topbar_foreground:'#FFFFFF'
11 | property int topbar_height: 50
12 |
13 | property color tabbar_background:alphaLv5
14 | property color tabbar_primary: themeColor
15 | property color tabbar_foreground:Material.color(Material.Grey)
16 | property color tabbar_accent:themeColor
17 | property color tabbar_line: Material.color(Material.Grey)
18 |
19 | property color musicbar_background:alphaLv5
20 | property color musicbar_foreground:themeColor
21 | property color musicbar_line: Material.color(Material.Grey)
22 | property color musicbar_slider: themeColor
23 |
24 | property color list_background: alphaLv1
25 | property color list_accent:alphaLv4
26 | property color list_line: Material.color(Material.Grey)
27 |
28 | property color alphaLv1: '#1FFFFFFF'
29 | property color alphaLv2: '#3FFFFFFF'
30 | property color alphaLv3: '#5FFFFFFF'
31 | property color alphaLv4: '#7FFFFFFF'
32 | property color alphaLv5: '#9FFFFFFF'
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | #include "kxmob/KxUtils.h"
16 | #include "kxmob/KxFileSearch.h"
17 | #include "kxmob/KxTagParser.h"
18 | #include "kxmob/KxBluetooth.h"
19 | #include "kxmob/KxDesktopServices.h"
20 |
21 | int main(int argc, char *argv[])
22 | {
23 | QGuiApplication::setApplicationName("czys");
24 | QGuiApplication::setOrganizationName("kxtry");
25 | QGuiApplication::setOrganizationDomain("kxtry.com");
26 | QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
27 |
28 | QGuiApplication app(argc, argv);
29 |
30 | int fontId = QFontDatabase::addApplicationFont(":/fonts/iconfont.ttf");
31 | QStringList fontFamilies = QFontDatabase::applicationFontFamilies(fontId);
32 | qDebug() << "fontId:" << fontId << ",fontFamily:" << fontFamilies;
33 |
34 | QTranslator translator;
35 | if(translator.load(":/czys.qm")){
36 | app.installTranslator(&translator);
37 | }
38 |
39 | QQuickStyle::setStyle("material");
40 |
41 | qmlRegisterType("KxFileSearch", 1,0, "KxFileSearch");
42 | qmlRegisterType("KxTagParser", 1,0, "KxTagParser");
43 | qmlRegisterType("KxBluetooth", 1,0, "KxBluetooth");
44 | qmlRegisterType("KxDesktopServices", 1,0, "KxDesktopServices");
45 |
46 | QQmlApplicationEngine engine;
47 | QQmlContext *qmlContext = engine.rootContext();
48 | qmlContext->setContextProperty("KxUtils", new KxUtils(qmlContext));
49 | engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
50 | if (engine.rootObjects().isEmpty()) {
51 | return -1;
52 | }
53 | QQuickWindow *appWindow = qobject_cast(engine.rootObjects().first());
54 | qmlContext->setContextProperty("AppWindow", appWindow);
55 | return app.exec();
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/qml.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | main.qml
4 | kxmob/KxFileDialog.qml
5 | listmgr/SongSearch.qml
6 | kxmob/KxFilePage.qml
7 | listmgr/ListManager.qml
8 | listmgr/SongList.qml
9 | listmgr/FolderList.qml
10 | kxmob/KxMessageBox.qml
11 | fonts/iconfont.ttf
12 | czys.qm
13 | czys.ts
14 | listmgr/MusicBar.qml
15 | listmgr/PopSongList.qml
16 | listmgr/PlayCenter.qml
17 | listmgr/PopHistory.qml
18 | listmgr/AboutPlayer.qml
19 | listmgr/Theme.qml
20 | kxmob/KxMenu.qml
21 |
22 |
23 |
--------------------------------------------------------------------------------
/taglib/ape/apeproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2010 by Alex Novichkov
3 | email : novichko@atnet.ru
4 |
5 | copyright : (C) 2006 by Lukáš Lalinský
6 | email : lalinsky@gmail.com
7 | (original WavPack implementation)
8 | ***************************************************************************/
9 |
10 | /***************************************************************************
11 | * This library is free software; you can redistribute it and/or modify *
12 | * it under the terms of the GNU Lesser General Public License version *
13 | * 2.1 as published by the Free Software Foundation. *
14 | * *
15 | * This library is distributed in the hope that it will be useful, but *
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
18 | * Lesser General Public License for more details. *
19 | * *
20 | * You should have received a copy of the GNU Lesser General Public *
21 | * License along with this library; if not, write to the Free Software *
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
23 | * 02110-1301 USA *
24 | * *
25 | * Alternatively, this file is available under the Mozilla Public *
26 | * License Version 1.1. You may obtain a copy of the License at *
27 | * http://www.mozilla.org/MPL/ *
28 | ***************************************************************************/
29 |
30 | #ifndef TAGLIB_APEPROPERTIES_H
31 | #define TAGLIB_APEPROPERTIES_H
32 |
33 | #include "taglib_export.h"
34 | #include "audioproperties.h"
35 |
36 | namespace TagLib {
37 |
38 | namespace APE {
39 |
40 | class File;
41 |
42 | //! An implementation of audio property reading for APE
43 |
44 | /*!
45 | * This reads the data from an APE stream found in the AudioProperties
46 | * API.
47 | */
48 |
49 | class TAGLIB_EXPORT Properties : public AudioProperties
50 | {
51 | public:
52 | /*!
53 | * Create an instance of APE::Properties with the data read from the
54 | * ByteVector \a data.
55 | */
56 | Properties(File *f, ReadStyle style = Average);
57 |
58 | /*!
59 | * Destroys this APE::Properties instance.
60 | */
61 | virtual ~Properties();
62 |
63 | // Reimplementations.
64 |
65 | virtual int length() const;
66 | virtual int bitrate() const;
67 | virtual int sampleRate() const;
68 | virtual int channels() const;
69 |
70 | /*!
71 | * Returns number of bits per sample.
72 | */
73 | int bitsPerSample() const;
74 | uint sampleFrames() const;
75 |
76 | /*!
77 | * Returns APE version.
78 | */
79 | int version() const;
80 |
81 | private:
82 | Properties(const Properties &);
83 | Properties &operator=(const Properties &);
84 |
85 | void read();
86 |
87 | long findDescriptor();
88 | long findID3v2();
89 |
90 | void analyzeCurrent();
91 | void analyzeOld();
92 |
93 | class PropertiesPrivate;
94 | PropertiesPrivate *d;
95 | };
96 | }
97 | }
98 |
99 | #endif
100 |
--------------------------------------------------------------------------------
/taglib/asf/asfproperties.cpp:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2005-2007 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include
27 | #include
28 | #include "asfproperties.h"
29 |
30 | using namespace TagLib;
31 |
32 | class ASF::Properties::PropertiesPrivate
33 | {
34 | public:
35 | PropertiesPrivate(): length(0), bitrate(0), sampleRate(0), channels(0), encrypted(false) {}
36 | int length;
37 | int bitrate;
38 | int sampleRate;
39 | int channels;
40 | bool encrypted;
41 | };
42 |
43 | ////////////////////////////////////////////////////////////////////////////////
44 | // public members
45 | ////////////////////////////////////////////////////////////////////////////////
46 |
47 | ASF::Properties::Properties() : AudioProperties(AudioProperties::Average)
48 | {
49 | d = new PropertiesPrivate;
50 | }
51 |
52 | ASF::Properties::~Properties()
53 | {
54 | if(d)
55 | delete d;
56 | }
57 |
58 | int ASF::Properties::length() const
59 | {
60 | return d->length;
61 | }
62 |
63 | int ASF::Properties::bitrate() const
64 | {
65 | return d->bitrate;
66 | }
67 |
68 | int ASF::Properties::sampleRate() const
69 | {
70 | return d->sampleRate;
71 | }
72 |
73 | int ASF::Properties::channels() const
74 | {
75 | return d->channels;
76 | }
77 |
78 | bool ASF::Properties::isEncrypted() const
79 | {
80 | return d->encrypted;
81 | }
82 |
83 | ////////////////////////////////////////////////////////////////////////////////
84 | // private members
85 | ////////////////////////////////////////////////////////////////////////////////
86 |
87 | void ASF::Properties::setLength(int length)
88 | {
89 | d->length = length;
90 | }
91 |
92 | void ASF::Properties::setBitrate(int length)
93 | {
94 | d->bitrate = length;
95 | }
96 |
97 | void ASF::Properties::setSampleRate(int length)
98 | {
99 | d->sampleRate = length;
100 | }
101 |
102 | void ASF::Properties::setChannels(int length)
103 | {
104 | d->channels = length;
105 | }
106 |
107 | void ASF::Properties::setEncrypted(bool encrypted)
108 | {
109 | d->encrypted = encrypted;
110 | }
111 |
112 |
--------------------------------------------------------------------------------
/taglib/asf/asfproperties.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2005-2007 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_ASFPROPERTIES_H
27 | #define TAGLIB_ASFPROPERTIES_H
28 |
29 | #include "audioproperties.h"
30 | #include "tstring.h"
31 | #include "taglib_export.h"
32 |
33 | namespace TagLib {
34 |
35 | namespace ASF {
36 |
37 | //! An implementation of ASF audio properties
38 | class TAGLIB_EXPORT Properties : public AudioProperties
39 | {
40 | public:
41 |
42 | /*!
43 | * Create an instance of ASF::Properties.
44 | */
45 | Properties();
46 |
47 | /*!
48 | * Destroys this ASF::Properties instance.
49 | */
50 | virtual ~Properties();
51 |
52 | // Reimplementations.
53 | virtual int length() const;
54 | virtual int bitrate() const;
55 | virtual int sampleRate() const;
56 | virtual int channels() const;
57 | bool isEncrypted() const;
58 |
59 | #ifndef DO_NOT_DOCUMENT
60 | void setLength(int value);
61 | void setBitrate(int value);
62 | void setSampleRate(int value);
63 | void setChannels(int value);
64 | void setEncrypted(bool value);
65 | #endif
66 |
67 | private:
68 | class PropertiesPrivate;
69 | PropertiesPrivate *d;
70 | };
71 |
72 | }
73 |
74 | }
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/taglib/audioproperties.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include "audioproperties.h"
27 |
28 | using namespace TagLib;
29 |
30 | class AudioProperties::AudioPropertiesPrivate
31 | {
32 |
33 | };
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | // public methods
37 | ////////////////////////////////////////////////////////////////////////////////
38 |
39 | AudioProperties::~AudioProperties()
40 | {
41 |
42 | }
43 |
44 | ////////////////////////////////////////////////////////////////////////////////
45 | // protected methods
46 | ////////////////////////////////////////////////////////////////////////////////
47 |
48 | AudioProperties::AudioProperties(ReadStyle)
49 | {
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/taglib/config.h:
--------------------------------------------------------------------------------
1 | /* config.h. Generated by cmake from config.h.cmake */
2 |
3 | /* Indicates the byte order of your target system */
4 | /* 1 if little-endian, 2 if big-endian. */
5 | #define SYSTEM_BYTEORDER 1
6 |
7 | /* Defined if your compiler supports some byte swap functions */
8 | /* #undef HAVE_GCC_BYTESWAP_16 */
9 | /* #undef HAVE_GCC_BYTESWAP_32 */
10 | /* #undef HAVE_GCC_BYTESWAP_64 */
11 | /* #undef HAVE_GLIBC_BYTESWAP */
12 | #define HAVE_MSC_BYTESWAP 1
13 | /* #undef HAVE_MAC_BYTESWAP */
14 | /* #undef HAVE_OPENBSD_BYTESWAP */
15 |
16 | /* Defined if your compiler supports codecvt */
17 | #define HAVE_STD_CODECVT 1
18 |
19 | /* Defined if your compiler supports some atomic operations */
20 | #define HAVE_STD_ATOMIC 1
21 | /* #undef HAVE_BOOST_ATOMIC */
22 | /* #undef HAVE_GCC_ATOMIC */
23 | /* #undef HAVE_MAC_ATOMIC */
24 | /* #undef HAVE_WIN_ATOMIC */
25 | /* #undef HAVE_IA64_ATOMIC */
26 |
27 | /* Defined if your compiler supports some safer version of sprintf */
28 | /* #undef HAVE_SNPRINTF */
29 | #define HAVE_SPRINTF_S 1
30 |
31 | /* Defined if you have libz */
32 | /* #undef HAVE_ZLIB */
33 |
34 | /* Indicates whether debug messages are shown even in release mode */
35 | /* #undef TRACE_IN_RELEASE */
36 |
--------------------------------------------------------------------------------
/taglib/flac/flacmetadatablock.cpp:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2010 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include
27 | #include
28 | #include "flacmetadatablock.h"
29 |
30 | using namespace TagLib;
31 |
32 | class FLAC::MetadataBlock::MetadataBlockPrivate
33 | {
34 | public:
35 | MetadataBlockPrivate() {}
36 |
37 | };
38 |
39 | FLAC::MetadataBlock::MetadataBlock()
40 | {
41 | d = 0;
42 | }
43 |
44 | FLAC::MetadataBlock::~MetadataBlock()
45 | {
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/taglib/flac/flacmetadatablock.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2010 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_FLACMETADATABLOCK_H
27 | #define TAGLIB_FLACMETADATABLOCK_H
28 |
29 | #include "tlist.h"
30 | #include "tbytevector.h"
31 | #include "taglib_export.h"
32 |
33 | namespace TagLib {
34 |
35 | namespace FLAC {
36 |
37 | class TAGLIB_EXPORT MetadataBlock
38 | {
39 | public:
40 | MetadataBlock();
41 | virtual ~MetadataBlock();
42 |
43 | enum BlockType {
44 | StreamInfo = 0,
45 | Padding,
46 | Application,
47 | SeekTable,
48 | VorbisComment,
49 | CueSheet,
50 | Picture
51 | };
52 |
53 | /*!
54 | * Returns the FLAC metadata block type.
55 | */
56 | virtual int code() const = 0;
57 |
58 | /*!
59 | * Render the content of the block.
60 | */
61 | virtual ByteVector render() const = 0;
62 |
63 | private:
64 | MetadataBlock(const MetadataBlock &item);
65 | MetadataBlock &operator=(const MetadataBlock &item);
66 |
67 | class MetadataBlockPrivate;
68 | MetadataBlockPrivate *d;
69 | };
70 |
71 | }
72 |
73 | }
74 |
75 | #endif
76 |
--------------------------------------------------------------------------------
/taglib/flac/flacproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2003 by Allan Sandfeld Jensen
3 | email : kde@carewolf.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_FLACPROPERTIES_H
27 | #define TAGLIB_FLACPROPERTIES_H
28 |
29 | #include "taglib_export.h"
30 | #include "audioproperties.h"
31 |
32 | namespace TagLib {
33 |
34 | namespace FLAC {
35 |
36 | class File;
37 |
38 | //! An implementation of audio property reading for FLAC
39 |
40 | /*!
41 | * This reads the data from an FLAC stream found in the AudioProperties
42 | * API.
43 | */
44 |
45 | class TAGLIB_EXPORT Properties : public AudioProperties
46 | {
47 | public:
48 | /*!
49 | * Create an instance of FLAC::Properties with the data read from the
50 | * ByteVector \a data.
51 | */
52 | // BIC: switch to const reference
53 | Properties(ByteVector data, long streamLength, ReadStyle style = Average);
54 |
55 | /*!
56 | * Create an instance of FLAC::Properties with the data read from the
57 | * FLAC::File \a file.
58 | */
59 | // BIC: remove
60 | Properties(File *file, ReadStyle style = Average);
61 |
62 | /*!
63 | * Destroys this FLAC::Properties instance.
64 | */
65 | virtual ~Properties();
66 |
67 | // Reimplementations.
68 |
69 | virtual int length() const;
70 | virtual int bitrate() const;
71 | virtual int sampleRate() const;
72 | virtual int channels() const;
73 |
74 | /*!
75 | * Returns the sample width as read from the FLAC identification
76 | * header.
77 | */
78 | int sampleWidth() const;
79 |
80 | /*!
81 | * Return the number of sample frames
82 | */
83 | unsigned long long sampleFrames() const;
84 |
85 | /*!
86 | * Returns the MD5 signature of the uncompressed audio stream as read
87 | * from the stream info header header.
88 | */
89 | ByteVector signature() const;
90 |
91 | private:
92 | Properties(const Properties &);
93 | Properties &operator=(const Properties &);
94 |
95 | void read();
96 |
97 | class PropertiesPrivate;
98 | PropertiesPrivate *d;
99 | };
100 | }
101 | }
102 |
103 | #endif
104 |
--------------------------------------------------------------------------------
/taglib/flac/flacunknownmetadatablock.cpp:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2010 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include
27 | #include
28 | #include
29 | #include "flacunknownmetadatablock.h"
30 |
31 | using namespace TagLib;
32 |
33 | class FLAC::UnknownMetadataBlock::UnknownMetadataBlockPrivate
34 | {
35 | public:
36 | UnknownMetadataBlockPrivate() : code(0) {}
37 |
38 | int code;
39 | ByteVector data;
40 | };
41 |
42 | FLAC::UnknownMetadataBlock::UnknownMetadataBlock(int code, const ByteVector &data)
43 | {
44 | d = new UnknownMetadataBlockPrivate;
45 | d->code = code;
46 | //debug(String(data.toHex()));
47 | d->data = data;
48 | }
49 |
50 | FLAC::UnknownMetadataBlock::~UnknownMetadataBlock()
51 | {
52 | delete d;
53 | }
54 |
55 | int FLAC::UnknownMetadataBlock::code() const
56 | {
57 | return d->code;
58 | }
59 |
60 | void FLAC::UnknownMetadataBlock::setCode(int code)
61 | {
62 | d->code = code;
63 | }
64 |
65 | ByteVector FLAC::UnknownMetadataBlock::data() const
66 | {
67 | return d->data;
68 | }
69 |
70 | void FLAC::UnknownMetadataBlock::setData(const ByteVector &data)
71 | {
72 | d->data = data;
73 | }
74 |
75 | ByteVector FLAC::UnknownMetadataBlock::render() const
76 | {
77 | return d->data;
78 | }
79 |
80 |
--------------------------------------------------------------------------------
/taglib/flac/flacunknownmetadatablock.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2010 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_FLACUNKNOWNMETADATABLOCK_H
27 | #define TAGLIB_FLACUNKNOWNMETADATABLOCK_H
28 |
29 | #include "tlist.h"
30 | #include "tbytevector.h"
31 | #include "taglib_export.h"
32 | #include "flacmetadatablock.h"
33 |
34 | namespace TagLib {
35 |
36 | namespace FLAC {
37 |
38 | class TAGLIB_EXPORT UnknownMetadataBlock : public MetadataBlock
39 | {
40 | public:
41 | UnknownMetadataBlock(int blockType, const ByteVector &data);
42 | ~UnknownMetadataBlock();
43 |
44 | /*!
45 | * Returns the FLAC metadata block type.
46 | */
47 | int code() const;
48 |
49 | /*!
50 | * Sets the FLAC metadata block type.
51 | */
52 | void setCode(int code);
53 |
54 | /*!
55 | * Returns the FLAC metadata block type.
56 | */
57 | ByteVector data() const;
58 |
59 | /*!
60 | * Sets the FLAC metadata block type.
61 | */
62 | void setData(const ByteVector &data);
63 |
64 | /*!
65 | * Render the content of the block.
66 | */
67 | ByteVector render() const;
68 |
69 | private:
70 | UnknownMetadataBlock(const MetadataBlock &item);
71 | UnknownMetadataBlock &operator=(const MetadataBlock &item);
72 |
73 | class UnknownMetadataBlockPrivate;
74 | UnknownMetadataBlockPrivate *d;
75 | };
76 |
77 | }
78 |
79 | }
80 |
81 | #endif
82 |
--------------------------------------------------------------------------------
/taglib/it/itproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #ifndef TAGLIB_ITPROPERTIES_H
23 | #define TAGLIB_ITPROPERTIES_H
24 |
25 | #include "taglib.h"
26 | #include "audioproperties.h"
27 |
28 | namespace TagLib {
29 | namespace IT {
30 | class TAGLIB_EXPORT Properties : public AudioProperties {
31 | friend class File;
32 | public:
33 | /*! Flag bits. */
34 | enum {
35 | Stereo = 1,
36 | Vol0MixOptimizations = 2,
37 | UseInstruments = 4,
38 | LinearSlides = 8,
39 | OldEffects = 16,
40 | LinkEffects = 32,
41 | UseMidiPitchController = 64,
42 | RequestEmbeddedMidiConf = 128
43 | };
44 |
45 | /*! Special bits. */
46 | enum {
47 | MessageAttached = 1,
48 | MidiConfEmbedded = 8
49 | };
50 |
51 | Properties(AudioProperties::ReadStyle propertiesStyle);
52 | virtual ~Properties();
53 |
54 | int length() const;
55 | int bitrate() const;
56 | int sampleRate() const;
57 | int channels() const;
58 |
59 | ushort lengthInPatterns() const;
60 | bool stereo() const;
61 | ushort instrumentCount() const;
62 | ushort sampleCount() const;
63 | ushort patternCount() const;
64 | ushort version() const;
65 | ushort compatibleVersion() const;
66 | ushort flags() const;
67 | ushort special() const;
68 | uchar globalVolume() const;
69 | uchar mixVolume() const;
70 | uchar tempo() const;
71 | uchar bpmSpeed() const;
72 | uchar panningSeparation() const;
73 | uchar pitchWheelDepth() const;
74 |
75 | void setChannels(int channels);
76 | void setLengthInPatterns(ushort lengthInPatterns);
77 | void setInstrumentCount(ushort instrumentCount);
78 | void setSampleCount (ushort sampleCount);
79 | void setPatternCount(ushort patternCount);
80 | void setVersion (ushort version);
81 | void setCompatibleVersion(ushort compatibleVersion);
82 | void setFlags (ushort flags);
83 | void setSpecial (ushort special);
84 | void setGlobalVolume(uchar globalVolume);
85 | void setMixVolume (uchar mixVolume);
86 | void setTempo (uchar tempo);
87 | void setBpmSpeed (uchar bpmSpeed);
88 | void setPanningSeparation(uchar panningSeparation);
89 | void setPitchWheelDepth (uchar pitchWheelDepth);
90 |
91 | private:
92 | Properties(const Properties&);
93 | Properties &operator=(const Properties&);
94 |
95 | class PropertiesPrivate;
96 | PropertiesPrivate *d;
97 | };
98 | }
99 | }
100 |
101 | #endif
102 |
--------------------------------------------------------------------------------
/taglib/mod/modfile.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #ifndef TAGLIB_MODFILE_H
23 | #define TAGLIB_MODFILE_H
24 |
25 | #include "tfile.h"
26 | #include "audioproperties.h"
27 | #include "taglib_export.h"
28 | #include "modfilebase.h"
29 | #include "modtag.h"
30 | #include "modproperties.h"
31 |
32 | namespace TagLib {
33 |
34 | namespace Mod {
35 |
36 | class TAGLIB_EXPORT File : public TagLib::Mod::FileBase
37 | {
38 | public:
39 | /*!
40 | * Constructs a Protracker file from \a file.
41 | *
42 | * \note In the current implementation, both \a readProperties and
43 | * \a propertiesStyle are ignored. The audio properties are always
44 | * read.
45 | */
46 | File(FileName file, bool readProperties = true,
47 | AudioProperties::ReadStyle propertiesStyle =
48 | AudioProperties::Average);
49 |
50 | /*!
51 | * Constructs a Protracker file from \a stream.
52 | *
53 | * \note In the current implementation, both \a readProperties and
54 | * \a propertiesStyle are ignored. The audio properties are always
55 | * read.
56 | *
57 | * \note TagLib will *not* take ownership of the stream, the caller is
58 | * responsible for deleting it after the File object.
59 | */
60 | File(IOStream *stream, bool readProperties = true,
61 | AudioProperties::ReadStyle propertiesStyle =
62 | AudioProperties::Average);
63 |
64 | /*!
65 | * Destroys this instance of the File.
66 | */
67 | virtual ~File();
68 |
69 | Mod::Tag *tag() const;
70 |
71 | /*!
72 | * Implements the unified property interface -- export function.
73 | * Forwards to Mod::Tag::properties().
74 | */
75 | PropertyMap properties() const;
76 |
77 | /*!
78 | * Implements the unified property interface -- import function.
79 | * Forwards to Mod::Tag::setProperties().
80 | */
81 | PropertyMap setProperties(const PropertyMap &);
82 | /*!
83 | * Returns the Mod::Properties for this file. If no audio properties
84 | * were read then this will return a null pointer.
85 | */
86 | Mod::Properties *audioProperties() const;
87 |
88 | /*!
89 | * Save the file.
90 | * This is the same as calling save(AllTags);
91 | *
92 | * \note Saving Protracker tags is not supported.
93 | */
94 | bool save();
95 |
96 | private:
97 | File(const File &);
98 | File &operator=(const File &);
99 |
100 | void read(bool readProperties);
101 |
102 | class FilePrivate;
103 | FilePrivate *d;
104 | };
105 |
106 | }
107 |
108 | }
109 |
110 | #endif
111 |
--------------------------------------------------------------------------------
/taglib/mod/modfilebase.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #include "tdebug.h"
23 | #include "modfilebase.h"
24 |
25 | using namespace TagLib;
26 | using namespace Mod;
27 |
28 | Mod::FileBase::FileBase(FileName file) : TagLib::File(file)
29 | {
30 | }
31 |
32 | Mod::FileBase::FileBase(IOStream *stream) : TagLib::File(stream)
33 | {
34 | }
35 |
36 | void Mod::FileBase::writeString(const String &s, ulong size, char padding)
37 | {
38 | ByteVector data(s.data(String::Latin1));
39 | data.resize(size, padding);
40 | writeBlock(data);
41 | }
42 |
43 | bool Mod::FileBase::readString(String &s, ulong size)
44 | {
45 | ByteVector data(readBlock(size));
46 | if(data.size() < size) return false;
47 | int index = data.find((char) 0);
48 | if(index > -1)
49 | {
50 | data.resize(index);
51 | }
52 | data.replace((char) 0xff, ' ');
53 |
54 | s = data;
55 | return true;
56 | }
57 |
58 | void Mod::FileBase::writeByte(uchar byte)
59 | {
60 | ByteVector data(1, byte);
61 | writeBlock(data);
62 | }
63 |
64 | void Mod::FileBase::writeU16L(ushort number)
65 | {
66 | writeBlock(ByteVector::fromShort(number, false));
67 | }
68 |
69 | void Mod::FileBase::writeU32L(ulong number)
70 | {
71 | writeBlock(ByteVector::fromUInt(number, false));
72 | }
73 |
74 | void Mod::FileBase::writeU16B(ushort number)
75 | {
76 | writeBlock(ByteVector::fromShort(number, true));
77 | }
78 |
79 | void Mod::FileBase::writeU32B(ulong number)
80 | {
81 | writeBlock(ByteVector::fromUInt(number, true));
82 | }
83 |
84 | bool Mod::FileBase::readByte(uchar &byte)
85 | {
86 | ByteVector data(readBlock(1));
87 | if(data.size() < 1) return false;
88 | byte = data[0];
89 | return true;
90 | }
91 |
92 | bool Mod::FileBase::readU16L(ushort &number)
93 | {
94 | ByteVector data(readBlock(2));
95 | if(data.size() < 2) return false;
96 | number = data.toUShort(false);
97 | return true;
98 | }
99 |
100 | bool Mod::FileBase::readU32L(ulong &number) {
101 | ByteVector data(readBlock(4));
102 | if(data.size() < 4) return false;
103 | number = data.toUInt(false);
104 | return true;
105 | }
106 |
107 | bool Mod::FileBase::readU16B(ushort &number)
108 | {
109 | ByteVector data(readBlock(2));
110 | if(data.size() < 2) return false;
111 | number = data.toUShort(true);
112 | return true;
113 | }
114 |
115 | bool Mod::FileBase::readU32B(ulong &number) {
116 | ByteVector data(readBlock(4));
117 | if(data.size() < 4) return false;
118 | number = data.toUInt(true);
119 | return true;
120 | }
121 |
--------------------------------------------------------------------------------
/taglib/mod/modfilebase.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #ifndef TAGLIB_MODFILEBASE_H
23 | #define TAGLIB_MODFILEBASE_H
24 |
25 | #include "taglib.h"
26 | #include "tfile.h"
27 | #include "tstring.h"
28 | #include "tlist.h"
29 | #include "taglib_export.h"
30 |
31 | #include
32 |
33 | namespace TagLib {
34 |
35 | namespace Mod {
36 |
37 | class TAGLIB_EXPORT FileBase : public TagLib::File
38 | {
39 | protected:
40 | FileBase(FileName file);
41 | FileBase(IOStream *stream);
42 |
43 | void writeString(const String &s, ulong size, char padding = 0);
44 | void writeByte(uchar byte);
45 | void writeU16L(ushort number);
46 | void writeU32L(ulong number);
47 | void writeU16B(ushort number);
48 | void writeU32B(ulong number);
49 |
50 | bool readString(String &s, ulong size);
51 | bool readByte(uchar &byte);
52 | bool readU16L(ushort &number);
53 | bool readU32L(ulong &number);
54 | bool readU16B(ushort &number);
55 | bool readU32B(ulong &number);
56 | };
57 |
58 | }
59 |
60 | }
61 |
62 | #endif
63 |
--------------------------------------------------------------------------------
/taglib/mod/modfileprivate.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #ifndef TAGLIB_MODFILEPRIVATE_H
23 | #define TAGLIB_MODFILEPRIVATE_H
24 |
25 | // some helper-macros only used internally by (s3m|it|xm)file.cpp
26 | #define READ_ASSERT(cond) \
27 | if(!(cond)) \
28 | { \
29 | setValid(false); \
30 | return; \
31 | }
32 |
33 | #define READ(setter,type,read) \
34 | { \
35 | type number; \
36 | READ_ASSERT(read(number)); \
37 | setter(number); \
38 | }
39 |
40 | #define READ_BYTE(setter) READ(setter,uchar,readByte)
41 | #define READ_U16L(setter) READ(setter,ushort,readU16L)
42 | #define READ_U32L(setter) READ(setter,ulong,readU32L)
43 | #define READ_U16B(setter) READ(setter,ushort,readU16B)
44 | #define READ_U32B(setter) READ(setter,ulong,readU32B)
45 |
46 | #define READ_STRING(setter,size) \
47 | { \
48 | String s; \
49 | READ_ASSERT(readString(s, size)); \
50 | setter(s); \
51 | }
52 |
53 | #define READ_AS(type,name,read) \
54 | type name = 0; \
55 | READ_ASSERT(read(name));
56 |
57 | #define READ_BYTE_AS(name) READ_AS(uchar,name,readByte)
58 | #define READ_U16L_AS(name) READ_AS(ushort,name,readU16L)
59 | #define READ_U32L_AS(name) READ_AS(ulong,name,readU32L)
60 | #define READ_U16B_AS(name) READ_AS(ushort,name,readU16B)
61 | #define READ_U32B_AS(name) READ_AS(ulong,name,readU32B)
62 |
63 | #define READ_STRING_AS(name,size) \
64 | String name; \
65 | READ_ASSERT(readString(name, size));
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/taglib/mod/modproperties.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #include "modproperties.h"
23 |
24 | using namespace TagLib;
25 | using namespace Mod;
26 |
27 | class Mod::Properties::PropertiesPrivate
28 | {
29 | public:
30 | PropertiesPrivate() :
31 | channels(0),
32 | instrumentCount(0),
33 | lengthInPatterns(0)
34 | {
35 | }
36 |
37 | int channels;
38 | uint instrumentCount;
39 | uchar lengthInPatterns;
40 | };
41 |
42 | Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) :
43 | AudioProperties(propertiesStyle),
44 | d(new PropertiesPrivate)
45 | {
46 | }
47 |
48 | Mod::Properties::~Properties()
49 | {
50 | delete d;
51 | }
52 |
53 | int Mod::Properties::length() const
54 | {
55 | return 0;
56 | }
57 |
58 | int Mod::Properties::bitrate() const
59 | {
60 | return 0;
61 | }
62 |
63 | int Mod::Properties::sampleRate() const
64 | {
65 | return 0;
66 | }
67 |
68 | int Mod::Properties::channels() const
69 | {
70 | return d->channels;
71 | }
72 |
73 | TagLib::uint Mod::Properties::instrumentCount() const
74 | {
75 | return d->instrumentCount;
76 | }
77 |
78 | uchar Mod::Properties::lengthInPatterns() const
79 | {
80 | return d->lengthInPatterns;
81 | }
82 |
83 | void Mod::Properties::setChannels(int channels)
84 | {
85 | d->channels = channels;
86 | }
87 |
88 | void Mod::Properties::setInstrumentCount(uint instrumentCount)
89 | {
90 | d->instrumentCount = instrumentCount;
91 | }
92 |
93 | void Mod::Properties::setLengthInPatterns(uchar lengthInPatterns)
94 | {
95 | d->lengthInPatterns = lengthInPatterns;
96 | }
97 |
--------------------------------------------------------------------------------
/taglib/mod/modproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #ifndef TAGLIB_MODPROPERTIES_H
23 | #define TAGLIB_MODPROPERTIES_H
24 |
25 | #include "taglib.h"
26 | #include "audioproperties.h"
27 |
28 | namespace TagLib {
29 |
30 | namespace Mod {
31 |
32 | class TAGLIB_EXPORT Properties : public AudioProperties
33 | {
34 | public:
35 | Properties(AudioProperties::ReadStyle propertiesStyle);
36 | virtual ~Properties();
37 |
38 | int length() const;
39 | int bitrate() const;
40 | int sampleRate() const;
41 | int channels() const;
42 |
43 | uint instrumentCount() const;
44 | uchar lengthInPatterns() const;
45 |
46 | void setChannels(int channels);
47 |
48 | void setInstrumentCount(uint sampleCount);
49 | void setLengthInPatterns(uchar lengthInPatterns);
50 |
51 | private:
52 | friend class File;
53 |
54 | Properties(const Properties&);
55 | Properties &operator=(const Properties&);
56 |
57 | class PropertiesPrivate;
58 | PropertiesPrivate *d;
59 | };
60 |
61 | }
62 |
63 | }
64 |
65 | #endif
66 |
--------------------------------------------------------------------------------
/taglib/mp4/mp4coverart.cpp:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2009 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include
27 | #include
28 | #include "trefcounter.h"
29 | #include "mp4coverart.h"
30 |
31 | using namespace TagLib;
32 |
33 | class MP4::CoverArt::CoverArtPrivate : public RefCounter
34 | {
35 | public:
36 | CoverArtPrivate() : RefCounter(), format(MP4::CoverArt::JPEG) {}
37 |
38 | Format format;
39 | ByteVector data;
40 | };
41 |
42 | MP4::CoverArt::CoverArt(Format format, const ByteVector &data)
43 | {
44 | d = new CoverArtPrivate;
45 | d->format = format;
46 | d->data = data;
47 | }
48 |
49 | MP4::CoverArt::CoverArt(const CoverArt &item) : d(item.d)
50 | {
51 | d->ref();
52 | }
53 |
54 | MP4::CoverArt &
55 | MP4::CoverArt::operator=(const CoverArt &item)
56 | {
57 | if(d->deref()) {
58 | delete d;
59 | }
60 | d = item.d;
61 | d->ref();
62 | return *this;
63 | }
64 |
65 | MP4::CoverArt::~CoverArt()
66 | {
67 | if(d->deref()) {
68 | delete d;
69 | }
70 | }
71 |
72 | MP4::CoverArt::Format
73 | MP4::CoverArt::format() const
74 | {
75 | return d->format;
76 | }
77 |
78 | ByteVector
79 | MP4::CoverArt::data() const
80 | {
81 | return d->data;
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/taglib/mp4/mp4coverart.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2009 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_MP4COVERART_H
27 | #define TAGLIB_MP4COVERART_H
28 |
29 | #include "tlist.h"
30 | #include "tbytevector.h"
31 | #include "taglib_export.h"
32 | #include "mp4atom.h"
33 |
34 | namespace TagLib {
35 |
36 | namespace MP4 {
37 |
38 | class TAGLIB_EXPORT CoverArt
39 | {
40 | public:
41 | /*!
42 | * This describes the image type.
43 | */
44 | enum Format {
45 | JPEG = TypeJPEG,
46 | PNG = TypePNG,
47 | BMP = TypeBMP,
48 | GIF = TypeGIF,
49 | Unknown = TypeImplicit,
50 | };
51 |
52 | CoverArt(Format format, const ByteVector &data);
53 | ~CoverArt();
54 |
55 | CoverArt(const CoverArt &item);
56 | CoverArt &operator=(const CoverArt &item);
57 |
58 | //! Format of the image
59 | Format format() const;
60 |
61 | //! The image data
62 | ByteVector data() const;
63 |
64 | private:
65 | class CoverArtPrivate;
66 | CoverArtPrivate *d;
67 | };
68 |
69 | typedef List CoverArtList;
70 |
71 | }
72 |
73 | }
74 |
75 | #endif
76 |
--------------------------------------------------------------------------------
/taglib/mp4/mp4item.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2007 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_MP4ITEM_H
27 | #define TAGLIB_MP4ITEM_H
28 |
29 | #include "tstringlist.h"
30 | #include "mp4coverart.h"
31 | #include "taglib_export.h"
32 |
33 | namespace TagLib {
34 |
35 | namespace MP4 {
36 |
37 | class TAGLIB_EXPORT Item
38 | {
39 | public:
40 | struct IntPair {
41 | int first, second;
42 | };
43 |
44 | Item();
45 | Item(const Item &item);
46 | Item &operator=(const Item &item);
47 | ~Item();
48 |
49 | Item(int value);
50 | Item(uchar value);
51 | Item(uint value);
52 | Item(long long value);
53 | Item(bool value);
54 | Item(int first, int second);
55 | Item(const StringList &value);
56 | Item(const ByteVectorList &value);
57 | Item(const CoverArtList &value);
58 |
59 | void setAtomDataType(AtomDataType type);
60 | AtomDataType atomDataType() const;
61 |
62 | int toInt() const;
63 | uchar toByte() const;
64 | uint toUInt() const;
65 | long long toLongLong() const;
66 | bool toBool() const;
67 | IntPair toIntPair() const;
68 | StringList toStringList() const;
69 | ByteVectorList toByteVectorList() const;
70 | CoverArtList toCoverArtList() const;
71 |
72 | bool isValid() const;
73 |
74 | private:
75 | class ItemPrivate;
76 | ItemPrivate *d;
77 | };
78 |
79 | }
80 |
81 | }
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/taglib/mp4/mp4properties.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************
2 | copyright : (C) 2007 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 | **************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_MP4PROPERTIES_H
27 | #define TAGLIB_MP4PROPERTIES_H
28 |
29 | #include "taglib_export.h"
30 | #include "audioproperties.h"
31 |
32 | namespace TagLib {
33 |
34 | namespace MP4 {
35 |
36 | class Atoms;
37 | class File;
38 |
39 | //! An implementation of MP4 audio properties
40 | class TAGLIB_EXPORT Properties : public AudioProperties
41 | {
42 | public:
43 | enum Codec {
44 | Unknown = 0,
45 | AAC,
46 | ALAC
47 | };
48 |
49 | Properties(File *file, Atoms *atoms, ReadStyle style = Average);
50 | virtual ~Properties();
51 |
52 | virtual int length() const;
53 | virtual int bitrate() const;
54 | virtual int sampleRate() const;
55 | virtual int channels() const;
56 | virtual int bitsPerSample() const;
57 | bool isEncrypted() const;
58 |
59 | //! Audio codec used in the MP4 file
60 | Codec codec() const;
61 |
62 | private:
63 | class PropertiesPrivate;
64 | PropertiesPrivate *d;
65 | };
66 |
67 | }
68 |
69 | }
70 |
71 | #endif
72 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v1/id3v1genres.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_ID3V1GENRE_H
27 | #define TAGLIB_ID3V1GENRE_H
28 |
29 | #include "tmap.h"
30 | #include "tstringlist.h"
31 | #include "taglib_export.h"
32 |
33 | namespace TagLib {
34 | namespace ID3v1 {
35 |
36 | typedef Map GenreMap;
37 |
38 | /*!
39 | * Returns the list of canonical ID3v1 genre names in the order that they
40 | * are listed in the standard.
41 | */
42 | StringList TAGLIB_EXPORT genreList();
43 |
44 | /*!
45 | * A "reverse mapping" that goes from the canonical ID3v1 genre name to the
46 | * respective genre number. genreMap()["Rock"] ==
47 | */
48 | GenreMap TAGLIB_EXPORT genreMap();
49 |
50 | /*!
51 | * Returns the name of the genre at \a index in the ID3v1 genre list. If
52 | * \a index is out of range -- less than zero or greater than 146 -- a null
53 | * string will be returned.
54 | */
55 | String TAGLIB_EXPORT genre(int index);
56 |
57 | /*!
58 | * Returns the genre index for the (case sensitive) genre \a name. If the
59 | * genre is not in the list 255 (which signifies an unknown genre in ID3v1)
60 | * will be returned.
61 | */
62 | int TAGLIB_EXPORT genreIndex(const String &name);
63 | }
64 | }
65 |
66 | #endif
67 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/frames/privateframe.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2008 by Serkan Kalyoncu
3 | copyright : (C) 2008 by Scott Wheeler
4 | email : wheeler@kde.org
5 | ***************************************************************************/
6 |
7 | /***************************************************************************
8 | * This library is free software; you can redistribute it and/or modify *
9 | * it under the terms of the GNU Lesser General Public License version *
10 | * 2.1 as published by the Free Software Foundation. *
11 | * *
12 | * This library is distributed in the hope that it will be useful, but *
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15 | * Lesser General Public License for more details. *
16 | * *
17 | * You should have received a copy of the GNU Lesser General Public *
18 | * License along with this library; if not, write to the Free Software *
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
20 | * 02110-1301 USA *
21 | * *
22 | * Alternatively, this file is available under the Mozilla Public *
23 | * License Version 1.1. You may obtain a copy of the License at *
24 | * http://www.mozilla.org/MPL/ *
25 | ***************************************************************************/
26 |
27 | #ifndef TAGLIB_PRIVATEFRAME_H
28 | #define TAGLIB_PRIVATEFRAME_H
29 |
30 | #include "id3v2frame.h"
31 | #include "taglib_export.h"
32 |
33 | namespace TagLib {
34 |
35 | namespace ID3v2 {
36 |
37 | //! An implementation of ID3v2 privateframe
38 |
39 | class TAGLIB_EXPORT PrivateFrame : public Frame
40 | {
41 | friend class FrameFactory;
42 |
43 | public:
44 | /*!
45 | * Construct an empty private frame.
46 | */
47 | PrivateFrame();
48 |
49 | /*!
50 | * Construct a private frame based on the data in \a data.
51 | *
52 | * \note This is the constructor used when parsing the frame from a file.
53 | */
54 | explicit PrivateFrame(const ByteVector &data);
55 |
56 | /*!
57 | * Destroys this private frame instance.
58 | */
59 | virtual ~PrivateFrame();
60 |
61 | /*!
62 | * Returns the text of this private frame, currently just the owner.
63 | *
64 | * \see text()
65 | */
66 | virtual String toString() const;
67 |
68 | /*!
69 | * \return The owner of the private frame.
70 | * \note This should contain an email address or link to a website.
71 | */
72 | String owner() const;
73 |
74 | /*!
75 | *
76 | */
77 | ByteVector data() const;
78 |
79 | /*!
80 | * Sets the owner of the frame to \a s.
81 | * \note This should contain an email address or link to a website.
82 | */
83 | void setOwner(const String &s);
84 |
85 | /*!
86 | *
87 | */
88 | void setData(const ByteVector &v);
89 |
90 | protected:
91 | // Reimplementations.
92 |
93 | virtual void parseFields(const ByteVector &data);
94 | virtual ByteVector renderFields() const;
95 |
96 | private:
97 | /*!
98 | * The constructor used by the FrameFactory.
99 | */
100 | PrivateFrame(const ByteVector &data, Header *h);
101 |
102 | PrivateFrame(const PrivateFrame &);
103 | PrivateFrame &operator=(const PrivateFrame &);
104 |
105 | class PrivateFramePrivate;
106 | PrivateFramePrivate *d;
107 | };
108 |
109 | }
110 | }
111 | #endif
112 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/frames/unknownframe.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include "unknownframe.h"
27 |
28 | using namespace TagLib;
29 | using namespace ID3v2;
30 |
31 | class UnknownFrame::UnknownFramePrivate
32 | {
33 | public:
34 | ByteVector fieldData;
35 | };
36 |
37 | ////////////////////////////////////////////////////////////////////////////////
38 | // public members
39 | ////////////////////////////////////////////////////////////////////////////////
40 |
41 | UnknownFrame::UnknownFrame(const ByteVector &data) : Frame(data)
42 | {
43 | d = new UnknownFramePrivate;
44 | setData(data);
45 | }
46 |
47 | UnknownFrame::~UnknownFrame()
48 | {
49 | delete d;
50 | }
51 |
52 | String UnknownFrame::toString() const
53 | {
54 | return String::null;
55 | }
56 |
57 | ByteVector UnknownFrame::data() const
58 | {
59 | return d->fieldData;
60 | }
61 |
62 | ////////////////////////////////////////////////////////////////////////////////
63 | // protected members
64 | ////////////////////////////////////////////////////////////////////////////////
65 |
66 | void UnknownFrame::parseFields(const ByteVector &data)
67 | {
68 | d->fieldData = data;
69 | }
70 |
71 | ByteVector UnknownFrame::renderFields() const
72 | {
73 | return d->fieldData;
74 | }
75 |
76 | ////////////////////////////////////////////////////////////////////////////////
77 | // private members
78 | ////////////////////////////////////////////////////////////////////////////////
79 |
80 | UnknownFrame::UnknownFrame(const ByteVector &data, Header *h) : Frame(h)
81 | {
82 | d = new UnknownFramePrivate;
83 | parseFields(fieldData(data));
84 | }
85 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/frames/unknownframe.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_UNKNOWNFRAME_H
27 | #define TAGLIB_UNKNOWNFRAME_H
28 |
29 | #include "id3v2frame.h"
30 | #include "taglib_export.h"
31 |
32 | namespace TagLib {
33 |
34 | namespace ID3v2 {
35 |
36 | //! A frame type \e unknown to TagLib.
37 |
38 | /*!
39 | * This class represents a frame type not known (or more often simply
40 | * unimplemented) in TagLib. This is here provide a basic API for
41 | * manipulating the binary data of unknown frames and to provide a means
42 | * of rendering such \e unknown frames.
43 | *
44 | * Please note that a cleaner way of handling frame types that TagLib
45 | * does not understand is to subclass ID3v2::Frame and ID3v2::FrameFactory
46 | * to have your frame type supported through the standard ID3v2 mechanism.
47 | */
48 |
49 | class TAGLIB_EXPORT UnknownFrame : public Frame
50 | {
51 | friend class FrameFactory;
52 |
53 | public:
54 | UnknownFrame(const ByteVector &data);
55 | virtual ~UnknownFrame();
56 |
57 | virtual String toString() const;
58 |
59 | /*!
60 | * Returns the field data (everything but the header) for this frame.
61 | */
62 | ByteVector data() const;
63 |
64 | protected:
65 | virtual void parseFields(const ByteVector &data);
66 | virtual ByteVector renderFields() const;
67 |
68 | private:
69 | UnknownFrame(const ByteVector &data, Header *h);
70 | UnknownFrame(const UnknownFrame &);
71 | UnknownFrame &operator=(const UnknownFrame &);
72 |
73 | class UnknownFramePrivate;
74 | UnknownFramePrivate *d;
75 | };
76 |
77 | }
78 | }
79 | #endif
80 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2.2.0.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/taglib/mpeg/id3v2/id3v2.2.0.txt
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2.3.0.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/taglib/mpeg/id3v2/id3v2.3.0.txt
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2.4.0-frames.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/taglib/mpeg/id3v2/id3v2.4.0-frames.txt
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2.4.0-structure.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kxtry/czys/fb151a2b1c3ca49c0e5decc7791df0cd28daf28b/taglib/mpeg/id3v2/id3v2.4.0-structure.txt
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2extendedheader.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include "id3v2extendedheader.h"
27 | #include "id3v2synchdata.h"
28 |
29 | using namespace TagLib;
30 | using namespace ID3v2;
31 |
32 | class ExtendedHeader::ExtendedHeaderPrivate
33 | {
34 | public:
35 | ExtendedHeaderPrivate() : size(0) {}
36 |
37 | uint size;
38 | };
39 |
40 | ////////////////////////////////////////////////////////////////////////////////
41 | // public methods
42 | ////////////////////////////////////////////////////////////////////////////////
43 |
44 | ExtendedHeader::ExtendedHeader()
45 | {
46 | d = new ExtendedHeaderPrivate();
47 | }
48 |
49 | ExtendedHeader::~ExtendedHeader()
50 | {
51 | delete d;
52 | }
53 |
54 | TagLib::uint ExtendedHeader::size() const
55 | {
56 | return d->size;
57 | }
58 |
59 | void ExtendedHeader::setData(const ByteVector &data)
60 | {
61 | parse(data);
62 | }
63 |
64 | ////////////////////////////////////////////////////////////////////////////////
65 | // protected members
66 | ////////////////////////////////////////////////////////////////////////////////
67 |
68 | void ExtendedHeader::parse(const ByteVector &data)
69 | {
70 | d->size = SynchData::toUInt(data.mid(0, 4)); // (structure 3.2 "Extended header size")
71 | }
72 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2extendedheader.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_ID3V2EXTENDEDHEADER_H
27 | #define TAGLIB_ID3V2EXTENDEDHEADER_H
28 |
29 | #include "taglib_export.h"
30 | #include "tbytevector.h"
31 | #include "taglib.h"
32 |
33 | namespace TagLib {
34 |
35 | namespace ID3v2 {
36 |
37 | //! ID3v2 extended header implementation
38 |
39 | /*!
40 | * This class implements ID3v2 extended headers. It attempts to follow,
41 | * both semantically and programatically, the structure specified in
42 | * the ID3v2 standard. The API is based on the properties of ID3v2 extended
43 | * headers specified there. If any of the terms used in this documentation
44 | * are unclear please check the specification in the linked section.
45 | * (Structure, 3.2)
46 | */
47 |
48 | class TAGLIB_EXPORT ExtendedHeader
49 | {
50 | public:
51 | /*!
52 | * Constructs an empty ID3v2 extended header.
53 | */
54 | ExtendedHeader();
55 |
56 | /*!
57 | * Destroys the extended header.
58 | */
59 | virtual ~ExtendedHeader();
60 |
61 | /*!
62 | * Returns the size of the extended header. This is variable for the
63 | * extended header.
64 | */
65 | uint size() const;
66 |
67 | /*!
68 | * Sets the data that will be used as the extended header. Since the
69 | * length is not known before the extended header has been parsed, this
70 | * should just be a pointer to the first byte of the extended header. It
71 | * will determine the length internally and make that available through
72 | * size().
73 | */
74 | void setData(const ByteVector &data);
75 |
76 | protected:
77 | /*!
78 | * Called by setData() to parse the extended header data. It makes this
79 | * information available through the public API.
80 | */
81 | void parse(const ByteVector &data);
82 |
83 | private:
84 | ExtendedHeader(const ExtendedHeader &);
85 | ExtendedHeader &operator=(const ExtendedHeader &);
86 |
87 | class ExtendedHeaderPrivate;
88 | ExtendedHeaderPrivate *d;
89 | };
90 |
91 | }
92 | }
93 | #endif
94 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2footer.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include "id3v2footer.h"
27 | #include "id3v2header.h"
28 |
29 | using namespace TagLib;
30 | using namespace ID3v2;
31 |
32 | class Footer::FooterPrivate
33 | {
34 | public:
35 | static const uint size = 10;
36 | };
37 |
38 | Footer::Footer()
39 | {
40 |
41 | }
42 |
43 | Footer::~Footer()
44 | {
45 |
46 | }
47 |
48 | TagLib::uint Footer::size()
49 | {
50 | return FooterPrivate::size;
51 | }
52 |
53 | ByteVector Footer::render(const Header *header) const
54 | {
55 | ByteVector headerData = header->render();
56 | headerData[0] = '3';
57 | headerData[1] = 'D';
58 | headerData[2] = 'I';
59 | return headerData;
60 | }
61 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2footer.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_ID3V2FOOTER_H
27 | #define TAGLIB_ID3V2FOOTER_H
28 |
29 | #include "taglib_export.h"
30 | #include "tbytevector.h"
31 |
32 | namespace TagLib {
33 |
34 | namespace ID3v2 {
35 |
36 | class Header;
37 |
38 | //! ID3v2 footer implementation
39 |
40 | /*!
41 | * Per the ID3v2 specification, the tag's footer is just a copy of the
42 | * information in the header. As such there is no API for reading the
43 | * data from the header, it can just as easily be done from the header.
44 | *
45 | * In fact, at this point, TagLib does not even parse the footer since
46 | * it is not useful internally. However, if the flag to include a footer
47 | * has been set in the ID3v2::Tag, TagLib will render a footer.
48 | */
49 |
50 | class TAGLIB_EXPORT Footer
51 | {
52 | public:
53 | /*!
54 | * Constructs an empty ID3v2 footer.
55 | */
56 | Footer();
57 | /*!
58 | * Destroys the footer.
59 | */
60 | virtual ~Footer();
61 |
62 | /*!
63 | * Returns the size of the footer. Presently this is always 10 bytes.
64 | */
65 | static uint size();
66 |
67 | /*!
68 | * Renders the footer based on the data in \a header.
69 | */
70 | ByteVector render(const Header *header) const;
71 |
72 | private:
73 | Footer(const Footer &);
74 | Footer &operator=(const Footer &);
75 |
76 | class FooterPrivate;
77 | FooterPrivate *d;
78 | };
79 |
80 | }
81 | }
82 | #endif
83 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2synchdata.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include
27 |
28 | #include "id3v2synchdata.h"
29 |
30 | using namespace TagLib;
31 | using namespace ID3v2;
32 |
33 | TagLib::uint SynchData::toUInt(const ByteVector &data)
34 | {
35 | uint sum = 0;
36 | bool notSynchSafe = false;
37 | int last = data.size() > 4 ? 3 : data.size() - 1;
38 |
39 | for(int i = 0; i <= last; i++) {
40 | if(data[i] & 0x80) {
41 | notSynchSafe = true;
42 | break;
43 | }
44 |
45 | sum |= (data[i] & 0x7f) << ((last - i) * 7);
46 | }
47 |
48 | if(notSynchSafe) {
49 | // Invalid data; assume this was created by some buggy software that just
50 | // put normal integers here rather than syncsafe ones, and try it that
51 | // way.
52 | if(data.size() >= 4) {
53 | sum = data.toUInt(0, true);
54 | }
55 | else {
56 | ByteVector tmp(data);
57 | tmp.resize(4);
58 | sum = tmp.toUInt(0, true);
59 | }
60 | }
61 |
62 | return sum;
63 | }
64 |
65 | ByteVector SynchData::fromUInt(uint value)
66 | {
67 | ByteVector v(4, 0);
68 |
69 | for(int i = 0; i < 4; i++)
70 | v[i] = uchar(value >> ((3 - i) * 7) & 0x7f);
71 |
72 | return v;
73 | }
74 |
75 | ByteVector SynchData::decode(const ByteVector &data)
76 | {
77 | ByteVector result = data;
78 |
79 | ByteVector pattern(2, char(0));
80 | pattern[0] = '\xFF';
81 | pattern[1] = '\x00';
82 |
83 | return result.replace(pattern, '\xFF');
84 | }
85 |
--------------------------------------------------------------------------------
/taglib/mpeg/id3v2/id3v2synchdata.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_ID3V2SYNCHDATA_H
27 | #define TAGLIB_ID3V2SYNCHDATA_H
28 |
29 | #include "tbytevector.h"
30 | #include "taglib.h"
31 |
32 | namespace TagLib {
33 |
34 | namespace ID3v2 {
35 |
36 | //! A few functions for ID3v2 synch safe integer conversion
37 |
38 | /*!
39 | * In the ID3v2.4 standard most integer values are encoded as "synch safe"
40 | * integers which are encoded in such a way that they will not give false
41 | * MPEG syncs and confuse MPEG decoders. This namespace provides some
42 | * methods for converting to and from these values to ByteVectors for
43 | * things rendering and parsing ID3v2 data.
44 | */
45 |
46 | namespace SynchData
47 | {
48 | /*!
49 | * This returns the unsigned integer value of \a data where \a data is a
50 | * ByteVector that contains a \e synchsafe integer (Structure,
51 | * 6.2). The default \a length of
52 | * 4 is used if another value is not specified.
53 | */
54 | TAGLIB_EXPORT uint toUInt(const ByteVector &data);
55 |
56 | /*!
57 | * Returns a 4 byte (32 bit) synchsafe integer based on \a value.
58 | */
59 | TAGLIB_EXPORT ByteVector fromUInt(uint value);
60 |
61 | /*!
62 | * Convert the data from unsynchronized data to its original format.
63 | */
64 | TAGLIB_EXPORT ByteVector decode(const ByteVector &input);
65 | }
66 |
67 | }
68 | }
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/taglib/mpeg/mpegproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_MPEGPROPERTIES_H
27 | #define TAGLIB_MPEGPROPERTIES_H
28 |
29 | #include "taglib_export.h"
30 | #include "audioproperties.h"
31 |
32 | #include "mpegheader.h"
33 |
34 | namespace TagLib {
35 |
36 | namespace MPEG {
37 |
38 | class File;
39 | class XingHeader;
40 |
41 | //! An implementation of audio property reading for MP3
42 |
43 | /*!
44 | * This reads the data from an MPEG Layer III stream found in the
45 | * AudioProperties API.
46 | */
47 |
48 | class TAGLIB_EXPORT Properties : public AudioProperties
49 | {
50 | public:
51 | /*!
52 | * Create an instance of MPEG::Properties with the data read from the
53 | * MPEG::File \a file.
54 | */
55 | Properties(File *file, ReadStyle style = Average);
56 |
57 | /*!
58 | * Destroys this MPEG Properties instance.
59 | */
60 | virtual ~Properties();
61 |
62 | // Reimplementations.
63 |
64 | virtual int length() const;
65 | virtual int bitrate() const;
66 | virtual int sampleRate() const;
67 | virtual int channels() const;
68 |
69 | /*!
70 | * Returns a pointer to the XingHeader if one exists or null if no
71 | * XingHeader was found.
72 | */
73 |
74 | const XingHeader *xingHeader() const;
75 |
76 | /*!
77 | * Returns the MPEG Version of the file.
78 | */
79 | Header::Version version() const;
80 |
81 | /*!
82 | * Returns the layer version. This will be between the values 1-3.
83 | */
84 | int layer() const;
85 |
86 | /*!
87 | * Returns true if the MPEG protection bit is enabled.
88 | */
89 | bool protectionEnabled() const;
90 |
91 | /*!
92 | * Returns the channel mode for this frame.
93 | */
94 | Header::ChannelMode channelMode() const;
95 |
96 | /*!
97 | * Returns true if the copyrighted bit is set.
98 | */
99 | bool isCopyrighted() const;
100 |
101 | /*!
102 | * Returns true if the "original" bit is set.
103 | */
104 | bool isOriginal() const;
105 |
106 | private:
107 | Properties(const Properties &);
108 | Properties &operator=(const Properties &);
109 |
110 | void read();
111 |
112 | class PropertiesPrivate;
113 | PropertiesPrivate *d;
114 | };
115 | }
116 | }
117 |
118 | #endif
119 |
--------------------------------------------------------------------------------
/taglib/mpeg/xingheader.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2003 by Ismael Orenstein
3 | email : orenstein@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | #include "xingheader.h"
31 |
32 | using namespace TagLib;
33 |
34 | class MPEG::XingHeader::XingHeaderPrivate
35 | {
36 | public:
37 | XingHeaderPrivate() :
38 | frames(0),
39 | size(0),
40 | valid(false)
41 | {}
42 |
43 | uint frames;
44 | uint size;
45 | bool valid;
46 | };
47 |
48 | MPEG::XingHeader::XingHeader(const ByteVector &data)
49 | {
50 | d = new XingHeaderPrivate;
51 | parse(data);
52 | }
53 |
54 | MPEG::XingHeader::~XingHeader()
55 | {
56 | delete d;
57 | }
58 |
59 | bool MPEG::XingHeader::isValid() const
60 | {
61 | return d->valid;
62 | }
63 |
64 | TagLib::uint MPEG::XingHeader::totalFrames() const
65 | {
66 | return d->frames;
67 | }
68 |
69 | TagLib::uint MPEG::XingHeader::totalSize() const
70 | {
71 | return d->size;
72 | }
73 |
74 | int MPEG::XingHeader::xingHeaderOffset(TagLib::MPEG::Header::Version v,
75 | TagLib::MPEG::Header::ChannelMode c)
76 | {
77 | if(v == MPEG::Header::Version1) {
78 | if(c == MPEG::Header::SingleChannel)
79 | return 0x15;
80 | else
81 | return 0x24;
82 | }
83 | else {
84 | if(c == MPEG::Header::SingleChannel)
85 | return 0x0D;
86 | else
87 | return 0x15;
88 | }
89 | }
90 |
91 | void MPEG::XingHeader::parse(const ByteVector &data)
92 | {
93 | // Check to see if a valid Xing header is available.
94 |
95 | if(!data.startsWith("Xing") && !data.startsWith("Info"))
96 | return;
97 |
98 | // If the XingHeader doesn't contain the number of frames and the total stream
99 | // info it's invalid.
100 |
101 | if(!(data[7] & 0x01)) {
102 | debug("MPEG::XingHeader::parse() -- Xing header doesn't contain the total number of frames.");
103 | return;
104 | }
105 |
106 | if(!(data[7] & 0x02)) {
107 | debug("MPEG::XingHeader::parse() -- Xing header doesn't contain the total stream size.");
108 | return;
109 | }
110 |
111 | d->frames = data.toUInt(8U);
112 | d->size = data.toUInt(12U);
113 |
114 | d->valid = true;
115 | }
116 |
--------------------------------------------------------------------------------
/taglib/mpeg/xingheader.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2003 by Ismael Orenstein
3 | email : orenstein@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_XINGHEADER_H
27 | #define TAGLIB_XINGHEADER_H
28 |
29 | #include "mpegheader.h"
30 | #include "taglib_export.h"
31 |
32 | namespace TagLib {
33 |
34 | class ByteVector;
35 |
36 | namespace MPEG {
37 |
38 | //! An implementation of the Xing VBR headers
39 |
40 | /*!
41 | * This is a minimalistic implementation of the Xing VBR headers. Xing
42 | * headers are often added to VBR (variable bit rate) MP3 streams to make it
43 | * easy to compute the length and quality of a VBR stream. Our implementation
44 | * is only concerned with the total size of the stream (so that we can
45 | * calculate the total playing time and the average bitrate). It uses
46 | * this text
47 | * and the XMMS sources as references.
48 | */
49 |
50 | class TAGLIB_EXPORT XingHeader
51 | {
52 | public:
53 | /*!
54 | * Parses a Xing header based on \a data. The data must be at least 16
55 | * bytes long (anything longer than this is discarded).
56 | */
57 | XingHeader(const ByteVector &data);
58 |
59 | /*!
60 | * Destroy this XingHeader instance.
61 | */
62 | virtual ~XingHeader();
63 |
64 | /*!
65 | * Returns true if the data was parsed properly and if there is a valid
66 | * Xing header present.
67 | */
68 | bool isValid() const;
69 |
70 | /*!
71 | * Returns the total number of frames.
72 | */
73 | uint totalFrames() const;
74 |
75 | /*!
76 | * Returns the total size of stream in bytes.
77 | */
78 | uint totalSize() const;
79 |
80 | /*!
81 | * Returns the offset for the start of this Xing header, given the
82 | * version and channels of the frame
83 | */
84 | // BIC: rename to offset()
85 | static int xingHeaderOffset(TagLib::MPEG::Header::Version v,
86 | TagLib::MPEG::Header::ChannelMode c);
87 |
88 | private:
89 | XingHeader(const XingHeader &);
90 | XingHeader &operator=(const XingHeader &);
91 |
92 | void parse(const ByteVector &data);
93 |
94 | class XingHeaderPrivate;
95 | XingHeaderPrivate *d;
96 | };
97 | }
98 | }
99 |
100 | #endif
101 |
--------------------------------------------------------------------------------
/taglib/ogg/opus/opusproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2012 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 |
5 | copyright : (C) 2002 - 2008 by Scott Wheeler
6 | email : wheeler@kde.org
7 | (original Vorbis implementation)
8 | ***************************************************************************/
9 |
10 | /***************************************************************************
11 | * This library is free software; you can redistribute it and/or modify *
12 | * it under the terms of the GNU Lesser General Public License version *
13 | * 2.1 as published by the Free Software Foundation. *
14 | * *
15 | * This library is distributed in the hope that it will be useful, but *
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
18 | * Lesser General Public License for more details. *
19 | * *
20 | * You should have received a copy of the GNU Lesser General Public *
21 | * License along with this library; if not, write to the Free Software *
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
23 | * 02110-1301 USA *
24 | * *
25 | * Alternatively, this file is available under the Mozilla Public *
26 | * License Version 1.1. You may obtain a copy of the License at *
27 | * http://www.mozilla.org/MPL/ *
28 | ***************************************************************************/
29 |
30 | #ifndef TAGLIB_OPUSPROPERTIES_H
31 | #define TAGLIB_OPUSPROPERTIES_H
32 |
33 | #include "audioproperties.h"
34 |
35 | namespace TagLib {
36 |
37 | namespace Ogg {
38 |
39 | namespace Opus {
40 |
41 | class File;
42 |
43 | //! An implementation of audio property reading for Ogg Opus
44 |
45 | /*!
46 | * This reads the data from an Ogg Opus stream found in the AudioProperties
47 | * API.
48 | */
49 |
50 | class TAGLIB_EXPORT Properties : public AudioProperties
51 | {
52 | public:
53 | /*!
54 | * Create an instance of Opus::Properties with the data read from the
55 | * Opus::File \a file.
56 | */
57 | Properties(File *file, ReadStyle style = Average);
58 |
59 | /*!
60 | * Destroys this Opus::Properties instance.
61 | */
62 | virtual ~Properties();
63 |
64 | // Reimplementations.
65 |
66 | virtual int length() const;
67 | virtual int bitrate() const;
68 | virtual int sampleRate() const;
69 | virtual int channels() const;
70 |
71 | /*!
72 | * The Opus codec supports decoding at multiple sample rates, there is no
73 | * single sample rate of the encoded stream. This returns the sample rate
74 | * of the original audio stream.
75 | */
76 | int inputSampleRate() const;
77 |
78 | /*!
79 | * Returns the Opus version, currently "0" (as specified by the spec).
80 | */
81 | int opusVersion() const;
82 |
83 | private:
84 | Properties(const Properties &);
85 | Properties &operator=(const Properties &);
86 |
87 | void read();
88 |
89 | class PropertiesPrivate;
90 | PropertiesPrivate *d;
91 | };
92 | }
93 | }
94 | }
95 |
96 | #endif
97 |
--------------------------------------------------------------------------------
/taglib/ogg/speex/speexproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2006 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 |
5 | copyright : (C) 2002 - 2008 by Scott Wheeler
6 | email : wheeler@kde.org
7 | (original Vorbis implementation)
8 | ***************************************************************************/
9 |
10 | /***************************************************************************
11 | * This library is free software; you can redistribute it and/or modify *
12 | * it under the terms of the GNU Lesser General Public License version *
13 | * 2.1 as published by the Free Software Foundation. *
14 | * *
15 | * This library is distributed in the hope that it will be useful, but *
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
18 | * Lesser General Public License for more details. *
19 | * *
20 | * You should have received a copy of the GNU Lesser General Public *
21 | * License along with this library; if not, write to the Free Software *
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
23 | * 02110-1301 USA *
24 | * *
25 | * Alternatively, this file is available under the Mozilla Public *
26 | * License Version 1.1. You may obtain a copy of the License at *
27 | * http://www.mozilla.org/MPL/ *
28 | ***************************************************************************/
29 |
30 | #ifndef TAGLIB_SPEEXPROPERTIES_H
31 | #define TAGLIB_SPEEXPROPERTIES_H
32 |
33 | #include "audioproperties.h"
34 |
35 | namespace TagLib {
36 |
37 | namespace Ogg {
38 |
39 | namespace Speex {
40 |
41 | class File;
42 |
43 | //! An implementation of audio property reading for Ogg Speex
44 |
45 | /*!
46 | * This reads the data from an Ogg Speex stream found in the AudioProperties
47 | * API.
48 | */
49 |
50 | class TAGLIB_EXPORT Properties : public AudioProperties
51 | {
52 | public:
53 | /*!
54 | * Create an instance of Speex::Properties with the data read from the
55 | * Speex::File \a file.
56 | */
57 | Properties(File *file, ReadStyle style = Average);
58 |
59 | /*!
60 | * Destroys this Speex::Properties instance.
61 | */
62 | virtual ~Properties();
63 |
64 | // Reimplementations.
65 |
66 | virtual int length() const;
67 | virtual int bitrate() const;
68 | virtual int sampleRate() const;
69 | virtual int channels() const;
70 |
71 | /*!
72 | * Returns the Speex version, currently "0" (as specified by the spec).
73 | */
74 | int speexVersion() const;
75 |
76 | private:
77 | Properties(const Properties &);
78 | Properties &operator=(const Properties &);
79 |
80 | void read();
81 |
82 | class PropertiesPrivate;
83 | PropertiesPrivate *d;
84 | };
85 | }
86 | }
87 | }
88 |
89 | #endif
90 |
--------------------------------------------------------------------------------
/taglib/riff/aiff/aiffproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_AIFFPROPERTIES_H
27 | #define TAGLIB_AIFFPROPERTIES_H
28 |
29 | #include "audioproperties.h"
30 |
31 | namespace TagLib {
32 |
33 | namespace RIFF {
34 |
35 | namespace AIFF {
36 |
37 | class File;
38 |
39 | //! An implementation of audio property reading for AIFF
40 |
41 | /*!
42 | * This reads the data from an AIFF stream found in the AudioProperties
43 | * API.
44 | */
45 |
46 | class TAGLIB_EXPORT Properties : public AudioProperties
47 | {
48 | public:
49 | /*!
50 | * Create an instance of AIFF::Properties with the data read from the
51 | * ByteVector \a data.
52 | */
53 | Properties(const ByteVector &data, ReadStyle style);
54 |
55 | /*!
56 | * Destroys this AIFF::Properties instance.
57 | */
58 | virtual ~Properties();
59 |
60 | // Reimplementations.
61 |
62 | virtual int length() const;
63 | virtual int bitrate() const;
64 | virtual int sampleRate() const;
65 | virtual int channels() const;
66 |
67 | int sampleWidth() const;
68 | uint sampleFrames() const;
69 |
70 | private:
71 | Properties(const Properties &);
72 | Properties &operator=(const Properties &);
73 |
74 | void read(const ByteVector &data);
75 |
76 | class PropertiesPrivate;
77 | PropertiesPrivate *d;
78 | };
79 | }
80 | }
81 | }
82 |
83 | #endif
84 |
--------------------------------------------------------------------------------
/taglib/riff/wav/wavproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_WAVPROPERTIES_H
27 | #define TAGLIB_WAVPROPERTIES_H
28 |
29 | #include "taglib.h"
30 | #include "audioproperties.h"
31 |
32 | namespace TagLib {
33 |
34 | class ByteVector;
35 |
36 | namespace RIFF {
37 |
38 | namespace WAV {
39 |
40 | class File;
41 |
42 | //! An implementation of audio property reading for WAV
43 |
44 | /*!
45 | * This reads the data from an WAV stream found in the AudioProperties
46 | * API.
47 | */
48 |
49 | class TAGLIB_EXPORT Properties : public AudioProperties
50 | {
51 | public:
52 | /*!
53 | * Create an instance of WAV::Properties with the data read from the
54 | * ByteVector \a data.
55 | */
56 | Properties(const ByteVector &data, ReadStyle style);
57 |
58 | /*!
59 | * Create an instance of WAV::Properties with the data read from the
60 | * ByteVector \a data and the length calculated using \a streamLength.
61 | */
62 | Properties(const ByteVector &data, uint streamLength, ReadStyle style);
63 |
64 | /*!
65 | * Destroys this WAV::Properties instance.
66 | */
67 | virtual ~Properties();
68 |
69 | // Reimplementations.
70 |
71 | virtual int length() const;
72 | virtual int bitrate() const;
73 | virtual int sampleRate() const;
74 | virtual int channels() const;
75 |
76 | int sampleWidth() const;
77 | uint sampleFrames() const;
78 |
79 | private:
80 | Properties(const Properties &);
81 | Properties &operator=(const Properties &);
82 |
83 | void read(const ByteVector &data);
84 |
85 | class PropertiesPrivate;
86 | PropertiesPrivate *d;
87 | };
88 | }
89 | }
90 | }
91 |
92 | #endif
93 |
--------------------------------------------------------------------------------
/taglib/s3m/s3mproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #ifndef TAGLIB_S3MPROPERTIES_H
23 | #define TAGLIB_S3MPROPERTIES_H
24 |
25 | #include "taglib.h"
26 | #include "audioproperties.h"
27 |
28 | namespace TagLib {
29 | namespace S3M {
30 | class TAGLIB_EXPORT Properties : public AudioProperties {
31 | friend class File;
32 | public:
33 | /*! Flag bits. */
34 | enum {
35 | ST2Vibrato = 1,
36 | ST2Tempo = 2,
37 | AmigaSlides = 4,
38 | Vol0MixOptimizations = 8,
39 | AmigaLimits = 16,
40 | EnableFilter = 32,
41 | CustomData = 128
42 | };
43 |
44 | Properties(AudioProperties::ReadStyle propertiesStyle);
45 | virtual ~Properties();
46 |
47 | int length() const;
48 | int bitrate() const;
49 | int sampleRate() const;
50 | int channels() const;
51 |
52 | ushort lengthInPatterns() const;
53 | bool stereo() const;
54 | ushort sampleCount() const;
55 | ushort patternCount() const;
56 | ushort flags() const;
57 | ushort trackerVersion() const;
58 | ushort fileFormatVersion() const;
59 | uchar globalVolume() const;
60 | uchar masterVolume() const;
61 | uchar tempo() const;
62 | uchar bpmSpeed() const;
63 |
64 | void setChannels(int channels);
65 |
66 | void setLengthInPatterns (ushort lengthInPatterns);
67 | void setStereo (bool stereo);
68 | void setSampleCount (ushort sampleCount);
69 | void setPatternCount (ushort patternCount);
70 | void setFlags (ushort flags);
71 | void setTrackerVersion (ushort trackerVersion);
72 | void setFileFormatVersion(ushort fileFormatVersion);
73 | void setGlobalVolume (uchar globalVolume);
74 | void setMasterVolume (uchar masterVolume);
75 | void setTempo (uchar tempo);
76 | void setBpmSpeed (uchar bpmSpeed);
77 |
78 | private:
79 | Properties(const Properties&);
80 | Properties &operator=(const Properties&);
81 |
82 | class PropertiesPrivate;
83 | PropertiesPrivate *d;
84 | };
85 | }
86 | }
87 |
88 | #endif
89 |
--------------------------------------------------------------------------------
/taglib/taglib_config.h:
--------------------------------------------------------------------------------
1 | /* taglib_config.h. Generated by cmake from taglib_config.h.cmake */
2 |
3 | #define TAGLIB_WITH_ASF 1
4 | #define TAGLIB_WITH_MP4 1
5 |
--------------------------------------------------------------------------------
/taglib/taglib_config.h.cmake:
--------------------------------------------------------------------------------
1 | /* taglib_config.h. Generated by cmake from taglib_config.h.cmake */
2 |
3 | #define TAGLIB_WITH_ASF 1
4 | #define TAGLIB_WITH_MP4 1
5 |
--------------------------------------------------------------------------------
/taglib/taglib_export.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_EXPORT_H
27 | #define TAGLIB_EXPORT_H
28 |
29 | #if defined(TAGLIB_STATIC)
30 | #define TAGLIB_EXPORT
31 | #elif (defined(_WIN32) || defined(_WIN64))
32 | #ifdef MAKE_TAGLIB_LIB
33 | #define TAGLIB_EXPORT __declspec(dllexport)
34 | #else
35 | #define TAGLIB_EXPORT __declspec(dllimport)
36 | #endif
37 | #elif defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 1)
38 | #define TAGLIB_EXPORT __attribute__ ((visibility("default")))
39 | #else
40 | #define TAGLIB_EXPORT
41 | #endif
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/taglib/tagunion.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_TAGUNION_H
27 | #define TAGLIB_TAGUNION_H
28 |
29 | #include "tag.h"
30 |
31 | #ifndef DO_NOT_DOCUMENT
32 |
33 | namespace TagLib {
34 |
35 | /*!
36 | * \internal
37 | */
38 |
39 | class TagUnion : public Tag
40 | {
41 | public:
42 |
43 | enum AccessType { Read, Write };
44 |
45 | /*!
46 | * Creates a TagLib::Tag that is the union of \a first, \a second, and
47 | * \a third. The TagUnion takes ownership of these tags and will handle
48 | * their deletion.
49 | */
50 | TagUnion(Tag *first = 0, Tag *second = 0, Tag *third = 0);
51 |
52 | virtual ~TagUnion();
53 |
54 | Tag *operator[](int index) const;
55 | Tag *tag(int index) const;
56 |
57 | void set(int index, Tag *tag);
58 |
59 | virtual String title() const;
60 | virtual String artist() const;
61 | virtual String album() const;
62 | virtual String comment() const;
63 | virtual String genre() const;
64 | virtual uint year() const;
65 | virtual uint track() const;
66 |
67 | virtual void setTitle(const String &s);
68 | virtual void setArtist(const String &s);
69 | virtual void setAlbum(const String &s);
70 | virtual void setComment(const String &s);
71 | virtual void setGenre(const String &s);
72 | virtual void setYear(uint i);
73 | virtual void setTrack(uint i);
74 | virtual bool isEmpty() const;
75 |
76 | template T *access(int index, bool create)
77 | {
78 | if(!create || tag(index))
79 | return static_cast(tag(index));
80 |
81 | set(index, new T);
82 | return static_cast(tag(index));
83 | }
84 |
85 | private:
86 | TagUnion(const Tag &);
87 | TagUnion &operator=(const Tag &);
88 |
89 | class TagUnionPrivate;
90 | TagUnionPrivate *d;
91 | };
92 | }
93 |
94 | #endif
95 | #endif
96 |
--------------------------------------------------------------------------------
/taglib/toolkit/tbytevectorlist.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include "tbytevectorlist.h"
27 |
28 | using namespace TagLib;
29 |
30 | class ByteVectorListPrivate
31 | {
32 |
33 | };
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | // static members
37 | ////////////////////////////////////////////////////////////////////////////////
38 |
39 | ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &pattern,
40 | int byteAlign)
41 | {
42 | return split(v, pattern, byteAlign, 0);
43 | }
44 |
45 | ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &pattern,
46 | int byteAlign, int max)
47 | {
48 | ByteVectorList l;
49 |
50 | uint previousOffset = 0;
51 | for(int offset = v.find(pattern, 0, byteAlign);
52 | offset != -1 && (max == 0 || max > int(l.size()) + 1);
53 | offset = v.find(pattern, offset + pattern.size(), byteAlign))
54 | {
55 | if(offset - previousOffset >= 1)
56 | l.append(v.mid(previousOffset, offset - previousOffset));
57 | else
58 | l.append(ByteVector::null);
59 |
60 | previousOffset = offset + pattern.size();
61 | }
62 |
63 | if(previousOffset < v.size())
64 | l.append(v.mid(previousOffset, v.size() - previousOffset));
65 |
66 | return l;
67 | }
68 |
69 | ////////////////////////////////////////////////////////////////////////////////
70 | // public members
71 | ////////////////////////////////////////////////////////////////////////////////
72 |
73 | ByteVectorList::ByteVectorList() : List()
74 | {
75 |
76 | }
77 |
78 | ByteVectorList::ByteVectorList(const ByteVectorList &l) : List(l)
79 | {
80 |
81 | }
82 |
83 | ByteVectorList::~ByteVectorList()
84 | {
85 |
86 | }
87 |
88 | ByteVector ByteVectorList::toByteVector(const ByteVector &separator) const
89 | {
90 | ByteVector v;
91 |
92 | ConstIterator it = begin();
93 |
94 | while(it != end()) {
95 | v.append(*it);
96 | it++;
97 | if(it != end())
98 | v.append(separator);
99 | }
100 |
101 | return v;
102 | }
103 |
--------------------------------------------------------------------------------
/taglib/toolkit/tbytevectorlist.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_BYTEVECTORLIST_H
27 | #define TAGLIB_BYTEVECTORLIST_H
28 |
29 | #include "taglib_export.h"
30 | #include "tbytevector.h"
31 | #include "tlist.h"
32 |
33 | namespace TagLib {
34 |
35 | //! A list of ByteVectors
36 |
37 | /*!
38 | * A List specialization with some handy features useful for ByteVectors.
39 | */
40 |
41 | class TAGLIB_EXPORT ByteVectorList : public List
42 | {
43 | public:
44 |
45 | /*!
46 | * Construct an empty ByteVectorList.
47 | */
48 | ByteVectorList();
49 |
50 | /*!
51 | * Destroys this ByteVectorList instance.
52 | */
53 | virtual ~ByteVectorList();
54 |
55 | /*!
56 | * Make a shallow, implicitly shared, copy of \a l. Because this is
57 | * implicitly shared, this method is lightweight and suitable for
58 | * pass-by-value usage.
59 | */
60 | ByteVectorList(const ByteVectorList &l);
61 |
62 | /*!
63 | * Convert the ByteVectorList to a ByteVector separated by \a separator. By
64 | * default a space is used.
65 | */
66 | ByteVector toByteVector(const ByteVector &separator = " ") const;
67 |
68 | /*!
69 | * Splits the ByteVector \a v into several strings at \a pattern. This will
70 | * not include the pattern in the returned ByteVectors.
71 | */
72 | static ByteVectorList split(const ByteVector &v, const ByteVector &pattern,
73 | int byteAlign = 1);
74 | /*!
75 | * Splits the ByteVector \a v into several strings at \a pattern. This will
76 | * not include the pattern in the returned ByteVectors. \a max is the
77 | * maximum number of entries that will be separated. If \a max for instance
78 | * is 2 then a maximum of 1 match will be found and the vector will be split
79 | * on that match.
80 | */
81 | // BIC: merge with the function above
82 | static ByteVectorList split(const ByteVector &v, const ByteVector &pattern,
83 | int byteAlign, int max);
84 | private:
85 | class ByteVectorListPrivate;
86 | ByteVectorListPrivate *d;
87 | };
88 |
89 | }
90 |
91 | #endif
92 |
--------------------------------------------------------------------------------
/taglib/toolkit/tdebug.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifdef HAVE_CONFIG_H
27 | #include
28 | #endif
29 |
30 | #include "tdebug.h"
31 | #include "tstring.h"
32 | #include "tdebuglistener.h"
33 |
34 | #include
35 | #include
36 | #include
37 |
38 | using namespace TagLib;
39 |
40 | namespace
41 | {
42 | String format(const char *fmt, ...)
43 | {
44 | va_list args;
45 | va_start(args, fmt);
46 |
47 | char buf[256];
48 |
49 | #if defined(HAVE_SNPRINTF)
50 |
51 | vsnprintf(buf, sizeof(buf), fmt, args);
52 |
53 | #elif defined(HAVE_SPRINTF_S)
54 |
55 | vsprintf_s(buf, fmt, args);
56 |
57 | #else
58 |
59 | // Be careful. May cause a buffer overflow.
60 | vsprintf(buf, fmt, args);
61 |
62 | #endif
63 |
64 | va_end(args);
65 |
66 | return String(buf);
67 | }
68 | }
69 |
70 | namespace TagLib
71 | {
72 | // The instance is defined in tdebuglistener.cpp.
73 | extern DebugListener *debugListener;
74 |
75 | void debug(const String &s)
76 | {
77 | #if !defined(NDEBUG) || defined(TRACE_IN_RELEASE)
78 |
79 | debugListener->printMessage("TagLib: " + s + "\n");
80 |
81 | #endif
82 | }
83 |
84 | void debugData(const ByteVector &v)
85 | {
86 | #if !defined(NDEBUG) || defined(TRACE_IN_RELEASE)
87 |
88 | for(size_t i = 0; i < v.size(); ++i)
89 | {
90 | std::string bits = std::bitset<8>(v[i]).to_string();
91 | String msg = format("*** [%d] - char '%c' - int %d, 0x%02x, 0b%s\n",
92 | i, v[i], v[i], v[i], bits.c_str());
93 |
94 | debugListener->printMessage(msg);
95 | }
96 |
97 | #endif
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/taglib/toolkit/tdebug.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_DEBUG_H
27 | #define TAGLIB_DEBUG_H
28 |
29 | namespace TagLib {
30 |
31 | class String;
32 | class ByteVector;
33 |
34 | #ifndef DO_NOT_DOCUMENT
35 |
36 | /*!
37 | * A simple function that outputs the debug messages to the listener.
38 | * The default listener redirects the messages to \a stderr when NDEBUG is
39 | * not defined.
40 | *
41 | * \warning Do not use this outside of TagLib, it could lead to undefined
42 | * symbols in your build if TagLib is built with NDEBUG defined and your
43 | * application is not.
44 | *
45 | * \internal
46 | */
47 | void debug(const String &s);
48 |
49 | /*!
50 | * For debugging binary data.
51 | *
52 | * \warning Do not use this outside of TagLib, it could lead to undefined
53 | * symbols in your build if TagLib is built with NDEBUG defined and your
54 | * application is not.
55 | *
56 | * \internal
57 | */
58 | void debugData(const ByteVector &v);
59 | }
60 |
61 | #endif
62 | #endif
63 |
--------------------------------------------------------------------------------
/taglib/toolkit/tdebuglistener.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2013 by Tsuda Kageyu
3 | email : tsuda.kageyu@gmail.com
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include "tdebuglistener.h"
27 |
28 | #include
29 | #include
30 |
31 | #ifdef _WIN32
32 | # include
33 | #endif
34 |
35 | using namespace TagLib;
36 |
37 | namespace
38 | {
39 | class DefaultListener : public DebugListener
40 | {
41 | public:
42 | virtual void printMessage(const String &msg)
43 | {
44 | #ifdef _WIN32
45 |
46 | const wstring wstr = msg.toWString();
47 | const int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, NULL, 0, NULL, NULL);
48 | if(len != 0) {
49 | std::vector buf(len);
50 | WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), -1, &buf[0], len, NULL, NULL);
51 |
52 | std::cerr << std::string(&buf[0]);
53 | }
54 |
55 | #else
56 |
57 | std::cerr << msg;
58 |
59 | #endif
60 | }
61 | };
62 |
63 | DefaultListener defaultListener;
64 | }
65 |
66 | namespace TagLib
67 | {
68 | DebugListener *debugListener = &defaultListener;
69 |
70 | DebugListener::DebugListener()
71 | {
72 | }
73 |
74 | DebugListener::~DebugListener()
75 | {
76 | }
77 |
78 | void setDebugListener(DebugListener *listener)
79 | {
80 | if(listener)
81 | debugListener = listener;
82 | else
83 | debugListener = &defaultListener;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/taglib/toolkit/tdebuglistener.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2013 by Tsuda Kageyu
3 | email : tsuda.kageyu@gmail.com
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifndef TAGLIB_DEBUGLISTENER_H
27 | #define TAGLIB_DEBUGLISTENER_H
28 |
29 | #include "taglib_export.h"
30 | #include "tstring.h"
31 |
32 | namespace TagLib
33 | {
34 | //! An abstraction for the listener to the debug messages.
35 |
36 | /*!
37 | * This class enables you to handle the debug messages in your preferred
38 | * way by subclassing this class, reimplementing printMessage() and setting
39 | * your reimplementation as the default with setDebugListener().
40 | *
41 | * \see setDebugListener()
42 | */
43 | class TAGLIB_EXPORT DebugListener
44 | {
45 | public:
46 | DebugListener();
47 | virtual ~DebugListener();
48 |
49 | /*!
50 | * When overridden in a derived class, redirects \a msg to your preferred
51 | * channel such as stderr, Windows debugger or so forth.
52 | */
53 | virtual void printMessage(const String &msg) = 0;
54 |
55 | private:
56 | // Noncopyable
57 | DebugListener(const DebugListener &);
58 | DebugListener &operator=(const DebugListener &);
59 | };
60 |
61 | /*!
62 | * Sets the listener that decides how the debug messages are redirected.
63 | * If the parameter \a listener is null, the previous listener is released
64 | * and default stderr listener is restored.
65 | *
66 | * \note The caller is responsible for deleting the previous listener
67 | * as needed after it is released.
68 | *
69 | * \see DebugListener
70 | */
71 | TAGLIB_EXPORT void setDebugListener(DebugListener *listener);
72 | }
73 |
74 | #endif
75 |
--------------------------------------------------------------------------------
/taglib/toolkit/trefcounter.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2013 by Tsuda Kageyu
3 | email : tsuda.kageyu@gmail.com
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #ifdef HAVE_CONFIG_H
27 | #include
28 | #endif
29 |
30 | #include "trefcounter.h"
31 |
32 | #if defined(HAVE_STD_ATOMIC)
33 | # include
34 | # define ATOMIC_INT std::atomic
35 | # define ATOMIC_INC(x) x.fetch_add(1)
36 | # define ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
37 | #elif defined(HAVE_BOOST_ATOMIC)
38 | # include
39 | # define ATOMIC_INT boost::atomic
40 | # define ATOMIC_INC(x) x.fetch_add(1)
41 | # define ATOMIC_DEC(x) (x.fetch_sub(1) - 1)
42 | #elif defined(HAVE_GCC_ATOMIC)
43 | # define ATOMIC_INT int
44 | # define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
45 | # define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
46 | #elif defined(HAVE_WIN_ATOMIC)
47 | # if !defined(NOMINMAX)
48 | # define NOMINMAX
49 | # endif
50 | # include
51 | # define ATOMIC_INT long
52 | # define ATOMIC_INC(x) InterlockedIncrement(&x)
53 | # define ATOMIC_DEC(x) InterlockedDecrement(&x)
54 | #elif defined(HAVE_MAC_ATOMIC)
55 | # include
56 | # define ATOMIC_INT int32_t
57 | # define ATOMIC_INC(x) OSAtomicIncrement32Barrier(&x)
58 | # define ATOMIC_DEC(x) OSAtomicDecrement32Barrier(&x)
59 | #elif defined(HAVE_IA64_ATOMIC)
60 | # include
61 | # define ATOMIC_INT int
62 | # define ATOMIC_INC(x) __sync_add_and_fetch(&x, 1)
63 | # define ATOMIC_DEC(x) __sync_sub_and_fetch(&x, 1)
64 | #else
65 | # define ATOMIC_INT int
66 | # define ATOMIC_INC(x) (++x)
67 | # define ATOMIC_DEC(x) (--x)
68 | #endif
69 |
70 | namespace TagLib
71 | {
72 | class RefCounter::RefCounterPrivate
73 | {
74 | public:
75 | RefCounterPrivate() : refCount(1) {}
76 |
77 | void ref() { ATOMIC_INC(refCount); }
78 | bool deref() { return (ATOMIC_DEC(refCount) == 0); }
79 | int count() const { return refCount; }
80 |
81 | volatile ATOMIC_INT refCount;
82 | };
83 |
84 | RefCounter::RefCounter()
85 | : d(new RefCounterPrivate())
86 | {
87 | }
88 |
89 | RefCounter::~RefCounter()
90 | {
91 | delete d;
92 | }
93 |
94 | void RefCounter::ref()
95 | {
96 | d->ref();
97 | }
98 |
99 | bool RefCounter::deref()
100 | {
101 | return d->deref();
102 | }
103 |
104 | int RefCounter::count() const
105 | {
106 | return d->count();
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/taglib/toolkit/tstringlist.cpp:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2002 - 2008 by Scott Wheeler
3 | email : wheeler@kde.org
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 | * 02110-1301 USA *
20 | * *
21 | * Alternatively, this file is available under the Mozilla Public *
22 | * License Version 1.1. You may obtain a copy of the License at *
23 | * http://www.mozilla.org/MPL/ *
24 | ***************************************************************************/
25 |
26 | #include "tstringlist.h"
27 |
28 | using namespace TagLib;
29 |
30 | class StringListPrivate
31 | {
32 |
33 | };
34 |
35 | ////////////////////////////////////////////////////////////////////////////////
36 | // static members
37 | ////////////////////////////////////////////////////////////////////////////////
38 |
39 | StringList StringList::split(const String &s, const String &pattern)
40 | {
41 | StringList l;
42 |
43 | int previousOffset = 0;
44 | for(int offset = s.find(pattern); offset != -1; offset = s.find(pattern, offset + 1)) {
45 | l.append(s.substr(previousOffset, offset - previousOffset));
46 | previousOffset = offset + 1;
47 | }
48 |
49 | l.append(s.substr(previousOffset, s.size() - previousOffset));
50 |
51 | return l;
52 | }
53 |
54 | ////////////////////////////////////////////////////////////////////////////////
55 | // public members
56 | ////////////////////////////////////////////////////////////////////////////////
57 |
58 | StringList::StringList() : List()
59 | {
60 |
61 | }
62 |
63 | StringList::StringList(const StringList &l) : List(l)
64 | {
65 |
66 | }
67 |
68 | StringList::StringList(const String &s) : List()
69 | {
70 | append(s);
71 | }
72 |
73 | StringList::StringList(const ByteVectorList &bl, String::Type t) : List()
74 | {
75 | ByteVectorList::ConstIterator i = bl.begin();
76 | for(;i != bl.end(); i++) {
77 | append(String(*i, t));
78 | }
79 | }
80 |
81 | StringList::~StringList()
82 | {
83 |
84 | }
85 |
86 | String StringList::toString(const String &separator) const
87 | {
88 | String s;
89 |
90 | ConstIterator it = begin();
91 | ConstIterator itEnd = end();
92 |
93 | while(it != itEnd) {
94 | s += *it;
95 | it++;
96 | if(it != itEnd)
97 | s += separator;
98 | }
99 |
100 | return s;
101 | }
102 |
103 | StringList &StringList::append(const String &s)
104 | {
105 | List::append(s);
106 | return *this;
107 | }
108 |
109 | StringList &StringList::append(const StringList &l)
110 | {
111 | List::append(l);
112 | return *this;
113 | }
114 |
115 | ////////////////////////////////////////////////////////////////////////////////
116 | // related functions
117 | ////////////////////////////////////////////////////////////////////////////////
118 |
119 | std::ostream &operator<<(std::ostream &s, const StringList &l)
120 | {
121 | s << l.toString();
122 | return s;
123 | }
124 |
--------------------------------------------------------------------------------
/taglib/trueaudio/trueaudioproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2006 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 |
5 | copyright : (C) 2004 by Allan Sandfeld Jensen
6 | email : kde@carewolf.org
7 | (original MPC implementation)
8 | ***************************************************************************/
9 |
10 | /***************************************************************************
11 | * This library is free software; you can redistribute it and/or modify *
12 | * it under the terms of the GNU Lesser General Public License version *
13 | * 2.1 as published by the Free Software Foundation. *
14 | * *
15 | * This library is distributed in the hope that it will be useful, but *
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
18 | * Lesser General Public License for more details. *
19 | * *
20 | * You should have received a copy of the GNU Lesser General Public *
21 | * License along with this library; if not, write to the Free Software *
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
23 | * 02110-1301 USA *
24 | * *
25 | * Alternatively, this file is available under the Mozilla Public *
26 | * License Version 1.1. You may obtain a copy of the License at *
27 | * http://www.mozilla.org/MPL/ *
28 | ***************************************************************************/
29 |
30 | #ifndef TAGLIB_TRUEAUDIOPROPERTIES_H
31 | #define TAGLIB_TRUEAUDIOPROPERTIES_H
32 |
33 | #include "audioproperties.h"
34 |
35 | namespace TagLib {
36 |
37 | namespace TrueAudio {
38 |
39 | class File;
40 |
41 | static const uint HeaderSize = 18;
42 |
43 | //! An implementation of audio property reading for TrueAudio
44 |
45 | /*!
46 | * This reads the data from an TrueAudio stream found in the AudioProperties
47 | * API.
48 | */
49 |
50 | class TAGLIB_EXPORT Properties : public AudioProperties
51 | {
52 | public:
53 | /*!
54 | * Create an instance of TrueAudio::Properties with the data read from the
55 | * ByteVector \a data.
56 | */
57 | Properties(const ByteVector &data, long streamLength, ReadStyle style = Average);
58 |
59 | /*!
60 | * Destroys this TrueAudio::Properties instance.
61 | */
62 | virtual ~Properties();
63 |
64 | // Reimplementations.
65 |
66 | virtual int length() const;
67 | virtual int bitrate() const;
68 | virtual int sampleRate() const;
69 | virtual int channels() const;
70 |
71 | /*!
72 | * Returns number of bits per sample.
73 | */
74 | int bitsPerSample() const;
75 |
76 | /*!
77 | * Returns the total number of sample frames
78 | */
79 | uint sampleFrames() const;
80 |
81 | /*!
82 | * Returns the major version number.
83 | */
84 | int ttaVersion() const;
85 |
86 | private:
87 | Properties(const Properties &);
88 | Properties &operator=(const Properties &);
89 |
90 | void read();
91 |
92 | class PropertiesPrivate;
93 | PropertiesPrivate *d;
94 | };
95 | }
96 | }
97 |
98 | #endif
99 |
--------------------------------------------------------------------------------
/taglib/wavpack/wavpackproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2006 by Lukáš Lalinský
3 | email : lalinsky@gmail.com
4 |
5 | copyright : (C) 2004 by Allan Sandfeld Jensen
6 | email : kde@carewolf.org
7 | (original MPC implementation)
8 | ***************************************************************************/
9 |
10 | /***************************************************************************
11 | * This library is free software; you can redistribute it and/or modify *
12 | * it under the terms of the GNU Lesser General Public License version *
13 | * 2.1 as published by the Free Software Foundation. *
14 | * *
15 | * This library is distributed in the hope that it will be useful, but *
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
18 | * Lesser General Public License for more details. *
19 | * *
20 | * You should have received a copy of the GNU Lesser General Public *
21 | * License along with this library; if not, write to the Free Software *
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
23 | * 02110-1301 USA *
24 | * *
25 | * Alternatively, this file is available under the Mozilla Public *
26 | * License Version 1.1. You may obtain a copy of the License at *
27 | * http://www.mozilla.org/MPL/ *
28 | ***************************************************************************/
29 |
30 | #ifndef TAGLIB_WVPROPERTIES_H
31 | #define TAGLIB_WVPROPERTIES_H
32 |
33 | #include "taglib_export.h"
34 | #include "audioproperties.h"
35 |
36 | namespace TagLib {
37 |
38 | namespace WavPack {
39 |
40 | class File;
41 |
42 | static const uint HeaderSize = 32;
43 |
44 | //! An implementation of audio property reading for WavPack
45 |
46 | /*!
47 | * This reads the data from an WavPack stream found in the AudioProperties
48 | * API.
49 | */
50 |
51 | class TAGLIB_EXPORT Properties : public AudioProperties
52 | {
53 | public:
54 | /*!
55 | * Create an instance of WavPack::Properties with the data read from the
56 | * ByteVector \a data.
57 | *
58 | * \deprecated This constructor will be dropped in favor of the one below
59 | * in a future version.
60 | */
61 | Properties(const ByteVector &data, long streamLength, ReadStyle style = Average);
62 |
63 | /*!
64 | * Create an instance of WavPack::Properties.
65 | */
66 | // BIC: merge with the above constructor
67 | Properties(File *file, long streamLength, ReadStyle style = Average);
68 |
69 | /*!
70 | * Destroys this WavPack::Properties instance.
71 | */
72 | virtual ~Properties();
73 |
74 | // Reimplementations.
75 |
76 | virtual int length() const;
77 | virtual int bitrate() const;
78 |
79 | /*!
80 | * Returns the sample rate in Hz. 0 means unknown or custom.
81 | */
82 | virtual int sampleRate() const;
83 |
84 | virtual int channels() const;
85 |
86 | /*!
87 | * Returns number of bits per sample.
88 | */
89 | int bitsPerSample() const;
90 | uint sampleFrames() const;
91 |
92 | /*!
93 | * Returns WavPack version.
94 | */
95 | int version() const;
96 |
97 | private:
98 | Properties(const Properties &);
99 | Properties &operator=(const Properties &);
100 |
101 | void read();
102 | unsigned int seekFinalIndex();
103 |
104 | class PropertiesPrivate;
105 | PropertiesPrivate *d;
106 | };
107 | }
108 | }
109 |
110 | #endif
111 |
--------------------------------------------------------------------------------
/taglib/xm/xmfile.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #ifndef TAGLIB_XMFILE_H
23 | #define TAGLIB_XMFILE_H
24 |
25 | #include "tfile.h"
26 | #include "audioproperties.h"
27 | #include "taglib_export.h"
28 | #include "modfilebase.h"
29 | #include "modtag.h"
30 | #include "xmproperties.h"
31 |
32 | namespace TagLib {
33 |
34 | namespace XM {
35 |
36 | class TAGLIB_EXPORT File : public Mod::FileBase {
37 | public:
38 | /*!
39 | * Constructs an Extended Module file from \a file.
40 | *
41 | * \note In the current implementation, both \a readProperties and
42 | * \a propertiesStyle are ignored. The audio properties are always
43 | * read.
44 | */
45 | File(FileName file, bool readProperties = true,
46 | AudioProperties::ReadStyle propertiesStyle =
47 | AudioProperties::Average);
48 |
49 | /*!
50 | * Constructs an Extended Module file from \a stream.
51 | *
52 | * \note In the current implementation, both \a readProperties and
53 | * \a propertiesStyle are ignored. The audio properties are always
54 | * read.
55 | *
56 | * \note TagLib will *not* take ownership of the stream, the caller is
57 | * responsible for deleting it after the File object.
58 | */
59 | File(IOStream *stream, bool readProperties = true,
60 | AudioProperties::ReadStyle propertiesStyle =
61 | AudioProperties::Average);
62 |
63 | /*!
64 | * Destroys this instance of the File.
65 | */
66 | virtual ~File();
67 |
68 | Mod::Tag *tag() const;
69 |
70 | /*!
71 | * Implements the unified property interface -- export function.
72 | * Forwards to Mod::Tag::properties().
73 | */
74 | PropertyMap properties() const;
75 |
76 | /*!
77 | * Implements the unified property interface -- import function.
78 | * Forwards to Mod::Tag::setProperties().
79 | */
80 | PropertyMap setProperties(const PropertyMap &);
81 |
82 | /*!
83 | * Returns the XM::Properties for this file. If no audio properties
84 | * were read then this will return a null pointer.
85 | */
86 | XM::Properties *audioProperties() const;
87 |
88 | /*!
89 | * Save the file.
90 | * This is the same as calling save(AllTags);
91 | *
92 | * \note Saving Extended Module tags is not supported.
93 | */
94 | bool save();
95 |
96 | private:
97 | File(const File &);
98 | File &operator=(const File &);
99 |
100 | void read(bool readProperties);
101 |
102 | class FilePrivate;
103 | FilePrivate *d;
104 | };
105 | }
106 | }
107 |
108 | #endif
109 |
--------------------------------------------------------------------------------
/taglib/xm/xmproperties.h:
--------------------------------------------------------------------------------
1 | /***************************************************************************
2 | copyright : (C) 2011 by Mathias Panzenböck
3 | email : grosser.meister.morti@gmx.net
4 | ***************************************************************************/
5 |
6 | /***************************************************************************
7 | * This library is free software; you can redistribute it and/or modify *
8 | * it under the terms of the GNU Lesser General Public License version *
9 | * 2.1 as published by the Free Software Foundation. *
10 | * *
11 | * This library is distributed in the hope that it will be useful, but *
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 | * Lesser General Public License for more details. *
15 | * *
16 | * You should have received a copy of the GNU Lesser General Public *
17 | * License along with this library; if not, write to the Free Software *
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
19 | * MA 02110-1301 USA *
20 | ***************************************************************************/
21 |
22 | #ifndef TAGLIB_XMPROPERTIES_H
23 | #define TAGLIB_XMPROPERTIES_H
24 |
25 | #include "taglib.h"
26 | #include "tstring.h"
27 | #include "audioproperties.h"
28 |
29 | namespace TagLib {
30 | namespace XM {
31 | class Properties : public AudioProperties {
32 | friend class File;
33 | public:
34 | /*! Flag bits. */
35 | enum {
36 | LinearFreqTable = 1 // otherwise its the amiga freq. table
37 | };
38 |
39 | Properties(AudioProperties::ReadStyle propertiesStyle);
40 | virtual ~Properties();
41 |
42 | int length() const;
43 | int bitrate() const;
44 | int sampleRate() const;
45 | int channels() const;
46 |
47 | ushort lengthInPatterns() const;
48 | ushort version() const;
49 | ushort restartPosition() const;
50 | ushort patternCount() const;
51 | ushort instrumentCount() const;
52 | uint sampleCount() const;
53 | ushort flags() const;
54 | ushort tempo() const;
55 | ushort bpmSpeed() const;
56 |
57 | void setChannels(int channels);
58 |
59 | void setLengthInPatterns(ushort lengthInPatterns);
60 | void setVersion(ushort version);
61 | void setRestartPosition(ushort restartPosition);
62 | void setPatternCount(ushort patternCount);
63 | void setInstrumentCount(ushort instrumentCount);
64 | void setSampleCount(uint sampleCount);
65 | void setFlags(ushort flags);
66 | void setTempo(ushort tempo);
67 | void setBpmSpeed(ushort bpmSpeed);
68 |
69 | private:
70 | Properties(const Properties&);
71 | Properties &operator=(const Properties&);
72 |
73 | class PropertiesPrivate;
74 | PropertiesPrivate *d;
75 | };
76 | }
77 | }
78 |
79 | #endif
80 |
--------------------------------------------------------------------------------