Package com.banuba.sdk.video
Class VideoFileRecorder
- java.lang.Object
-
- com.banuba.sdk.player.VerifyCloseable
-
- com.banuba.sdk.video.VideoFileRecorder
-
- All Implemented Interfaces:
IVideoRecorder
,java.io.Closeable
,java.lang.AutoCloseable
- Direct Known Subclasses:
VideoOutput
public class VideoFileRecorder extends VerifyCloseable implements IVideoRecorder
Render video to the offscreen surface and save it to a video file
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
VideoFileRecorder.IRecordingStateChangedListener
-
Field Summary
-
Fields inherited from class com.banuba.sdk.player.VerifyCloseable
mIsClosed, mTag
-
-
Constructor Summary
Constructors Modifier Constructor Description VideoFileRecorder()
protected
VideoFileRecorder(java.lang.String tag)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close an instance and free resourcesprotected void
frameAvailable(long frameTimeNanos)
Captures the next frame and writes it to a fileRecordingState
getRecordingState()
Get current state of recordingprotected WindowSurface
getRenderingSurface()
Returns the surface for drawing the frameprotected void
initializeMuxerAndSurface(EglCore eglCore, android.util.Size frameSize)
Must be called after calling startRecording(...) method and before frameAvailable(...).void
pauseRecording()
Check state and pause recordingvoid
recordAudioFromMicrophone(boolean recordAudio)
Capture audio from microphonevoid
resumeRecording()
Check state and resume recordingprotected void
setRecordingStateChangedListener(VideoFileRecorder.IRecordingStateChangedListener listener)
Set a callback to change the state of a recordvoid
startRecording(java.io.File outputFile)
Start recording to video filevoid
startRecording(java.io.File outputFile, IAudioDataProvider audioDataProvider)
Start recording to video filevoid
stopRecording()
Stop recording.void
stopRecordingAndWaitForFinish()
Stops recording if recording was started and waits for the end of the video writing.-
Methods inherited from class com.banuba.sdk.player.VerifyCloseable
finalize
-
-
-
-
Method Detail
-
recordAudioFromMicrophone
public void recordAudioFromMicrophone(boolean recordAudio)
Capture audio from microphone- Parameters:
recordAudio
- do the capture flag
-
setRecordingStateChangedListener
protected void setRecordingStateChangedListener(VideoFileRecorder.IRecordingStateChangedListener listener)
Set a callback to change the state of a record- Parameters:
listener
- callback
-
startRecording
@CallSuper public void startRecording(java.io.File outputFile)
Start recording to video file- Specified by:
startRecording
in interfaceIVideoRecorder
- Parameters:
outputFile
- the output filename
-
startRecording
@CallSuper public void startRecording(java.io.File outputFile, IAudioDataProvider audioDataProvider)
Start recording to video file- Specified by:
startRecording
in interfaceIVideoRecorder
- Parameters:
outputFile
- the output filenameaudioDataProvider
- callback with audio data
-
pauseRecording
@CallSuper public void pauseRecording()
Check state and pause recording- Specified by:
pauseRecording
in interfaceIVideoRecorder
-
resumeRecording
@CallSuper public void resumeRecording()
Check state and resume recording- Specified by:
resumeRecording
in interfaceIVideoRecorder
-
stopRecording
@CallSuper public void stopRecording()
Stop recording. After call this method the file will be automatically saved to the path specified at the start of recording. File will be saved in another thread. To wait for a video file to be written, use thestopRecordingAndWaitForFinish()
method.- Specified by:
stopRecording
in interfaceIVideoRecorder
-
stopRecordingAndWaitForFinish
@CallSuper public void stopRecordingAndWaitForFinish()
Stops recording if recording was started and waits for the end of the video writing.- Specified by:
stopRecordingAndWaitForFinish
in interfaceIVideoRecorder
- See Also:
stopRecording()
-
getRecordingState
public RecordingState getRecordingState()
Get current state of recording- Specified by:
getRecordingState
in interfaceIVideoRecorder
- Returns:
- recording state
-
close
public void close()
Close an instance and free resources- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classVerifyCloseable
-
initializeMuxerAndSurface
protected void initializeMuxerAndSurface(@NonNull EglCore eglCore, android.util.Size frameSize)
Must be called after calling startRecording(...) method and before frameAvailable(...). Initializes writing to a file.- Parameters:
eglCore
- opengl contextframeSize
- output video file resolution
-
getRenderingSurface
protected WindowSurface getRenderingSurface()
Returns the surface for drawing the frame
-
frameAvailable
protected void frameAvailable(long frameTimeNanos)
Captures the next frame and writes it to a file- Parameters:
frameTimeNanos
- frame time in nanoseconds
-
-