Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
V
V8
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
V8
Commits
ce18df34
Commit
ce18df34
authored
Mar 02, 2023
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get input file extension from input file instead of simple
use .aac.
parent
f1a4f8aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
+27
-3
builtins-encoder.cc
src/builtins/builtins-encoder.cc
+27
-3
No files found.
src/builtins/builtins-encoder.cc
View file @
ce18df34
#include <stdio.h>
#include <iostream>
#include <array>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <dlfcn.h>
#include "builtins-encoder.h"
...
...
@@ -371,9 +373,30 @@ BUILTIN(AddAudioURL) {
isolate
,
url_str
,
Object
::
ToString
(
isolate
,
url
));
std
::
string
url_cppstr
=
url_str
->
ToCString
().
get
();
std
::
string
outpath
=
std
::
tmpnam
(
nullptr
);
outpath
+=
".aac"
;
// Get extension of input file
std
::
string
inputExt
{},
outpath
=
std
::
tmpnam
(
nullptr
);
std
::
array
<
char
,
1
>
search_for
=
{
'.'
};
std
::
array
<
char
,
1
>
search_for_slash
=
{
'/'
};
auto
iter
=
std
::
find_end
(
std
::
begin
(
url_cppstr
),
std
::
end
(
url_cppstr
),
std
::
begin
(
search_for
),
std
::
end
(
search_for
));
auto
iter_slash
=
std
::
find_end
(
std
::
begin
(
url_cppstr
),
std
::
end
(
url_cppstr
),
std
::
begin
(
search_for_slash
),
std
::
end
(
search_for_slash
));
// If no extension found then leave input file empty
// extension. It's format and codec_type will determine by
// decoder.
// FIXME: Condistion still too weak
if
(
iter
!=
std
::
end
(
url_cppstr
)
&&
iter_slash
!=
std
::
end
(
url_cppstr
)
&&
iter
>
iter_slash
)
{
inputExt
=
url_cppstr
.
substr
(
std
::
distance
(
std
::
begin
(
url_cppstr
),
iter
));
outpath
+=
inputExt
;
}
// Add audio file into AudioEffecter
Handle
<
Object
>
volume
=
args
.
atOrUndefined
(
isolate
,
2
);
...
...
@@ -422,6 +445,7 @@ BUILTIN(AddAudioURL) {
int
errorCode
=
fetchRe
(
resourcer
,
url_cppstr
.
c_str
(),
outpath
.
c_str
());
if
(
errorCode
==
200
)
{
bool
isLoop_bool
=
isLoop_
==
1
;
// FIXME: Check success of add operation of audio file is required, at least warning.
addInputFileAE
(
audioEffecter
,
outpath
.
c_str
(),
volume_
,
strong_end_time_
,
start_time_
,
end_time_
,
delay_
,
duration_
,
fade_out_duration_
,
isLoop_bool
);
}
...
...
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