Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ffworker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Video AG Infrastruktur
ffworker
Commits
ee20797c
Commit
ee20797c
authored
7 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Implemented job canceling
parent
17eeeac6
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
simple_live_transcode.c
+5
-3
5 additions, 3 deletions
simple_live_transcode.c
transcode.c
+5
-3
5 additions, 3 deletions
transcode.c
util/api.c
+4
-0
4 additions, 0 deletions
util/api.c
with
14 additions
and
6 deletions
simple_live_transcode.c
+
5
−
3
View file @
ee20797c
...
@@ -17,7 +17,7 @@ static void copy_to_log(int fd)
...
@@ -17,7 +17,7 @@ static void copy_to_log(int fd)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
ret
,
errpipe
[
2
]
=
{
-
1
,
-
1
};
int
ret
,
canceled
=
0
,
errpipe
[
2
]
=
{
-
1
,
-
1
};
char
*
src
,
*
dest
;
char
*
src
,
*
dest
;
pid_t
pid
;
pid_t
pid
;
struct
pollfd
fds
=
{.
fd
=
-
1
,
.
events
=
POLLIN
};
struct
pollfd
fds
=
{.
fd
=
-
1
,
.
events
=
POLLIN
};
...
@@ -48,7 +48,9 @@ int main(int argc, char *argv[])
...
@@ -48,7 +48,9 @@ int main(int argc, char *argv[])
while
(
1
)
while
(
1
)
{
{
ping_job
(
jobid
,
"running"
,
"{
\"
log
\"
:
\"
%s
\"
}"
,
jescape
(
get_avlogbuf
()));
canceled
=
ping_job
(
jobid
,
"running"
,
"{
\"
log
\"
:
\"
%s
\"
}"
,
jescape
(
get_avlogbuf
()));
if
(
canceled
)
kill
(
pid
,
SIGINT
);
/* Stop ffmpeg */
poll
(
&
fds
,
1
,
15000
);
poll
(
&
fds
,
1
,
15000
);
if
(
fds
.
revents
&
POLLIN
)
if
(
fds
.
revents
&
POLLIN
)
copy_to_log
(
fds
.
fd
);
copy_to_log
(
fds
.
fd
);
...
@@ -57,7 +59,7 @@ int main(int argc, char *argv[])
...
@@ -57,7 +59,7 @@ int main(int argc, char *argv[])
}
}
waitpid
(
pid
,
&
ret
,
0
);
waitpid
(
pid
,
&
ret
,
0
);
if
(
!
WEXITSTATUS
(
ret
))
if
(
canceled
&&
(
WEXITSTATUS
(
ret
)
==
255
||
(
WIFSIGNALED
(
ret
)
&&
WTERMSIG
(
ret
)
==
SIGINT
))
)
ping_job
(
jobid
,
"finished"
,
"{
\"
log
\"
:
\"
%s
\"
}"
,
jescape
(
get_avlogbuf
()));
ping_job
(
jobid
,
"finished"
,
"{
\"
log
\"
:
\"
%s
\"
}"
,
jescape
(
get_avlogbuf
()));
else
if
(
WIFSIGNALED
(
ret
))
else
if
(
WIFSIGNALED
(
ret
))
job_failed
(
"Subprocesses was killed by signal %s (%i)"
,
strsignal
(
WTERMSIG
(
ret
)),
WTERMSIG
(
ret
));
job_failed
(
"Subprocesses was killed by signal %s (%i)"
,
strsignal
(
WTERMSIG
(
ret
)),
WTERMSIG
(
ret
));
...
...
This diff is collapsed.
Click to expand it.
transcode.c
+
5
−
3
View file @
ee20797c
...
@@ -247,7 +247,7 @@ void connect_pads(AVFilterInOut **ins, AVFilterInOut **outs)
...
@@ -247,7 +247,7 @@ void connect_pads(AVFilterInOut **ins, AVFilterInOut **outs)
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
int
err
,
i
,
progress
,
_progress
;
int
err
,
i
,
progress
,
_progress
,
canceled
;
char
*
p
,
*
input
,
*
output
,
*
inpath
,
*
outpath
,
*
tmppath
,
*
oldsrcpath
;
char
*
p
,
*
input
,
*
output
,
*
inpath
,
*
outpath
,
*
tmppath
,
*
oldsrcpath
;
AVFormatContext
*
demux
,
*
mux
;
AVFormatContext
*
demux
,
*
mux
;
AVCodecContext
**
decs
,
**
encs
;
AVCodecContext
**
decs
,
**
encs
;
...
@@ -329,14 +329,16 @@ int main(int argc, char *argv[])
...
@@ -329,14 +329,16 @@ int main(int argc, char *argv[])
progress
=
0
;
progress
=
0
;
ping_job
(
jobid
,
"running"
,
0
);
ping_job
(
jobid
,
"running"
,
0
);
while
(
!
av_read_frame
(
demux
,
&
pkt
))
while
(
!
canceled
&&
!
av_read_frame
(
demux
,
&
pkt
))
{
{
i
=
pkt
.
stream_index
;
i
=
pkt
.
stream_index
;
_progress
=
av_rescale_q
(
pkt
.
pts
,
demux
->
streams
[
i
]
->
time_base
,
AV_TIME_BASE_Q
)
*
100
/
demux
->
duration
;
_progress
=
av_rescale_q
(
pkt
.
pts
,
demux
->
streams
[
i
]
->
time_base
,
AV_TIME_BASE_Q
)
*
100
/
demux
->
duration
;
if
(
_progress
>
progress
||
!
checktime
(
30
))
if
(
_progress
>
progress
||
!
checktime
(
30
))
{
{
ping_job
(
jobid
,
"running"
,
"{
\"
progress
\"
: %i,
\"
log
\"
:
\"
%s
\"
}"
,
_progress
,
canceled
=
ping_job
(
jobid
,
"running"
,
"{
\"
progress
\"
: %i,
\"
log
\"
:
\"
%s
\"
}"
,
_progress
,
jescape
(
get_avlogbuf
()));
jescape
(
get_avlogbuf
()));
if
(
canceled
)
job_failed
(
"Job canceled"
);
progress
=
_progress
;
progress
=
_progress
;
}
}
filtergraph_send
(
srcs
[
i
],
decs
[
i
],
&
pkt
);
filtergraph_send
(
srcs
[
i
],
decs
[
i
],
&
pkt
);
...
...
This diff is collapsed.
Click to expand it.
util/api.c
+
4
−
0
View file @
ee20797c
...
@@ -15,6 +15,7 @@ static size_t curl_write_cb(char *ptr, size_t size, size_t nmemb, void *user)
...
@@ -15,6 +15,7 @@ static size_t curl_write_cb(char *ptr, size_t size, size_t nmemb, void *user)
int
ping_job
(
int
id
,
char
*
state
,
char
*
status
,
...)
int
ping_job
(
int
id
,
char
*
state
,
char
*
status
,
...)
{
{
int
ret
;
int
ret
;
long
http_status
;
CURL
*
curl
;
CURL
*
curl
;
va_list
ap
;
va_list
ap
;
char
*
p
,
*
url
,
*
e_host
,
*
e_status
,
*
e_apikey
,
*
e_state
;
char
*
p
,
*
url
,
*
e_host
,
*
e_status
,
*
e_apikey
,
*
e_state
;
...
@@ -48,6 +49,7 @@ int ping_job(int id, char *state, char *status, ...)
...
@@ -48,6 +49,7 @@ int ping_job(int id, char *state, char *status, ...)
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url
);
ret
=
curl_easy_perform
(
curl
);
ret
=
curl_easy_perform
(
curl
);
free
(
p
);
free
(
p
);
curl_easy_getinfo
(
curl
,
CURLINFO_RESPONSE_CODE
,
&
http_status
);
curl_easy_cleanup
(
curl
);
curl_easy_cleanup
(
curl
);
if
(
ret
)
if
(
ret
)
{
{
...
@@ -56,5 +58,7 @@ int ping_job(int id, char *state, char *status, ...)
...
@@ -56,5 +58,7 @@ int ping_job(int id, char *state, char *status, ...)
return
-
1
;
return
-
1
;
}
}
free
(
url
);
free
(
url
);
if
(
http_status
==
205
)
return
1
;
/* Job canceled */
return
0
;
return
0
;
}
}
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