Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gerion Entrup
ffmpeg
Commits
919c7c3e
Commit
919c7c3e
authored
Nov 17, 2013
by
Gerion Entrup
Browse files
cdda: add basic open and seek function
parent
1a626abf
Changes
1
Hide whitespace changes
Inline
Side-by-side
libavformat/cdda.c
View file @
919c7c3e
...
...
@@ -32,9 +32,11 @@
typedef
struct
{
const
AVClass
*
class
;
CDDA
*
cd
;
cdrom_drive_t
*
cd
;
cdrom_paranoid_t
*
cdp
;
int
playlist
;
int
paranoia_mode
;
int
track
;
int
angle
;
int
chapter
;
/*int region;*/
...
...
@@ -56,12 +58,67 @@ static const AVClass cdda_context_class = {
.
version
=
LIBAVUTIL_VERSION_INT
,
};
static
int
cdda_open
(
URLContext
*
h
,
const
char
*
path
,
int
flags
)
{
CddaContext
*
cd
=
h
->
priv_data
;
int
mode
=
cd
->
paranoid_mode
;
int
num_tracks
;
const
char
*
diskname
=
path
;
cd_info_t
*
cd_info
;
av_strstart
(
path
,
CDDA_PROTO_PREFIX
,
&
diskname
);
/* identify device */
cd
->
cd
=
cdda_identify
(
diskname
,
0
,
NULL
);
if
(
!
cd
->
cd
)
{
av_log
(
h
,
AV_LOG_ERROR
,
"Can't open CDDA device.
\n
"
);
return
AVERROR
(
EIO
);
}
/* be quiet */
cdio_cddap_verbose_set
(
cd
->
cd
,
CDDA_MESSAGE_FORGETIT
,
CDDA_MESSAGE_FORGETIT
);
/* open cd */
if
(
cdda_open
(
cd
->
cd
)
!=
0
)
{
av_log
(
h
,
AV_LOG_ERROR
,
"Can't open disc.
\n
"
);
cdda_close
(
cd
->
cd
)
return
AVERROR
(
EIO
);
}
cd_info
=
cd_info_new
();
/* load title list */
num_tracks
=
(
int
)
cdda_tracks
(
cd
->
cd
);
av_log
(
h
,
AV_LOG_INFO
,
"Found audio CD with %d tracks:
\n
"
,
num_tracks
);
if
(
num_tracks
<
1
)
{
return
AVERROR
(
EIO
);
}
int
i
;
for
(
i
=
1
;
i
<=
num_tracks
;
i
++
)
{
long
sec
=
cdda_track_firstsector
(
cd
->
cd
,
i
);
long
off
=
cdda_track_lastsector
(
cd
->
cd
,
i
)
-
sec
+
1
;
av_log
(
h
,
AV_LOG_INFO
,
"Track %d, Length: %d sec, at posistion %d sec"
,
i
,
sec
,
off
);
}
/* if track was not given, select first track */
if
(
cd
->
track
<
1
)
{
cd
->
track
=
1
;
}
/* select speed */
if
(
cd
->
speed
>
0
)
{
cdda_speed_set
(
cd
->
cd
,
cd
->
speed
);
}
return
0
;
}
static
int64_t
bluray_seek
(
URLContext
*
h
,
int64_t
pos
,
int
whence
)
{
CddaContext
*
cd
=
h
->
priv_data
;
if
(
!
b
d
||
!
b
d
->
b
d
)
{
if
(
!
c
d
||
!
c
d
->
c
d
)
{
return
AVERROR
(
EFAULT
);
}
...
...
@@ -69,7 +126,7 @@ static int64_t bluray_seek(URLContext *h, int64_t pos, int whence)
case
SEEK_SET
:
case
SEEK_CUR
:
case
SEEK_END
:
return
bd
_seek
(
b
d
->
bd
,
pos
);
return
paranoia
_seek
(
c
d
->
cdp
,
pos
);
case
AVSEEK_SIZE
:
return
bd_get_title_size
(
bd
->
bd
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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