20 #include <com/avpkit/ferry/Logger.h>
21 #include <com/avpkit/ferry/RefPointer.h>
22 #include <com/avpkit/core/Global.h>
23 #include <com/avpkit/core/Codec.h>
24 #include <com/avpkit/core/ContainerFormat.h>
26 VS_LOG_SETUP(VS_CPP_PACKAGE);
28 namespace com {
namespace avpkit {
namespace core
34 VS_LOG_TRACE(
"Starting");
46 const char * retval = 0;
48 retval = mCodec->name;
55 int retval = AV_CODEC_ID_NONE;
64 Type retval = (
Type) AVMEDIA_TYPE_UNKNOWN;
66 retval = (
Type) mCodec->type;
71 Codec :: make(
const AVCodec *aCodec)
76 retval = Codec::make();
78 retval->mCodec = aCodec;
86 if (IPixelFormat::NONE == type){
87 return Codec::findEncodingCodecByIntID((
const int)
id);
90 AVHWAccel *hwaccel = NULL;
92 while ((hwaccel = av_hwaccel_next(hwaccel))){
93 if (hwaccel->id ==
id && hwaccel->pix_fmt == type){
94 return findEncodingCodecByName(hwaccel->name);
102 Codec :: findEncodingCodecByIntID(
const int id)
106 enum AVCodecID ffmpeg_id = (
enum AVCodecID)
id;
108 codec = avcodec_find_encoder(ffmpeg_id);
111 retval = Codec::make(codec);
117 Codec :: findEncodingCodecByName(
const char* name)
124 codec = avcodec_find_encoder_by_name(name);
127 retval = Codec::make(codec);
136 if (IPixelFormat::NONE == type){
137 return Codec::findDecodingCodecByIntID((
const int)
id);
140 AVHWAccel *hwaccel = NULL;
142 while ((hwaccel = av_hwaccel_next(hwaccel))){
143 if (hwaccel->id ==
id && hwaccel->pix_fmt == type){
144 return findDecodingCodecByName(hwaccel->name);
152 Codec :: findDecodingCodecByIntID(
const int id)
158 codec = avcodec_find_decoder((
enum AVCodecID)
id);
162 retval = Codec::make(codec);
167 Codec :: findDecodingCodecByName(
const char* name)
174 codec = avcodec_find_decoder_by_name(name);
177 retval = Codec::make(codec);
184 return mCodec ? (mCodec->decode != NULL) :
false;
190 return mCodec ? (mCodec->encode2 != NULL) :
false;
195 const char* shortName,
197 const char* mimeType,
202 AVOutputFormat * oFmt = 0;
212 fmt->setOutputFormat(shortName, url, mimeType);
215 oFmt = fmt->getOutputFormat();
228 enum AVCodecID
id = av_guess_codec(oFmt, shortName, url,
229 mimeType, (
enum AVMediaType) type);
230 retval = Codec::findEncodingCodecByIntID((
int)
id);
240 VS_LOG_TRACE(
"Acquired %p: %d",
this, retval);
248 VS_LOG_TRACE(
"Released %p: %d",
this, retval);
254 return mCodec ? mCodec->long_name : 0;
262 return mCodec->capabilities;
269 return mCodec->capabilities&flag;
279 const AVRational* p=mCodec->supported_framerates;
280 p && !(!p->den && !p->num);
293 const AVRational* p=mCodec->supported_framerates;
294 p && !(!p->den && !p->num);
308 for(
const AVPixelFormat* p = mCodec->pix_fmts;
320 return IPixelFormat::NONE;
322 for(
const AVPixelFormat* p = mCodec->pix_fmts;
327 return IPixelFormat::NONE;
336 for(
const int *p = mCodec->supported_samplerates;
348 for(
const int *p = mCodec->supported_samplerates;
362 for(
const enum AVSampleFormat* p=mCodec->sample_fmts;
373 return IAudioSamples::FMT_NONE;
375 for(
const enum AVSampleFormat* p=mCodec->sample_fmts;
380 return IAudioSamples::FMT_NONE;
390 for(
const uint64_t* p=mCodec->channel_layouts;
402 for(
const uint64_t* p=mCodec->channel_layouts;
virtual bool hasCapability(Capabilities flag)
Convenience method to check individual capability flags.
virtual bool canEncode()
Can this codec be used for encoding?
virtual int32_t getNumSupportedAudioChannelLayouts()
Get the number of different audio channel layouts this codec supports for encoding.
virtual int32_t getNumSupportedVideoPixelFormats()
Get the number of supported video pixel formats this codec supports for encoding.
virtual IPixelFormat::Type getSupportedVideoPixelFormat(int32_t index)
Return the supported video pixel format at the given index.
virtual int32_t release()
Internal Only.
virtual IRational * getSupportedVideoFrameRate(int32_t index)
Return the supported frame rate at the given index.
virtual int64_t getSupportedAudioChannelLayout(int32_t index)
Get the supported audio channel layout at this index.
virtual int32_t getNumSupportedAudioSampleFormats()
Get the number of different audio sample formats this codec supports for encoding.
virtual int32_t acquire()
Internal Only.
virtual IAudioSamples::Format getSupportedAudioSampleFormat(int32_t index)
Get the supported sample format at this index.
virtual int32_t getCapabilities()
Get the capabilites flag from the codec.
virtual const char * getLongName()
Added for 1.17.
virtual int32_t getNumSupportedVideoFrameRates()
Get the number of frame rates this codec supports for encoding.
virtual const char * getName()
Get the name of the codec.
virtual int32_t getNumSupportedAudioSampleRates()
Get the number of different audio sample rates this codec supports for encoding.
virtual int32_t getSupportedAudioSampleRate(int32_t index)
Return the support audio sample rate at the given index.
virtual bool canDecode()
Can this codec be used for decoding?
virtual Type getType()
Get the type of this codec.
virtual int getIDAsInt()
Get the ID of this codec, as an integer.
static void unlock()
Unlock the global lock.
static void lock()
Performs a global-level lock of the AVPKIT library.
Format
The format we use to represent audio.
Capabilities
Capability flags.
ID
These are the codecs this library currently supports.
Type
The different types of Codecs that can exist in the system.
This class wraps represents a Rational number for the AVPKit.
static IRational * make()
Get a new rational that will be set to 0/0.
virtual int32_t acquire()
Internal Only.
virtual int32_t release()
Internal Only.
This class is only useful from C++.
void reset(T *ptr=0, bool acquire=false)
Reset the managed pointer, calling RefCounted::release() on the previously managed pointer first.
This library contains routines used by AVPKit libraries for "ferry"ing Java objects to and from nativ...
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...