Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
42d63b69
Commit
42d63b69
authored
6 years ago
by
George Joseph
Committed by
Gerrit Code Review
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge "format_g726: add support for seeking"
parents
423a51ca
aede7397
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
formats/format_g726.c
+33
-2
33 additions, 2 deletions
formats/format_g726.c
with
33 additions
and
2 deletions
formats/format_g726.c
+
33
−
2
View file @
42d63b69
...
...
@@ -155,7 +155,38 @@ static int g726_write(struct ast_filestream *s, struct ast_frame *f)
static
int
g726_seek
(
struct
ast_filestream
*
fs
,
off_t
sample_offset
,
int
whence
)
{
return
-
1
;
off_t
offset
=
0
,
min
=
0
,
cur
,
max
,
distance
;
if
((
cur
=
ftello
(
fs
->
f
))
<
0
)
{
ast_log
(
AST_LOG_WARNING
,
"Unable to determine current position in g726 filestream %p: %s
\n
"
,
fs
,
strerror
(
errno
));
return
-
1
;
}
if
(
fseeko
(
fs
->
f
,
0
,
SEEK_END
)
<
0
)
{
ast_log
(
AST_LOG_WARNING
,
"Unable to seek to end of g726 filestream %p: %s
\n
"
,
fs
,
strerror
(
errno
));
return
-
1
;
}
if
((
max
=
ftello
(
fs
->
f
))
<
0
)
{
ast_log
(
AST_LOG_WARNING
,
"Unable to determine max position in g726 filestream %p: %s
\n
"
,
fs
,
strerror
(
errno
));
return
-
1
;
}
/* have to fudge to frame here, so not fully to sample */
distance
=
sample_offset
/
2
;
if
(
whence
==
SEEK_SET
)
{
offset
=
distance
;
}
else
if
(
whence
==
SEEK_CUR
||
whence
==
SEEK_FORCECUR
)
{
offset
=
distance
+
cur
;
}
else
if
(
whence
==
SEEK_END
)
{
offset
=
max
-
distance
;
}
if
(
whence
!=
SEEK_FORCECUR
)
{
offset
=
offset
>
max
?
max
:
offset
;
offset
=
offset
<
min
?
min
:
offset
;
}
return
fseeko
(
fs
->
f
,
offset
,
SEEK_SET
);
}
static
int
g726_trunc
(
struct
ast_filestream
*
fs
)
...
...
@@ -165,7 +196,7 @@ static int g726_trunc(struct ast_filestream *fs)
static
off_t
g726_tell
(
struct
ast_filestream
*
fs
)
{
return
-
1
;
return
ftello
(
fs
->
f
)
<<
1
;
}
static
struct
ast_format_def
f
[]
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment