Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libjitsi
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
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
ZRTP
libjitsi
Commits
b9420895
You need to sign in or sign up before continuing.
Commit
b9420895
authored
10 years ago
by
Boris Grozev
Browse files
Options
Downloads
Patches
Plain Diff
Prevents WebmDataSink from (crashing because of) writing to a closed file.
parent
55e712e2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/org/jitsi/impl/neomedia/recording/WebmDataSink.java
+44
-23
44 additions, 23 deletions
src/org/jitsi/impl/neomedia/recording/WebmDataSink.java
with
44 additions
and
23 deletions
src/org/jitsi/impl/neomedia/recording/WebmDataSink.java
+
44
−
23
View file @
b9420895
...
...
@@ -40,6 +40,13 @@ public class WebmDataSink
private
RecorderEventHandler
eventHandler
;
private
long
ssrc
=
-
1
;
/**
* Whether this <tt>DataSink</tt> is open and should write to its
* <tt>WebmWriter</tt>.
*/
private
boolean
open
=
false
;
private
final
Object
openCloseSyncRoot
=
new
Object
();
/**
* Whether we are in a state of waiting for a keyframe and discarding
* non-key frames.
...
...
@@ -129,21 +136,25 @@ public void addDataSinkListener(DataSinkListener dataSinkListener)
@Override
public
void
close
()
{
if
(
writer
!=
null
)
writer
.
close
();
if
(
eventHandler
!=
null
&&
firstFrameTime
!=
-
1
&&
lastFramePts
!=
-
1
)
synchronized
(
openCloseSyncRoot
)
{
RecorderEvent
event
=
new
RecorderEvent
();
event
.
setType
(
RecorderEvent
.
Type
.
RECORDING_ENDED
);
event
.
setSsrc
(
ssrc
);
event
.
setFilename
(
filename
);
if
(
writer
!=
null
)
writer
.
close
();
if
(
eventHandler
!=
null
&&
firstFrameTime
!=
-
1
&&
lastFramePts
!=
-
1
)
{
RecorderEvent
event
=
new
RecorderEvent
();
event
.
setType
(
RecorderEvent
.
Type
.
RECORDING_ENDED
);
event
.
setSsrc
(
ssrc
);
event
.
setFilename
(
filename
);
// make sure that the difference in the 'instant'-s of the
// STARTED and ENDED events matches the duration of the file
event
.
setDuration
(
lastFramePts
);
// make sure that the difference in the 'instant'-s of the
// STARTED and ENDED events matches the duration of the file
event
.
setDuration
(
lastFramePts
);
event
.
setMediaType
(
MediaType
.
VIDEO
);
eventHandler
.
handleEvent
(
event
);
event
.
setMediaType
(
MediaType
.
VIDEO
);
eventHandler
.
handleEvent
(
event
);
}
open
=
false
;
}
}
...
...
@@ -171,22 +182,27 @@ public MediaLocator getOutputLocator()
@Override
public
void
open
()
throws
IOException
,
SecurityException
{
if
(
dataSource
instanceof
PushBufferDataSource
)
synchronized
(
openCloseSyncRoot
)
{
PushBufferDataSource
pbds
=
(
PushBufferDataSource
)
dataSource
;
PushBufferStream
[]
streams
=
pbds
.
getStreams
();
//XXX: should we allow for multiple streams in the data source?
for
(
PushBufferStream
stream
:
streams
)
if
(
dataSource
instanceof
PushBufferDataSource
)
{
//XXX whats the proper way to check for this? and handle?
if
(!
stream
.
getFormat
().
matches
(
new
VideoFormat
(
"VP8"
)))
throw
new
IOException
(
"Unsupported stream format"
);
PushBufferDataSource
pbds
=
(
PushBufferDataSource
)
dataSource
;
PushBufferStream
[]
streams
=
pbds
.
getStreams
();
stream
.
setTransferHandler
(
this
);
//XXX: should we allow for multiple streams in the data source?
for
(
PushBufferStream
stream
:
streams
)
{
//XXX whats the proper way to check for this? and handle?
if
(!
stream
.
getFormat
().
matches
(
new
VideoFormat
(
"VP8"
)))
throw
new
IOException
(
"Unsupported stream format"
);
stream
.
setTransferHandler
(
this
);
}
}
dataSource
.
connect
();
open
=
true
;
}
dataSource
.
connect
();
}
/**
...
...
@@ -261,6 +277,10 @@ public void setSource(DataSource dataSource)
@Override
public
void
transferData
(
PushBufferStream
stream
)
{
synchronized
(
openCloseSyncRoot
)
{
if
(!
open
)
return
;
try
{
stream
.
read
(
buffer
);
...
...
@@ -391,6 +411,7 @@ else if (height*16 == width*9)
lastFramePts
=
fd
.
pts
;
}
}
//synchronized
}
/**
...
...
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