#include <icy/av/mediacapture.h>Inherits:
ICapture,RunnableSubclassed by:AudioCapture,VideoCapture
Unified capture and decode source for files and live media devices.
| Return | Name | Description |
|---|---|---|
NullSignal | Closing | Signals that the capture thread is closing. This signal is emitted from the capture thread context. |
NullSignal ClosingSignals that the capture thread is closing. This signal is emitted from the capture thread context.
| Return | Name | Description |
|---|---|---|
MediaCapture | ||
MediaCapture | Deleted constructor. | |
MediaCapture | Deleted constructor. | |
void | openFile virtual | Open a media file for decoding. Automatically detects video and audio streams. |
void | close virtual | Stop the capture thread and close the media stream and all decoders. |
void | start virtual | Start the background capture and decode thread. Throws std::runtime_error if no media streams have been opened. |
void | stop virtual | Signal the capture thread to stop and join it before returning. |
void | run virtual | Entry point for the background capture thread. Reads and decodes packets from the format context until EOF or stop() is called. |
void | getEncoderFormat virtual | Fill format with the combined encoder-ready video and audio codec parameters. |
void | getEncoderAudioCodec virtual | Fill params with the decoder's output audio codec parameters. Throws std::runtime_error if audio parameters have not been initialised. |
void | getEncoderVideoCodec virtual | Fill params with the decoder's output video codec parameters. Throws std::runtime_error if video parameters have not been initialised. |
void | setLoopInput | Continuously loop the input file when set. |
void | setLimitFramerate | Limit playback to video FPS. |
void | setRealtimePTS | Set to use realtime PTS calculation. This is preferred when using live captures as FFmpeg-provided values are not always reliable. |
AVFormatContext * | formatCtx const | #### Returns |
VideoDecoder * | video const | #### Returns |
AudioDecoder * | audio const | #### Returns |
bool | stopping const | #### Returns |
std::string | error const | #### Returns |
MediaCapture()MediaCapture(const MediaCapture &) = deleteDeleted constructor.
MediaCapture(MediaCapture &&) = deleteDeleted constructor.
virtual
virtual void openFile(const std::string & file)Open a media file for decoding. Automatically detects video and audio streams.
file Path to the media file.virtual
virtual void close()Stop the capture thread and close the media stream and all decoders.
virtual
virtual void start()Start the background capture and decode thread. Throws std::runtime_error if no media streams have been opened.
virtual
virtual void stop()Signal the capture thread to stop and join it before returning.
virtual
virtual void run()Entry point for the background capture thread. Reads and decodes packets from the format context until EOF or stop() is called.
virtual
virtual void getEncoderFormat(Format & format)Fill format with the combined encoder-ready video and audio codec parameters.
format Output Format struct to populate.virtual
virtual void getEncoderAudioCodec(AudioCodec & params)Fill params with the decoder's output audio codec parameters. Throws std::runtime_error if audio parameters have not been initialised.
params Output AudioCodec struct to populate.virtual
virtual void getEncoderVideoCodec(VideoCodec & params)Fill params with the decoder's output video codec parameters. Throws std::runtime_error if video parameters have not been initialised.
params Output VideoCodec struct to populate.void setLoopInput(bool flag)Continuously loop the input file when set.
void setLimitFramerate(bool flag)Limit playback to video FPS.
void setRealtimePTS(bool flag)Set to use realtime PTS calculation. This is preferred when using live captures as FFmpeg-provided values are not always reliable.
const
AVFormatContext * formatCtx() constThe underlying AVFormatContext (thread-safe, mutex-protected).
const
VideoDecoder * video() constThe active VideoDecoder, or nullptr if no video stream was opened.
const
AudioDecoder * audio() constThe active AudioDecoder, or nullptr if no audio stream was opened.
const
bool stopping() constTrue if the capture thread has been asked to stop.
const
std::string error() constThe last error message, or an empty string if no error has occurred.
| Return | Name | Description |
|---|---|---|
std::mutex | _mutex | |
Thread | _thread | |
AVFormatContext * | _formatCtx | |
std::unique_ptr< VideoDecoder > | _video | |
std::unique_ptr< AudioDecoder > | _audio | |
std::string | _error | |
std::atomic< bool > | _stopping | |
std::atomic< bool > | _looping | |
std::atomic< bool > | _realtime | |
std::atomic< bool > | _ratelimit |
std::mutex _mutexThread _threadAVFormatContext * _formatCtxstd::unique_ptr< VideoDecoder > _videostd::unique_ptr< AudioDecoder > _audiostd::string _errorstd::atomic< bool > _stoppingstd::atomic< bool > _loopingstd::atomic< bool > _realtimestd::atomic< bool > _ratelimit| Return | Name | Description |
|---|---|---|
void | openStream virtual | Open the underlying media stream. |
void | emit virtual | Emit an existing packet directly onto the outgoing signal. |
virtual
virtual void openStream(const std::string & filename, const AVInputFormat * inputFormat, AVDictionary ** formatParams)Open the underlying media stream.
filename The file path or device name to open.
inputFormat The forced input format, or nullptr for auto-detect.
formatParams Optional format parameters; may be updated by FFmpeg on return.
virtual
virtual void emit(IPacket & packet)Emit an existing packet directly onto the outgoing signal.
packet The packet to forward; must remain valid for the duration of the call.| Name | Description |
|---|---|
Ptr |
std::shared_ptr< MediaCapture > Ptr()