Ocean
Loading...
Searching...
No Matches
Ocean::Media::AVFoundation::AVFMovieRecorder Class Reference

This class implements a AVFoundation movie recorder. More...

#include <AVFMovieRecorder.h>

Inheritance diagram for Ocean::Media::AVFoundation::AVFMovieRecorder:

Public Member Functions

bool setFilename (const std::string &filename) override
 Sets the filename of this recorder.
 
bool start () override
 Sets the recorder.
 
bool stop () override
 Stops the recorder.
 
bool isRecording () const override
 Returns whether this recorder is currently recording.
 
Encoders frameEncoders () const override
 Returns a list of possible frame encoders for this recorder.
 
bool lockBufferToFill (Frame &recorderFrame, const bool respectFrameFrequency=true) override
 Returns a pointer to the most recent buffer to be filled immediately and locks it.
 
void unlockBufferToFill () override
 Unlocks the filled buffer.
 
- Public Member Functions inherited from Ocean::Media::FileRecorder
const std::string & filename () const
 Returns the filename of this recorder.
 
bool filenameSuffixed () const
 Returns whether the filename of this recorder will be suffixed with date and time.
 
virtual bool setFilenameSuffixed (const bool suffixed)
 Sets whether the filename will be suffixed with date and time.
 
- Public Member Functions inherited from Ocean::Media::Recorder
Type type () const
 Returns the type of this recorder.
 
- Public Member Functions inherited from Ocean::Media::FrameRecorder
const FrameTypeframeType () const
 Returns the actual frame type of this recorder.
 
double frameFrequency () const
 Returns the frame frequency of this recorder in Hz.
 
const std::string & frameEncoder () const
 Returns the name of the encoder used to encoder the frames.
 
virtual bool frameEncoderHasConfiguration ()
 Returns whether the selected frame encoder has a configuration possibility.
 
virtual bool setPreferredFrameType (const FrameType &type)
 Sets the preferred frame type of this recorder.
 
virtual bool setFrameFrequency (const double frequency)
 Sets the frame frequency of this recorder.
 
virtual bool setFrameEncoder (const std::string &encoder)
 Sets the frame encoder used to encode the frames.
 
virtual bool frameEncoderConfiguration (long long data)
 Starts the frame encoder configuration possibility.
 

Static Public Member Functions

static AVVideoCodecType frameEncoderToVideoCodecType (const std::string &frameEncoder)
 Translates a frame encoder to a corresponding AVVideoCodecType.
 
static AVFileType fileExtensionToFileType (const std::string &fileExtension)
 Translates the file extension of a movie to a corresponding AVFileType.
 
- Static Public Member Functions inherited from Ocean::Media::FileRecorder
static std::string addOptionalSuffixToFilename (const std::string &filename, const bool addSuffix)
 Determines the filename to be used for the next file.
 
static std::string addOptionalSuffixToFilename (const std::string &filename, const unsigned int index, const bool addSuffix)
 Determines the filename to be used for the next file.
 

Protected Member Functions

 AVFMovieRecorder ()
 Creates a new movie recorder object.
 
 ~AVFMovieRecorder () override
 Destructs a movie recorder object.
 
bool createNewAssetWriter ()
 Creates a new asset writer and all associated resources.
 
void release ()
 Releases all resources.
 
CMTime time (const double timestamp)
 Returns the time for a given timestamp.
 
- Protected Member Functions inherited from Ocean::Media::MovieRecorder
 MovieRecorder ()
 Creates a new movie recorder.
 
 ~MovieRecorder () override
 Destructs a movie recorder.
 
- Protected Member Functions inherited from Ocean::Media::FileRecorder
 FileRecorder ()
 Creates a new file recorder.
 
 ~FileRecorder () override
 Destructs a file recorder.
 
- Protected Member Functions inherited from Ocean::Media::ExplicitRecorder
 ExplicitRecorder ()
 Creates a new explicit recorder.
 
 ~ExplicitRecorder () override
 Destructs a explicit recorder.
 
- Protected Member Functions inherited from Ocean::Media::Recorder
 Recorder ()
 Creates a new recorder.
 
virtual ~Recorder ()
 Destructs a recorder.
 
- Protected Member Functions inherited from Ocean::Media::FrameRecorder
 FrameRecorder ()
 Creats a new frame recorder.
 
 ~FrameRecorder () override
 Destructs a frame recorder.
 

Static Protected Member Functions

static FrameType::PixelFormat bestMatchingPixelFormat (const FrameType::PixelFormat preferredPixelFormat)
 Returns the best matching pixel format for a preferred pixel format.
 

Protected Attributes

AVAssetWriter * assetWriter_ = nullptr
 The asset writer.
 
AVAssetWriterInput * assetWriterInput_ = nullptr
 The input for the asset writer.
 
AVAssetWriterInputPixelBufferAdaptor * assetWriterInputPixelBufferAdaptor_ = nullptr
 The pixel buffer adaptor for the input asset writer.
 
CVPixelBufferRef pixelBuffer_ = nullptr
 The pixel buffer to be filled.
 
PixelBufferAccessor pixelBufferAccessor_
 The pixel buffer accessor.
 
double nextFrameTimestamp_ = 0.0
 The timestamp of the next frame.
 
double previousFrameTimestamp_ = -1.0
 The timestamp of the previous frame.
 
bool isRecording_ = false
 True, if the recoder is actively recording frames; False, otherwise.
 
bool isStopped_ = true
 True, if this recorder is stopped.
 
- Protected Attributes inherited from Ocean::Media::FileRecorder
std::string recorderFilename
 Filename of this recorder.
 
bool recorderFilenameSuffixed
 Flag determining whether the filename will be suffixed with date and time.
 
- Protected Attributes inherited from Ocean::Media::Recorder
Type recorderType
 Type of this recorder.
 
Lock recorderLock
 Lock of this recorder.
 
- Protected Attributes inherited from Ocean::Media::FrameRecorder
FrameType recorderFrameType
 Type of the frame to record.
 
double recorderFrameFrequency
 Frame frequency used by the recorder.
 
std::string recorderFrameEncoder
 Name of the frame encoder used to encode the frames.
 

Friends

class AVFLibrary
 

Additional Inherited Members

- Public Types inherited from Ocean::Media::Recorder
enum  Type {
  RECORDER = 0 , FRAME_RECORDER = 1 , SOUND_RECORDER = 2 , EXPLICIT_RECORDER = 4 ,
  IMPLICIT_RECORDER = 8 , FILE_RECORDER = 16 | EXPLICIT_RECORDER , BUFFER_RECORDER = 32 | EXPLICIT_RECORDER , STREAMING_RECORDER = 64 | IMPLICIT_RECORDER ,
  MOVIE_RECORDER = 128 | FRAME_RECORDER | FILE_RECORDER , FRAME_STREAMING_RECORDER = 256 | FRAME_RECORDER | STREAMING_RECORDER , IMAGE_RECORDER = 512 | FRAME_RECORDER | FILE_RECORDER , BUFFER_IMAGE_RECORDER = 1024 | FRAME_RECORDER | BUFFER_RECORDER ,
  IMAGE_SEQUENCE_RECORDER = 2048 | FRAME_RECORDER | FILE_RECORDER , FRAME_MEMORY_RECORDER = 4096 | FRAME_RECORDER
}
 Definition of different recorder types. More...
 
typedef std::vector< std::string > Encoders
 Definition of a vector holding encoder names.
 

Detailed Description

This class implements a AVFoundation movie recorder.

The recorder can record mp4 files and mov files.

Constructor & Destructor Documentation

◆ AVFMovieRecorder()

Ocean::Media::AVFoundation::AVFMovieRecorder::AVFMovieRecorder ( )
protected

Creates a new movie recorder object.

◆ ~AVFMovieRecorder()

Ocean::Media::AVFoundation::AVFMovieRecorder::~AVFMovieRecorder ( )
overrideprotected

Destructs a movie recorder object.

Member Function Documentation

◆ bestMatchingPixelFormat()

static FrameType::PixelFormat Ocean::Media::AVFoundation::AVFMovieRecorder::bestMatchingPixelFormat ( const FrameType::PixelFormat  preferredPixelFormat)
staticprotected

Returns the best matching pixel format for a preferred pixel format.

Depending on the platform, not each preferred pixel format may be supported. This function allows to determine the best matching pixel format closes to the preferred pixel format.

Parameters
preferredPixelFormatThe preferred pixel format, can be invalid
Returns
The supported pixel format best matching with the preferred pixel format

◆ createNewAssetWriter()

bool Ocean::Media::AVFoundation::AVFMovieRecorder::createNewAssetWriter ( )
protected

Creates a new asset writer and all associated resources.

Returns
True, if succeeded

◆ fileExtensionToFileType()

static AVFileType Ocean::Media::AVFoundation::AVFMovieRecorder::fileExtensionToFileType ( const std::string &  fileExtension)
static

Translates the file extension of a movie to a corresponding AVFileType.

The following extensions are supported: mp4, mov.

Parameters
fileExtensionThe extension of the movie's filename
Returns
The corresponding AVFileType value, if existing, invalid otherwise

◆ frameEncoders()

Encoders Ocean::Media::AVFoundation::AVFMovieRecorder::frameEncoders ( ) const
overridevirtual

Returns a list of possible frame encoders for this recorder.

Returns
Encoder names

Reimplemented from Ocean::Media::FrameRecorder.

◆ frameEncoderToVideoCodecType()

static AVVideoCodecType Ocean::Media::AVFoundation::AVFMovieRecorder::frameEncoderToVideoCodecType ( const std::string &  frameEncoder)
static

Translates a frame encoder to a corresponding AVVideoCodecType.

Parameters
frameEncoderThe name of the encoder
Returns
The corresponding AVVideoCodecType value, if existing, invalid otherwise
See also
frameEncoders().

◆ isRecording()

bool Ocean::Media::AVFoundation::AVFMovieRecorder::isRecording ( ) const
overridevirtual

Returns whether this recorder is currently recording.

Returns
True, if so

Implements Ocean::Media::Recorder.

◆ lockBufferToFill()

bool Ocean::Media::AVFoundation::AVFMovieRecorder::lockBufferToFill ( Frame recorderFrame,
const bool  respectFrameFrequency = true 
)
overridevirtual

Returns a pointer to the most recent buffer to be filled immediately and locks it.

Beware: Call unlockBufferToFill() once the image data is written to the frame.

Parameters
recorderFrameThe resulting frame in which the image data can be copied, the frame type of this frame must not be changed
respectFrameFrequencyFlag determining that a buffer will be returned if it is time for a new frame only

Implements Ocean::Media::FrameRecorder.

◆ release()

void Ocean::Media::AVFoundation::AVFMovieRecorder::release ( )
protected

Releases all resources.

◆ setFilename()

bool Ocean::Media::AVFoundation::AVFMovieRecorder::setFilename ( const std::string &  filename)
overridevirtual

Sets the filename of this recorder.

The filename must be set before recordings starts.

See also
MovieRecorder::setFilename().

Reimplemented from Ocean::Media::FileRecorder.

◆ start()

bool Ocean::Media::AVFoundation::AVFMovieRecorder::start ( )
overridevirtual

Sets the recorder.

See also
ExplicitRecorder::start().

Implements Ocean::Media::ExplicitRecorder.

◆ stop()

bool Ocean::Media::AVFoundation::AVFMovieRecorder::stop ( )
overridevirtual

Stops the recorder.

See also
ExplicitRecorder::stop().

Implements Ocean::Media::ExplicitRecorder.

◆ time()

CMTime Ocean::Media::AVFoundation::AVFMovieRecorder::time ( const double  timestamp)
inlineprotected

Returns the time for a given timestamp.

Parameters
timestampPlayback timestamp in seconds, with range [0, infinity)

◆ unlockBufferToFill()

void Ocean::Media::AVFoundation::AVFMovieRecorder::unlockBufferToFill ( )
overridevirtual

Unlocks the filled buffer.

Beware: The buffer has to be locked by lockBufferToFill() before.

Implements Ocean::Media::FrameRecorder.

Friends And Related Symbol Documentation

◆ AVFLibrary

friend class AVFLibrary
friend

Field Documentation

◆ assetWriter_

AVAssetWriter* Ocean::Media::AVFoundation::AVFMovieRecorder::assetWriter_ = nullptr
protected

The asset writer.

◆ assetWriterInput_

AVAssetWriterInput* Ocean::Media::AVFoundation::AVFMovieRecorder::assetWriterInput_ = nullptr
protected

The input for the asset writer.

◆ assetWriterInputPixelBufferAdaptor_

AVAssetWriterInputPixelBufferAdaptor* Ocean::Media::AVFoundation::AVFMovieRecorder::assetWriterInputPixelBufferAdaptor_ = nullptr
protected

The pixel buffer adaptor for the input asset writer.

◆ isRecording_

bool Ocean::Media::AVFoundation::AVFMovieRecorder::isRecording_ = false
protected

True, if the recoder is actively recording frames; False, otherwise.

◆ isStopped_

bool Ocean::Media::AVFoundation::AVFMovieRecorder::isStopped_ = true
protected

True, if this recorder is stopped.

◆ nextFrameTimestamp_

double Ocean::Media::AVFoundation::AVFMovieRecorder::nextFrameTimestamp_ = 0.0
protected

The timestamp of the next frame.

◆ pixelBuffer_

CVPixelBufferRef Ocean::Media::AVFoundation::AVFMovieRecorder::pixelBuffer_ = nullptr
protected

The pixel buffer to be filled.

◆ pixelBufferAccessor_

PixelBufferAccessor Ocean::Media::AVFoundation::AVFMovieRecorder::pixelBufferAccessor_
protected

The pixel buffer accessor.

◆ previousFrameTimestamp_

double Ocean::Media::AVFoundation::AVFMovieRecorder::previousFrameTimestamp_ = -1.0
protected

The timestamp of the previous frame.


The documentation for this class was generated from the following file: