AVPKit
com::avpkit::core::Global Class Reference

A collection of static functions that refer to the entire package (like version getters). More...

#include <Global.h>

Inheritance diagram for com::avpkit::core::Global:
Collaboration diagram for com::avpkit::core::Global:

Static Public Member Functions

static int64_t getVersion ()
 Returns a 64 bit version number for this library. More...
 
static int32_t getVersionMajor ()
 Get the major version number of this library. More...
 
static int32_t getVersionMinor ()
 Get the minor version number of this library. More...
 
static int32_t getVersionRevision ()
 Get the revision number of this library. More...
 
static const char * getVersionStr ()
 Get a string representation of the version of this library. More...
 
static int getAVFormatVersion ()
 Get the version of the FFMPEG libavformat library we are compiled against. More...
 
static const char * getAVFormatVersionStr ()
 Get the version of the FFMPEG libavformat library we are compiled against. More...
 
static int getAVCodecVersion ()
 Get the version of the FFMPEG libavcodec library we are compiled against. More...
 
static const char * getAVCodecVersionStr ()
 Get the version of the FFMPEG libavcodec library we are compiled against. More...
 
static void lock ()
 Performs a global-level lock of the AVPKIT library. More...
 
static void unlock ()
 Unlock the global lock. More...
 
static int avioInterruptCB (void *)
 Internal Only. More...
 
static void deinit ()
 Internal Only. More...
 
static void init ()
 Internal Only. More...
 
static void setFFmpegLoggingLevel (int32_t level)
 Internal Only. More...
 

Static Public Attributes

static const int64_t NO_PTS =0x8000000000000000LL
 A value that means no time stamp is set for a given object. More...
 
static const int64_t DEFAULT_PTS_PER_SECOND =1000000
 The default time units per second that we use for decoded IAudioSamples and IVideoPicture objects. More...
 

Additional Inherited Members

- Public Member Functions inherited from com::avpkit::ferry::RefCounted
virtual int32_t acquire ()
 Internal Only. More...
 
virtual int32_t release ()
 Internal Only. More...
 
virtual RefCountedcopyReference ()
 Create a new Java object that refers to the same native object. More...
 
virtual int32_t getCurrentRefCount ()
 Return the current reference count on this object. More...
 
void setJavaAllocator (void *allocator)
 This method is public but not part of the standard API. More...
 
void * getJavaAllocator ()
 This method is public but not part of the standard API. More...
 
- Protected Member Functions inherited from com::avpkit::ferry::RefCounted
virtual void destroy ()
 This method is called by RefCounted objects when their Ref Count reaches zero and they are about to be destroyed.
 
- Protected Attributes inherited from com::avpkit::ferry::RefCounted
AtomicIntegermRefCount
 This is the internal reference count, represented as an AtomicInteger to make sure it is thread safe.
 
void * mAllocator
 Not part of public API.
 

Detailed Description

A collection of static functions that refer to the entire package (like version getters).

Definition at line 42 of file Global.h.

Member Function Documentation

◆ avioInterruptCB()

int com::avpkit::core::Global::avioInterruptCB ( void *  )
static

Internal Only.

Do not call. Checks to determine if there is

Definition at line 115 of file Global.cpp.

116  {
117  JNIHelper* helper = JNIHelper::getHelper();
118  int retval = 0;
119  if (helper) {
120  retval = helper->isInterrupted();
121  }
122  return retval;
123  }
The JNIHelper object contains a series of methods designed to assist functions when running inside a ...
Definition: JNIHelper.h:37

◆ deinit()

void com::avpkit::core::Global::deinit ( )
static

Internal Only.

Call to relese globals.

Definition at line 177 of file Global.cpp.

178  {
179  avformat_network_deinit();
180  }

◆ getAVCodecVersion()

int com::avpkit::core::Global::getAVCodecVersion ( )
static

Get the version of the FFMPEG libavcodec library we are compiled against.

Returns
the version.

Definition at line 265 of file Global.cpp.

266  {
267  Global::init();
268  return LIBAVCODEC_VERSION_INT;
269  }
static void init()
Internal Only.
Definition: Global.cpp:157

References init().

◆ getAVCodecVersionStr()

const char * com::avpkit::core::Global::getAVCodecVersionStr ( )
static

Get the version of the FFMPEG libavcodec library we are compiled against.

Returns
the version.

Definition at line 271 of file Global.cpp.

272  {
273  Global::init();
274  return AV_STRINGIFY(LIBAVCODEC_VERSION);
275  }

References init().

◆ getAVFormatVersion()

int32_t com::avpkit::core::Global::getAVFormatVersion ( )
static

Get the version of the FFMPEG libavformat library we are compiled against.

Returns
the version.

Definition at line 253 of file Global.cpp.

254  {
255  Global::init();
256  return LIBAVFORMAT_VERSION_INT;
257  }

References init().

◆ getAVFormatVersionStr()

const char * com::avpkit::core::Global::getAVFormatVersionStr ( )
static

Get the version of the FFMPEG libavformat library we are compiled against.

Returns
the version.

Definition at line 259 of file Global.cpp.

260  {
261  Global::init();
262  return AV_STRINGIFY(LIBAVFORMAT_VERSION);
263  }

References init().

◆ getVersion()

int64_t com::avpkit::core::Global::getVersion ( )
static

Returns a 64 bit version number for this library.

Returns
a 64-bit integer version number for this library. The top 16 bits is the getVersionMajor() value. The next 16-bits are the getVersionMinor() value, and the last 32-bits are the getVersionRevision() value.

Definition at line 223 of file Global.cpp.

224  {
225  return ((int64_t)getVersionMajor())<<48 | ((int64_t)getVersionMinor())<<32 | (int64_t)getVersionRevision();
226  }
static int32_t getVersionRevision()
Get the revision number of this library.
Definition: Global.cpp:240
static int32_t getVersionMinor()
Get the minor version number of this library.
Definition: Global.cpp:234
static int32_t getVersionMajor()
Get the major version number of this library.
Definition: Global.cpp:228

◆ getVersionMajor()

int32_t com::avpkit::core::Global::getVersionMajor ( )
static

Get the major version number of this library.

Returns
the major version number of this library or 0 if unknown.

Definition at line 228 of file Global.cpp.

229  {
230  Global::init();
231  return VS_LIB_MAJOR_VERSION;
232  }

References init().

◆ getVersionMinor()

int32_t com::avpkit::core::Global::getVersionMinor ( )
static

Get the minor version number of this library.

Returns
the minor version number of this library or 0 if unknown.

Definition at line 234 of file Global.cpp.

235  {
236  Global::init();
237  return VS_LIB_MINOR_VERSION;
238  }

References init().

◆ getVersionRevision()

int32_t com::avpkit::core::Global::getVersionRevision ( )
static

Get the revision number of this library.

Returns
the revision number of this library, or 0 if unknown.

Definition at line 240 of file Global.cpp.

241  {
242  Global::init();
243  return VS_REVISION;
244  }

References init().

◆ getVersionStr()

const char * com::avpkit::core::Global::getVersionStr ( )
static

Get a string representation of the version of this library.

Returns
the version of this library in string form.

Definition at line 247 of file Global.cpp.

248  {
249  Global::init();
250  return PACKAGE_VERSION "." VS_STRINGIFY(VS_REVISION);
251  }

References init().

◆ init()

void com::avpkit::core::Global::init ( )
static

Internal Only.

Do not call. Methods using the C++ interface that will not necessarily create other Global object should call this. In general, unless you're extending core directly yourself, ordinary users of this library don't need to call this.

It's main purpose is to ensure any FFmpeg required environment initialization functions are called, and any AVPKit required environmental contexts are set up.

Definition at line 157 of file Global.cpp.

158  {
159  if (!sGlobal)
160  {
161  av_lockmgr_register(core_lockmgr_cb);
162  av_log_set_callback(core_log_callback);
163  av_log_set_level(AV_LOG_ERROR); // Only log errors by default
164  av_register_all();
165  avformat_network_init();
166  // and set up filter support
167  avfilter_register_all();
168 
169  // and set up the device library for webcam support
170  avdevice_register_all();
171 
172  // turn down logging
173  sGlobal = new Global();
174  }
175  }

Referenced by com::avpkit::core::IAudioSamples::defaultPtsToSamples(), com::avpkit::core::ICodec::findDecodingCodec(), com::avpkit::core::ICodec::findDecodingCodecByIntID(), com::avpkit::core::ICodec::findDecodingCodecByName(), com::avpkit::core::ICodec::findEncodingCodec(), com::avpkit::core::ICodec::findEncodingCodecByIntID(), com::avpkit::core::ICodec::findEncodingCodecByName(), getAVCodecVersion(), getAVCodecVersionStr(), getAVFormatVersion(), getAVFormatVersionStr(), com::avpkit::core::ICodec::getInstalledCodec(), com::avpkit::core::IContainerFormat::getInstalledInputFormat(), com::avpkit::core::IContainerFormat::getInstalledOutputFormat(), com::avpkit::core::ICodec::getNumInstalledCodecs(), com::avpkit::core::IContainerFormat::getNumInstalledInputFormats(), com::avpkit::core::IContainerFormat::getNumInstalledOutputFormats(), getVersionMajor(), getVersionMinor(), getVersionRevision(), getVersionStr(), com::avpkit::core::ICodec::guessEncodingCodec(), lock(), com::avpkit::core::IContainer::make(), com::avpkit::core::IContainerFormat::make(), com::avpkit::core::IPacket::make(), com::avpkit::core::IRational::make(), com::avpkit::core::IStreamCoder::make(), com::avpkit::core::IMediaDataWrapper::make(), com::avpkit::core::IAudioSamples::make(), com::avpkit::core::IAudioResampler::make(), com::avpkit::core::IVideoResampler::make(), com::avpkit::core::IVideoPicture::make(), com::avpkit::core::IAudioSamples::samplesToDefaultPts(), setFFmpegLoggingLevel(), and unlock().

◆ lock()

void com::avpkit::core::Global::lock ( )
static

Performs a global-level lock of the AVPKIT library.

While this lock() is held, every other method that calls lock() in the same DLL/SO will block.

Use this sparingly. FFMPEG's libraries have few real global objects, but when they do exist, you must lock.

Lastly, if you lock, make damn sure you call unlock()

Definition at line 207 of file Global.cpp.

208  {
209  Global::init();
210  if (sGlobal && sGlobal->mLock)
211  sGlobal->mLock->lock();
212  }

References init().

◆ setFFmpegLoggingLevel()

void com::avpkit::core::Global::setFFmpegLoggingLevel ( int32_t  level)
static

Internal Only.

This method can be used to turn up or down FFmpeg's logging level.

Parameters
levelAn integer value for level. Lower numbers mean less logging. A negative number tells FFmpeg to shut up.

Definition at line 278 of file Global.cpp.

279  {
280  Global::init();
281  if (level < AV_LOG_PANIC)
282  av_log_set_level(AV_LOG_QUIET);
283  else if (level < AV_LOG_FATAL)
284  av_log_set_level(AV_LOG_PANIC);
285  else if (level < AV_LOG_ERROR)
286  av_log_set_level(AV_LOG_FATAL);
287  else if (level < AV_LOG_WARNING)
288  av_log_set_level(AV_LOG_ERROR);
289  else if (level < AV_LOG_INFO)
290  av_log_set_level(AV_LOG_WARNING);
291  else if (level < AV_LOG_VERBOSE)
292  av_log_set_level(AV_LOG_INFO);
293  else if (level < AV_LOG_DEBUG)
294  av_log_set_level(AV_LOG_VERBOSE);
295  else
296  av_log_set_level(AV_LOG_DEBUG);
297 // fprintf(stderr, "FFmpeg logging level = %d\n", av_log_get_level());
298  }

References init().

◆ unlock()

void com::avpkit::core::Global::unlock ( )
static

Unlock the global lock.

See also
lock()

Definition at line 215 of file Global.cpp.

216  {
217  Global::init();
218  if (sGlobal && sGlobal->mLock)
219  sGlobal->mLock->unlock();
220  }

References init().

Member Data Documentation

◆ DEFAULT_PTS_PER_SECOND

const int64_t com::avpkit::core::Global::DEFAULT_PTS_PER_SECOND =1000000
static

The default time units per second that we use for decoded IAudioSamples and IVideoPicture objects.

This means that 1 tick of a time stamp is 1 Microsecond.

Definition at line 57 of file Global.h.

Referenced by com::avpkit::core::IAudioSamples::defaultPtsToSamples(), and com::avpkit::core::IAudioSamples::samplesToDefaultPts().

◆ NO_PTS


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