annotate libmpdemux/demux_realaud.c @ 15842:57ba4b5a3d8e

Synced with 1.80
author jheryan
date Tue, 28 Jun 2005 13:29:49 +0000
parents aa6715eaa28c
children 6b86089c2edd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
1 /*
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
2 Realaudio demuxer for MPlayer
14908
82344f91104a Fix some 28.8 ra files with four text strings
rtognimp
parents: 11544
diff changeset
3 (c) 2003, 2005 Roberto Togni
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
4 */
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
5
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
6 #include <stdio.h>
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
7 #include <stdlib.h>
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
8 #include <unistd.h>
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
9
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
10 #include "config.h"
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
11 #include "mp_msg.h"
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
12 #include "help_mp.h"
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
13
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
14 #include "stream.h"
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
15 #include "demuxer.h"
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
16 #include "stheader.h"
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
17 #include "bswap.h"
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
18
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
19
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
20 #define FOURCC_DOTRA mmioFOURCC('.','r','a', 0xfd)
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
21 #define FOURCC_144 mmioFOURCC('1','4','_','4')
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
22 #define FOURCC_288 mmioFOURCC('2','8','_','8')
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
23 #define FOURCC_DNET mmioFOURCC('d','n','e','t')
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
24 #define FOURCC_LPCJ mmioFOURCC('l','p','c','J')
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
25
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
26
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
27 typedef struct {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
28 unsigned short version;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
29 unsigned int dotranum;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
30 unsigned int data_size;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
31 unsigned short version2;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
32 unsigned int hdr_size;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
33 unsigned short codec_flavor;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
34 unsigned int coded_framesize;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
35 unsigned short sub_packet_h;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
36 unsigned short frame_size;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
37 unsigned short sub_packet_size;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
38 char genr[4];
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
39 } ra_priv_t;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
40
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
41
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
42
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
43 int ra_check_file(demuxer_t* demuxer)
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
44 {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
45 unsigned int chunk_id;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
46
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
47 chunk_id = stream_read_dword_le(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
48 if (chunk_id == FOURCC_DOTRA)
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
49 return 1;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
50 else
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
51 return 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
52 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
53
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
54
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
55
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
56 void hexdump(char *, unsigned long);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
57
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
58 // return value:
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
59 // 0 = EOF or no stream found
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
60 // 1 = successfully read a packet
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
61 int demux_ra_fill_buffer(demuxer_t *demuxer)
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
62 {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
63 ra_priv_t *ra_priv = demuxer->priv;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
64 int len;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
65 int timestamp;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
66 int flags;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
67 demux_stream_t *ds = demuxer->audio;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
68 sh_audio_t *sh = ds->sh;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
69 WAVEFORMATEX *wf = sh->wf;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
70 demux_packet_t *dp;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
71
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
72 if (demuxer->stream->eof)
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
73 return 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
74
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
75 len = wf->nBlockAlign;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
76 demuxer->filepos = stream_tell(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
77
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
78 dp = new_demux_packet(len);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
79 stream_read(demuxer->stream, dp->buffer, len);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
80
10035
d4ecf93e236a Remove broker reset/seek and fix ;;
rtognimp
parents: 10034
diff changeset
81 dp->pts = demuxer->filepos / ra_priv->data_size;
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
82 dp->pos = demuxer->filepos;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
83 dp->flags = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
84 ds_add_packet(ds, dp);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
85
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
86 return 1;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
87 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
88
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
89
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
90
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
91 extern void print_wave_header(WAVEFORMATEX *h);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
92
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
93
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
94
10232
939ff11825de Warning fixes, patch by Dominik Mierzejewski
rtognimp
parents: 10124
diff changeset
95 int demux_open_ra(demuxer_t* demuxer)
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
96 {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
97 ra_priv_t* ra_priv = demuxer->priv;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
98 sh_audio_t *sh;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
99 int i;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
100 char *buf;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
101
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
102 if ((ra_priv = (ra_priv_t *)malloc(sizeof(ra_priv_t))) == NULL) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
103 mp_msg(MSGT_DEMUX, MSGL_ERR, "[RealAudio] Can't allocate memory for private data.\n");
10232
939ff11825de Warning fixes, patch by Dominik Mierzejewski
rtognimp
parents: 10124
diff changeset
104 return 0;
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
105 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
106 memset(ra_priv, 0, sizeof(ra_priv_t));
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
107
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
108 demuxer->priv = ra_priv;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
109 sh = new_sh_audio(demuxer, 0);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
110 demuxer->audio->id = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
111 sh->ds=demuxer->audio;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
112 demuxer->audio->sh = sh;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
113
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
114 ra_priv->version = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
115 mp_msg(MSGT_DEMUX,MSGL_V,"[RealAudio] File version: %d\n", ra_priv->version);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
116 if ((ra_priv->version < 3) || (ra_priv->version > 4)) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
117 mp_msg(MSGT_DEMUX,MSGL_WARN,"[RealAudio] ra version %d is not supported yet, please "
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
118 "contact MPlayer developers\n", ra_priv->version);
10232
939ff11825de Warning fixes, patch by Dominik Mierzejewski
rtognimp
parents: 10124
diff changeset
119 return 0;
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
120 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
121 if (ra_priv->version == 3) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
122 ra_priv->hdr_size = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
123 stream_skip(demuxer->stream, 10);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
124 ra_priv->data_size = stream_read_dword(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
125 } else {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
126 stream_skip(demuxer->stream, 2);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
127 ra_priv->dotranum = stream_read_dword(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
128 ra_priv->data_size = stream_read_dword(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
129 ra_priv->version2 = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
130 ra_priv->hdr_size = stream_read_dword(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
131 ra_priv->codec_flavor = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
132 ra_priv->coded_framesize = stream_read_dword(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
133 stream_skip(demuxer->stream, 4); // data size?
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
134 stream_skip(demuxer->stream, 8);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
135 ra_priv->sub_packet_h = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
136 ra_priv->frame_size = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
137 mp_msg(MSGT_DEMUX,MSGL_V,"[RealAudio] Frame size: %d\n", ra_priv->frame_size);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
138 ra_priv->sub_packet_size = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
139 mp_msg(MSGT_DEMUX,MSGL_V,"[RealAudio] Sub packet size: %d\n", ra_priv->sub_packet_size);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
140 stream_skip(demuxer->stream, 2);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
141 sh->samplerate = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
142 stream_skip(demuxer->stream, 2);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
143 sh->samplesize = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
144 sh->channels = stream_read_word(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
145 mp_msg(MSGT_DEMUX,MSGL_V,"[RealAudio] %d channel, %d bit, %dHz\n", sh->channels,
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
146 sh->samplesize, sh->samplerate);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
147 i = stream_read_char(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
148 *((unsigned int *)(ra_priv->genr)) = stream_read_dword(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
149 if (i != 4) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
150 mp_msg(MSGT_DEMUX,MSGL_WARN,"[RealAudio] Genr size is not 4 (%d), please report to "
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
151 "MPlayer developers\n", i);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
152 stream_skip(demuxer->stream, i - 4);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
153 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
154 i = stream_read_char(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
155 sh->format = stream_read_dword_le(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
156 if (i != 4) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
157 mp_msg(MSGT_DEMUX,MSGL_WARN,"[RealAudio] FourCC size is not 4 (%d), please report to "
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
158 "MPlayer developers\n", i);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
159 stream_skip(demuxer->stream, i - 4);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
160 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
161 stream_skip(demuxer->stream, 3);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
162 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
163
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
164 if ((i = stream_read_char(demuxer->stream)) != 0) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
165 buf = malloc(i+1);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
166 stream_read(demuxer->stream, buf, i);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
167 buf[i] = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
168 demux_info_add(demuxer, "Title", buf);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
169 free(buf);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
170 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
171 if ((i = stream_read_char(demuxer->stream)) != 0) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
172 buf = malloc(i+1);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
173 stream_read(demuxer->stream, buf, i);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
174 buf[i] = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
175 demux_info_add(demuxer, "Author", buf);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
176 free(buf);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
177 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
178 if ((i = stream_read_char(demuxer->stream)) != 0) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
179 buf = malloc(i+1);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
180 stream_read(demuxer->stream, buf, i);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
181 buf[i] = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
182 demux_info_add(demuxer, "Copyright", buf);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
183 free(buf);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
184 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
185
14908
82344f91104a Fix some 28.8 ra files with four text strings
rtognimp
parents: 11544
diff changeset
186 if ((i = stream_read_char(demuxer->stream)) != 0) {
82344f91104a Fix some 28.8 ra files with four text strings
rtognimp
parents: 11544
diff changeset
187 buf = malloc(i+1);
82344f91104a Fix some 28.8 ra files with four text strings
rtognimp
parents: 11544
diff changeset
188 stream_read(demuxer->stream, buf, i);
82344f91104a Fix some 28.8 ra files with four text strings
rtognimp
parents: 11544
diff changeset
189 buf[i] = 0;
82344f91104a Fix some 28.8 ra files with four text strings
rtognimp
parents: 11544
diff changeset
190 demux_info_add(demuxer, "Comment", buf);
82344f91104a Fix some 28.8 ra files with four text strings
rtognimp
parents: 11544
diff changeset
191 free(buf);
82344f91104a Fix some 28.8 ra files with four text strings
rtognimp
parents: 11544
diff changeset
192 }
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
193
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
194 if (ra_priv->version == 3) {
14909
aa6715eaa28c Fix very old ra files with no fourcc
rtognimp
parents: 14908
diff changeset
195 if(ra_priv->hdr_size + 8 > stream_tell(demuxer->stream)) {
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
196 stream_skip(demuxer->stream, 1);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
197 i = stream_read_char(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
198 sh->format = stream_read_dword_le(demuxer->stream);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
199 if (i != 4) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
200 mp_msg(MSGT_DEMUX,MSGL_WARN,"[RealAudio] FourCC size is not 4 (%d), please report to "
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
201 "MPlayer developers\n", i);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
202 stream_skip(demuxer->stream, i - 4);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
203 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
204
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
205 if (sh->format != FOURCC_LPCJ) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
206 mp_msg(MSGT_DEMUX,MSGL_WARN,"[RealAudio] Version 3 with FourCC %8x, please report to "
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
207 "MPlayer developers\n", sh->format);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
208 }
14909
aa6715eaa28c Fix very old ra files with no fourcc
rtognimp
parents: 14908
diff changeset
209 } else
aa6715eaa28c Fix very old ra files with no fourcc
rtognimp
parents: 14908
diff changeset
210 // If a stream does not have fourcc, let's assume it's 14.4
aa6715eaa28c Fix very old ra files with no fourcc
rtognimp
parents: 14908
diff changeset
211 sh->format = FOURCC_LPCJ;
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
212
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
213 sh->channels = 1;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
214 sh->samplesize = 16;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
215 sh->samplerate = 8000;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
216 ra_priv->frame_size = 240;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
217 sh->format = FOURCC_144;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
218 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
219
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
220 /* Fill WAVEFORMATEX */
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
221 sh->wf = malloc(sizeof(WAVEFORMATEX));
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
222 memset(sh->wf, 0, sizeof(WAVEFORMATEX));
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
223 sh->wf->nChannels = sh->channels;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
224 sh->wf->wBitsPerSample = sh->samplesize;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
225 sh->wf->nSamplesPerSec = sh->samplerate;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
226 sh->wf->nAvgBytesPerSec = sh->samplerate*sh->samplesize/8;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
227 sh->wf->nBlockAlign = ra_priv->frame_size;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
228 sh->wf->cbSize = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
229 sh->wf->wFormatTag = sh->format;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
230
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
231 switch (sh->format) {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
232 case FOURCC_144:
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
233 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: 14_4\n");
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
234 sh->wf->cbSize = 10/*+codecdata_length*/;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
235 sh->wf = realloc(sh->wf, sizeof(WAVEFORMATEX)+sh->wf->cbSize);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
236 ((short*)(sh->wf+1))[0]=0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
237 ((short*)(sh->wf+1))[1]=240;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
238 ((short*)(sh->wf+1))[2]=0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
239 ((short*)(sh->wf+1))[3]=0x14;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
240 ((short*)(sh->wf+1))[4]=0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
241 break;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
242 case FOURCC_288:
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
243 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: 28_8\n");
11544
rtognimp
parents: 10232
diff changeset
244 sh->wf->cbSize = 10/*+codecdata_length*/;
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
245 sh->wf = realloc(sh->wf, sizeof(WAVEFORMATEX)+sh->wf->cbSize);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
246 ((short*)(sh->wf+1))[0]=0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
247 ((short*)(sh->wf+1))[1]=ra_priv->sub_packet_h;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
248 ((short*)(sh->wf+1))[2]=ra_priv->codec_flavor;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
249 ((short*)(sh->wf+1))[3]=ra_priv->coded_framesize;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
250 ((short*)(sh->wf+1))[4]=0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
251 break;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
252 case FOURCC_DNET:
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
253 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: DNET -> AC3\n");
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
254 break;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
255 default:
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
256 mp_msg(MSGT_DEMUX,MSGL_V,"Audio: Unknown (%d)\n", sh->format);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
257 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
258
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
259 print_wave_header(sh->wf);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
260
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
261 /* disable seeking */
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
262 demuxer->seekable = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
263
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
264 if(!ds_fill_buffer(demuxer->audio))
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
265 mp_msg(MSGT_DEMUXER,MSGL_INFO,"[RealAudio] No data.\n");
10232
939ff11825de Warning fixes, patch by Dominik Mierzejewski
rtognimp
parents: 10124
diff changeset
266
939ff11825de Warning fixes, patch by Dominik Mierzejewski
rtognimp
parents: 10124
diff changeset
267 return 1;
10034
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
268 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
269
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
270
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
271
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
272 void demux_close_ra(demuxer_t *demuxer)
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
273 {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
274 ra_priv_t* ra_priv = demuxer->priv;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
275
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
276 if (ra_priv)
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
277 free(ra_priv);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
278
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
279 return;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
280 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
281
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
282
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
283 #if 0
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
284 /* please upload RV10 samples WITH INDEX CHUNK */
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
285 int demux_seek_ra(demuxer_t *demuxer, float rel_seek_secs, int flags)
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
286 {
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
287 real_priv_t *priv = demuxer->priv;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
288 demux_stream_t *d_audio = demuxer->audio;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
289 sh_audio_t *sh_audio = d_audio->sh;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
290 int aid = d_audio->id;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
291 int next_offset = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
292 int rel_seek_frames = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
293 int streams = 0;
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
294
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
295 return stream_seek(demuxer->stream, next_offset);
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
296 }
4f434f04b5bf Realaudio support
rtognimp
parents:
diff changeset
297 #endif