Skip to content

Commit 11b72e8

Browse files
author
Clement Champetier
committed
Frame: added isVideo/AudioFrame methods
1 parent c613802 commit 11b72e8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/AvTranscoder/data/decoded/Frame.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,18 @@ void Frame::allocateAVFrame()
8080
throw std::runtime_error("Unable to allocate an empty Frame.");
8181
}
8282
}
83+
84+
bool Frame::isAudioFrame() const
85+
{
86+
if(_frame->sample_rate && _frame->channels && _frame->channel_layout && _frame->format != -1)
87+
return true;
88+
return false;
89+
}
90+
91+
bool Frame::isVideoFrame() const
92+
{
93+
if(_frame->width && _frame->height && _frame->format != -1)
94+
return true;
95+
return false;
96+
}
8397
}

src/AvTranscoder/data/decoded/Frame.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ class AvExport Frame
6363
*/
6464
void clear();
6565

66+
/**
67+
* @return If it corresponds to a valid audio frame.
68+
* @see AudioFrame
69+
*/
70+
bool isAudioFrame() const;
71+
72+
/**
73+
* @return If it corresponds to a valid video frame.
74+
* @see VideoFrame
75+
*/
76+
bool isVideoFrame() const;
77+
6678
#ifndef SWIG
6779
AVFrame& getAVFrame() { return *_frame; }
6880
const AVFrame& getAVFrame() const { return *_frame; }

0 commit comments

Comments
 (0)