Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
George Kiagiadakis
gst-plugins-good
Commits
f1ceaab0
Commit
f1ceaab0
authored
Apr 17, 2015
by
Edward Hervey
Committed by
Edward Hervey
May 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multifilesink: streamline the file-switch code a bit
Use the same functions regardless of the mode we are using
parent
db0abbd5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
35 deletions
+15
-35
gst/multifile/gstmultifilesink.c
gst/multifile/gstmultifilesink.c
+15
-35
No files found.
gst/multifile/gstmultifilesink.c
View file @
f1ceaab0
...
...
@@ -556,6 +556,8 @@ gst_multi_file_sink_write_stream_headers (GstMultiFileSink * sink)
if
(
sink
->
streamheaders
==
NULL
)
return
TRUE
;
GST_DEBUG_OBJECT
(
sink
,
"Writing stream headers"
);
/* we want to write these at the beginning */
g_assert
(
sink
->
cur_file_size
==
0
);
...
...
@@ -583,29 +585,27 @@ gst_multi_file_sink_write_buffer (GstMultiFileSink * multifilesink,
GstBuffer
*
buffer
)
{
GstMapInfo
map
;
gchar
*
filename
;
gboolean
ret
;
GError
*
error
=
NULL
;
gboolean
first_file
=
TRUE
;
gst_buffer_map
(
buffer
,
&
map
,
GST_MAP_READ
);
switch
(
multifilesink
->
next_file
)
{
case
GST_MULTI_FILE_SINK_NEXT_BUFFER
:
gst_multi_file_sink_ensure_max_files
(
multifilesink
);
filename
=
g_strdup_printf
(
multifilesink
->
filename
,
multifilesink
->
index
);
ret
=
g_file_set_contents
(
filename
,
(
char
*
)
map
.
data
,
map
.
size
,
&
error
);
if
(
!
ret
)
goto
write_error
;
multifilesink
->
files
=
g_slist_append
(
multifilesink
->
files
,
filename
);
multifilesink
->
n_files
+=
1
;
gst_multi_file_sink_post_message
(
multifilesink
,
buffer
,
filename
);
multifilesink
->
index
++
;
if
(
multifilesink
->
files
!=
NULL
)
first_file
=
FALSE
;
if
(
!
gst_multi_file_sink_open_next_file
(
multifilesink
))
goto
stdio_write_error
;
if
(
first_file
==
FALSE
)
gst_multi_file_sink_write_stream_headers
(
multifilesink
);
GST_DEBUG_OBJECT
(
multifilesink
,
"Writing buffer data (%"
G_GSIZE_FORMAT
" bytes) to new file"
,
map
.
size
);
ret
=
fwrite
(
map
.
data
,
map
.
size
,
1
,
multifilesink
->
file
);
if
(
ret
!=
1
)
goto
stdio_write_error
;
gst_multi_file_sink_close_file
(
multifilesink
,
buffer
);
break
;
case
GST_MULTI_FILE_SINK_NEXT_DISCONT
:
if
(
GST_BUFFER_IS_DISCONT
(
buffer
))
{
...
...
@@ -712,26 +712,6 @@ gst_multi_file_sink_write_buffer (GstMultiFileSink * multifilesink,
return
GST_FLOW_OK
;
/* ERRORS */
write_error:
{
switch
(
error
->
code
)
{
case
G_FILE_ERROR_NOSPC
:{
GST_ELEMENT_ERROR
(
multifilesink
,
RESOURCE
,
NO_SPACE_LEFT
,
(
NULL
),
(
NULL
));
break
;
}
default:
{
GST_ELEMENT_ERROR
(
multifilesink
,
RESOURCE
,
WRITE
,
(
"Error while writing to file
\"
%s
\"
."
,
filename
),
(
"%s"
,
g_strerror
(
errno
)));
}
}
g_error_free
(
error
);
g_free
(
filename
);
gst_buffer_unmap
(
buffer
,
&
map
);
return
GST_FLOW_ERROR
;
}
stdio_write_error:
switch
(
errno
)
{
case
ENOSPC
:
...
...
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