15234
|
1 #include <stdio.h>
|
|
2 #include <string.h>
|
|
3 #include <stdlib.h>
|
|
4 #include <inttypes.h>
|
15238
|
5 #include <unistd.h>
|
15240
|
6 #include <sys/types.h>
|
15234
|
7 #include <math.h>
|
|
8 #include "aviheader.h"
|
|
9 #include "ms_hdr.h"
|
|
10 #include "muxer.h"
|
|
11 #include "ae.h"
|
|
12 #include "../config.h"
|
|
13
|
|
14 #ifdef HAVE_TOOLAME
|
|
15 #include "ae_toolame.h"
|
|
16 #endif
|
|
17
|
|
18 #ifdef HAVE_MP3LAME
|
|
19 #include "ae_lame.h"
|
|
20 #endif
|
|
21
|
|
22 #ifdef USE_LIBAVCODEC
|
|
23 #include "ae_lavc.h"
|
|
24 #endif
|
|
25
|
|
26 audio_encoder_t *new_audio_encoder(muxer_stream_t *stream, audio_encoding_params_t *params)
|
|
27 {
|
|
28 int ris;
|
15242
|
29 audio_encoder_t *encoder;
|
15234
|
30 if(! params)
|
|
31 return NULL;
|
|
32
|
15242
|
33 encoder = (audio_encoder_t *) calloc(1, sizeof(audio_encoder_t));
|
15234
|
34 memcpy(&encoder->params, params, sizeof(audio_encoding_params_t));
|
|
35 encoder->stream = stream;
|
|
36
|
|
37 switch(stream->codec)
|
|
38 {
|
|
39 case ACODEC_PCM:
|
|
40 ris = mpae_init_pcm(encoder);
|
|
41 break;
|
|
42 #ifdef HAVE_TOOLAME
|
|
43 case ACODEC_TOOLAME:
|
|
44 ris = mpae_init_toolame(encoder);
|
|
45 break;
|
|
46 #endif
|
|
47 #ifdef USE_LIBAVCODEC
|
|
48 case ACODEC_LAVC:
|
|
49 ris = mpae_init_lavc(encoder);
|
|
50 break;
|
|
51 #endif
|
|
52 #ifdef HAVE_MP3LAME
|
|
53 case ACODEC_VBRMP3:
|
|
54 ris = mpae_init_lame(encoder);
|
|
55 break;
|
|
56 #endif
|
|
57 }
|
|
58
|
|
59 if(! ris)
|
|
60 {
|
|
61 free(encoder);
|
|
62 return NULL;
|
|
63 }
|
|
64 encoder->bind(encoder, stream);
|
|
65 encoder->decode_buffer = (int*)malloc(encoder->decode_buffer_size);
|
|
66 if(! encoder->decode_buffer)
|
|
67 {
|
|
68 free(encoder);
|
|
69 return NULL;
|
|
70 }
|
|
71
|
|
72 encoder->codec = stream->codec;
|
|
73 return encoder;
|
|
74 }
|
|
75
|
|
76
|