[Ogg Vorbis / Opus Inputs] Fix streaming titles
Fix streaming metadata titles being overridden by the Icecast stream strings. Now the Icy metadata only overrides missing strings, so Vorbis Comments take priority. Fixes #275 Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
a0761a41c9
commit
0931686a78
|
@ -34,6 +34,11 @@
|
|||
float replayGainAlbumGain;
|
||||
float replayGainTrackGain;
|
||||
|
||||
NSString *icygenre;
|
||||
NSString *icyalbum;
|
||||
NSString *icyartist;
|
||||
NSString *icytitle;
|
||||
|
||||
NSData *albumArt;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#import "HTTPSource.h"
|
||||
|
||||
#import "NSDictionary+Merge.h"
|
||||
|
||||
@implementation OpusFile
|
||||
|
||||
static const int MAXCHANNELS = 8;
|
||||
|
@ -124,6 +126,10 @@ opus_int64 sourceTell(void *_stream) {
|
|||
album = @"";
|
||||
title = @"";
|
||||
genre = @"";
|
||||
icygenre = @"";
|
||||
icyalbum = @"";
|
||||
icyartist = @"";
|
||||
icytitle = @"";
|
||||
year = @(0);
|
||||
track = @(0);
|
||||
disc = @(0);
|
||||
|
@ -233,10 +239,10 @@ opus_int64 sourceTell(void *_stream) {
|
|||
- (void)updateIcyMetadata {
|
||||
if([source seekable]) return;
|
||||
|
||||
NSString *_genre = genre;
|
||||
NSString *_album = album;
|
||||
NSString *_artist = artist;
|
||||
NSString *_title = title;
|
||||
NSString *_genre = icygenre;
|
||||
NSString *_album = icyalbum;
|
||||
NSString *_artist = icyartist;
|
||||
NSString *_title = icytitle;
|
||||
|
||||
Class sourceClass = [source class];
|
||||
if([sourceClass isEqual:NSClassFromString(@"HTTPSource")]) {
|
||||
|
@ -250,14 +256,14 @@ opus_int64 sourceTell(void *_stream) {
|
|||
}
|
||||
}
|
||||
|
||||
if(![_genre isEqual:genre] ||
|
||||
![_album isEqual:album] ||
|
||||
![_artist isEqual:artist] ||
|
||||
![_title isEqual:title]) {
|
||||
genre = _genre;
|
||||
album = _album;
|
||||
artist = _artist;
|
||||
title = _title;
|
||||
if(![_genre isEqual:icygenre] ||
|
||||
![_album isEqual:icyalbum] ||
|
||||
![_artist isEqual:icyartist] ||
|
||||
![_title isEqual:icytitle]) {
|
||||
icygenre = _genre;
|
||||
icyalbum = _album;
|
||||
icyartist = _artist;
|
||||
icytitle = _title;
|
||||
[self willChangeValueForKey:@"metadata"];
|
||||
[self didChangeValueForKey:@"metadata"];
|
||||
}
|
||||
|
@ -340,7 +346,7 @@ opus_int64 sourceTell(void *_stream) {
|
|||
}
|
||||
|
||||
- (NSDictionary *)metadata {
|
||||
return @{ @"artist": artist, @"albumartist": albumartist, @"album": album, @"title": title, @"genre": genre, @"year": year, @"track": track, @"disc": disc, @"albumArt": albumArt };
|
||||
return [@{ @"artist": artist, @"albumartist": albumartist, @"album": album, @"title": title, @"genre": genre, @"year": year, @"track": track, @"disc": disc, @"albumArt": albumArt } dictionaryByMergingWith:@{ @"genre": icygenre, @"album": icyalbum, @"artist": icyartist, @"title": icytitle }];
|
||||
}
|
||||
|
||||
+ (NSArray *)fileTypes {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
83186316285CEC91001422CC /* NSDictionary+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = 83186315285CEC91001422CC /* NSDictionary+Merge.m */; };
|
||||
836EF0CF27BB952F00BF35B2 /* libopusfile.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 836EF0CE27BB952F00BF35B2 /* libopusfile.0.dylib */; };
|
||||
8375B04017FFEA400092A79F /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8375B03F17FFEA400092A79F /* Cocoa.framework */; };
|
||||
8375B04A17FFEA400092A79F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8375B04817FFEA400092A79F /* InfoPlist.strings */; };
|
||||
|
@ -26,6 +27,8 @@
|
|||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
83186314285CEC91001422CC /* NSDictionary+Merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Merge.h"; path = "../../../Utils/NSDictionary+Merge.h"; sourceTree = "<group>"; };
|
||||
83186315285CEC91001422CC /* NSDictionary+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Merge.m"; path = "../../../Utils/NSDictionary+Merge.m"; sourceTree = "<group>"; };
|
||||
833F68411CDBCABC00AFB9F0 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
8356BD1B27B469B80074E50C /* HTTPSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPSource.h; path = ../../HTTPSource/HTTPSource.h; sourceTree = "<group>"; };
|
||||
836EF0CE27BB952F00BF35B2 /* libopusfile.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libopusfile.0.dylib; path = ../../ThirdParty/opusfile/lib/libopusfile.0.dylib; sourceTree = "<group>"; };
|
||||
|
@ -96,6 +99,8 @@
|
|||
8375B04517FFEA400092A79F /* Opus */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83186314285CEC91001422CC /* NSDictionary+Merge.h */,
|
||||
83186315285CEC91001422CC /* NSDictionary+Merge.m */,
|
||||
8356BD1B27B469B80074E50C /* HTTPSource.h */,
|
||||
8384913718081F2700E7332D /* Logging.h */,
|
||||
8375B36D17FFF1FE0092A79F /* Plugin.h */,
|
||||
|
@ -188,6 +193,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8375B36C17FFF1CB0092A79F /* OpusDecoder.m in Sources */,
|
||||
83186316285CEC91001422CC /* NSDictionary+Merge.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -45,6 +45,11 @@
|
|||
float replayGainTrackGain;
|
||||
float replayGainTrackPeak;
|
||||
|
||||
NSString *icygenre;
|
||||
NSString *icyalbum;
|
||||
NSString *icyartist;
|
||||
NSString *icytitle;
|
||||
|
||||
NSData *albumArt;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#import "picture.h"
|
||||
|
||||
#import "NSDictionary+Merge.h"
|
||||
|
||||
@implementation VorbisDecoder
|
||||
|
||||
static const int MAXCHANNELS = 8;
|
||||
|
@ -104,6 +106,10 @@ long sourceTell(void *datasource) {
|
|||
album = @"";
|
||||
title = @"";
|
||||
genre = @"";
|
||||
icygenre = @"";
|
||||
icyalbum = @"";
|
||||
icyartist = @"";
|
||||
icytitle = @"";
|
||||
year = @(0);
|
||||
track = @(0);
|
||||
disc = @(0);
|
||||
|
@ -211,10 +217,10 @@ long sourceTell(void *datasource) {
|
|||
- (void)updateIcyMetadata {
|
||||
if([source seekable]) return;
|
||||
|
||||
NSString *_genre = genre;
|
||||
NSString *_album = album;
|
||||
NSString *_artist = artist;
|
||||
NSString *_title = title;
|
||||
NSString *_genre = icygenre;
|
||||
NSString *_album = icyalbum;
|
||||
NSString *_artist = icyartist;
|
||||
NSString *_title = icytitle;
|
||||
|
||||
Class sourceClass = [source class];
|
||||
if([sourceClass isEqual:NSClassFromString(@"HTTPSource")]) {
|
||||
|
@ -228,14 +234,14 @@ long sourceTell(void *datasource) {
|
|||
}
|
||||
}
|
||||
|
||||
if(![_genre isEqual:genre] ||
|
||||
![_album isEqual:album] ||
|
||||
![_artist isEqual:artist] ||
|
||||
![_title isEqual:title]) {
|
||||
genre = _genre;
|
||||
album = _album;
|
||||
artist = _artist;
|
||||
title = _title;
|
||||
if(![_genre isEqual:icygenre] ||
|
||||
![_album isEqual:icyalbum] ||
|
||||
![_artist isEqual:icyartist] ||
|
||||
![_title isEqual:icytitle]) {
|
||||
icygenre = _genre;
|
||||
icyalbum = _album;
|
||||
icyartist = _artist;
|
||||
icytitle = _title;
|
||||
[self willChangeValueForKey:@"metadata"];
|
||||
[self didChangeValueForKey:@"metadata"];
|
||||
}
|
||||
|
@ -319,7 +325,7 @@ long sourceTell(void *datasource) {
|
|||
}
|
||||
|
||||
- (NSDictionary *)metadata {
|
||||
return @{ @"artist": artist, @"albumartist": albumartist, @"album": album, @"title": title, @"genre": genre, @"year": year, @"track": track, @"disc": disc, @"albumArt": albumArt };
|
||||
return [@{ @"artist": artist, @"albumartist": albumartist, @"album": album, @"title": title, @"genre": genre, @"year": year, @"track": track, @"disc": disc, @"albumArt": albumArt } dictionaryByMergingWith:@{ @"genre": icygenre, @"album": icyalbum, @"artist": icyartist, @"title": icytitle }];
|
||||
}
|
||||
|
||||
+ (NSArray *)fileTypes {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
/* Begin PBXBuildFile section */
|
||||
17C93D360B8FDA66008627D6 /* VorbisDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 17C93D340B8FDA66008627D6 /* VorbisDecoder.m */; };
|
||||
83186313285CEBD2001422CC /* NSDictionary+Merge.m in Sources */ = {isa = PBXBuildFile; fileRef = 83186312285CEBD2001422CC /* NSDictionary+Merge.m */; };
|
||||
836EF0D627BB969D00BF35B2 /* libvorbisfile.3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 836EF0D427BB969D00BF35B2 /* libvorbisfile.3.dylib */; };
|
||||
836EF0DF27BB987000BF35B2 /* libvorbis.0.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 836EF0DE27BB987000BF35B2 /* libvorbis.0.dylib */; };
|
||||
83AA661627B7FAFC0098D4B8 /* picture.c in Sources */ = {isa = PBXBuildFile; fileRef = 83AA661127B7FAFC0098D4B8 /* picture.c */; };
|
||||
|
@ -23,6 +24,8 @@
|
|||
17C93D330B8FDA66008627D6 /* VorbisDecoder.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = VorbisDecoder.h; sourceTree = "<group>"; };
|
||||
17C93D340B8FDA66008627D6 /* VorbisDecoder.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = VorbisDecoder.m; sourceTree = "<group>"; };
|
||||
32DBCF630370AF2F00C91783 /* VorbisPlugin_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VorbisPlugin_Prefix.pch; sourceTree = "<group>"; };
|
||||
83186311285CEBD2001422CC /* NSDictionary+Merge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSDictionary+Merge.h"; path = "../../Utils/NSDictionary+Merge.h"; sourceTree = "<group>"; };
|
||||
83186312285CEBD2001422CC /* NSDictionary+Merge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSDictionary+Merge.m"; path = "../../Utils/NSDictionary+Merge.m"; sourceTree = "<group>"; };
|
||||
8356BD1C27B46A2D0074E50C /* HTTPSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTTPSource.h; path = ../HTTPSource/HTTPSource.h; sourceTree = "<group>"; };
|
||||
836EF0D427BB969D00BF35B2 /* libvorbisfile.3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libvorbisfile.3.dylib; path = ../../ThirdParty/vorbis/lib/libvorbisfile.3.dylib; sourceTree = "<group>"; };
|
||||
836EF0DE27BB987000BF35B2 /* libvorbis.0.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libvorbis.0.dylib; path = ../../ThirdParty/vorbis/lib/libvorbis.0.dylib; sourceTree = "<group>"; };
|
||||
|
@ -84,6 +87,8 @@
|
|||
08FB77AFFE84173DC02AAC07 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
83186311285CEBD2001422CC /* NSDictionary+Merge.h */,
|
||||
83186312285CEBD2001422CC /* NSDictionary+Merge.m */,
|
||||
8356BD1C27B46A2D0074E50C /* HTTPSource.h */,
|
||||
8384913418081A3900E7332D /* Logging.h */,
|
||||
177FCF9D0B90C9530011C3B5 /* Plugin.h */,
|
||||
|
@ -250,6 +255,7 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
83AA661627B7FAFC0098D4B8 /* picture.c in Sources */,
|
||||
83186313285CEBD2001422CC /* NSDictionary+Merge.m in Sources */,
|
||||
83AA661727B7FAFD0098D4B8 /* base64.c in Sources */,
|
||||
17C93D360B8FDA66008627D6 /* VorbisDecoder.m in Sources */,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue