aac读写操作调试例子

// 读取aac文件
#if 1
		static FILE * faacE = NULL;
        static int id = 0;
        if (faacE == NULL) {
			faacE = fopen("/data/testE.aac", "r");
			//faacE = fopen("/data/test.aac", "r");
			rewind(faacE);
        }	
		if (faacE) {
			rel = fread(buf, 1, 7, faacE);
			TRACE1("read file rel=%d\n", rel);
			if (rel < 7) {
				TRACE1("read file eof1\n");
				rewind(faacE);
				id = 0;
			} else {
		        if((buf[0] == 0xff) && ((buf[1] & 0xf0) == 0xf0) ){  
		            size |= ((buf[3] & 0x03) <<11);     //high 2 bit  
		            size |= buf[4]<<3;                //middle 8 bit  
		            size |= ((buf[5] & 0xe0)>>5);        //low 3bit   
		        }
				rel = fread(buf + 7, 1, size - 7, faacE);
				TRACE1("read file size: %d, id : %d, rel : %d\n", size, id++, rel);
				if (rel < (size - 7)) {
					TRACE1("read file eof2\n");
					rewind(faacE);
					id = 0;
				}
			}	
		}
#endif		
	}

// 保存aac数据到文件
#if 1
    static FILE * faacE = NULL;
    if(faacE == NULL)
    {
#if 0
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
        NSMutableString * path = [[NSMutableString alloc]initWithString:documentsDirectory];
        [path appendString:@"/testE.aac"];
        faacE = fopen([path UTF8String], "wb");
#else
        faacE = fopen("/mnt/sdcard/testE.aac", "wb");
#endif
    }
    if(faacE)
    {
        fwrite(adts_buf, 1, 7, faacE);
        fwrite(apInputBuffer, 1, anInputLen, faacE);
        fflush(faacE);
    }
#endif

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值