267 lines
11 KiB
C++
267 lines
11 KiB
C++
/******************************************************************************
|
|
QtAV: Multimedia framework based on Qt and FFmpeg
|
|
Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>
|
|
|
|
* This file is part of QtAV
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with this library; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
******************************************************************************/
|
|
|
|
|
|
#ifndef QTFAV_GLOBAL_H
|
|
#define QTFAV_GLOBAL_H
|
|
|
|
#include <stdarg.h>
|
|
#include <QtCore/QMetaType>
|
|
#include <QtCore/QByteArray>
|
|
#include <QtCore/qglobal.h>
|
|
#include "dptr.h"
|
|
|
|
#define FAST_VIDEO_LOADER 1 // probesize 및 analyze_duration 값을 줄여 비디오를 빨리 로딩하고 실패시 늘려서 다시 로딩
|
|
#define DO_NOT_USE_SUBTITLE 1 // 자막 사용금지
|
|
|
|
#define USE_SKIP_COUNT 1 // 프레임 스킵처리
|
|
|
|
#define ORIGINAL_PARAMETER 1 // 만도 152 버전 파라미터 사용 (사용하지 않으면 노트북에서 에러 발생함)
|
|
#define SKIP_WAIT_UNTIL_FIRST_FRAME 1 // 초기 프레임 제거 (사용)
|
|
|
|
#define SLOW_SKIP_SEC 2 // 2초이상 늦지 않도록 ..(기본값)
|
|
#define FORCE_FPS_NO_PTS_COUNT 5 // 프레임 개수가 초과하였을 경우 강제 FPS 설정 default = 5,
|
|
#define AVFORMAT_FILTER_SPEED 1 // AVFORMAT 필터 사용
|
|
#define FORCE_USE_AUDIO_DURATION 0 // 원래 pro 파일에 있었음 -> 사용하면 마지막 프레임이 안보이는 경우가 발생
|
|
#define FORCE_USE_AUDIO_DURATION_SCALE 1000 // AUDIO DURATION 계산시 * N
|
|
#define FIRST_FRAME_NOTIFY 1 // 재생시 초기 프레임 decoding 되면 이벤트 발생
|
|
#define REMOVE_EOF_SEEK_NOTIFY 1 // VideoThread 종료시 남은 SEEK 메시지 전달 방지
|
|
#define FIX_SPEED_CHANGE_ERROR 1
|
|
// 사용금지 옵션 (나중에 다시 추가하는 일 없도록 그대로 유지)
|
|
#define FIX_SYNC_TIME 0 // 동기화 수정
|
|
#define SKIP_FIRST_CORRUPT_FRAME 0 // 초기 프레임 제거 (사용금지)
|
|
#define IGNORE_BIG_FRAME_SKIP 0 // H265 코덱용으로 사용했으나 텔레비트 같은 경우 플레이중 전방으로 이동하는 경우가 발생하여
|
|
#define USE_AUDIO_DISABLE 0 // 사용금지!!! -> 처리하면 (AUDIO 로 영상 PTS 동기화 하는)후방 동기화 문제 발생함
|
|
#define USE_DURATION_IN_THREAD 0 // duration 에 thread 추가하여 종료확인
|
|
#define FORCE_END_OF_MEDIA 0 // demux thread 및 avthread(audio,video) 종료시 강제로 StalledMedia 가 아닌 EndOfMedia 전송
|
|
#define WAIT_CHANNEL_CHANGE 0 // 채널 변경시 video thread 종료 대기 (이거 사용하면 안됨, 플레이 시작 느려짐)
|
|
#define WAIT_KEY_FRAME 0 // Video Thread Corrput test (ON: video thread run 시작시 200msec 하면 노이즈 발생 재연가능)
|
|
#define K_WAIT_SLICE 10 // 10 ms 씩 처리 (기본값은 20ms 이나 영상이 끊김)
|
|
// 테스트 옵션
|
|
#define OFF_OTHER_DEBUG 1 // 기타 LOG OFF
|
|
#define LOADING_PERFORMANCE_TEST 0 // 로딩 타임 개선작업
|
|
#define DEBUG_PLAYER 0 // pts 가 0 인 프레임 디버깅
|
|
#define DEBUG_PLAYER_AVPACKET 0 // PACKET 디버깅
|
|
|
|
#define UPDATE_LAST_PACKET_DURATION 0 // EOF 는 없으나 마지막 패킷 감지될 경우 재생시간 업데이트 -> 사용하지 않음
|
|
|
|
#if (USE_SKIP_COUNT)
|
|
extern int g_SkipCount;
|
|
#endif
|
|
|
|
#if (SKIP_FIRST_CORRUPT_FRAME)
|
|
extern int g_firstCorruptFrameSkipWait;
|
|
#endif
|
|
|
|
//#ifdef BUILD_QTAV_STATIC
|
|
#define Q_AV_EXPORT
|
|
//#else
|
|
//#if defined(BUILD_QTAV_LIB)
|
|
//# undef Q_AV_EXPORT
|
|
//# define Q_AV_EXPORT Q_DECL_EXPORT
|
|
//#else
|
|
//# undef Q_AV_EXPORT
|
|
//# define Q_AV_EXPORT Q_DECL_IMPORT //only for vc?
|
|
//#endif
|
|
//#endif //BUILD_QTAV_STATIC
|
|
#define Q_AV_PRIVATE_EXPORT Q_AV_EXPORT
|
|
|
|
/* runtime version. used to compare with compile time version */
|
|
Q_AV_EXPORT unsigned QtAV_Version();
|
|
Q_AV_EXPORT QString QtAV_Version_String();
|
|
Q_AV_EXPORT QString QtAV_Version_String_Long();
|
|
namespace FAV {
|
|
enum LogLevel {
|
|
LogOff,
|
|
LogDebug, // log all
|
|
LogWarning, // log warning, critical, fatal
|
|
LogCritical, // log critical, fatal
|
|
LogFatal, // log fatal
|
|
LogAll
|
|
};
|
|
Q_AV_EXPORT QString aboutFFmpeg_PlainText();
|
|
Q_AV_EXPORT QString aboutFFmpeg_HTML();
|
|
Q_AV_EXPORT QString aboutQtAV_PlainText();
|
|
Q_AV_EXPORT QString aboutQtAV_HTML();
|
|
/*!
|
|
* Default value: LogOff for release build. LogAll for debug build.
|
|
* The level can also be changed at runtime by setting the QTAV_LOG_LEVEL or QTAV_LOG environment variable;
|
|
* QTAV_LOG_LEVEL can be: off, debug, warning, critical, fatal, all. Or use their enum values
|
|
* if both setLogLevel() is called and QTAV_LOG_LEVEL is set, the environment variable takes preceden.
|
|
*/
|
|
Q_AV_EXPORT void setLogLevel(LogLevel value);
|
|
Q_AV_EXPORT LogLevel logLevel();
|
|
/// Default handler is qt message logger. Set environment QTAV_FFMPEG_LOG=0 or setFFmpegLogHandler(0) to disable.
|
|
Q_AV_EXPORT void setFFmpegLogHandler(void(*)(void *, int, const char *, va_list));
|
|
/*!
|
|
* \brief setFFmpegLogLevel
|
|
* \param level can be: quiet, panic, fatal, error, warn, info, verbose, debug, trace
|
|
*/
|
|
Q_AV_EXPORT void setFFmpegLogLevel(const QByteArray& level);
|
|
|
|
/// query the common options of avformat/avcodec that can be used by AVPlayer::setOptionsForXXX. Format/codec specified options are also included
|
|
Q_AV_EXPORT QString avformatOptions();
|
|
Q_AV_EXPORT QString avcodecOptions();
|
|
|
|
////////////Types/////////////
|
|
enum MediaStatus
|
|
{
|
|
UnknownMediaStatus,
|
|
NoMedia,
|
|
LoadingMedia, // when source is set
|
|
LoadedMedia, // if auto load and source is set. player is stopped state
|
|
StalledMedia, // insufficient buffering or other interruptions (timeout, user interrupt)
|
|
BufferingMedia, // 5 NOT IMPLEMENTED
|
|
BufferedMedia, // 6 when playing //NOT IMPLEMENTED
|
|
EndOfMedia, // Playback has reached the end of the current media. The player is in the StoppedState.
|
|
InvalidMedia // what if loop > 0 or stopPosition() is not mediaStopPosition()?
|
|
};
|
|
|
|
enum BufferMode {
|
|
BufferTime,
|
|
BufferBytes,
|
|
BufferPackets
|
|
};
|
|
|
|
enum MediaEndActionFlag {
|
|
MediaEndAction_Default, /// stop playback (if loop end) and clear video renderer
|
|
MediaEndAction_KeepDisplay = 1, /// stop playback but video renderer keeps the last frame
|
|
MediaEndAction_Pause = 1 << 1 /// pause playback. Currently AVPlayer repeat mode will not work if this flag is set
|
|
};
|
|
Q_DECLARE_FLAGS(MediaEndAction, MediaEndActionFlag)
|
|
|
|
enum SeekUnit {
|
|
SeekByTime, // only this is supported now
|
|
SeekByByte,
|
|
SeekByFrame
|
|
};
|
|
enum SeekType {
|
|
AccurateSeek, // slow
|
|
KeyFrameSeek, // fast
|
|
AnyFrameSeek
|
|
};
|
|
|
|
//http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.709-5-200204-I!!PDF-E.pdf
|
|
// TODO: other color spaces (yuv itu.xxxx, XYZ, ...)
|
|
enum ColorSpace {
|
|
ColorSpace_Unknown,
|
|
ColorSpace_RGB,
|
|
ColorSpace_GBR, // for planar gbr format(e.g. video from x264) used in glsl
|
|
ColorSpace_BT601,
|
|
ColorSpace_BT709,
|
|
ColorSpace_XYZ
|
|
};
|
|
|
|
/*!
|
|
* \brief The ColorRange enum
|
|
* YUV or RGB color range
|
|
*/
|
|
enum ColorRange {
|
|
ColorRange_Unknown,
|
|
ColorRange_Limited, // TV, MPEG
|
|
ColorRange_Full // PC, JPEG
|
|
};
|
|
|
|
/*!
|
|
* \brief The SurfaceType enum
|
|
* HostMemorySurface:
|
|
* Map the decoded frame to host memory
|
|
* GLTextureSurface:
|
|
* Map the decoded frame as an OpenGL texture
|
|
* SourceSurface:
|
|
* get the original surface from decoder, for example VASurfaceID for va-api, CUdeviceptr for CUDA and IDirect3DSurface9* for DXVA.
|
|
* Zero copy mode is required.
|
|
* UserSurface:
|
|
* Do your own magic mapping with it
|
|
*/
|
|
enum SurfaceType {
|
|
HostMemorySurface,
|
|
GLTextureSurface,
|
|
SourceSurface,
|
|
UserSurface = 0xffff
|
|
};
|
|
} //namespace QtFAV
|
|
|
|
Q_DECLARE_METATYPE(FAV::MediaStatus)
|
|
Q_DECLARE_METATYPE(FAV::MediaEndAction)
|
|
|
|
// TODO: internal use. move to a private header
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
|
#define QStringLiteral(X) QString::fromUtf8(X)
|
|
#endif //QT_VERSION
|
|
#ifndef QByteArrayLiteral
|
|
#define QByteArrayLiteral(str) QByteArray(str, sizeof(str) - 1)
|
|
#endif
|
|
/*
|
|
* msvc sucks! can not deal with (defined(QTAV_HAVE_##FEATURE) && QTAV_HAVE_##FEATURE)
|
|
*/
|
|
// TODO: internal use. move to a private header
|
|
#define QTAV_HAVE(FEATURE) (defined QTAV_HAVE_##FEATURE && QTAV_HAVE_##FEATURE)
|
|
|
|
#ifndef Q_DECL_OVERRIDE
|
|
#define Q_DECL_OVERRIDE
|
|
#endif
|
|
#ifndef Q_DECL_FINAL
|
|
#define Q_DECL_FINAL
|
|
#endif
|
|
|
|
#if defined(BUILD_QTAV_LIB)
|
|
#define QTAV_DEPRECATED
|
|
#else
|
|
#define QTAV_DEPRECATED Q_DECL_DEPRECATED
|
|
#endif
|
|
|
|
#if defined(Q_OS_WIN32)
|
|
//#define FORCE_TO_USE_XAUDIO 1
|
|
#define QTAV_HAVE_SWRESAMPLE 1
|
|
#define QTAV_HAVE_AVRESAMPLE 1
|
|
#endif
|
|
|
|
// 초기에 CLOCK DELAY 가 발생하여 WAIT 가 걸리는 현상
|
|
#define FIX_FIRST_FRAME_DELAY 1
|
|
|
|
// 디버그 및 신규 구조 개발용
|
|
#if (PLAY_SYNC_FIX2)
|
|
#define VTHREAD_DEBUG_ON 0
|
|
#define VTHREAD_DEBUG_PLAYER 0 // 디버깅할 플레이어 0:전방, 1:후방
|
|
#define VTHREAD_DEBUG_MIN_LEVEL 90
|
|
#if (VTHREAD_DEBUG_ON)
|
|
class QElapsedTimer;
|
|
extern QElapsedTimer g_et;
|
|
//#define PLAYER_DEBUG_CHECK ()
|
|
#define PLAYER_DEBUG(__FSUFFIX__,__FLEVEL__) if (playerID == VTHREAD_DEBUG_PLAYER && __FLEVEL__ > VTHREAD_DEBUG_MIN_LEVEL) { qInfo() << __FSUFFIX__ << "***" << __LINE__ << __FUNCTION__ << g_et.elapsed(); }
|
|
#define PLAYER_DEBUG_V(__FSUFFIX__,__FLEVEL__,__FVALUE1__) if (playerID == VTHREAD_DEBUG_PLAYER && __FLEVEL__ > VTHREAD_DEBUG_MIN_LEVEL) { qInfo() << __FSUFFIX__ << __FVALUE1__ << "***" << __LINE__ << __FUNCTION__ << g_et.elapsed(); }
|
|
#define PLAYER_DEBUG_V2(__FSUFFIX__,__FLEVEL__,__FVALUE1__,__FVALUE2__) if (playerID == VTHREAD_DEBUG_PLAYER && __FLEVEL__ > VTHREAD_DEBUG_MIN_LEVEL) { qInfo() << __FSUFFIX__ << __FVALUE1__ << __FVALUE2__ << "***" <<__LINE__ << __FUNCTION__ << g_et.elapsed(); }
|
|
#define PLAYER_DEBUG_V3(__FSUFFIX__,__FLEVEL__,__FVALUE1__,__FVALUE2__,__FVALUE3__) if (playerID == VTHREAD_DEBUG_PLAYER && __FLEVEL__ > VTHREAD_DEBUG_MIN_LEVEL) { qInfo() << __FSUFFIX__ << __FVALUE1__ << __FVALUE2__ << __FVALUE3__ << "***" <<__LINE__ << __FUNCTION__ << g_et.elapsed(); }
|
|
#endif // VTHREAD_DEBUG_ON
|
|
#endif // #if (PLAY_SYNC_FIX2)
|
|
|
|
#ifndef PLAYER_DEBUG
|
|
#define PLAYER_DEBUG(__FSUFFIX__,__FLEVEL__)
|
|
#define PLAYER_DEBUG_V(__FSUFFIX__,__FLEVEL__,__FVALUE1__)
|
|
#define PLAYER_DEBUG_V2(__FSUFFIX__,__FLEVEL__,__FVALUE1__,__FVALUE2__)
|
|
#define PLAYER_DEBUG_V3(__FSUFFIX__,__FLEVEL__,__FVALUE1__,__FVALUE2__,__FVALUE3__)
|
|
#endif // ifndef PLAYER_DEBUG
|
|
|
|
|
|
#endif // QTFAV_GLOBAL_H
|
|
|