AVPKit
com::avpkit::core::ContainerFormat Class Reference
Inheritance diagram for com::avpkit::core::ContainerFormat:
Collaboration diagram for com::avpkit::core::ContainerFormat:

Public Member Functions

virtual int32_t setInputFormat (const char *shortName)
 Sets the input format for this container. More...
 
virtual int32_t setOutputFormat (const char *shortName, const char *url, const char *mimeType)
 Sets the output format for this container. More...
 
virtual const char * getInputFormatShortName ()
 Get the short name for the input format. More...
 
virtual const char * getInputFormatLongName ()
 Get the long name for the input format. More...
 
virtual const char * getOutputFormatShortName ()
 Get the short name for the output format. More...
 
virtual const char * getOutputFormatLongName ()
 Get the long name for the output format. More...
 
virtual const char * getOutputFormatMimeType ()
 Get the mime type for the output format. More...
 
AVInputFormat * getInputFormat ()
 
AVOutputFormat * getOutputFormat ()
 
void setInputFormat (AVInputFormat *)
 
void setOutputFormat (AVOutputFormat *)
 
virtual int32_t getInputFlags ()
 Get the input flags associated with this object. More...
 
virtual void setInputFlags (int32_t newFlags)
 Set the input flags to use with this object. More...
 
virtual bool getInputFlag (Flags flag)
 Get the input setting for the specified flag. More...
 
virtual void setInputFlag (Flags flag, bool value)
 Set the input flag. More...
 
virtual int32_t getOutputFlags ()
 Get the output flags associated with this object. More...
 
virtual void setOutputFlags (int32_t newFlags)
 Set the output flags to use with this object. More...
 
virtual bool getOutputFlag (Flags flag)
 Get the output setting for the specified flag. More...
 
virtual void setOutputFlag (Flags flag, bool value)
 Set the output flag. More...
 
virtual bool isOutput ()
 Is this an output container format? More...
 
virtual bool isInput ()
 Is this an input container format? More...
 
virtual const char * getOutputExtensions ()
 Get the filename extensions that this output format prefers (most common first). More...
 
virtual ICodec::ID getOutputDefaultAudioCodec ()
 Get the default audio codec this container prefers, if known. More...
 
virtual ICodec::ID getOutputDefaultVideoCodec ()
 Get the default video codec this container prefers, if known. More...
 
virtual ICodec::ID getOutputDefaultSubtitleCodec ()
 Get the default subtitle codec this container prefers, if known. More...
 
virtual int32_t getOutputNumCodecsSupported ()
 Gets the number of different codecs this container can include for encoding. More...
 
virtual ICodec::ID getOutputCodecID (int32_t index)
 Queries for a supported codec id from the list of codecs that can be encoded into this ContainerFormat. More...
 
virtual int32_t getOutputCodecTag (int32_t index)
 Queries for a supported codec tag from the list of codecs that can be encoded into this ContainerFormat. More...
 
virtual int32_t getOutputCodecTag (ICodec::ID id)
 Get the 4-byte tag the container would output for the given codec id. More...
 
virtual bool isCodecSupportedForOutput (ICodec::ID id)
 Returns true if this container format can output media encoded with the given codec. More...
 
- 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...
 

Additional Inherited Members

- Public Types inherited from com::avpkit::core::IContainerFormat
enum  Flags {
  FLAG_NOFILE =0x0001 , FLAG_NEEDNUMBER = 0x0002 , FLAG_SHOW_IDS =0x0008 , FLAG_RAWPICTURE =0x0020 ,
  FLAG_GLOBALHEADER =0x0040 , FLAG_NOTIMESTAMPS =0x0080 , FLAG_GENERIC_INDEX =0x0100 , FLAG_TS_DISCONT =0x0200
}
 
- Static Public Member Functions inherited from com::avpkit::core::IContainerFormat
static IContainerFormatmake ()
 Create a new IContainerFormat object. More...
 
static int32_t getNumInstalledInputFormats ()
 Get the number of input formats this install can demultiplex (read) from. More...
 
static IContainerFormatgetInstalledInputFormat (int32_t index)
 Return an object for the input format at the given index. More...
 
static int32_t getNumInstalledOutputFormats ()
 Get the number of output formats this install can multiplex (write) to. More...
 
static IContainerFormatgetInstalledOutputFormat (int32_t index)
 Return an object for the output format at the given index. 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

Definition at line 29 of file ContainerFormat.h.

Member Function Documentation

◆ getInputFlag()

bool com::avpkit::core::ContainerFormat::getInputFlag ( Flags  flag)
virtual

Get the input setting for the specified flag.

Parameters
flagThe flag you want to find the setting for
Returns
0 for false; non-zero for true

Implements com::avpkit::core::IContainerFormat.

Definition at line 136 of file ContainerFormat.cpp.

137  {
138  bool result = false;
139  if (mInputFormat)
140  result = mInputFormat->flags & flag;
141  return result;
142  }

◆ getInputFlags()

int32_t com::avpkit::core::ContainerFormat::getInputFlags ( )
virtual

Get the input flags associated with this object.

Returns
The (compacted) value of all flags set.

Implements com::avpkit::core::IContainerFormat.

Definition at line 123 of file ContainerFormat.cpp.

124  {
125  return (mInputFormat ? mInputFormat->flags : 0);
126  }

◆ getInputFormatLongName()

const char * com::avpkit::core::ContainerFormat::getInputFormatLongName ( )
virtual

Get the long name for the input format.

Returns
The long name for the input format, or null if none.

Implements com::avpkit::core::IContainerFormat.

Definition at line 82 of file ContainerFormat.cpp.

83  {
84  return (mInputFormat ? mInputFormat->long_name : 0);
85  }

◆ getInputFormatShortName()

const char * com::avpkit::core::ContainerFormat::getInputFormatShortName ( )
virtual

Get the short name for the input format.

Returns
The short name for the input format, or null if none.

Implements com::avpkit::core::IContainerFormat.

Definition at line 77 of file ContainerFormat.cpp.

78  {
79  return (mInputFormat ? mInputFormat->name : 0);
80  }

◆ getOutputCodecID()

ICodec::ID com::avpkit::core::ContainerFormat::getOutputCodecID ( int32_t  index)
virtual

Queries for a supported codec id from the list of codecs that can be encoded into this ContainerFormat.

Parameters
indexThe index in our lookup table. Index >= 0 and < getOutputNumCodecsSupported(). Index values may change between releases, so always query.
Returns
The codec id at this position, or ICodec.ID#CODEC_ID_NONE if there is none.

Implements com::avpkit::core::IContainerFormat.

Definition at line 268 of file ContainerFormat.cpp.

269  {
270  if (index < 0)
271  return ICodec::AV_CODEC_ID_NONE;
272 
273  const struct AVCodecTag * const*tags = mOutputFormat->codec_tag;
274  if (!tags)
275  return ICodec::AV_CODEC_ID_NONE;
276 
277  int numCodecs = 0;
278 
279  for(int i = 0;
280  tags[i];
281  i++)
282  {
283  for(
284  const struct AVCodecTag * tag = tags[i];
285  tag && tag->id != ICodec::AV_CODEC_ID_NONE;
286  ++tag, ++numCodecs)
287  {
288  if (numCodecs == index)
289  return (ICodec::ID)tag->id;
290  }
291  }
292  return ICodec::AV_CODEC_ID_NONE;
293  }
ID
These are the codecs this library currently supports.
Definition: ICodec.h:61

◆ getOutputCodecTag() [1/2]

int32_t com::avpkit::core::ContainerFormat::getOutputCodecTag ( ICodec::ID  id)
virtual

Get the 4-byte tag the container would output for the given codec id.

Parameters
idthe codec you are about
Returns
the 4-byte codec tag, or 0 if that id is not supported.

Implements com::avpkit::core::IContainerFormat.

Definition at line 330 of file ContainerFormat.cpp.

331  {
332  if (!mOutputFormat)
333  return 0;
334  return (int32_t)av_codec_get_tag(mOutputFormat->codec_tag,
335  (enum AVCodecID)id);
336 
337  }

◆ getOutputCodecTag() [2/2]

int32_t com::avpkit::core::ContainerFormat::getOutputCodecTag ( int32_t  index)
virtual

Queries for a supported codec tag from the list of codecs that can be encoded into this ContainerFormat.

Tags are 4-byte values that are often used as markers in a container format for a codec type.

Parameters
indexThe index in our lookup table. Index >= 0 and < getOutputNumCodecsSupported(). Index values may change between releases, so always query.
Returns
The codec id tag this position, or 0 if there is none.

Implements com::avpkit::core::IContainerFormat.

Definition at line 296 of file ContainerFormat.cpp.

297  {
298  if (index < 0)
299  return ICodec::AV_CODEC_ID_NONE;
300 
301  const struct AVCodecTag * const*tags = mOutputFormat->codec_tag;
302  if (!tags)
303  return ICodec::AV_CODEC_ID_NONE;
304 
305  int numCodecs = 0;
306 
307  for(int i = 0;
308  tags[i];
309  i++)
310  {
311  for(
312  const struct AVCodecTag * tag = tags[i];
313  tag && tag->id != ICodec::AV_CODEC_ID_NONE;
314  ++tag, ++numCodecs)
315  {
316  if (numCodecs == index)
317  return tag->tag;
318  }
319  }
320  return ICodec::AV_CODEC_ID_NONE;
321  }

Referenced by isCodecSupportedForOutput().

◆ getOutputDefaultAudioCodec()

ICodec::ID com::avpkit::core::ContainerFormat::getOutputDefaultAudioCodec ( )
virtual

Get the default audio codec this container prefers, if known.

Returns
the default audio codec id, or ICodec.ID#CODEC_ID_NONE if unknown.

Implements com::avpkit::core::IContainerFormat.

Definition at line 219 of file ContainerFormat.cpp.

220  {
221  if (!mOutputFormat)
222  return ICodec::AV_CODEC_ID_NONE;
223  return (ICodec::ID)mOutputFormat->audio_codec;
224  }

◆ getOutputDefaultSubtitleCodec()

ICodec::ID com::avpkit::core::ContainerFormat::getOutputDefaultSubtitleCodec ( )
virtual

Get the default subtitle codec this container prefers, if known.

Returns
the default subtitle codec id, or ICodec.ID#CODEC_ID_NONE if unknown.

Implements com::avpkit::core::IContainerFormat.

Definition at line 235 of file ContainerFormat.cpp.

236  {
237  if (!mOutputFormat)
238  return ICodec::AV_CODEC_ID_NONE;
239  return (ICodec::ID)mOutputFormat->subtitle_codec;
240  }

◆ getOutputDefaultVideoCodec()

ICodec::ID com::avpkit::core::ContainerFormat::getOutputDefaultVideoCodec ( )
virtual

Get the default video codec this container prefers, if known.

Returns
the default video codec id, or ICodec.ID#CODEC_ID_NONE if unknown.

Implements com::avpkit::core::IContainerFormat.

Definition at line 227 of file ContainerFormat.cpp.

228  {
229  if (!mOutputFormat)
230  return ICodec::AV_CODEC_ID_NONE;
231  return (ICodec::ID)mOutputFormat->video_codec;
232  }

◆ getOutputExtensions()

const char * com::avpkit::core::ContainerFormat::getOutputExtensions ( )
virtual

Get the filename extensions that this output format prefers (most common first).

Returns
a command separated string of output extensions, or null if none.

Implements com::avpkit::core::IContainerFormat.

Definition at line 210 of file ContainerFormat.cpp.

211  {
212  if (!mOutputFormat || !mOutputFormat->extensions ||
213  !*mOutputFormat->extensions)
214  return 0;
215  return mOutputFormat->extensions;
216  }

◆ getOutputFlag()

bool com::avpkit::core::ContainerFormat::getOutputFlag ( Flags  flag)
virtual

Get the output setting for the specified flag.

Parameters
flagThe flag you want to find the setting for
Returns
0 for false; non-zero for true

Implements com::avpkit::core::IContainerFormat.

Definition at line 174 of file ContainerFormat.cpp.

175  {
176  bool result = false;
177  if (mOutputFormat)
178  result = mOutputFormat->flags & flag;
179  return result;
180  }

◆ getOutputFlags()

int32_t com::avpkit::core::ContainerFormat::getOutputFlags ( )
virtual

Get the output flags associated with this object.

Returns
The (compacted) value of all flags set.

Implements com::avpkit::core::IContainerFormat.

Definition at line 161 of file ContainerFormat.cpp.

162  {
163  return (mOutputFormat ? mOutputFormat->flags : 0);
164  }

◆ getOutputFormatLongName()

const char * com::avpkit::core::ContainerFormat::getOutputFormatLongName ( )
virtual

Get the long name for the output format.

Returns
The long name for the output format, or null if none.

Implements com::avpkit::core::IContainerFormat.

Definition at line 92 of file ContainerFormat.cpp.

93  {
94  return (mOutputFormat ? mOutputFormat->long_name : 0);
95  }

◆ getOutputFormatMimeType()

const char * com::avpkit::core::ContainerFormat::getOutputFormatMimeType ( )
virtual

Get the mime type for the output format.

Returns
The mime type for the output format, or null if none.

Implements com::avpkit::core::IContainerFormat.

Definition at line 97 of file ContainerFormat.cpp.

98  {
99  return (mOutputFormat ? mOutputFormat->mime_type : 0);
100  }

◆ getOutputFormatShortName()

const char * com::avpkit::core::ContainerFormat::getOutputFormatShortName ( )
virtual

Get the short name for the output format.

Returns
The short name for the output format, or null if none.

Implements com::avpkit::core::IContainerFormat.

Definition at line 87 of file ContainerFormat.cpp.

88  {
89  return (mOutputFormat ? mOutputFormat->name : 0);
90  }

◆ getOutputNumCodecsSupported()

int32_t com::avpkit::core::ContainerFormat::getOutputNumCodecsSupported ( )
virtual

Gets the number of different codecs this container can include for encoding.

This can be used as an upper bound when using the getOutputCodecID(int) and getOutputCodecTag(int) methods to dynamically query the actual codecs.

Returns
The total number of different codec types that can be encoded into this container format.

Implements com::avpkit::core::IContainerFormat.

Definition at line 243 of file ContainerFormat.cpp.

244  {
245  if (!mOutputFormat)
246  return 0;
247 
248  const struct AVCodecTag * const*tags = mOutputFormat->codec_tag;
249  if (!tags)
250  return 0;
251 
252  int numCodecs = 0;
253 
254  for(int i = 0;
255  tags[i];
256  i++)
257  {
258  for(const struct AVCodecTag * tag = tags[i];
259  tag && tag->id != ICodec::AV_CODEC_ID_NONE;
260  ++tag)
261  {
262  ++numCodecs;
263  }
264  }
265  return numCodecs;
266  }

◆ isCodecSupportedForOutput()

bool com::avpkit::core::ContainerFormat::isCodecSupportedForOutput ( ICodec::ID  id)
virtual

Returns true if this container format can output media encoded with the given codec.

Parameters
idthe codec you care about.
Returns
true if the codec can be put in this output container; false otherwise.

Implements com::avpkit::core::IContainerFormat.

Definition at line 324 of file ContainerFormat.cpp.

325  {
326  return getOutputCodecTag(id);
327  }
virtual int32_t getOutputCodecTag(int32_t index)
Queries for a supported codec tag from the list of codecs that can be encoded into this ContainerForm...

References getOutputCodecTag().

◆ isInput()

bool com::avpkit::core::ContainerFormat::isInput ( )
virtual

Is this an input container format?

Returns
true if input; false it not

Implements com::avpkit::core::IContainerFormat.

Definition at line 204 of file ContainerFormat.cpp.

205  {
206  return mInputFormat;
207  }

◆ isOutput()

bool com::avpkit::core::ContainerFormat::isOutput ( )
virtual

Is this an output container format?

Returns
true if output; false it not

Implements com::avpkit::core::IContainerFormat.

Definition at line 198 of file ContainerFormat.cpp.

199  {
200  return mOutputFormat;
201  }

◆ setInputFlag()

void com::avpkit::core::ContainerFormat::setInputFlag ( Flags  flag,
bool  value 
)
virtual

Set the input flag.

Parameters
flagThe flag to set
valueThe value to set it to (true or false)

Implements com::avpkit::core::IContainerFormat.

Definition at line 145 of file ContainerFormat.cpp.

146  {
147  if (mInputFormat)
148  {
149  if (value)
150  {
151  mInputFormat->flags |= flag;
152  }
153  else
154  {
155  mInputFormat->flags &= (~flag);
156  }
157  }
158  }

◆ setInputFlags()

void com::avpkit::core::ContainerFormat::setInputFlags ( int32_t  newFlags)
virtual

Set the input flags to use with this object.

All values must be ORed (|) together.

See also
Flags
Parameters
newFlagsThe new set flags for this codec.

Implements com::avpkit::core::IContainerFormat.

Definition at line 129 of file ContainerFormat.cpp.

130  {
131  if (mInputFormat)
132  mInputFormat->flags = newFlags;
133  }

◆ setInputFormat()

int32_t com::avpkit::core::ContainerFormat::setInputFormat ( const char *  shortName)
virtual

Sets the input format for this container.

Parameters
shortNameThe short name for this container (using FFMPEG's short name).
Returns
>= 0 on success. < 0 if shortName cannot be found.

Implements com::avpkit::core::IContainerFormat.

Definition at line 51 of file ContainerFormat.cpp.

52  {
53  if (shortName && *shortName)
54  {
55  mInputFormat = av_find_input_format(shortName);
56  } else {
57  mInputFormat = NULL;
58  }
59  return (mInputFormat == NULL ? -1 : 0);
60  }

Referenced by com::avpkit::core::Container::getContainerFormat(), and com::avpkit::core::IContainerFormat::getInstalledInputFormat().

◆ setOutputFlag()

void com::avpkit::core::ContainerFormat::setOutputFlag ( Flags  flag,
bool  value 
)
virtual

Set the output flag.

Parameters
flagThe flag to set
valueThe value to set it to (true or false)

Implements com::avpkit::core::IContainerFormat.

Definition at line 183 of file ContainerFormat.cpp.

184  {
185  if (mOutputFormat)
186  {
187  if (value)
188  {
189  mOutputFormat->flags |= flag;
190  }
191  else
192  {
193  mOutputFormat->flags &= (~flag);
194  }
195  }
196  }

◆ setOutputFlags()

void com::avpkit::core::ContainerFormat::setOutputFlags ( int32_t  newFlags)
virtual

Set the output flags to use with this object.

All values must be ORed (|) together.

See also
Flags
Parameters
newFlagsThe new set flags for this codec.

Implements com::avpkit::core::IContainerFormat.

Definition at line 167 of file ContainerFormat.cpp.

168  {
169  if (mOutputFormat)
170  mOutputFormat->flags = newFlags;
171  }

◆ setOutputFormat()

int32_t com::avpkit::core::ContainerFormat::setOutputFormat ( const char *  shortName,
const char *  url,
const char *  mimeType 
)
virtual

Sets the output format for this container.

We'll look at the shortName, url and mimeType and try to guess a valid output container format.

Parameters
shortNameThe short name for this container (using FFMPEG's short name).
urlThe URL for this container.
mimeTypeThe mime type for this container.
Returns
>= 0 on success. < 0 if we cannot find a good container.

Implements com::avpkit::core::IContainerFormat.

Definition at line 62 of file ContainerFormat.cpp.

65  {
66  if ((shortName && *shortName) ||
67  (url && *url) ||
68  (mimeType && *mimeType))
69  {
70  mOutputFormat = av_guess_format(shortName, url, mimeType);
71  } else {
72  mOutputFormat = NULL;
73  }
74  return (mOutputFormat == NULL ? -1 : 0);
75  }

Referenced by com::avpkit::core::Container::getContainerFormat(), and com::avpkit::core::IContainerFormat::getInstalledOutputFormat().


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