]> sjero.net Git - linphone/blob - console/wav2raw.c
Aac-eld add missing header according to RFC3640 3.3.6
[linphone] / console / wav2raw.c
1
2
3 #include "../config.h"
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include <string.h>
10 #include <unistd.h>
11 #include <errno.h>
12
13 int main(int argc, char *argv[])
14 {
15         int ifd,ofd;
16         char *name,*p;
17         char buf[200];
18         int len;
19
20         if (argc<2) return -1;  
21         name=malloc(strlen(argv[1])+10);
22         sprintf(name,"%s",argv[1]);
23         p=strstr(name,".raw");
24         if (p!=NULL){
25                 sprintf(p,"%s",".wav\0");
26         }else{
27                 sprintf(name,"%s%s",argv[1],".raw");
28         }
29         
30         ifd=open(name,O_RDONLY);
31         if (ifd<0) {
32                 perror("Could not open input file");
33                 return -1;
34         }
35         ofd=open(argv[1],O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP);
36         if (ofd<0) {
37                 perror("Could not open output file");
38                 return -1;
39         }
40         len=read(ifd,buf,20);
41         printf("len=%i\n",len);
42         /* erase the wav header */
43         if (len>0){
44                 memset(buf,0,20);
45                 write(ofd,buf,20);
46         }else{
47                 printf("Error while processing %s: %s\n",argv[1],strerror(errno));
48                 return -1;
49         };
50
51         while ( (len=read(ifd,buf,200))>0){
52                 #ifdef WORDS_BIGENDIAN  
53                 for (i=0;i<len/2;i+=2){
54                         tmp=buf[i];
55                         buf[i]=buf[i+1];
56                         buf[i+1]=tmp;
57                 }
58                 #endif
59                 write(ofd,buf,len);
60         }
61
62         close(ifd);
63         close(ofd);
64         return 0;
65 }
66
67