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

Public Member Functions

virtual int32_t getNumKeys ()
 Get the total number of keys currently in this IMetaData object. More...
 
virtual const char * getKey (int32_t position)
 Get the key at the given position, or null if no such key at that position. More...
 
virtual const char * getValue (const char *key, Flags flag)
 Get the value for the given key. More...
 
virtual int32_t setValue (const char *key, const char *value)
 Sets the value for the given key to value. More...
 
virtual int32_t setValue (const char *key, const char *value, Flags flag)
 Sets the value for the given key to value. More...
 
int32_t copy (IMetaData *copy)
 Destroys the current data, and copies all data from copy.
 
int32_t copy (AVDictionary *copy)
 Destroys the current data and copies all data from copy.
 
AVDictionary * getDictionary ()
 Returns the AVDictionary for passing to FFmpeg calls. 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...
 

Static Public Member Functions

static MetaDatamake (AVDictionary **metaDataToReference)
 Create a MetaData object using metaDataToReference. More...
 
static MetaDatamake (AVDictionary *metaDataToCopy)
 Copies all meta data currently in metaDataToCopy and returns a new object.
 

Additional Inherited Members

 Different types of flags that can be passed to IMetaData#getValue. 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 34 of file MetaData.h.

Member Function Documentation

◆ getDictionary()

AVDictionary* com::avpkit::core::MetaData::getDictionary ( )
inline

Returns the AVDictionary for passing to FFmpeg calls.

Returns
The underlying AVDictionary

Definition at line 76 of file MetaData.h.

76 { return (mMetaData ? *mMetaData : 0); }

Referenced by copy(), com::avpkit::core::Container::open(), com::avpkit::core::StreamCoder::open(), and com::avpkit::core::Property::setProperty().

◆ getKey()

const char * com::avpkit::core::MetaData::getKey ( int32_t  position)
virtual

Get the key at the given position, or null if no such key at that position.

Note: positions of keys may change between calls to setValue(String, String) and should be requiried.

Parameters
positionThe position. Must be >=0 and < getNumKeys().
Returns
the key, or null if not found.

Implements com::avpkit::core::IMetaData.

Definition at line 67 of file MetaData.cpp.

68 {
69  if (!mMetaData || !*mMetaData || index < 0)
70  return 0;
71 
72  AVDictionaryEntry* tag=0;
73  int32_t position=-1;
74  do
75  {
76  tag = av_dict_get(*mMetaData, "", tag, AV_DICT_IGNORE_SUFFIX);
77  if (tag) {
78  position++;
79  if (position == index)
80  return tag->key;
81  }
82  } while(tag);
83  return 0;
84 }

◆ getNumKeys()

int32_t com::avpkit::core::MetaData::getNumKeys ( )
virtual

Get the total number of keys currently in this IMetaData object.

Returns
the number of keys.

Implements com::avpkit::core::IMetaData.

Definition at line 50 of file MetaData.cpp.

51 {
52  if (!mMetaData || !*mMetaData)
53  return 0;
54 
55  AVDictionaryEntry* tag=0;
56  int32_t retval=0;
57  do
58  {
59  tag = av_dict_get(*mMetaData, "", tag, AV_DICT_IGNORE_SUFFIX);
60  if (tag)
61  retval++;
62  } while(tag);
63  return retval;
64 }

◆ getValue()

const char * com::avpkit::core::MetaData::getValue ( const char *  key,
Flags  flag 
)
virtual

Get the value for the given key.

Parameters
keyThe key
flagA flag for how to search
Returns
The value, or null if none.

Implements com::avpkit::core::IMetaData.

Definition at line 86 of file MetaData.cpp.

87 {
88  if (!mMetaData || !*mMetaData || !key || !*key)
89  return 0;
90  AVDictionaryEntry* tag = av_dict_get(*mMetaData, key, 0, (int)flag);
91  if (tag)
92  return tag->value;
93  else
94  return 0;
95 }

◆ make()

MetaData * com::avpkit::core::MetaData::make ( AVDictionary **  metaDataToReference)
static

Create a MetaData object using metaDataToReference.

Once this is done, this MetaData object is responsible for calling av_dict_free(*metaDataToReference), so take care.

Definition at line 112 of file MetaData.cpp.

113 {
114  if (!metaToUse)
115  return 0;
116 
117  MetaData* retval = make();
118 
119  if (retval)
120  retval->mMetaData = metaToUse;
121 
122  return retval;
123 }
static IMetaData * make()
Create a new IMetaData bag of properties with no values set.
Definition: IMetaData.cpp:36

References com::avpkit::core::IMetaData::make().

◆ setValue() [1/2]

int32_t com::avpkit::core::MetaData::setValue ( const char *  key,
const char *  value 
)
virtual

Sets the value for the given key to value.

This overrides any prior setting for key, or adds key to the meta-data if appropriate.

Parameters
keyThe key to set.
valueThe value to set.

Implements com::avpkit::core::IMetaData.

Definition at line 98 of file MetaData.cpp.

99 {
100  return setValue(key, value, METADATA_NONE);
101 }
@ METADATA_NONE
For getValue(String) case-insensitive match of key.
Definition: IMetaData.h:60
virtual int32_t setValue(const char *key, const char *value)
Sets the value for the given key to value.
Definition: MetaData.cpp:98

References com::avpkit::core::IMetaData::METADATA_NONE.

◆ setValue() [2/2]

int32_t com::avpkit::core::MetaData::setValue ( const char *  key,
const char *  value,
Flags  flag 
)
virtual

Sets the value for the given key to value.

This overrides any prior setting for key, or adds key to the meta-data if appropriate.

Parameters
keyThe key to set.
valueThe value to set.
flagA flag on how this should be set.
Since
5.0

Implements com::avpkit::core::IMetaData.

Definition at line 104 of file MetaData.cpp.

105 {
106  if (!key || !*key || !mMetaData)
107  return -1;
108  return (int32_t)av_dict_set(mMetaData, key, value, (int)flag);
109 }

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