diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp index f45eb99..34ef917 100644 --- a/libffmpegthumbnailer/moviedecoder.cpp +++ b/libffmpegthumbnailer/moviedecoder.cpp @@ -106,12 +106,12 @@ void MovieDecoder::destroy() avformat_network_deinit(); } -bool MovieDecoder::embeddedMetaDataIsAvailable() +bool MovieDecoder::embeddedMetaDataIsAvailable() const { return m_UseEmbeddedData; } -string MovieDecoder::getCodec() +string MovieDecoder::getCodec() const { if (m_pVideoCodec) { return m_pVideoCodec->name; @@ -374,7 +374,7 @@ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std:: checkRc(avfilter_graph_config(m_pFilterGraph, nullptr), "Failed to configure filter graph"); } -int MovieDecoder::getWidth() +int MovieDecoder::getWidth() const { if (m_pVideoCodecContext) { return m_pVideoCodecContext->width; @@ -383,7 +383,7 @@ int MovieDecoder::getWidth() return -1; } -int MovieDecoder::getHeight() +int MovieDecoder::getHeight() const { if (m_pVideoCodecContext) { return m_pVideoCodecContext->height; @@ -392,7 +392,7 @@ int MovieDecoder::getHeight() return -1; } -int MovieDecoder::getDuration() +int MovieDecoder::getDuration() const { if (m_pFormatContext) { return static_cast(m_pFormatContext->duration / AV_TIME_BASE); @@ -540,7 +540,7 @@ void MovieDecoder::getScaledVideoFrame(const std::string& scaledSize, bool maint } } -void MovieDecoder::checkRc(int ret, const std::string& message) +void MovieDecoder::checkRc(int ret, const std::string& message) const { if (ret < 0) { char buf[256]; @@ -550,7 +550,7 @@ void MovieDecoder::checkRc(int ret, const std::string& message) } } -int32_t MovieDecoder::getStreamRotation() +int32_t MovieDecoder::getStreamRotation() const { if (!m_pVideoStream || !m_pVideoStream->codecpar) { return -1; diff --git a/libffmpegthumbnailer/moviedecoder.h b/libffmpegthumbnailer/moviedecoder.h index 22113d4..b0436bb 100644 --- a/libffmpegthumbnailer/moviedecoder.h +++ b/libffmpegthumbnailer/moviedecoder.h @@ -46,19 +46,19 @@ class MovieDecoder MovieDecoder(AVFormatContext* pavContext = nullptr); ~MovieDecoder(); - std::string getCodec(); + std::string getCodec() const; void seek(int timeInSeconds); void decodeVideoFrame(); void getScaledVideoFrame(const std::string& scaledSize, bool maintainAspectRatio, VideoFrame& videoFrame); - int getWidth(); - int getHeight(); - int getDuration(); + int getWidth() const; + int getHeight() const; + int getDuration() const; void initialize(const std::string& filename, bool preferEmbeddedMetadata); void destroy(); - bool embeddedMetaDataIsAvailable(); + bool embeddedMetaDataIsAvailable() const; private: int32_t findPreferredVideoStream(bool preferEmbeddedMetadata); @@ -68,10 +68,10 @@ class MovieDecoder bool decodeVideoPacket(); bool getVideoPacket(); - int32_t getStreamRotation(); + int32_t getStreamRotation() const; std::string createScaleString(const std::string& size, bool maintainAspectRatio); - void checkRc(int ret, const std::string& message); + void checkRc(int ret, const std::string& message) const; private: int m_VideoStream; diff --git a/libffmpegthumbnailer/videothumbnailer.cpp b/libffmpegthumbnailer/videothumbnailer.cpp index 6e2c8da..178d3df 100644 --- a/libffmpegthumbnailer/videothumbnailer.cpp +++ b/libffmpegthumbnailer/videothumbnailer.cpp @@ -201,7 +201,7 @@ VideoFrameInfo VideoThumbnailer::generateThumbnail(const string& videoFile, Imag return info; } -void VideoThumbnailer::generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame) +void VideoThumbnailer::generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame) const { vector videoFrames(SMART_FRAME_ATTEMPTS); vector> histograms(SMART_FRAME_ATTEMPTS); @@ -262,7 +262,7 @@ void VideoThumbnailer::writeImage(const string& videoFile, ImageWriter& imageWri imageWriter.writeFrame(&(rowPointers.front()), videoFrame.width, videoFrame.height, m_ImageQuality); } -string VideoThumbnailer::getMimeType(const string& videoFile) +string VideoThumbnailer::getMimeType(const string& videoFile) const { string extension = getExtension(videoFile); @@ -289,7 +289,7 @@ string VideoThumbnailer::getMimeType(const string& videoFile) } } -string VideoThumbnailer::getExtension(const string& videoFilename) +string VideoThumbnailer::getExtension(const string& videoFilename) const { string extension; auto pos = videoFilename.rfind('.'); @@ -328,7 +328,7 @@ void VideoThumbnailer::applyFilters(VideoFrame& frameData) } } -int VideoThumbnailer::getBestThumbnailIndex(vector& videoFrames, const vector>& histograms) +int VideoThumbnailer::getBestThumbnailIndex(vector& videoFrames, const vector>& histograms) const { Histogram avgHistogram; for (auto&& histogram : histograms) { diff --git a/libffmpegthumbnailer/videothumbnailer.h b/libffmpegthumbnailer/videothumbnailer.h index 7de942a..ce277a6 100644 --- a/libffmpegthumbnailer/videothumbnailer.h +++ b/libffmpegthumbnailer/videothumbnailer.h @@ -70,13 +70,13 @@ class VideoThumbnailer private: VideoFrameInfo generateThumbnail(const std::string& videoFile, ImageWriter& imageWriter, AVFormatContext* pAvContext = nullptr); - void generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame); + void generateSmartThumbnail(MovieDecoder& movieDecoder, VideoFrame& videoFrame) const; void writeImage(const std::string& videoFile, ImageWriter& imageWriter, const VideoFrame& videoFrame, int duration, std::vector& rowPointers); - std::string getMimeType(const std::string& videoFile); - std::string getExtension(const std::string& videoFilename); + std::string getMimeType(const std::string& videoFile) const; + std::string getExtension(const std::string& videoFilename) const; - int getBestThumbnailIndex(std::vector& videoFrames, const std::vector>& histograms); + int getBestThumbnailIndex(std::vector& videoFrames, const std::vector>& histograms) const; void applyFilters(VideoFrame& frameData); void TraceMessage(ThumbnailerLogLevel lvl, const std::string& msg);