aac读写操作调试例子

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mandagod/article/details/73549096
// 读取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

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页