Some basic WMA code added, reads file properties correctly, code of function tag_recode in asf.c changed due to crasher (this needs to be investigated)

CQTexperiment
areff 2008-02-28 05:33:56 +00:00
parent 37d159e009
commit c5a869d406
5 changed files with 146 additions and 8 deletions

View File

@ -832,6 +832,7 @@ static char *getlocale()
static void tag_recode(char *before, unsigned int len) static void tag_recode(char *before, unsigned int len)
{ {
return;
int result; int result;
iconv_t frt; iconv_t frt;
char ansb[len]; char ansb[len];

View File

@ -399,9 +399,9 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
if (!fmt || must_open_file) { if (!fmt || must_open_file) {
/* if no file needed do not try to open one */ /* if no file needed do not try to open one */
if (url_fopen(pb, filename, URL_RDONLY) < 0) { if ((err = url_fopen(pb, filename, URL_RDONLY)) < 0) {
err = AVERROR_IO; //err = AVERROR_IO;
goto fail; goto fail;
} }
file_opened = 1; file_opened = 1;
if (buf_size > 0) { if (buf_size > 0) {

View File

@ -19,14 +19,14 @@
isa = PBXContainerItemProxy; isa = PBXContainerItemProxy;
containerPortal = B09E95030D748F9B0064F138 /* WMA.xcodeproj */; containerPortal = B09E95030D748F9B0064F138 /* WMA.xcodeproj */;
proxyType = 2; proxyType = 2;
remoteGlobalIDString = 8DC2EF5B0486A6940098B216 /* WMA.framework */; remoteGlobalIDString = 8DC2EF5B0486A6940098B216;
remoteInfo = WMA; remoteInfo = WMA;
}; };
B09E95450D7496C60064F138 /* PBXContainerItemProxy */ = { B09E95450D7496C60064F138 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy; isa = PBXContainerItemProxy;
containerPortal = B09E95030D748F9B0064F138 /* WMA.xcodeproj */; containerPortal = B09E95030D748F9B0064F138 /* WMA.xcodeproj */;
proxyType = 1; proxyType = 1;
remoteGlobalIDString = 8DC2EF4F0486A6940098B216 /* WMA Framework */; remoteGlobalIDString = 8DC2EF4F0486A6940098B216;
remoteInfo = "WMA Framework"; remoteInfo = "WMA Framework";
}; };
/* End PBXContainerItemProxy section */ /* End PBXContainerItemProxy section */
@ -56,7 +56,6 @@
B09E942E0D747F410064F138 /* WMADecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMADecoder.m; sourceTree = "<group>"; }; B09E942E0D747F410064F138 /* WMADecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WMADecoder.m; sourceTree = "<group>"; };
B09E94370D747FAD0064F138 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../Audio/Plugin.h; sourceTree = SOURCE_ROOT; }; B09E94370D747FAD0064F138 /* Plugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Plugin.h; path = ../../Audio/Plugin.h; sourceTree = SOURCE_ROOT; };
B09E95030D748F9B0064F138 /* WMA.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = WMA.xcodeproj; path = ../../Frameworks/WMA/WMA.xcodeproj; sourceTree = SOURCE_ROOT; }; B09E95030D748F9B0064F138 /* WMA.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = WMA.xcodeproj; path = ../../Frameworks/WMA/WMA.xcodeproj; sourceTree = SOURCE_ROOT; };
B09E958A0D749E890064F138 /* WMA.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WMA.framework; path = ../../build/Release/WMA.framework; sourceTree = SOURCE_ROOT; };
B09E95F50D74A3ED0064F138 /* Frameworks-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Frameworks-Info.plist"; sourceTree = "<group>"; }; B09E95F50D74A3ED0064F138 /* Frameworks-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Frameworks-Info.plist"; sourceTree = "<group>"; };
D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; }; D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -77,7 +76,6 @@
089C166AFE841209C02AAC07 /* WMA */ = { 089C166AFE841209C02AAC07 /* WMA */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
B09E958A0D749E890064F138 /* WMA.framework */,
08FB77AFFE84173DC02AAC07 /* Classes */, 08FB77AFFE84173DC02AAC07 /* Classes */,
32C88E010371C26100C91783 /* Other Sources */, 32C88E010371C26100C91783 /* Other Sources */,
089C167CFE841241C02AAC07 /* Resources */, 089C167CFE841241C02AAC07 /* Resources */,

View File

@ -9,7 +9,23 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "Plugin.h" #import "Plugin.h"
@interface WMADecoder : NSObject { #import "WMA/avcodec.h"
#import "WMA/avformat.h"
@interface WMADecoder : NSObject <CogDecoder>
{
id<CogSource> source;
AVFormatContext *ic;
AVCodecContext *c;
AVCodec *codec;
BOOL seekable;
int bitsPerSample;
int bitrate;
int channels;
float frequency;
long totalFrames;
} }

View File

@ -9,7 +9,130 @@
// test // test
#import "WMADecoder.h" #import "WMADecoder.h"
#define ST_BUFF 2048
@implementation WMADecoder @implementation WMADecoder
- (BOOL)open:(id<CogSource>)s
{
source = [s retain];
ic = NULL;
av_register_all();
int err, i;
const char *filename = [[[source url] path] UTF8String];
int st_buff;
uint8_t *outbuf, *s_outbuf;
NSLog(@"lolbots: %s", filename);
err = av_open_input_file(&ic, filename, NULL, 0, NULL);
if (err < 0)
NSLog(@"Opening .WMA file failed horribly: %d", err);
for(i = 0; i < ic->nb_streams; i++) {
c = &ic->streams[i]->codec;
if(c->codec_type == CODEC_TYPE_AUDIO)
{
NSLog(@"audio codec found");
break;
}
}
av_find_stream_info(ic);
codec = avcodec_find_decoder(c->codec_id);
if (!codec) {
NSLog(@"codec not found");
return NO;
}
if (avcodec_open(c, codec) < 0) {
NSLog(@"could not open codec");
return NO;
}
st_buff = ST_BUFF;
outbuf = av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
s_outbuf = av_malloc(st_buff);
dump_format(ic, 0, filename, 0);
if (ic->title[0] != '\0')
NSLog(@"Title: %s", ic->title);
if (ic->author[0] != '\0')
NSLog(@"Author: %s", ic->author);
if (ic->album[0] != '\0')
NSLog(@"Album: %s", ic->album);
if (ic->year != 0)
NSLog(@"Year: %d", ic->year);
if (ic->track != 0)
NSLog(@"Track: %d", ic->track);
if (ic->genre[0] != '\0')
NSLog(@"Genre: %s", ic->genre);
if (ic->copyright[0] != '\0')
NSLog(@"Copyright: %s", ic->copyright);
if (ic->comment[0] != '\0')
NSLog(@"Comments: %s", ic->comment);
NSLog(@"bitrate: %d", ic->bit_rate);
return YES;
}
- (void)close
{
avcodec_close(c);
av_close_input_file(ic);
[source close];
[source release];
}
- (int)readAudio:(void *)buf frames:(UInt32)frames
{
return 0;
}
- (long)seek:(long)frame
{
return 0;
}
- (NSDictionary *)properties
{
return [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:channels], @"channels",
[NSNumber numberWithInt:bitsPerSample], @"bitsPerSample",
[NSNumber numberWithFloat:frequency], @"sampleRate",
[NSNumber numberWithDouble:totalFrames], @"totalFrames",
[NSNumber numberWithInt:bitrate], @"bitrate",
[NSNumber numberWithBool:([source seekable] && seekable)], @"seekable",
nil];
}
+ (NSArray *)fileTypes
{
return [NSArray arrayWithObjects:@"wma",nil];
}
+ (NSArray *)mimeTypes
{
return [NSArray arrayWithObjects:@"application/wma", @"application/x-wma", @"audio/x-wma", nil];
}
@end @end