├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── binding.gyp ├── build ├── binding.sln ├── binding.vcxproj ├── binding.vcxproj.filters └── config.gypi ├── examples └── aimp.ts ├── index.d.ts ├── index.js ├── index.js.map ├── index.ts ├── list-sources.js ├── package.json ├── src ├── Cover.cpp ├── Cover.h ├── NowPlaying-node.cpp ├── NowPlaying.cpp ├── NowPlaying.h ├── Player.cpp ├── Player.h ├── PlayerAIMP.cpp ├── PlayerAIMP.h ├── PlayerCAD.cpp ├── PlayerCAD.h ├── PlayerITunes.cpp ├── PlayerITunes.h ├── PlayerSpotify.cpp ├── PlayerSpotify.h ├── PlayerWLM.cpp ├── PlayerWLM.h ├── PlayerWMP.cpp ├── PlayerWMP.h ├── PlayerWinamp.cpp ├── PlayerWinamp.h ├── SDKs │ ├── AIMP │ │ └── aimp2_sdk.h │ ├── CAD │ │ └── cad_sdk.h │ ├── Winamp │ │ ├── wa_cmd.h │ │ ├── wa_dlg.h │ │ ├── wa_hotkeys.h │ │ └── wa_ipc.h │ └── iTunes │ │ ├── iTunesCOMInterface.h │ │ └── iTunesCOMInterface_i.c ├── readme.txt └── taglib │ ├── COPYING.LGPL │ ├── COPYING.MPL │ ├── TagLibUnity.cpp │ ├── TagLibUnity_ape.cpp │ ├── TagLibUnity_asf.cpp │ ├── TagLibUnity_flac.cpp │ ├── TagLibUnity_mp4.cpp │ ├── TagLibUnity_mpeg.cpp │ ├── TagLibUnity_mpeg_id3v2.cpp │ ├── TagLibUnity_ogg.cpp │ ├── TagLibUnity_toolkit.cpp │ ├── 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 │ ├── 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 │ ├── 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 │ ├── speex │ │ ├── speexfile.cpp │ │ ├── speexfile.h │ │ ├── speexproperties.cpp │ │ └── speexproperties.h │ ├── vorbis │ │ ├── vorbisfile.cpp │ │ ├── vorbisfile.h │ │ ├── vorbisproperties.cpp │ │ └── vorbisproperties.h │ ├── xiphcomment.cpp │ └── xiphcomment.h │ ├── tag.cpp │ ├── tag.h │ ├── taglib_config.h │ ├── 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 ├── tsconfig.json └── yarn.lock /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | #Binary files 33 | build/Release 34 | build/Debug 35 | 36 | # Dependency directories 37 | node_modules/ 38 | jspm_packages/ 39 | 40 | # TypeScript v1 declaration files 41 | typings/ 42 | 43 | # Optional npm cache directory 44 | .npm 45 | 46 | # Optional eslint cache 47 | .eslintcache 48 | 49 | # Optional REPL history 50 | .node_repl_history 51 | 52 | # Output of 'npm pack' 53 | *.tgz 54 | 55 | # Yarn Integrity file 56 | .yarn-integrity 57 | 58 | # dotenv environment variables file 59 | .env 60 | 61 | # next.js build output 62 | .next 63 | 64 | .vscode -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Nguyen Xuan Khanh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nowplaying-node 2 | 3 | ![build](https://ci.appveyor.com/api/projects/status/drbuy98474cs9rcf?svg=true) 4 | 5 | Currently investigating foobar and WMP player freezing cause. 6 | 7 | ## Install 8 | You need windows-build-tools to build native module: 9 | ``` 10 | npm --add-python-to-path install --global windows-build-tools 11 | ``` 12 | 13 | then run: 14 | ``` 15 | npm install nowplaying-node 16 | ``` 17 | 18 | ## Electron 19 | 20 | If you're making electron app, you might need to install `electron-rebuild`: 21 | ``` 22 | npm install --save-dev electron-rebuild 23 | ``` 24 | then run: 25 | ``` 26 | .\node_modules\.bin\electron-rebuild 27 | ``` 28 | to rebuild usable module for your current Electron's Node version 29 | 30 | # How to use: 31 | Import NowPlaying: 32 | ```js 33 | import { NowPlaying, PlayerName } from "nowplaying-node"; 34 | ``` 35 | 36 | Create player interface: 37 | ```js 38 | const myAIMP = new NowPlaying({ 39 | fetchCover: true, 40 | player: PlayerName.AIMP, 41 | }); 42 | ``` 43 | 44 | Get information: 45 | ```js 46 | myAIMP.update(); 47 | console.log("%s - %s", myAIMP.getArtist(), myAIMP.getTitle()) 48 | ``` 49 | 50 | Track info only is updated when `.update()` is called, so put them in an interval to always have most recent info: 51 | ```js 52 | setInterval(() => { 53 | myAIMP.update(); 54 | console.log("%s - %s", myAIMP.getArtist(), myAIMP.getTitle()) 55 | console.log(myAIMP.getPosition()); 56 | console.log(myAIMP.getCoverPath()); 57 | }, 1000); 58 | ``` 59 | 60 | 61 | List of supported players: 62 | 63 | - AIMP: 64 | ```js 65 | player = PlayerName.AIMP 66 | ``` 67 | Fully supported. 68 | - foobar2000: 69 | ```js 70 | player = PlayerName.CAD 71 | ``` 72 | Fully supported. The [foo_cad plugin (download)](http://poiru.github.com/foo-cad/) needs to be installed. 73 | - iTunes: 74 | ```js 75 | player = PlayerName.ITUNES 76 | ``` 77 | Fully supported. Tested with iTunes 10.2. 78 | - J. River Media Center and Media Jukebox: 79 | ```js 80 | player = PlayerName.CAD 81 | ``` 82 | Fully supported through the CAD interface with Media Center 19 and later. More information [here](http://yabb.jriver.com/interact/index.php?topic=84508.0). 83 | - MediaMonkey: 84 | ```js 85 | player = PlayerName.MEDIAMONKEY 86 | ``` 87 | Fully supported. Tested with MediaMonkey 3.2.5. 88 | - MusicBee: 89 | ```js 90 | player = PlayerName.CAD 91 | ``` 92 | Fully supported. MusicBee 1.2 (or higher) is required. 93 | - Winamp: 94 | ```js 95 | player = PlayerName.WINAMP 96 | ``` 97 | Fully supported. 98 | - WMP: 99 | ```js 100 | player = PlayerName.WMP 101 | ``` 102 | Fully supported, except for the `.getRepeat()` / `.getShuffle()`. 103 | 104 | - Spotify: 105 | ```js 106 | player = PlayerName.SPOTIFY 107 | ``` 108 | Partially supported. Only the `.getArtist()`, `.getTitle()` information and `.play()`, `.pause()`, `.stop()`, `.next()`, and `.previous()` controls are available. 109 | - Last.fm Client, TTPlayer, OpenPandora, Zune: 110 | ```js 111 | player = PlayerName.WLM 112 | ``` 113 | Partially supported. Even in the best case, only the types `.getTitle()`, `.getArtist()`, `.getAlbum()` information and `.play()`, `.pause()`, `.stop()`, `.next()`, and `.previous()` are supported. 114 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "binding", 5 | "sources": [ 6 | " { 9 | np.update(); 10 | console.log(np.getTitle()); 11 | console.log(np.getArtist()); 12 | console.log(np.getPosition()); 13 | console.log(np.getCoverPath()); 14 | }, 1000); 15 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | export declare enum PlayerName { 2 | WLM = 0, 3 | AIMP = 1, 4 | CAD = 2, 5 | FOOBAR = 3, 6 | ITUNES = 4, 7 | MEDIAMONKEY = 5, 8 | SPOTIFY = 6, 9 | WINAMP = 7, 10 | WMP = 8, 11 | } 12 | export interface NowPlayingConfig { 13 | getCover?: boolean; 14 | player: PlayerName; 15 | playerPath?: string; 16 | } 17 | export declare class NowPlaying { 18 | private instance; 19 | constructor(config: NowPlayingConfig); 20 | /** 21 | * Closes the player. 22 | */ 23 | closePlayer(): void; 24 | /** 25 | * Current album. 26 | */ 27 | getAlbum(): string; 28 | /** 29 | * Track artist. 30 | */ 31 | getArtist(): string; 32 | /** 33 | * Path to cover art. 34 | */ 35 | getCoverPath(): string; 36 | /** 37 | * Total length of track in seconds. 38 | */ 39 | getDuration(): number; 40 | /** 41 | * Path to the playing media file. 42 | */ 43 | getFilePath(): string; 44 | /** 45 | * Track genre. 46 | */ 47 | getGenre(): string; 48 | /** 49 | * Track number. 50 | */ 51 | getNumber(): number; 52 | /** 53 | * Current position in track in seconds. 54 | */ 55 | getPosition(): number; 56 | /** 57 | * Percentage of track completed. 58 | */ 59 | getProgress(): number; 60 | /** 61 | * Rating of current track (0 to 5). 62 | */ 63 | getRating(): number; 64 | /** 65 | * `false` if repeat/loop track is off, `true` if on. 66 | */ 67 | getRepeat(): boolean; 68 | /** 69 | * `false` if shuffle/random tracks is off, `true` if on. 70 | */ 71 | getShuffle(): boolean; 72 | /** 73 | * `0` for stopped, `1` for playing, and `2` for paused. 74 | */ 75 | getState(): number; 76 | /** 77 | * `false` for inactive (player closed) and `true` for active (player open). 78 | */ 79 | getStatus(): boolean; 80 | /** 81 | * Track title. 82 | */ 83 | getTitle(): string; 84 | /** 85 | * From 0 to 100. 86 | */ 87 | getVolume(): number; 88 | /** 89 | * Track year. 90 | */ 91 | getYear(): number; 92 | /** 93 | * Change to next track. 94 | */ 95 | next(): void; 96 | /** 97 | * Opens the player. If already open, the player will be brought to the top. 98 | */ 99 | openPlayer(): void; 100 | /** 101 | * Pause current track. 102 | */ 103 | pause(): void; 104 | /** 105 | * Play current track. 106 | */ 107 | play(): void; 108 | /** 109 | * Change to previous track. 110 | */ 111 | previous(): void; 112 | /** 113 | * Change track position. 114 | * @param position in second 115 | */ 116 | setPosition(position: number): void; 117 | /** 118 | * Change track rating. 119 | * @param rating `0` (no rating) to `5` (maximum rating) 120 | */ 121 | setRating(rating: number): void; 122 | /** 123 | * Change player repeat state. 124 | * @param isRepeat `true`: repeat on. `false`: repeat off. 125 | */ 126 | setRepeat(isRepeat: boolean): void; 127 | /** 128 | * Change player shuffle state. 129 | * @param isShuffle `true`: shuffle on. `false`: shuffle off. 130 | */ 131 | setShuffle(isShuffle: boolean): void; 132 | /** 133 | * Change player volume level. 134 | * @param level 0 to 100. 135 | */ 136 | setVolume(level: number): void; 137 | /** 138 | * Stop current track. 139 | */ 140 | stop(): void; 141 | /** 142 | * Update all information. Call this method before get any information. 143 | */ 144 | update(): void; 145 | } 146 | -------------------------------------------------------------------------------- /index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,MAAM,EAAE,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAEnD,IAAY,UAUX;AAVD,WAAY,UAAU;IAClB,yCAAG,CAAA;IACH,2CAAI,CAAA;IACJ,yCAAG,CAAA;IACH,+CAAM,CAAA;IACN,+CAAM,CAAA;IACN,yDAAW,CAAA;IACX,iDAAO,CAAA;IACP,+CAAM,CAAA;IACN,yCAAG,CAAA;AACP,CAAC,EAVW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAUrB;AAQD;IAGI,YAAY,MAAwB;QAChC,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,MAAM,KAAK,SAAS,EAAE;YACtB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;SAC1B;IACL,CAAC;IAED;;OAEG;IACI,WAAW;QACd,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,YAAY;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC;IACxC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,WAAW;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACvC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,UAAU;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACtC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,QAAQ;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,SAAS;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;IACrC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,OAAO;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IACnC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,IAAI;QACP,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,UAAU;QACb,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IAC/B,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,IAAI;QACP,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,QAAQ;QACX,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAAA,CAAC;IAEF;;;OAGG;IACI,WAAW,CAAC,QAAgB;QAC/B,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAAA,CAAC;IAEF;;;OAGG;IACI,SAAS,CAAC,MAAc;QAC3B,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IAAA,CAAC;IAEF;;;OAGG;IACI,SAAS,CAAC,QAAiB;QAC9B,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAAA,CAAC;IAEF;;;OAGG;IACI,UAAU,CAAC,SAAkB;QAChC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAAA,CAAC;IAEF;;;OAGG;IACI,SAAS,CAAC,KAAa;QAC1B,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,IAAI;QACP,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAAA,CAAC;IAEF;;OAEG;IACI,MAAM;QACT,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;IAAA,CAAC;CACL;AAhOD,gCAgOC"} -------------------------------------------------------------------------------- /list-sources.js: -------------------------------------------------------------------------------- 1 | const { readdirSync, statSync } = require("fs"); 2 | 3 | const reducer = (f, o) => o.reduce((a, b) => a || f.endsWith(b), false) 4 | 5 | function listDirRecur(dir, endsWithOpt) { 6 | readdirSync(dir) 7 | .forEach(f => { 8 | const curf = dir + '/' + f; 9 | if (statSync(curf).isDirectory()) { 10 | listDirRecur(curf, endsWithOpt); 11 | } else { 12 | if (reducer(f, endsWithOpt)) { 13 | console.log(curf); 14 | } 15 | } 16 | }) 17 | } 18 | 19 | function listDir(dir, endsWithOpt) { 20 | readdirSync(dir) 21 | .filter(f => reducer(f, endsWithOpt)) 22 | .forEach(f => console.log(dir + '/' + f)) 23 | } 24 | 25 | listDirRecur('src/SDKs', [".cpp", ".c", ".h"]); 26 | listDirRecur('src/taglib', [".h"]); 27 | listDir("src", [".h",".cpp"]) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nowplaying-node", 3 | "version": "0.1.3", 4 | "description": "Control AIMP, foobar2000, iTunes,... players and get track information.", 5 | "author": { 6 | "name": "khanhas", 7 | "url": "http://khanhas.github.com" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/khanhas/nowplaying-node" 12 | }, 13 | "gypfile": true, 14 | "main": "index.js", 15 | "dependencies": { 16 | "@types/node": "^10.1.2", 17 | "node-addon-api": "^1.2.0", 18 | "node-gyp": "^3.6.2" 19 | }, 20 | "devDependencies": { 21 | "clang-format": "^1.2.3", 22 | "ts-node": "^6.0.5", 23 | "typescript": "^2.8.3", 24 | "windows-build-tools": "^2.3.0" 25 | }, 26 | "scripts": { 27 | "build": "node-gyp build", 28 | "rebuild": "node-gyp rebuild", 29 | "lint": "clang-format -i --glob=src/*.{cpp,h}", 30 | "tsc": "tsc", 31 | "ex": "ts-node" 32 | }, 33 | "files": [ 34 | "index.ts", 35 | "index.d.ts", 36 | "index.js", 37 | "list-sources.js", 38 | "binding.gyp", 39 | "src" 40 | ], 41 | "license": "MIT", 42 | "keywords": [ 43 | "aimp", 44 | "foobar", 45 | "foobar2000", 46 | "itunes", 47 | "j.river media center", 48 | "j.river", 49 | "jriver", 50 | "jukebox", 51 | "media control", 52 | "media", 53 | "mediamonkey", 54 | "music", 55 | "musicbee", 56 | "player", 57 | "song metadata", 58 | "song", 59 | "spotify", 60 | "track metadata", 61 | "winamp", 62 | "windows media player", 63 | "windows" 64 | ] 65 | } 66 | -------------------------------------------------------------------------------- /src/Cover.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at . */ 7 | 8 | #ifndef __COVER_H__ 9 | #define __COVER_H__ 10 | 11 | // TagLib 12 | #include "apefile.h" 13 | #include "apetag.h" 14 | #include "asffile.h" 15 | #include "attachedpictureframe.h" 16 | #include "commentsframe.h" 17 | #include "fileref.h" 18 | #include "flacfile.h" 19 | #include "id3v1genres.h" 20 | #include "id3v2tag.h" 21 | #include "mp4file.h" 22 | #include "mpcfile.h" 23 | #include "mpegfile.h" 24 | #include "tag.h" 25 | #include "taglib.h" 26 | #include "textidentificationframe.h" 27 | #include "tstring.h" 28 | #include "vorbisfile.h" 29 | 30 | class CCover { 31 | public: 32 | static bool GetCached(std::wstring &path); 33 | static bool GetLocal(std::wstring filename, const std::wstring &folder, 34 | std::wstring &target); 35 | static bool GetEmbedded(const TagLib::FileRef &fr, 36 | const std::wstring &target); 37 | static std::wstring GetFileFolder(const std::wstring &file); 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/NowPlaying-node.cpp: -------------------------------------------------------------------------------- 1 | #include "NowPlaying.h" 2 | #include 3 | 4 | void InitAll(v8::Local exports, v8::Local module) { 5 | NowPlaying::Init(exports); 6 | }; 7 | 8 | NODE_MODULE(NODE_GYP_MODULE_NAME, InitAll) -------------------------------------------------------------------------------- /src/NowPlaying.h: -------------------------------------------------------------------------------- 1 | #include "Player.h" 2 | #include 3 | #include 4 | #include 5 | 6 | using v8::Function; 7 | using v8::FunctionCallbackInfo; 8 | using v8::Isolate; 9 | using v8::Local; 10 | using v8::Object; 11 | using v8::Persistent; 12 | using v8::Value; 13 | 14 | // Do not hover mouse over v8::FunctionTemplate to read description, Visual 15 | // Studio will freeze. 16 | #define FUNCTIONTEMPLATE v8::FunctionTemplate 17 | #define FBVALUE v8::FunctionCallbackInfo 18 | 19 | class NowPlaying : public node::ObjectWrap { 20 | public: 21 | static void Init(Local exports); 22 | static Persistent constructor; 23 | static void New(const FBVALUE &args); 24 | static void Update(const FBVALUE &args); 25 | static void GetState(const FBVALUE &args); 26 | static void GetArtist(const FBVALUE &args); 27 | static void GetAlbum(const FBVALUE &args); 28 | static void GetTitle(const FBVALUE &args); 29 | static void GetGenre(const FBVALUE &args); 30 | static void GetCoverPath(const FBVALUE &args); 31 | static void GetFilePath(const FBVALUE &args); 32 | static void GetDuration(const FBVALUE &args); 33 | static void GetPosition(const FBVALUE &args); 34 | static void GetProgress(const FBVALUE &args); 35 | static void GetRating(const FBVALUE &args); 36 | static void GetVolume(const FBVALUE &args); 37 | static void GetNumber(const FBVALUE &args); 38 | static void GetYear(const FBVALUE &args); 39 | static void GetShuffle(const FBVALUE &args); 40 | static void GetRepeat(const FBVALUE &args); 41 | static void GetStatus(const FBVALUE &args); 42 | static void Pause(const FBVALUE &args); 43 | static void Play(const FBVALUE &args); 44 | static void Stop(const FBVALUE &args); 45 | static void Next(const FBVALUE &args); 46 | static void Previous(const FBVALUE &args); 47 | static void SetPosition(const FBVALUE &args); 48 | static void SetRating(const FBVALUE &args); 49 | static void SetVolume(const FBVALUE &args); 50 | static void SetShuffle(const FBVALUE &args); 51 | static void SetRepeat(const FBVALUE &args); 52 | static void OpenPlayer(const FBVALUE &args); 53 | static void ClosePlayer(const FBVALUE &args); 54 | 55 | Player *_player; 56 | 57 | UINT trackCount; 58 | bool trackChanged; 59 | std::wstring playerPath; 60 | 61 | private: 62 | explicit NowPlaying(Player *player, std::wstring playerPath); 63 | ~NowPlaying(); 64 | }; 65 | -------------------------------------------------------------------------------- /src/Player.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at . */ 7 | 8 | #include "Player.h" 9 | 10 | /* 11 | ** Constructor. 12 | ** 13 | */ 14 | Player::Player() 15 | : m_Initialized(false), m_TrackCount(), m_State(), m_Number(), m_Year(), 16 | m_Shuffle(false), m_Repeat(false), m_Duration(), m_Position(), m_Rating(), 17 | m_Volume(), m_fetchCover(false) { 18 | // Get temporary file for cover art 19 | WCHAR buffer[MAX_PATH]; 20 | GetTempPath(MAX_PATH, buffer); 21 | GetTempFileName(buffer, L"jpg", 0, buffer); 22 | m_TempCoverPath = buffer; 23 | } 24 | 25 | /* 26 | ** Destructor. 27 | ** 28 | */ 29 | Player::~Player() { DeleteFile(m_TempCoverPath.c_str()); } 30 | 31 | /* 32 | ** Called during update of main measure. 33 | ** 34 | */ 35 | void Player::UpdateMeasure() { UpdateData(); } 36 | 37 | /* 38 | ** Default implementation for getting cover. 39 | ** 40 | */ 41 | void Player::FindCover() { 42 | TagLib::FileRef fr(m_FilePath.c_str(), false); 43 | if (!fr.isNull() && CCover::GetEmbedded(fr, m_TempCoverPath)) { 44 | m_CoverPath = m_TempCoverPath; 45 | } else { 46 | std::wstring trackFolder = CCover::GetFileFolder(m_FilePath); 47 | 48 | if (!CCover::GetLocal(L"cover", trackFolder, m_CoverPath) && 49 | !CCover::GetLocal(L"folder", trackFolder, m_CoverPath)) { 50 | // Nothing found 51 | m_CoverPath.clear(); 52 | } 53 | } 54 | } 55 | 56 | /* 57 | ** Clear track information. 58 | ** 59 | */ 60 | void Player::ClearData(bool all) { 61 | m_State = STATE_STOPPED; 62 | m_Artist.clear(); 63 | m_Album.clear(); 64 | m_Title.clear(); 65 | m_Genre.clear(); 66 | m_FilePath.clear(); 67 | m_CoverPath.clear(); 68 | m_Duration = 0; 69 | m_Position = 0; 70 | m_Rating = 0; 71 | m_Number = 0; 72 | m_Year = 0; 73 | 74 | if (all) { 75 | m_Volume = 0; 76 | m_Shuffle = false; 77 | m_Repeat = false; 78 | } 79 | } -------------------------------------------------------------------------------- /src/Player.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at . */ 7 | 8 | #ifndef __PLAYER_H__ 9 | #define __PLAYER_H__ 10 | 11 | #include "Cover.h" 12 | #include "taglib\fileref.h" 13 | #include "taglib\tag.h" 14 | #include 15 | #include 16 | 17 | enum StateType { STATE_STOPPED, STATE_PLAYING, STATE_PAUSED }; 18 | 19 | class __declspec(novtable) Player { 20 | public: 21 | Player(); 22 | virtual ~Player() = 0; 23 | 24 | void UpdateMeasure(); 25 | virtual void UpdateData() = 0; 26 | 27 | bool IsInitialized() const { return m_Initialized; } 28 | UINT GetTrackCount() const { return m_TrackCount; } 29 | 30 | void FindCover(); 31 | bool m_fetchCover; 32 | 33 | virtual void Pause() {} 34 | virtual void Play() {} 35 | virtual void Stop() {} 36 | virtual void Next() {} 37 | virtual void Previous() {} 38 | virtual void SetPosition(int position) {} // position: position in seconds 39 | virtual void SetRating(int rating) {} // rating: 0 - 5 40 | virtual void SetVolume(int volume) {} // volume: 0 - 100 41 | virtual void SetShuffle(bool state) {} // state: off = 0, on = 1 42 | virtual void SetRepeat(bool state) {} // state: off = 0, on = 1 43 | virtual void OpenPlayer(std::wstring &path) {} 44 | virtual void ClosePlayer() {} 45 | 46 | StateType GetState() const { return m_State; } 47 | LPCWSTR GetArtist() const { return m_Artist.c_str(); } 48 | LPCWSTR GetAlbum() const { return m_Album.c_str(); } 49 | LPCWSTR GetTitle() const { return m_Title.c_str(); } 50 | LPCWSTR GetGenre() const { return m_Genre.c_str(); } 51 | LPCWSTR GetCoverPath() const { return m_CoverPath.c_str(); } 52 | LPCWSTR GetFilePath() const { return m_FilePath.c_str(); } 53 | UINT GetDuration() const { return m_Duration; } 54 | UINT GetPosition() const { return m_Position; } 55 | UINT GetRating() const { return m_Rating; } 56 | UINT GetVolume() const { return m_Volume; } 57 | UINT GetNumber() const { return m_Number; } 58 | UINT GetYear() const { return m_Year; } 59 | bool GetShuffle() const { return m_Shuffle; } 60 | bool GetRepeat() const { return m_Repeat; } 61 | 62 | protected: 63 | void ClearData(bool all = true); 64 | 65 | bool m_Initialized; 66 | UINT m_TrackCount; 67 | std::wstring m_TempCoverPath; 68 | 69 | INT m_Measures; 70 | 71 | StateType m_State; 72 | std::wstring m_Artist; 73 | std::wstring m_Title; 74 | std::wstring m_Album; 75 | std::wstring m_Genre; 76 | std::wstring m_CoverPath; // Path to cover art image 77 | std::wstring m_FilePath; // Path to playing file 78 | UINT m_Duration; // Track duration in seconds 79 | UINT m_Position; // Current position in seconds 80 | UINT m_Rating; // Track rating from 0 to 100 81 | UINT m_Volume; // Volume from 0 to 100 82 | UINT m_Number; 83 | UINT m_Year; 84 | bool m_Shuffle; 85 | bool m_Repeat; 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/PlayerAIMP.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at . */ 7 | 8 | #ifndef __PLAYERAIMP_H__ 9 | #define __PLAYERAIMP_H__ 10 | 11 | #include "Player.h" 12 | 13 | class PlayerAIMP : public Player { 14 | public: 15 | virtual ~PlayerAIMP(); 16 | 17 | static Player *Create(); 18 | 19 | virtual void UpdateData(); 20 | 21 | virtual void Pause(); 22 | virtual void Play(); 23 | virtual void Stop(); 24 | virtual void Next(); 25 | virtual void Previous(); 26 | virtual void SetPosition(int position); 27 | virtual void SetRating(int rating); 28 | virtual void SetVolume(int volume); 29 | virtual void SetShuffle(bool state); 30 | virtual void SetRepeat(bool state); 31 | virtual void ClosePlayer(); 32 | virtual void OpenPlayer(std::wstring &path); 33 | 34 | protected: 35 | PlayerAIMP(); 36 | 37 | private: 38 | bool Initialize(); 39 | bool CheckWindow(); 40 | 41 | static Player *c_Player; 42 | 43 | HWND m_Window; // AIMP window 44 | HWND m_WinampWindow; // AIMP Winamp API window 45 | DWORD m_LastCheckTime; 46 | INT64 m_LastFileSize; 47 | DWORD m_LastTitleSize; 48 | LPVOID m_FileMap; 49 | HANDLE m_FileMapHandle; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/PlayerCAD.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at . */ 7 | 8 | #ifndef __PLAYERCAD_H__ 9 | #define __PLAYERCAD_H__ 10 | 11 | #include "Player.h" 12 | 13 | class PlayerCAD : public Player { 14 | public: 15 | virtual ~PlayerCAD(); 16 | 17 | static Player *Create(); 18 | 19 | virtual void UpdateData(); 20 | 21 | virtual void Pause(); 22 | virtual void Play(); 23 | virtual void Stop(); 24 | virtual void Next(); 25 | virtual void Previous(); 26 | virtual void SetPosition(int position); 27 | virtual void SetRating(int rating); 28 | virtual void SetVolume(int volume); 29 | virtual void SetShuffle(bool state); 30 | virtual void SetRepeat(bool state); 31 | virtual void ClosePlayer(); 32 | virtual void OpenPlayer(std::wstring &path); 33 | 34 | protected: 35 | PlayerCAD(); 36 | 37 | private: 38 | void Initialize(); 39 | void Uninitialize(); 40 | static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, 41 | LPARAM lParam); 42 | 43 | static Player *c_Player; 44 | 45 | HWND m_Window; 46 | HWND m_PlayerWindow; 47 | std::wstring m_PlayerPath; 48 | bool m_ExtendedAPI; 49 | bool m_Open; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/PlayerITunes.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at . */ 7 | 8 | #ifndef __PLAYERITUNES_H__ 9 | #define __PLAYERITUNES_H__ 10 | 11 | #include "Player.h" 12 | #include "iTunes/iTunesCOMInterface.h" 13 | 14 | const int TIMER_CHECKACTIVE = 1; 15 | 16 | class PlayerITunes : public Player { 17 | public: 18 | virtual ~PlayerITunes(); 19 | 20 | static Player *Create(); 21 | 22 | virtual void UpdateData(); 23 | virtual void UpdateCachedData(); 24 | 25 | // Used to check if track is different 26 | long m_TrackID; 27 | 28 | virtual void Pause(); 29 | virtual void Play(); 30 | virtual void Stop(); 31 | virtual void Next(); 32 | virtual void Previous(); 33 | virtual void SetPosition(int position); 34 | virtual void SetRating(int rating); 35 | virtual void SetVolume(int volume); 36 | virtual void SetShuffle(bool state); 37 | virtual void SetRepeat(bool state); 38 | virtual void ClosePlayer(); 39 | virtual void OpenPlayer(std::wstring &path); 40 | 41 | protected: 42 | PlayerITunes(); 43 | 44 | private: 45 | class CEventHandler : public _IiTunesEvents { 46 | public: 47 | CEventHandler(PlayerITunes *player); 48 | ~CEventHandler(); 49 | 50 | // IUnknown 51 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void **ppvObject); 52 | ULONG STDMETHODCALLTYPE AddRef(); 53 | ULONG STDMETHODCALLTYPE Release(); 54 | 55 | // IDispatch 56 | HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT *) { return E_NOTIMPL; } 57 | HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT, LCID, ITypeInfo **) { 58 | return E_NOTIMPL; 59 | } 60 | HRESULT STDMETHODCALLTYPE GetIDsOfNames(const IID &, LPOLESTR *, UINT, LCID, 61 | DISPID *) { 62 | return E_NOTIMPL; 63 | } 64 | 65 | private: 66 | ULONG m_RefCount; 67 | PlayerITunes *m_Player; 68 | IConnectionPoint *m_ConnectionPoint; 69 | DWORD m_ConnectionCookie; 70 | }; 71 | 72 | void Initialize(); 73 | void Uninitialize(); 74 | bool CheckWindow(); 75 | 76 | static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, 77 | LPARAM lParam); 78 | 79 | static Player *c_Player; 80 | 81 | HWND m_CallbackWindow; 82 | DWORD m_LastCheckTime; 83 | bool m_iTunesActive; 84 | IiTunes *m_iTunes; 85 | CEventHandler *m_iTunesEvent; 86 | }; 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/PlayerSpotify.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at . */ 7 | 8 | #ifndef __PLAYERSPOTIFY_H__ 9 | #define __PLAYERSPOTIFY_H__ 10 | 11 | #include "Player.h" 12 | 13 | class PlayerSpotify : public Player { 14 | public: 15 | virtual ~PlayerSpotify(); 16 | 17 | static Player *Create(); 18 | 19 | virtual void Pause() { return Play(); } 20 | virtual void Play(); 21 | virtual void Stop(); 22 | virtual void Next(); 23 | virtual void Previous(); 24 | virtual void ClosePlayer(); 25 | virtual void OpenPlayer(std::wstring &path); 26 | virtual void UpdateData(); 27 | 28 | protected: 29 | PlayerSpotify(); 30 | 31 | private: 32 | enum SPOTIFYCOMMAND { 33 | SPOTIFY_MUTE = 524288, 34 | SPOTIFY_VOLUMEDOWN = 589824, 35 | SPOTIFY_VOLUMEUP = 655360, 36 | SPOTIFY_NEXT = 720896, 37 | SPOTIFY_PREV = 786432, 38 | SPOTIFY_STOP = 851968, 39 | SPOTIFY_PLAYPAUSE = 917504 40 | }; 41 | 42 | bool CheckWindow(); 43 | 44 | static Player *c_Player; 45 | 46 | HWND m_Window; 47 | DWORD m_LastCheckTime; 48 | }; 49 | 50 | LPCWSTR GetExe(HWND hwnd); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/PlayerWLM.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at . */ 7 | 8 | #include "PlayerWLM.h" 9 | 10 | Player *PlayerWLM::c_Player = nullptr; 11 | extern HINSTANCE g_Instance; 12 | 13 | // This player emulates the MSN/WLM Messenger 'Listening to' interface, which is 14 | // supported by OpenPandora, Last.fm, Media Player Classic, TTPlayer, Zune, etc. 15 | 16 | /* 17 | ** Constructor. 18 | ** 19 | */ 20 | PlayerWLM::PlayerWLM() : Player(), m_Window() { 21 | // Create windows class 22 | WNDCLASS wc = {0}; 23 | wc.hInstance = g_Instance; 24 | wc.lpfnWndProc = WndProc; 25 | wc.lpszClassName = L"MsnMsgrUIManager"; 26 | RegisterClass(&wc); 27 | 28 | // Create dummy window 29 | m_Window = CreateWindow(L"MsnMsgrUIManager", L"", WS_DISABLED, CW_USEDEFAULT, 30 | CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, 31 | nullptr, g_Instance, this); 32 | 33 | m_Initialized = true; 34 | } 35 | 36 | /* 37 | ** Destructor. 38 | ** 39 | */ 40 | PlayerWLM::~PlayerWLM() { 41 | c_Player = nullptr; 42 | DestroyWindow(m_Window); 43 | UnregisterClass(L"MsnMsgrUIManager", g_Instance); 44 | } 45 | 46 | /* 47 | ** Creates a shared class object. 48 | ** 49 | */ 50 | Player *PlayerWLM::Create() { 51 | if (!c_Player) { 52 | c_Player = new PlayerWLM(); 53 | } 54 | 55 | return c_Player; 56 | } 57 | 58 | LRESULT CALLBACK PlayerWLM::WndProc(HWND hWnd, UINT msg, WPARAM wParam, 59 | LPARAM lParam) { 60 | static PlayerWLM *player; 61 | 62 | switch (msg) { 63 | case WM_CREATE: { 64 | // Get pointer to the PlayerWLM class from the CreateWindow call 65 | player = (PlayerWLM *)((CREATESTRUCT *)lParam)->lpCreateParams; 66 | return 0; 67 | } 68 | 69 | case WM_COPYDATA: { 70 | PCOPYDATASTRUCT cds = (PCOPYDATASTRUCT)lParam; 71 | if (cds->dwData != 1351) 72 | return 0; 73 | 74 | // lpData: \0Music\0\0\0\0<artist>\0<album>\0 75 | std::wstring data = (WCHAR *)cds->lpData; 76 | 77 | // Some players include player name in the beginning. Skip that. 78 | std::wstring::size_type len = data.find(L"\\0Music\\0"); 79 | len += 9; 80 | data.erase(0, len); // Get rid of \0Music\0 81 | 82 | bool playing = (data[0] == L'1'); 83 | 84 | if (playing) { 85 | ++player->m_TrackCount; 86 | player->m_State = STATE_PLAYING; 87 | data.erase(0, 3); // Get rid of the status 88 | 89 | // TODO: Handle invalid 90 | len = data.find_first_of(L'\\'); 91 | len += 2; 92 | data.erase(0, len); // Get rid of the format 93 | 94 | len = data.find_first_of(L'\\'); 95 | player->m_Title.assign(data, 0, len); 96 | len += 2; 97 | data.erase(0, len); 98 | 99 | len = data.find_first_of(L'\\'); 100 | player->m_Artist.assign(data, 0, len); 101 | len += 2; 102 | data.erase(0, len); 103 | 104 | len = data.find_first_of(L'\\'); 105 | player->m_Album.assign(data, 0, len); 106 | } else { 107 | player->ClearData(false); 108 | } 109 | 110 | return 0; 111 | } 112 | } 113 | 114 | return DefWindowProc(hWnd, msg, wParam, lParam); 115 | } 116 | 117 | void PlayerWLM::SendKeyInput(WORD key) { 118 | KEYBDINPUT kbi = {0}; 119 | kbi.wVk = key; 120 | kbi.dwExtraInfo = (ULONG_PTR)GetMessageExtraInfo(); 121 | 122 | INPUT input = {0}; 123 | input.type = INPUT_KEYBOARD; 124 | input.ki = kbi; 125 | 126 | SendInput(1, &input, sizeof(INPUT)); 127 | } 128 | 129 | /* 130 | ** Called during each update of the main measure. 131 | ** 132 | */ 133 | void PlayerWLM::UpdateData() {} 134 | 135 | /* 136 | ** Handles the Play bang. 137 | ** 138 | */ 139 | void PlayerWLM::Play() { SendKeyInput(VK_MEDIA_PLAY_PAUSE); } 140 | 141 | /* 142 | ** Handles the Stop bang. 143 | ** 144 | */ 145 | void PlayerWLM::Stop() { SendKeyInput(VK_MEDIA_STOP); } 146 | 147 | /* 148 | ** Handles the Next bang. 149 | ** 150 | */ 151 | void PlayerWLM::Next() { SendKeyInput(VK_MEDIA_NEXT_TRACK); } 152 | 153 | /* 154 | ** Handles the Previous bang. 155 | ** 156 | */ 157 | void PlayerWLM::Previous() { SendKeyInput(VK_MEDIA_PREV_TRACK); } 158 | -------------------------------------------------------------------------------- /src/PlayerWLM.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | #ifndef __PLAYERWLM_H__ 9 | #define __PLAYERWLM_H__ 10 | 11 | #include "Player.h" 12 | 13 | class PlayerWLM : public Player { 14 | public: 15 | virtual ~PlayerWLM(); 16 | 17 | static Player *Create(); 18 | 19 | virtual void UpdateData(); 20 | 21 | virtual void Pause() { return Play(); } 22 | virtual void Play(); 23 | virtual void Stop(); 24 | virtual void Next(); 25 | virtual void Previous(); 26 | 27 | protected: 28 | PlayerWLM(); 29 | 30 | private: 31 | static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, 32 | LPARAM lParam); 33 | void SendKeyInput(WORD key); 34 | 35 | static Player *c_Player; 36 | 37 | HWND m_Window; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/PlayerWinamp.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2011 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | #ifndef __PLAYERWINAMP_H__ 9 | #define __PLAYERWINAMP_H__ 10 | 11 | #include "Player.h" 12 | 13 | enum WINAMPTYPE { WA_WINAMP, WA_MEDIAMONKEY }; 14 | 15 | class PlayerWinamp : public Player { 16 | public: 17 | virtual ~PlayerWinamp(); 18 | 19 | static Player *Create(WINAMPTYPE type); 20 | 21 | virtual void UpdateData(); 22 | 23 | virtual void Pause(); 24 | virtual void Play(); 25 | virtual void Stop(); 26 | virtual void Next(); 27 | virtual void Previous(); 28 | virtual void SetPosition(int position); 29 | virtual void SetRating(int rating); 30 | virtual void SetVolume(int volume); 31 | virtual void SetShuffle(bool state); 32 | virtual void SetRepeat(bool state); 33 | virtual void ClosePlayer(); 34 | virtual void OpenPlayer(std::wstring &path); 35 | 36 | protected: 37 | PlayerWinamp(WINAMPTYPE type); 38 | 39 | private: 40 | bool CheckWindow(); 41 | 42 | static Player *c_Player; 43 | 44 | HWND m_Window; // Winamp window 45 | DWORD m_LastCheckTime; 46 | bool m_UseUnicodeAPI; 47 | bool m_PlayingStream; 48 | WINAMPTYPE m_WinampType; 49 | HANDLE m_WinampHandle; // Handle to Winamp process 50 | LPCVOID m_WinampAddress; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/SDKs/CAD/cad_sdk.h: -------------------------------------------------------------------------------- 1 | #ifndef __CADSDK_H__ 2 | #define __CADSDK_H__ 3 | 4 | enum IPCMESSAGE { 5 | IPC_PLAY = 100, 6 | IPC_PLAYPAUSE = 101, 7 | IPC_PAUSE = 102, 8 | IPC_STOP = 103, 9 | IPC_NEXT = 104, 10 | IPC_PREVIOUS = 105, 11 | IPC_VOLUME_CHANGED_NOTIFICATION = 108, 12 | IPC_SET_VOLUME = 108, 13 | IPC_GET_VOLUME = 109, 14 | IPC_GET_CURRENT_TRACK = 110, 15 | IPC_GET_DURATION = 113, 16 | IPC_SET_POSITION = 114, 17 | IPC_SET_CALLBACK_HWND = 120, 18 | IPC_GET_POSITION = 122, 19 | IPC_TRACK_CHANGED_NOTIFICATION = 123, 20 | IPC_SHOW_WINDOW = 124, 21 | IPC_GET_STATE = 125, 22 | IPC_STATE_CHANGED_NOTIFICATION = 126, 23 | IPC_REPEAT_CHANGED_NOTIFICATION = 128, 24 | IPC_SET_REPEAT = 128, 25 | IPC_SHUTDOWN_NOTIFICATION = 129, 26 | IPC_GET_REPEAT = 130, 27 | IPC_CLOSE = 131, 28 | IPC_SHUFFLE_CHANGED_NOTIFICATION = 140, 29 | IPC_GET_SHUFFLE = 140, 30 | IPC_SET_SHUFFLE = 141, 31 | IPC_RATING_CHANGED_NOTIFICATION = 639, 32 | IPC_SET_RATING = 639, 33 | IPC_REGISTER_NOTIFICATION = 700, 34 | IPC_CURRENT_TRACK_NOTIFICATION = 701, 35 | IPC_CURRENT_LYRICS_NOTIFICATION = 702, 36 | IPC_NEW_LYRICS_NOTIFICATION = 703, 37 | IPC_NEW_COVER_NOTIFICATION = 800, 38 | IPC_GET_LYRICS = 801 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/SDKs/Winamp/wa_cmd.h: -------------------------------------------------------------------------------- 1 | #define WINAMP_STOPPED 0 2 | #define WINAMP_PLAYING 1 3 | #define WINAMP_PAUSED 3 4 | 5 | #define WINAMP_FILE_QUIT 40001 6 | #define WINAMP_OPTIONS_PREFS 40012 7 | #define WINAMP_OPTIONS_AOT 40019 8 | #define WINAMP_FILE_REPEAT 40022 9 | #define WINAMP_FILE_SHUFFLE 40023 10 | #define WINAMP_HIGH_PRIORITY 40025 11 | #define WINAMP_FILE_PLAY 40029 12 | #define WINAMP_OPTIONS_EQ 40036 13 | #define WINAMP_OPTIONS_ELAPSED 40037 14 | #define WINAMP_OPTIONS_REMAINING 40038 15 | #define WINAMP_OPTIONS_PLEDIT 40040 16 | #define WINAMP_HELP_ABOUT 40041 17 | #define WINAMP_MAINMENU 40043 18 | #define WINAMP_REWIND 40044 19 | #define WINAMP_PLAY 40045 20 | #define WINAMP_PAUSE 40046 21 | #define WINAMP_STOP 40047 22 | #define WINAMP_FASTFWD 40048 23 | #define WINAMP_VOLUMEUP 40058 24 | #define WINAMP_VOLUMEDOWN 40059 25 | #define WINAMP_FFWD5S 40060 26 | #define WINAMP_REW5S 40061 27 | #define WINAMP_NEXT_WINDOW 40063 28 | #define WINAMP_OPTIONS_WINDOWSHADE 40064 29 | #define WINAMP_REWIND_SHIFT 40144 30 | #define WINAMP_PLAY_SHIFT 40145 31 | #define WINAMP_PAUSE_SHIFT 40146 32 | #define WINAMP_STOP_SHIFT 40147 33 | #define WINAMP_FASTFWD_SHIFT 40148 34 | #define WINAMP_REWIND_CTRL 40154 35 | #define WINAMP_PLAY_CTRL 40155 36 | #define WINAMP_PAUSE_CTRL 40156 37 | #define WINAMP_STOP_CTRL 40157 38 | #define WINAMP_FASTFWD_CTRL 40158 39 | #define WINAMP_OPTIONS_DSIZE 40165 40 | #define IDC_SORT_FILENAME 40166 41 | #define IDC_SORT_FILETITLE 40167 42 | #define IDC_SORT_ENTIREFILENAME 40168 43 | #define IDC_SELECTALL 40169 44 | #define IDC_SELECTNONE 40170 45 | #define IDC_SELECTINV 40171 46 | #define IDM_EQ_LOADPRE 40172 47 | #define IDM_EQ_LOADMP3 40173 48 | #define IDM_EQ_LOADDEFAULT 40174 49 | #define IDM_EQ_SAVEPRE 40175 50 | #define IDM_EQ_SAVEMP3 40176 51 | #define IDM_EQ_SAVEDEFAULT 40177 52 | #define IDM_EQ_DELPRE 40178 53 | #define IDM_EQ_DELMP3 40180 54 | #define IDC_PLAYLIST_PLAY 40184 55 | #define WINAMP_FILE_LOC 40185 56 | #define WINAMP_OPTIONS_EASYMOVE 40186 57 | #define WINAMP_FILE_DIR 40187 58 | #define WINAMP_EDIT_ID3 40188 59 | #define WINAMP_TOGGLE_AUTOSCROLL 40189 60 | #define WINAMP_VISSETUP 40190 61 | #define WINAMP_PLGSETUP 40191 62 | #define WINAMP_VISPLUGIN 40192 63 | #define WINAMP_JUMP 40193 64 | #define WINAMP_JUMPFILE 40194 65 | #define WINAMP_JUMP10FWD 40195 66 | #define WINAMP_JUMP10BACK 40197 67 | 68 | #define WINAMP_OPTIONS_EQ 40036 // toggles the EQ window 69 | #define WINAMP_OPTIONS_PLEDIT 40040 // toggles the playlist window 70 | #define WINAMP_VOLUMEUP 40058 // turns the volume up a little 71 | #define WINAMP_VOLUMEDOWN 40059 // turns the volume down a little 72 | #define WINAMP_FFWD5S 40060 // fast forwards 5 seconds 73 | #define WINAMP_REW5S 40061 // rewinds 5 seconds 74 | 75 | // the following are the five main control buttons, with optionally shift 76 | // or control pressed 77 | // (for the exact functions of each, just try it out) 78 | #define WINAMP_BUTTON1 40044 79 | #define WINAMP_BUTTON2 40045 80 | #define WINAMP_BUTTON3 40046 81 | #define WINAMP_BUTTON4 40047 82 | #define WINAMP_BUTTON5 40048 83 | #define WINAMP_BUTTON1_SHIFT 40144 84 | #define WINAMP_BUTTON2_SHIFT 40145 85 | #define WINAMP_BUTTON3_SHIFT 40146 86 | #define WINAMP_BUTTON4_SHIFT 40147 87 | #define WINAMP_BUTTON5_SHIFT 40148 88 | #define WINAMP_BUTTON1_CTRL 40154 89 | #define WINAMP_BUTTON2_CTRL 40155 90 | #define WINAMP_BUTTON3_CTRL 40156 91 | #define WINAMP_BUTTON4_CTRL 40157 92 | #define WINAMP_BUTTON5_CTRL 40158 93 | 94 | #define WINAMP_FILE_PLAY 40029 // pops up the load file(s) box 95 | #define WINAMP_OPTIONS_PREFS 40012 // pops up the preferences 96 | #define WINAMP_OPTIONS_AOT 40019 // toggles always on top 97 | #define WINAMP_HELP_ABOUT 40041 // pops up the about box :) 98 | -------------------------------------------------------------------------------- /src/SDKs/Winamp/wa_hotkeys.h: -------------------------------------------------------------------------------- 1 | #ifndef WA_HOTKEYS 2 | #define WA_HOTKEYS 3 | 4 | //#define IPC_GEN_HOTKEYS_ADD xxxx //pass a genHotkeysAddStruct * struct in data 5 | // 6 | // To get the IPC_GEN_HOTKEYS_ADD IPC number, do this: 7 | // 8 | // genhotkeys_add_ipc=SendMessage(winampWindow,WM_WA_IPC,(WPARAM)&"GenHotkeysAdd",IPC_REGISTER_WINAMP_IPCMESSAGE); 9 | // 10 | // Then you can use: 11 | // 12 | // PostMessage(winampWindow,WM_WA_IPC,(WPARAM)&myGenHotkeysAddStruct,genhotkeys_add_ipc); 13 | // 14 | 15 | // flags for the genHotkeysAddStruct struct 16 | #define HKF_BRING_TO_FRONT \ 17 | 0x1 // calls SetForegroundWindow before sending the message 18 | #define HKF_HWND_WPARAM 0x2 // sets wParam with Winamp's window handle 19 | #define HKF_COPY 0x4 // copies returned text to the clipboard 20 | #define HKF_PLPOS_WPARAM 0x8 // sets wParam with current pledit position 21 | #define HKF_ISPLAYING_WL \ 22 | 0x10 // sets wParam to genHotkeysAddStruct's wParam if playing, lParam if not 23 | // uses IPC_ISPLAYING to check if playing 24 | #define HKF_SHOWHIDE \ 25 | 0x20 // brings Winamp to front or minimizes Winamp if already at front 26 | #define HKF_NOSENDMSG 0x40 // don't send any message to the winamp window 27 | 28 | #define HKF_DISABLED 0x80000000 29 | 30 | typedef struct { 31 | char *name; // name that will appear in the Global Hotkeys preferences panel 32 | DWORD flags; // one or more flags from above 33 | UINT uMsg; // message that will be sent to winamp's main window (must always 34 | // be !=NULL) 35 | WPARAM wParam; // wParam that will be sent to winamp's main window 36 | LPARAM lParam; // lParam that will be sent to winamp's main window 37 | char *id; // unique string to identify this command - case insensitive 38 | HWND wnd; // set the HWND to send message (or 0 for main winamp window) 39 | 40 | int extended[6]; // for future extension - always set to zero! 41 | } genHotkeysAddStruct; 42 | 43 | #endif -------------------------------------------------------------------------------- /src/readme.txt: -------------------------------------------------------------------------------- 1 | * iTunes implementation based on 2 | - onlylyric by zlbruce (onlylyric.googlecode.com) 3 | - iTunesPlugin by Elestel (rainmeter.googlecode.com) 4 | 5 | * WMP implementation based on 6 | - onlylyric by zlbruce (onlylyric.googlecode.com) 7 | - Last.fm WMP plugin (www.last.fm) -------------------------------------------------------------------------------- /src/taglib/TagLibUnity.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | // TagLib unity build: This file includes several TagLib source files. By compiling all of them 9 | // together, the build performance is greatly increased. 10 | 11 | // The files have been separated into several TagLibUnity_*.cpp files in order help the optimizer. 12 | // Including everything here increases the binary size. 13 | 14 | #pragma warning(push) 15 | #pragma warning(disable: 4244; disable: 4267) 16 | 17 | #include "fileref.cpp" 18 | #include "tag.cpp" 19 | #include "tagunion.cpp" 20 | #include "audioproperties.cpp" 21 | 22 | #include "mpc\mpcfile.cpp" 23 | #include "mpc\mpcproperties.cpp" 24 | 25 | // Included here due to mismatch with toolkit\tfilestream.cpp. 26 | #include "toolkit\tfile.cpp" 27 | 28 | #pragma warning(pop) 29 | -------------------------------------------------------------------------------- /src/taglib/TagLibUnity_ape.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | // TagLib unity build: This file includes several TagLib source files. By compiling all of them 9 | // together, the build performance is greatly increased. 10 | 11 | #pragma warning(push) 12 | #pragma warning(disable: 4244; disable: 4267) 13 | 14 | #include "ape\apefile.cpp" 15 | #include "ape\apefooter.cpp" 16 | #include "ape\apeitem.cpp" 17 | #include "ape\apeproperties.cpp" 18 | #include "ape\apetag.cpp" 19 | 20 | #pragma warning(pop) 21 | -------------------------------------------------------------------------------- /src/taglib/TagLibUnity_asf.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | // TagLib unity build: This file includes several TagLib source files. By compiling all of them 9 | // together, the build performance is greatly increased. 10 | 11 | #pragma warning(push) 12 | #pragma warning(disable: 4244; disable: 4267) 13 | 14 | #include "asf\asfattribute.cpp" 15 | #include "asf\asffile.cpp" 16 | #include "asf\asfpicture.cpp" 17 | #include "asf\asfproperties.cpp" 18 | #include "asf\asftag.cpp" 19 | 20 | #pragma warning(pop) 21 | -------------------------------------------------------------------------------- /src/taglib/TagLibUnity_flac.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | // TagLib unity build: This file includes several TagLib source files. By compiling all of them 9 | // together, the build performance is greatly increased. 10 | 11 | #pragma warning(push) 12 | #pragma warning(disable: 4244; disable: 4267) 13 | 14 | #include "flac\flacfile.cpp" 15 | #include "flac\flacmetadatablock.cpp" 16 | #include "flac\flacpicture.cpp" 17 | #include "flac\flacunknownmetadatablock.cpp" 18 | #include "flac\flacproperties.cpp" 19 | 20 | #pragma warning(pop) 21 | -------------------------------------------------------------------------------- /src/taglib/TagLibUnity_mp4.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | // TagLib unity build: This file includes several TagLib source files. By compiling all of them 9 | // together, the build performance is greatly increased. 10 | 11 | #pragma warning(push) 12 | #pragma warning(disable: 4244; disable: 4267) 13 | 14 | #include "mp4\mp4atom.cpp" 15 | #include "mp4\mp4coverart.cpp" 16 | #include "mp4\mp4file.cpp" 17 | #include "mp4\mp4item.cpp" 18 | #include "mp4\mp4properties.cpp" 19 | #include "mp4\mp4tag.cpp" 20 | 21 | #pragma warning(pop) 22 | -------------------------------------------------------------------------------- /src/taglib/TagLibUnity_mpeg.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | // TagLib unity build: This file includes several TagLib source files. By compiling all of them 9 | // together, the build performance is greatly increased. 10 | 11 | #pragma warning(push) 12 | #pragma warning(disable: 4244; disable: 4267) 13 | 14 | #include "mpeg\mpegfile.cpp" 15 | #include "mpeg\mpegheader.cpp" 16 | #include "mpeg\mpegproperties.cpp" 17 | #include "mpeg\xingheader.cpp" 18 | 19 | #include "mpeg\id3v1\id3v1genres.cpp" 20 | #include "mpeg\id3v1\id3v1tag.cpp" 21 | 22 | #pragma warning(pop) 23 | -------------------------------------------------------------------------------- /src/taglib/TagLibUnity_mpeg_id3v2.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | // TagLib unity build: This file includes several TagLib source files. By compiling all of them 9 | // together, the build performance is greatly increased. 10 | 11 | #pragma warning(push) 12 | #pragma warning(disable: 4244; disable: 4267) 13 | 14 | #include "mpeg\id3v2\frames\attachedpictureframe.cpp" 15 | #include "mpeg\id3v2\frames\commentsframe.cpp" 16 | #include "mpeg\id3v2\frames\generalencapsulatedobjectframe.cpp" 17 | #include "mpeg\id3v2\frames\ownershipframe.cpp" 18 | #include "mpeg\id3v2\frames\popularimeterframe.cpp" 19 | #include "mpeg\id3v2\frames\privateframe.cpp" 20 | #include "mpeg\id3v2\frames\relativevolumeframe.cpp" 21 | #include "mpeg\id3v2\frames\textidentificationframe.cpp" 22 | #include "mpeg\id3v2\frames\uniquefileidentifierframe.cpp" 23 | #include "mpeg\id3v2\frames\unknownframe.cpp" 24 | #include "mpeg\id3v2\frames\unsynchronizedlyricsframe.cpp" 25 | #include "mpeg\id3v2\frames\urllinkframe.cpp" 26 | #include "mpeg\id3v2\id3v2extendedheader.cpp" 27 | #include "mpeg\id3v2\id3v2footer.cpp" 28 | #include "mpeg\id3v2\id3v2frame.cpp" 29 | #include "mpeg\id3v2\id3v2framefactory.cpp" 30 | #include "mpeg\id3v2\id3v2header.cpp" 31 | #include "mpeg\id3v2\id3v2synchdata.cpp" 32 | #include "mpeg\id3v2\id3v2tag.cpp" 33 | 34 | #pragma warning(pop) 35 | -------------------------------------------------------------------------------- /src/taglib/TagLibUnity_ogg.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | // TagLib unity build: This file includes several TagLib source files. By compiling all of them 9 | // together, the build performance is greatly increased. 10 | 11 | #pragma warning(push) 12 | #pragma warning(disable: 4244; disable: 4267) 13 | 14 | #include "ogg\flac\oggflacfile.cpp" 15 | #include "ogg\oggfile.cpp" 16 | #include "ogg\oggpage.cpp" 17 | #include "ogg\oggpageheader.cpp" 18 | #include "ogg\vorbis\vorbisfile.cpp" 19 | #include "ogg\vorbis\vorbisproperties.cpp" 20 | #include "ogg\xiphcomment.cpp" 21 | 22 | #pragma warning(pop) 23 | -------------------------------------------------------------------------------- /src/taglib/TagLibUnity_toolkit.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2014 Rainmeter Project Developers 2 | * 3 | * This Source Code Form is subject to the terms of the GNU General Public 4 | * License; either version 2 of the License, or (at your option) any later 5 | * version. If a copy of the GPL was not distributed with this file, You can 6 | * obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */ 7 | 8 | // TagLib unity build: This file includes most TagLib source files. By compiling all of them 9 | // together, the build performance is greatly increased. 10 | 11 | // The following includes have been commented out and are compiled separately due to e.g. 12 | // mismatching symbols. 13 | /* 14 | #include "mpeg\id3v2\id3v2tag.cpp" 15 | #include "toolkit\tfile.cpp" 16 | */ 17 | 18 | #pragma warning(push) 19 | #pragma warning(disable: 4244; disable: 4267) 20 | 21 | #include "toolkit\tbytevector.cpp" 22 | #include "toolkit\tbytevectorlist.cpp" 23 | #include "toolkit\tbytevectorstream.cpp" 24 | #include "toolkit\tdebug.cpp" 25 | #include "toolkit\tdebuglistener.cpp" 26 | #include "toolkit\tfilestream.cpp" 27 | #include "toolkit\tiostream.cpp" 28 | #include "toolkit\tpropertymap.cpp" 29 | #include "toolkit\trefcounter.cpp" 30 | #include "toolkit\tstring.cpp" 31 | #include "toolkit\tstringlist.cpp" 32 | #include "toolkit\unicode.cpp" 33 | 34 | #pragma warning(pop) 35 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 <tdebug.h> 27 | #include <tstring.h> 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/taglib/audioproperties.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_AUDIOPROPERTIES_H 27 | #define TAGLIB_AUDIOPROPERTIES_H 28 | 29 | #include "taglib_export.h" 30 | 31 | namespace TagLib { 32 | 33 | //! A simple, abstract interface to common audio properties 34 | 35 | /*! 36 | * The values here are common to most audio formats. For more specific, codec 37 | * dependant values, please see see the subclasses APIs. This is meant to 38 | * compliment the TagLib::File and TagLib::Tag APIs in providing a simple 39 | * interface that is sufficient for most applications. 40 | */ 41 | 42 | class TAGLIB_EXPORT AudioProperties 43 | { 44 | public: 45 | 46 | /*! 47 | * Reading audio properties from a file can sometimes be very time consuming 48 | * and for the most accurate results can often involve reading the entire 49 | * file. Because in many situations speed is critical or the accuracy of the 50 | * values is not particularly important this allows the level of desired 51 | * accuracy to be set. 52 | */ 53 | enum ReadStyle { 54 | //! Read as little of the file as possible 55 | Fast, 56 | //! Read more of the file and make better values guesses 57 | Average, 58 | //! Read as much of the file as needed to report accurate values 59 | Accurate 60 | }; 61 | 62 | /*! 63 | * Destroys this AudioProperties instance. 64 | */ 65 | virtual ~AudioProperties(); 66 | 67 | /*! 68 | * Returns the length of the file in seconds. 69 | */ 70 | virtual int length() const = 0; 71 | 72 | /*! 73 | * Returns the most appropriate bit rate for the file in kb/s. For constant 74 | * bitrate formats this is simply the bitrate of the file. For variable 75 | * bitrate formats this is either the average or nominal bitrate. 76 | */ 77 | virtual int bitrate() const = 0; 78 | 79 | /*! 80 | * Returns the sample rate in Hz. 81 | */ 82 | virtual int sampleRate() const = 0; 83 | 84 | /*! 85 | * Returns the number of audio channels. 86 | */ 87 | virtual int channels() const = 0; 88 | 89 | protected: 90 | 91 | /*! 92 | * Construct an audio properties instance. This is protected as this class 93 | * should not be instantiated directly, but should be instantiated via its 94 | * subclasses and can be fetched from the FileRef or File APIs. 95 | * 96 | * \see ReadStyle 97 | */ 98 | AudioProperties(ReadStyle style); 99 | 100 | private: 101 | AudioProperties(const AudioProperties &); 102 | AudioProperties &operator=(const AudioProperties &); 103 | 104 | class AudioPropertiesPrivate; 105 | AudioPropertiesPrivate *d; 106 | }; 107 | 108 | } 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /src/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 <taglib.h> 27 | #include <tdebug.h> 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 <taglib.h> 27 | #include <tdebug.h> 28 | #include <tstring.h> 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 <taglib.h> 27 | #include <tdebug.h> 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 | -------------------------------------------------------------------------------- /src/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<CoverArt> CoverArtList; 70 | 71 | } 72 | 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/taglib/mpc/mpcproperties.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | copyright : (C) 2004 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_MPCPROPERTIES_H 27 | #define TAGLIB_MPCPROPERTIES_H 28 | 29 | #include "taglib_export.h" 30 | #include "audioproperties.h" 31 | 32 | namespace TagLib { 33 | 34 | namespace MPC { 35 | 36 | class File; 37 | 38 | static const uint HeaderSize = 8*7; 39 | 40 | //! An implementation of audio property reading for MPC 41 | 42 | /*! 43 | * This reads the data from an MPC stream found in the AudioProperties 44 | * API. 45 | */ 46 | 47 | class TAGLIB_EXPORT Properties : public AudioProperties 48 | { 49 | public: 50 | /*! 51 | * Create an instance of MPC::Properties with the data read from the 52 | * ByteVector \a data. 53 | * 54 | * This constructor is deprecated. It only works for MPC version up to 7. 55 | */ 56 | Properties(const ByteVector &data, long streamLength, ReadStyle style = Average); 57 | 58 | /*! 59 | * Create an instance of MPC::Properties with the data read directly 60 | * from a MPC::File. 61 | */ 62 | Properties(File *file, long streamLength, ReadStyle style = Average); 63 | 64 | /*! 65 | * Destroys this MPC::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 | /*! 77 | * Returns the version of the bitstream (SV4-SV8) 78 | */ 79 | int mpcVersion() const; 80 | uint totalFrames() const; 81 | uint sampleFrames() const; 82 | 83 | /*! 84 | * Returns the track gain as an integer value, 85 | * to convert to dB: trackGain in dB = 64.82 - (trackGain / 256) 86 | */ 87 | int trackGain() const; 88 | 89 | /*! 90 | * Returns the track peak as an integer value, 91 | * to convert to dB: trackPeak in dB = trackPeak / 256 92 | * to convert to floating [-1..1]: trackPeak = 10^(trackPeak / 256 / 20)/32768 93 | */ 94 | int trackPeak() const; 95 | 96 | /*! 97 | * Returns the album gain as an integer value, 98 | * to convert to dB: albumGain in dB = 64.82 - (albumGain / 256) 99 | */ 100 | int albumGain() const; 101 | 102 | /*! 103 | * Returns the album peak as an integer value, 104 | * to convert to dB: albumPeak in dB = albumPeak / 256 105 | * to convert to floating [-1..1]: albumPeak = 10^(albumPeak / 256 / 20)/32768 106 | */ 107 | int albumPeak() const; 108 | 109 | private: 110 | Properties(const Properties &); 111 | Properties &operator=(const Properties &); 112 | 113 | void readSV7(const ByteVector &data); 114 | void readSV8(File *file); 115 | 116 | class PropertiesPrivate; 117 | PropertiesPrivate *d; 118 | }; 119 | } 120 | } 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /src/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<String, int> 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 | -------------------------------------------------------------------------------- /src/taglib/mpeg/id3v2/frames/popularimeterframe.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | copyright : (C) 2008 by Lukas Lalinsky 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_POPULARIMETERFRAME_H 27 | #define TAGLIB_POPULARIMETERFRAME_H 28 | 29 | #include "id3v2frame.h" 30 | #include "taglib_export.h" 31 | 32 | namespace TagLib { 33 | 34 | namespace ID3v2 { 35 | 36 | //! An implementation of ID3v2 "popularimeter" 37 | 38 | /*! 39 | * This implements the ID3v2 popularimeter (POPM frame). It concists of 40 | * an email, a rating and an optional counter. 41 | */ 42 | 43 | class TAGLIB_EXPORT PopularimeterFrame : public Frame 44 | { 45 | friend class FrameFactory; 46 | 47 | public: 48 | /*! 49 | * Construct an empty popularimeter frame. 50 | */ 51 | explicit PopularimeterFrame(); 52 | 53 | /*! 54 | * Construct a popularimeter based on the data in \a data. 55 | */ 56 | explicit PopularimeterFrame(const ByteVector &data); 57 | 58 | /*! 59 | * Destroys this PopularimeterFrame instance. 60 | */ 61 | virtual ~PopularimeterFrame(); 62 | 63 | /*! 64 | * Returns the text of this popularimeter. 65 | * 66 | * \see text() 67 | */ 68 | virtual String toString() const; 69 | 70 | /*! 71 | * Returns the email. 72 | * 73 | * \see setEmail() 74 | */ 75 | String email() const; 76 | 77 | /*! 78 | * Set the email. 79 | * 80 | * \see email() 81 | */ 82 | void setEmail(const String &email); 83 | 84 | /*! 85 | * Returns the rating. 86 | * 87 | * \see setRating() 88 | */ 89 | int rating() const; 90 | 91 | /*! 92 | * Set the rating. 93 | * 94 | * \see rating() 95 | */ 96 | void setRating(int rating); 97 | 98 | /*! 99 | * Returns the counter. 100 | * 101 | * \see setCounter() 102 | */ 103 | uint counter() const; 104 | 105 | /*! 106 | * Set the counter. 107 | * 108 | * \see counter() 109 | */ 110 | void setCounter(uint counter); 111 | 112 | protected: 113 | // Reimplementations. 114 | 115 | virtual void parseFields(const ByteVector &data); 116 | virtual ByteVector renderFields() const; 117 | 118 | private: 119 | /*! 120 | * The constructor used by the FrameFactory. 121 | */ 122 | PopularimeterFrame(const ByteVector &data, Header *h); 123 | PopularimeterFrame(const PopularimeterFrame &); 124 | PopularimeterFrame &operator=(const PopularimeterFrame &); 125 | 126 | class PopularimeterFramePrivate; 127 | PopularimeterFramePrivate *d; 128 | }; 129 | 130 | } 131 | } 132 | #endif 133 | -------------------------------------------------------------------------------- /src/taglib/mpeg/id3v2/frames/privateframe.cpp: -------------------------------------------------------------------------------- 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 | #include <tbytevectorlist.h> 28 | #include <id3v2tag.h> 29 | #include <tdebug.h> 30 | 31 | #include "privateframe.h" 32 | 33 | using namespace TagLib; 34 | using namespace ID3v2; 35 | 36 | 37 | class PrivateFrame::PrivateFramePrivate 38 | { 39 | public: 40 | ByteVector data; 41 | String owner; 42 | }; 43 | 44 | //////////////////////////////////////////////////////////////////////////////// 45 | // public members 46 | //////////////////////////////////////////////////////////////////////////////// 47 | 48 | PrivateFrame::PrivateFrame() : Frame("PRIV") 49 | { 50 | d = new PrivateFramePrivate; 51 | } 52 | 53 | PrivateFrame::PrivateFrame(const ByteVector &data) : Frame(data) 54 | { 55 | d = new PrivateFramePrivate; 56 | setData(data); 57 | } 58 | 59 | PrivateFrame::~PrivateFrame() 60 | { 61 | delete d; 62 | } 63 | 64 | String PrivateFrame::toString() const 65 | { 66 | return d->owner; 67 | } 68 | 69 | String PrivateFrame::owner() const 70 | { 71 | return d->owner; 72 | } 73 | 74 | ByteVector PrivateFrame::data() const 75 | { 76 | return d->data; 77 | } 78 | 79 | void PrivateFrame::setOwner(const String &s) 80 | { 81 | d->owner = s; 82 | } 83 | 84 | void PrivateFrame::setData(const ByteVector & data) 85 | { 86 | d->data = data; 87 | } 88 | 89 | //////////////////////////////////////////////////////////////////////////////// 90 | // protected members 91 | //////////////////////////////////////////////////////////////////////////////// 92 | 93 | void PrivateFrame::parseFields(const ByteVector &data) 94 | { 95 | if(data.size() < 2) { 96 | debug("A private frame must contain at least 2 bytes."); 97 | return; 98 | } 99 | 100 | // Owner identifier is assumed to be Latin1 101 | 102 | const int byteAlign = 1; 103 | const int endOfOwner = data.find(textDelimiter(String::Latin1), 0, byteAlign); 104 | 105 | d->owner = String(data.mid(0, endOfOwner)); 106 | d->data = data.mid(endOfOwner + 1); 107 | } 108 | 109 | ByteVector PrivateFrame::renderFields() const 110 | { 111 | ByteVector v; 112 | 113 | v.append(d->owner.data(String::Latin1)); 114 | v.append(textDelimiter(String::Latin1)); 115 | v.append(d->data); 116 | 117 | return v; 118 | } 119 | 120 | //////////////////////////////////////////////////////////////////////////////// 121 | // private members 122 | //////////////////////////////////////////////////////////////////////////////// 123 | 124 | PrivateFrame::PrivateFrame(const ByteVector &data, Header *h) : Frame(h) 125 | { 126 | d = new PrivateFramePrivate(); 127 | parseFields(fieldData(data)); 128 | } 129 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/taglib/mpeg/id3v2/id3v2.2.0.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhas/nowplaying-node/6d4455d6ab196866ad409635f6db3fd15cc96251/src/taglib/mpeg/id3v2/id3v2.2.0.txt -------------------------------------------------------------------------------- /src/taglib/mpeg/id3v2/id3v2.3.0.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhas/nowplaying-node/6d4455d6ab196866ad409635f6db3fd15cc96251/src/taglib/mpeg/id3v2/id3v2.3.0.txt -------------------------------------------------------------------------------- /src/taglib/mpeg/id3v2/id3v2.4.0-frames.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhas/nowplaying-node/6d4455d6ab196866ad409635f6db3fd15cc96251/src/taglib/mpeg/id3v2/id3v2.4.0-frames.txt -------------------------------------------------------------------------------- /src/taglib/mpeg/id3v2/id3v2.4.0-structure.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/khanhas/nowplaying-node/6d4455d6ab196866ad409635f6db3fd15cc96251/src/taglib/mpeg/id3v2/id3v2.4.0-structure.txt -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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, <a href="id3v2-structure.html#3.2">3.2</a>) 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 <iostream> 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 | -------------------------------------------------------------------------------- /src/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 | * <a href="id3v2-structure.html#6.2">6.2</a>). 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 <tbytevector.h> 27 | #include <tstring.h> 28 | #include <tdebug.h> 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 | -------------------------------------------------------------------------------- /src/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 | * <a href="http://home.pcisys.net/~melanson/codecs/mp3extensions.txt">this text</a> 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 | -------------------------------------------------------------------------------- /src/taglib/ogg/speex/speexfile.cpp: -------------------------------------------------------------------------------- 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 | #include <bitset> 31 | 32 | #include <tstring.h> 33 | #include <tdebug.h> 34 | #include <tpropertymap.h> 35 | 36 | #include "speexfile.h" 37 | 38 | using namespace TagLib; 39 | using namespace TagLib::Ogg; 40 | 41 | class Speex::File::FilePrivate 42 | { 43 | public: 44 | FilePrivate() : 45 | comment(0), 46 | properties(0) {} 47 | 48 | ~FilePrivate() 49 | { 50 | delete comment; 51 | delete properties; 52 | } 53 | 54 | Ogg::XiphComment *comment; 55 | Properties *properties; 56 | }; 57 | 58 | //////////////////////////////////////////////////////////////////////////////// 59 | // public members 60 | //////////////////////////////////////////////////////////////////////////////// 61 | 62 | Speex::File::File(FileName file, bool readProperties, 63 | Properties::ReadStyle propertiesStyle) : Ogg::File(file) 64 | { 65 | d = new FilePrivate; 66 | if(isOpen()) 67 | read(readProperties, propertiesStyle); 68 | } 69 | 70 | Speex::File::File(IOStream *stream, bool readProperties, 71 | Properties::ReadStyle propertiesStyle) : Ogg::File(stream) 72 | { 73 | d = new FilePrivate; 74 | if(isOpen()) 75 | read(readProperties, propertiesStyle); 76 | } 77 | 78 | Speex::File::~File() 79 | { 80 | delete d; 81 | } 82 | 83 | Ogg::XiphComment *Speex::File::tag() const 84 | { 85 | return d->comment; 86 | } 87 | 88 | PropertyMap Speex::File::properties() const 89 | { 90 | return d->comment->properties(); 91 | } 92 | 93 | PropertyMap Speex::File::setProperties(const PropertyMap &properties) 94 | { 95 | return d->comment->setProperties(properties); 96 | } 97 | 98 | Speex::Properties *Speex::File::audioProperties() const 99 | { 100 | return d->properties; 101 | } 102 | 103 | bool Speex::File::save() 104 | { 105 | if(!d->comment) 106 | d->comment = new Ogg::XiphComment; 107 | 108 | setPacket(1, d->comment->render()); 109 | 110 | return Ogg::File::save(); 111 | } 112 | 113 | //////////////////////////////////////////////////////////////////////////////// 114 | // private members 115 | //////////////////////////////////////////////////////////////////////////////// 116 | 117 | void Speex::File::read(bool readProperties, Properties::ReadStyle propertiesStyle) 118 | { 119 | ByteVector speexHeaderData = packet(0); 120 | 121 | if(!speexHeaderData.startsWith("Speex ")) { 122 | debug("Speex::File::read() -- invalid Speex identification header"); 123 | return; 124 | } 125 | 126 | ByteVector commentHeaderData = packet(1); 127 | 128 | d->comment = new Ogg::XiphComment(commentHeaderData); 129 | 130 | if(readProperties) 131 | d->properties = new Properties(this, propertiesStyle); 132 | } 133 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/taglib/ogg/vorbis/vorbisproperties.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_VORBISPROPERTIES_H 27 | #define TAGLIB_VORBISPROPERTIES_H 28 | 29 | #include "taglib_export.h" 30 | #include "audioproperties.h" 31 | 32 | namespace TagLib { 33 | 34 | /* 35 | * This is just to make this appear to be in the Ogg namespace in the 36 | * documentation. The typedef below will make this work with the current code. 37 | * In the next BIC version of TagLib this will be really moved into the Ogg 38 | * namespace. 39 | */ 40 | 41 | #ifdef DOXYGEN 42 | namespace Ogg { 43 | #endif 44 | 45 | namespace Vorbis { 46 | 47 | class File; 48 | 49 | //! An implementation of audio property reading for Ogg Vorbis 50 | 51 | /*! 52 | * This reads the data from an Ogg Vorbis stream found in the AudioProperties 53 | * API. 54 | */ 55 | 56 | class TAGLIB_EXPORT Properties : public AudioProperties 57 | { 58 | public: 59 | /*! 60 | * Create an instance of Vorbis::Properties with the data read from the 61 | * Vorbis::File \a file. 62 | */ 63 | Properties(File *file, ReadStyle style = Average); 64 | 65 | /*! 66 | * Destroys this VorbisProperties instance. 67 | */ 68 | virtual ~Properties(); 69 | 70 | // Reimplementations. 71 | 72 | virtual int length() const; 73 | virtual int bitrate() const; 74 | virtual int sampleRate() const; 75 | virtual int channels() const; 76 | 77 | /*! 78 | * Returns the Vorbis version, currently "0" (as specified by the spec). 79 | */ 80 | int vorbisVersion() const; 81 | 82 | /*! 83 | * Returns the maximum bitrate as read from the Vorbis identification 84 | * header. 85 | */ 86 | int bitrateMaximum() const; 87 | 88 | /*! 89 | * Returns the nominal bitrate as read from the Vorbis identification 90 | * header. 91 | */ 92 | int bitrateNominal() const; 93 | 94 | /*! 95 | * Returns the minimum bitrate as read from the Vorbis identification 96 | * header. 97 | */ 98 | int bitrateMinimum() const; 99 | 100 | private: 101 | Properties(const Properties &); 102 | Properties &operator=(const Properties &); 103 | 104 | void read(); 105 | 106 | class PropertiesPrivate; 107 | PropertiesPrivate *d; 108 | }; 109 | } 110 | 111 | /* 112 | * To keep compatibility with the current version put Vorbis in the Ogg namespace 113 | * only in the docs and provide a typedef to make it work. In the next BIC 114 | * version this will be removed and it will only exist in the Ogg namespace. 115 | */ 116 | 117 | #ifdef DOXYGEN 118 | } 119 | #else 120 | namespace Ogg { namespace Vorbis { typedef TagLib::AudioProperties AudioProperties; } } 121 | #endif 122 | 123 | } 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 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 | -------------------------------------------------------------------------------- /src/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 <class T> T *access(int index, bool create) 77 | { 78 | if(!create || tag(index)) 79 | return static_cast<T *>(tag(index)); 80 | 81 | set(index, new T); 82 | return static_cast<T *>(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 | -------------------------------------------------------------------------------- /src/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<ByteVector>() 74 | { 75 | 76 | } 77 | 78 | ByteVectorList::ByteVectorList(const ByteVectorList &l) : List<ByteVector>(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 | -------------------------------------------------------------------------------- /src/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<ByteVector> 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 | -------------------------------------------------------------------------------- /src/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 <config.h> 28 | #endif 29 | 30 | #include "tdebug.h" 31 | #include "tstring.h" 32 | #include "tdebuglistener.h" 33 | 34 | #include <bitset> 35 | #include <cstdio> 36 | #include <cstdarg> 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 <iostream> 29 | #include <bitset> 30 | 31 | #ifdef _WIN32 32 | # include <windows.h> 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<char> 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 <config.h> 28 | #endif 29 | 30 | #include "trefcounter.h" 31 | 32 | #if defined(HAVE_STD_ATOMIC) 33 | # include <atomic> 34 | # define ATOMIC_INT std::atomic<unsigned int> 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 <boost/atomic.hpp> 39 | # define ATOMIC_INT boost::atomic<unsigned int> 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 <windows.h> 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 <libkern/OSAtomic.h> 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 <ia64intrin.h> 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 | -------------------------------------------------------------------------------- /src/taglib/toolkit/trefcounter.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_REFCOUNTER_H 27 | #define TAGLIB_REFCOUNTER_H 28 | 29 | #include "taglib_export.h" 30 | #include "taglib.h" 31 | 32 | #ifdef __APPLE__ 33 | # include <libkern/OSAtomic.h> 34 | # define TAGLIB_ATOMIC_MAC 35 | #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 36 | # define NOMINMAX 37 | # include <windows.h> 38 | # define TAGLIB_ATOMIC_WIN 39 | #elif defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 401) \ 40 | && (defined(__i386__) || defined(__i486__) || defined(__i586__) || \ 41 | defined(__i686__) || defined(__x86_64) || defined(__ia64)) \ 42 | && !defined(__INTEL_COMPILER) 43 | # define TAGLIB_ATOMIC_GCC 44 | #elif defined(__ia64) && defined(__INTEL_COMPILER) 45 | # include <ia64intrin.h> 46 | # define TAGLIB_ATOMIC_GCC 47 | #endif 48 | 49 | #ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class. 50 | /*! 51 | * \internal 52 | * This is just used as a base class for shared classes in TagLib. 53 | * 54 | * \warning This <b>is not</b> part of the TagLib public API! 55 | */ 56 | namespace TagLib 57 | { 58 | 59 | class TAGLIB_EXPORT RefCounter 60 | { 61 | public: 62 | RefCounter(); 63 | virtual ~RefCounter(); 64 | 65 | void ref(); 66 | bool deref(); 67 | int count() const; 68 | 69 | private: 70 | class RefCounterPrivate; 71 | RefCounterPrivate *d; 72 | }; 73 | 74 | // BIC this old class is needed by tlist.tcc and tmap.tcc 75 | class RefCounterOld 76 | { 77 | public: 78 | RefCounterOld() : refCount(1) {} 79 | 80 | #ifdef TAGLIB_ATOMIC_MAC 81 | void ref() { OSAtomicIncrement32Barrier(const_cast<int32_t*>(&refCount)); } 82 | bool deref() { return ! OSAtomicDecrement32Barrier(const_cast<int32_t*>(&refCount)); } 83 | int32_t count() { return refCount; } 84 | private: 85 | volatile int32_t refCount; 86 | #elif defined(TAGLIB_ATOMIC_WIN) 87 | void ref() { InterlockedIncrement(&refCount); } 88 | bool deref() { return ! InterlockedDecrement(&refCount); } 89 | long count() { return refCount; } 90 | private: 91 | volatile long refCount; 92 | #elif defined(TAGLIB_ATOMIC_GCC) 93 | void ref() { __sync_add_and_fetch(&refCount, 1); } 94 | bool deref() { return ! __sync_sub_and_fetch(&refCount, 1); } 95 | int count() { return refCount; } 96 | private: 97 | volatile int refCount; 98 | #else 99 | void ref() { refCount++; } 100 | bool deref() { return ! --refCount; } 101 | int count() { return refCount; } 102 | private: 103 | uint refCount; 104 | #endif 105 | }; 106 | 107 | } 108 | 109 | #endif // DO_NOT_DOCUMENT 110 | #endif 111 | 112 | -------------------------------------------------------------------------------- /src/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<String>() 59 | { 60 | 61 | } 62 | 63 | StringList::StringList(const StringList &l) : List<String>(l) 64 | { 65 | 66 | } 67 | 68 | StringList::StringList(const String &s) : List<String>() 69 | { 70 | append(s); 71 | } 72 | 73 | StringList::StringList(const ByteVectorList &bl, String::Type t) : List<String>() 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<String>::append(s); 106 | return *this; 107 | } 108 | 109 | StringList &StringList::append(const StringList &l) 110 | { 111 | List<String>::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 | -------------------------------------------------------------------------------- /src/taglib/toolkit/tstringlist.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_STRINGLIST_H 27 | #define TAGLIB_STRINGLIST_H 28 | 29 | #include "tstring.h" 30 | #include "tlist.h" 31 | #include "tbytevectorlist.h" 32 | #include "taglib_export.h" 33 | 34 | #include <iostream> 35 | 36 | namespace TagLib { 37 | 38 | //! A list of strings 39 | 40 | /*! 41 | * This is a spcialization of the List class with some members convention for 42 | * string operations. 43 | */ 44 | 45 | class TAGLIB_EXPORT StringList : public List<String> 46 | { 47 | public: 48 | 49 | /*! 50 | * Constructs an empty StringList. 51 | */ 52 | StringList(); 53 | 54 | /*! 55 | * Make a shallow, implicitly shared, copy of \a l. Because this is 56 | * implicitly shared, this method is lightweight and suitable for 57 | * pass-by-value usage. 58 | */ 59 | StringList(const StringList &l); 60 | 61 | /*! 62 | * Constructs a StringList with \a s as a member. 63 | */ 64 | StringList(const String &s); 65 | 66 | /*! 67 | * Makes a deep copy of the data in \a vl. 68 | * 69 | * \note This should only be used with the 8-bit codecs Latin1 and UTF8, when 70 | * used with other codecs it will simply print a warning and exit. 71 | */ 72 | StringList(const ByteVectorList &vl, String::Type t = String::Latin1); 73 | 74 | /*! 75 | * Destroys this StringList instance. 76 | */ 77 | virtual ~StringList(); 78 | 79 | /*! 80 | * Concatenate the list of strings into one string separated by \a separator. 81 | */ 82 | String toString(const String &separator = " ") const; 83 | 84 | /*! 85 | * Appends \a s to the end of the list and returns a reference to the 86 | * list. 87 | */ 88 | StringList &append(const String &s); 89 | 90 | /*! 91 | * Appends all of the values in \a l to the end of the list and returns a 92 | * reference to the list. 93 | */ 94 | StringList &append(const StringList &l); 95 | 96 | /*! 97 | * Splits the String \a s into several strings at \a pattern. This will not include 98 | * the pattern in the returned strings. 99 | */ 100 | static StringList split(const String &s, const String &pattern); 101 | 102 | private: 103 | class StringListPrivate; 104 | StringListPrivate *d; 105 | }; 106 | 107 | } 108 | 109 | /*! 110 | * \related TagLib::StringList 111 | * Send the StringList to an output stream. 112 | */ 113 | std::ostream &operator<<(std::ostream &s, const TagLib::StringList &l); 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2015", 4 | "types": ["node"], 5 | "typeRoots": ["node_modules/@types"], 6 | "sourceMap": true, 7 | "module": "commonjs", 8 | "moduleResolution": "node", 9 | "noImplicitAny": true, 10 | "removeComments": false, 11 | "preserveConstEnums": true, 12 | "suppressImplicitAnyIndexErrors": false, 13 | "noResolve": false, 14 | "noUnusedParameters": true, 15 | "noUnusedLocals": true, 16 | "strictNullChecks": true 17 | }, 18 | "include": [ 19 | "index.ts" 20 | ], 21 | } --------------------------------------------------------------------------------