Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-1.1
Commits
a9654857
Commit
a9654857
authored
Jun 14, 2008
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parse RealAudio headers files. Doesn't decode correctly yet .
parent
cc6941a5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
93 deletions
+129
-93
modules/demux/real.c
modules/demux/real.c
+129
-93
No files found.
modules/demux/real.c
View file @
a9654857
...
...
@@ -39,12 +39,14 @@
*
* Real Audio Only
* ---------------
* Not supported...
* v3 and v4/5 headers are parsed.
* Doesn't work yet...
*/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
...
...
@@ -52,7 +54,6 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h>
#include <vlc_charset.h>
#include <vlc_meta.h>
...
...
@@ -115,6 +116,8 @@ struct demux_sys_t
uint32_t
i_data_packets
;
int64_t
i_data_offset_next
;
bool
b_is_real_audio
;
int
i_our_duration
;
int
i_mux_rate
;
...
...
@@ -133,13 +136,14 @@ struct demux_sys_t
int64_t
i_index_offset
;
int
b_seek
;
rm_index_t
*
p_index
;
rm_index_t
*
p_index
;
};
static
int
Demux
(
demux_t
*
p_demux
);
static
int
Control
(
demux_t
*
p_demux
,
int
i_query
,
va_list
args
);
static
int
HeaderRead
(
demux_t
*
p_demux
);
static
uint8_t
*
MetaRead
(
demux_t
*
p_demux
,
const
uint8_t
*
p_peek
);
static
int
ReadCodecSpecificData
(
demux_t
*
p_demux
,
int
i_len
,
int
i_num
);
/*****************************************************************************
...
...
@@ -151,14 +155,18 @@ static int Open( vlc_object_t *p_this )
demux_sys_t
*
p_sys
;
const
uint8_t
*
p_peek
;
bool
b_is_real_audio
=
false
;
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
10
)
<
10
)
return
VLC_EGENERIC
;
/* Real Audio */
if
(
!
memcmp
(
p_peek
,
".ra"
,
3
)
)
{
msg_
Warn
(
p_demux
,
".ra files unsuported"
);
return
VLC_EGENERIC
;
msg_
Err
(
p_demux
,
".ra files unsuported"
);
b_is_real_audio
=
true
;
}
if
(
memcmp
(
p_peek
,
".RMF"
,
4
)
)
return
VLC_EGENERIC
;
/* Real Media Format */
else
if
(
memcmp
(
p_peek
,
".RMF"
,
4
)
)
return
VLC_EGENERIC
;
/* Fill p_demux field */
p_demux
->
pf_demux
=
Demux
;
...
...
@@ -176,9 +184,18 @@ static int Open( vlc_object_t *p_this )
p_sys
->
i_pcr
=
1
;
p_sys
->
b_seek
=
0
;
p_sys
->
b_is_real_audio
=
b_is_real_audio
;
/* Parse the headers */
if
(
HeaderRead
(
p_demux
)
)
/* Real Audio files */
if
(
b_is_real_audio
)
{
ReadCodecSpecificData
(
p_demux
,
32
,
0
);
/* At least 32 */
return
VLC_EGENERIC
;
/* We don't know how to read
correctly the data yet */
}
/* RMF files */
else
if
(
HeaderRead
(
p_demux
)
)
{
int
i
;
msg_Err
(
p_demux
,
"invalid header"
);
...
...
@@ -281,6 +298,7 @@ static int Demux( demux_t *p_demux )
if
(
stream_Read
(
p_demux
->
s
,
header
,
12
)
<
12
)
return
0
;
// int i_version = GetWBE( &header[0] );
i_size
=
GetWBE
(
&
header
[
2
]
)
-
12
;
i_id
=
GetWBE
(
&
header
[
4
]
);
i_pts
=
1000
*
GetDWBE
(
&
header
[
6
]
);
...
...
@@ -1167,6 +1185,73 @@ static int HeaderRead( demux_t *p_demux )
return
VLC_SUCCESS
;
}
static
uint8_t
*
MetaRead
(
demux_t
*
p_demux
,
const
uint8_t
*
p_peek
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
int
i_len
;
char
*
psz
;
/* Title */
i_len
=
*
p_peek
;
p_peek
++
;
if
(
i_len
>
0
)
{
psz
=
malloc
(
i_len
+
1
);
memcpy
(
psz
,
p_peek
,
i_len
);
psz
[
i_len
]
=
'\0'
;
EnsureUTF8
(
psz
);
msg_Dbg
(
p_demux
,
" - title=`%s'"
,
psz
);
p_sys
->
psz_title
=
psz
;
}
p_peek
+=
i_len
;
/* Authors */
i_len
=
*
p_peek
;
p_peek
++
;
if
(
i_len
>
0
)
{
psz
=
malloc
(
i_len
+
1
);
memcpy
(
psz
,
p_peek
,
i_len
);
psz
[
i_len
]
=
'\0'
;
EnsureUTF8
(
psz
);
msg_Dbg
(
p_demux
,
" - artist=`%s'"
,
psz
);
p_sys
->
psz_artist
=
psz
;
}
p_peek
+=
i_len
;
/* Copyright */
i_len
=
*
p_peek
;
p_peek
++
;
if
(
i_len
>
0
)
{
psz
=
malloc
(
i_len
+
1
);
memcpy
(
psz
,
p_peek
,
i_len
);
psz
[
i_len
]
=
'\0'
;
EnsureUTF8
(
psz
);
msg_Dbg
(
p_demux
,
" - Copyright=`%s'"
,
psz
);
p_sys
->
psz_copyright
=
psz
;
}
p_peek
+=
i_len
;
/* Comment */
i_len
=
*
p_peek
;
p_peek
++
;
if
(
i_len
>
0
)
{
psz
=
malloc
(
i_len
+
1
);
memcpy
(
psz
,
p_peek
,
i_len
);
psz
[
i_len
]
=
'\0'
;
EnsureUTF8
(
psz
);
msg_Dbg
(
p_demux
,
" - Comment=`%s'"
,
psz
);
p_sys
->
psz_description
=
psz
;
}
p_peek
+=
i_len
;
return
p_peek
;
}
static
int
ReadCodecSpecificData
(
demux_t
*
p_demux
,
int
i_len
,
int
i_num
)
{
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
...
...
@@ -1244,77 +1329,20 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
p_peek
+=
6
;
/* 4 + version */
es_format_Init
(
&
fmt
,
AUDIO_ES
,
0
);
if
(
i_version
==
3
)
if
(
i_version
==
3
)
/* RMF version 3 or .ra version 3 */
{
int
i_len
;
char
*
psz
;
i_header_size
=
GetWBE
(
p_peek
);
p_peek
+=
2
;
/* Size from now */
p_peek
+=
10
;
/* Unknown */
msg_Dbg
(
p_demux
,
"Data Size: %i"
,
GetDWBE
(
p_peek
)
);
p_peek
+=
4
;
/* Data Size */
/* Title */
i_len
=
*
p_peek
;
p_peek
++
;
if
(
i_len
>
0
)
{
psz
=
malloc
(
i_len
+
1
);
memcpy
(
psz
,
p_peek
,
i_len
);
psz
[
i_len
]
=
'\0'
;
EnsureUTF8
(
psz
);
msg_Dbg
(
p_demux
,
" - title=`%s'"
,
psz
);
p_sys
->
psz_title
=
psz
;
}
p_peek
+=
i_len
;
/* Authors */
i_len
=
*
p_peek
;
p_peek
++
;
if
(
i_len
>
0
)
{
psz
=
malloc
(
i_len
+
1
);
memcpy
(
psz
,
p_peek
,
i_len
);
psz
[
i_len
]
=
'\0'
;
EnsureUTF8
(
psz
);
msg_Dbg
(
p_demux
,
" - artist=`%s'"
,
psz
);
p_sys
->
psz_artist
=
psz
;
}
p_peek
+=
i_len
;
/* Copyright */
i_len
=
*
p_peek
;
p_peek
++
;
if
(
i_len
>
0
)
{
psz
=
malloc
(
i_len
+
1
);
memcpy
(
psz
,
p_peek
,
i_len
);
psz
[
i_len
]
=
'\0'
;
EnsureUTF8
(
psz
);
msg_Dbg
(
p_demux
,
" - Copyright=`%s'"
,
psz
);
p_sys
->
psz_copyright
=
psz
;
}
p_peek
+=
i_len
;
/* Comment */
i_len
=
*
p_peek
;
p_peek
++
;
if
(
i_len
>
0
)
{
psz
=
malloc
(
i_len
+
1
);
memcpy
(
psz
,
p_peek
,
i_len
);
psz
[
i_len
]
=
'\0'
;
EnsureUTF8
(
psz
);
msg_Dbg
(
p_demux
,
" - Comment=`%s'"
,
psz
);
p_sys
->
psz_description
=
psz
;
}
/* This might be unusefull */
p_peek
+=
i_len
;
/* Meta Datas */
p_peek
=
MetaRead
(
p_demux
,
p_peek
);
p_peek
++
;
/* Unknown */
p_peek
++
;
/* FourCC length = 4 */
memcpy
(
(
char
*
)
&
fmt
.
i_codec
,
p_peek
,
4
);
p_peek
+=
4
;
/* Up to here :) */
memcpy
(
(
char
*
)
&
fmt
.
i_codec
,
p_peek
,
4
);
p_peek
+=
4
;
/* FourCC*/
fmt
.
audio
.
i_channels
=
1
;
/* This is always the case in rm3 */
fmt
.
audio
.
i_rate
=
8000
;
...
...
@@ -1322,7 +1350,7 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
msg_Dbg
(
p_demux
,
" - audio codec=%4.4s channels=%d rate=%dHz"
,
(
char
*
)
&
fmt
.
i_codec
,
fmt
.
audio
.
i_channels
,
fmt
.
audio
.
i_rate
);
}
else
/* RMF version 4/5
*/
else
/* RMF version 4/5 or .ra version 4
*/
{
p_peek
+=
2
;
/* 00 00 */
p_peek
+=
4
;
/* .ra4 or .ra5 */
...
...
@@ -1337,7 +1365,8 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
i_subpacket_h
=
GetWBE
(
p_peek
);
p_peek
+=
2
;
/* 1 */
i_frame_size
=
GetWBE
(
p_peek
);
p_peek
+=
2
;
/* frame size */
i_subpacket_size
=
GetWBE
(
p_peek
);
p_peek
+=
2
;
/* subpacket_size */
if
(
!
i_subpacket_size
||
!
i_frame_size
||
!
i_coded_frame_size
)
if
(
(
!
i_subpacket_size
&&
!
p_sys
->
b_is_real_audio
)
||
!
i_frame_size
||
!
i_coded_frame_size
)
return
VLC_EGENERIC
;
p_peek
+=
2
;
/* ?? */
...
...
@@ -1354,30 +1383,36 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
memcpy
(
(
char
*
)
p_genr
,
p_peek
,
4
);
p_peek
+=
4
;
/* genr */
memcpy
(
(
char
*
)
&
fmt
.
i_codec
,
p_peek
,
4
);
p_peek
+=
4
;
}
else
else
/* version 4 */
{
p_peek
+=
p_peek
[
0
]
+
1
;
/* descr 1
*/
memcpy
(
(
char
*
)
&
fmt
.
i_codec
,
p_peek
+
1
,
4
);
/* descr 2
*/
p_peek
+=
p_peek
[
0
]
+
1
;
p_peek
+=
1
+
p_peek
[
0
];
/* Inteleaver ID string and lenth
*/
memcpy
(
(
char
*
)
&
fmt
.
i_codec
,
p_peek
+
1
,
4
);
/* FourCC
*/
p_peek
+=
1
+
p_peek
[
0
]
;
}
msg_Dbg
(
p_demux
,
" - audio codec=%4.4s channels=%d rate=%dHz"
,
(
char
*
)
&
fmt
.
i_codec
,
fmt
.
audio
.
i_channels
,
fmt
.
audio
.
i_rate
);
p_peek
+=
3
;
/* ?? */
if
(
p_sys
->
b_is_real_audio
)
{
p_peek
=
MetaRead
(
p_demux
,
p_peek
);
}
else
{
if
(
i_version
==
5
)
p_peek
++
;
/* Extra Data then: DWord + byte[] */
fmt
.
i_extra
=
GetDWBE
(
p_peek
);
p_peek
+=
4
;
}
}
switch
(
fmt
.
i_codec
)
{
case
VLC_FOURCC
(
'1'
,
'4'
,
'_'
,
'4'
):
/* fmt.audio.i_blockalign = 0x14 */
break
;
case
VLC_FOURCC
(
'l'
,
'p'
,
'c'
,
'J'
):
/* fmt.audio.i_blockalign = 0x14 */
fmt
.
i_codec
=
VLC_FOURCC
(
'1'
,
'4'
,
'_'
,
'4'
);
case
VLC_FOURCC
(
'1'
,
'4'
,
'_'
,
'4'
):
fmt
.
audio
.
i_blockalign
=
0x14
;
break
;
case
VLC_FOURCC
(
'2'
,
'8'
,
'_'
,
'8'
):
...
...
@@ -1494,3 +1529,4 @@ static int ReadCodecSpecificData( demux_t *p_demux, int i_len, int i_num )
return
VLC_SUCCESS
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment