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

Public Member Functions

virtual int64_t getTimeStamp ()
 Get the time stamp of this object in getTimeBase() units. More...
 
virtual void setTimeStamp (int64_t aTimeStamp)
 Set the time stamp for this object in getTimeBase() units. More...
 
virtual IRationalgetTimeBase ()
 Get the time base that time stamps of this object are represented in. More...
 
virtual void setTimeBase (IRational *aBase)
 Set the time base that time stamps of this object are represented in. More...
 
virtual com::avpkit::ferry::IBuffergetData ()
 Get any underlying raw data available for this object. More...
 
virtual int32_t getSize ()
 Get the size in bytes of the raw data available for this object. More...
 
virtual bool isKey ()
 Is this object a key object? i.e. More...
 
virtual IMediaDataget ()
 Return the object being wrapped. More...
 
virtual void wrap (IMediaData *aObj)
 Set an object to wrap, or null to release the old object. More...
 
virtual void setKey (bool aIsKey)
 Allows you to reset whether the wrapper things this is key or not. More...
 
virtual IMediaDataunwrap ()
 Gets the non IMediaDataWrapper object ultimately wrapped in this wrapper, or null if there isn't one. More...
 
virtual void setData (com::avpkit::ferry::IBuffer *)
 Sets the underlying buffer used by this object. 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 MediaDataWrappermake (IMediaData *obj)
 Create a new IMediaDataWrapper that wraps a given object. More...
 
- Static Public Member Functions inherited from com::avpkit::core::IMediaDataWrapper
static IMediaDataWrappermake (IMediaData *obj)
 Create a new IMediaDataWrapper object that wraps the given obj. More...
 

Additional Inherited Members

- 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 28 of file MediaDataWrapper.h.

Member Function Documentation

◆ get()

IMediaData * com::avpkit::core::MediaDataWrapper::get ( )
virtual

Return the object being wrapped.

Returns
the wrapped object

Implements com::avpkit::core::IMediaDataWrapper.

Definition at line 159 of file MediaDataWrapper.cpp.

160 {
161  return mWrapped.get();
162 }

◆ getData()

IBuffer * com::avpkit::core::MediaDataWrapper::getData ( )
virtual

Get any underlying raw data available for this object.

Returns
The raw data, or null if not accessible.

Implements com::avpkit::core::IMediaData.

Definition at line 77 of file MediaDataWrapper.cpp.

78 {
79  IBuffer* retval=0;
80  // forward to wrapped object
81  if (mWrapped)
82  {
83  retval = mWrapped->getData();
84  }
85  return retval;
86 }
Allows Java code to get data from a native buffers, and optionally modify native memory directly.
Definition: IBuffer.h:54

◆ getSize()

int32_t com::avpkit::core::MediaDataWrapper::getSize ( )
virtual

Get the size in bytes of the raw data available for this object.

Returns
the size in bytes, or -1 if it cannot be computed.

Implements com::avpkit::core::IMediaData.

Definition at line 89 of file MediaDataWrapper.cpp.

90 {
91  int retval = -1;
92  // forward to wrapped object
93  if (mWrapped)
94  {
95  retval = mWrapped->getSize();
96  }
97  return retval;
98 }

◆ getTimeBase()

IRational * com::avpkit::core::MediaDataWrapper::getTimeBase ( )
virtual

Get the time base that time stamps of this object are represented in.

Caller must release the returned value.

Returns
the time base.

Implements com::avpkit::core::IMediaData.

Definition at line 65 of file MediaDataWrapper.cpp.

66 {
67  return mTimeBase.get();
68 }

◆ getTimeStamp()

int64_t com::avpkit::core::MediaDataWrapper::getTimeStamp ( )
virtual

Get the time stamp of this object in getTimeBase() units.

Returns
the time stamp

Implements com::avpkit::core::IMediaData.

Definition at line 53 of file MediaDataWrapper.cpp.

54 {
55  return mTimeStamp;
56 }

◆ isKey()

bool com::avpkit::core::MediaDataWrapper::isKey ( )
virtual

Is this object a key object? i.e.

it can be interpreted without needing any other media objects

Returns
true if it's a key, false if not

Implements com::avpkit::core::IMediaData.

Definition at line 101 of file MediaDataWrapper.cpp.

102 {
103  return mIsKey;
104 }

◆ make()

MediaDataWrapper * com::avpkit::core::MediaDataWrapper::make ( IMediaData obj)
static

Create a new IMediaDataWrapper that wraps a given object.

Parameters
objThe object to wrap. Can be null.
Returns
a new object, or null if we cannot allocate one.

Definition at line 42 of file MediaDataWrapper.cpp.

43 {
44  MediaDataWrapper* retval = make();
45  if (retval)
46  {
47  retval->wrap(obj);
48  }
49  return retval;
50 }
static MediaDataWrapper * make(IMediaData *obj)
Create a new IMediaDataWrapper that wraps a given object.

References wrap().

Referenced by com::avpkit::core::IMediaDataWrapper::make().

◆ setData()

void com::avpkit::core::MediaDataWrapper::setData ( com::avpkit::ferry::IBuffer buffer)
virtual

Sets the underlying buffer used by this object.

This is an advanced method and is not recommended for use by those who don't fully understand how IBuffers work. Implementations of IMediaData may behave in undefined ways if the buffer you pass in is not big enough for what you ask them to do (e.g. they may discard your buffer and allocate a larger one if they need more space). It is up to the caller to ensure the buffer passed in is large enough, and is not simultaneously in use by another part of the system.

Parameters
bufferThe buffer to set. If null, this method is ignored.

Implements com::avpkit::core::IMediaData.

Definition at line 152 of file MediaDataWrapper.cpp.

153 {
154  if (mWrapped)
155  mWrapped->setData(buffer);
156 }

◆ setKey()

void com::avpkit::core::MediaDataWrapper::setKey ( bool  aIsKey)
virtual

Allows you to reset whether the wrapper things this is key or not.

Note the underlying wrapped object will continue to keep it's prior setting.

Parameters
aIsKeyThe new key value.

Implements com::avpkit::core::IMediaDataWrapper.

Definition at line 107 of file MediaDataWrapper.cpp.

108 {
109  mIsKey = aIsKey;
110 }

◆ setTimeBase()

void com::avpkit::core::MediaDataWrapper::setTimeBase ( IRational aBase)
virtual

Set the time base that time stamps of this object are represented in.

Parameters
aBasethe new time base. If null an exception is thrown.

Implements com::avpkit::core::IMediaData.

Definition at line 71 of file MediaDataWrapper.cpp.

72 {
73  mTimeBase.reset(aBase, true);
74 }

◆ setTimeStamp()

void com::avpkit::core::MediaDataWrapper::setTimeStamp ( int64_t  aTimeStamp)
virtual

Set the time stamp for this object in getTimeBase() units.

Parameters
aTimeStampThe time stamp

Implements com::avpkit::core::IMediaData.

Definition at line 59 of file MediaDataWrapper.cpp.

60 {
61  mTimeStamp = aTimeStamp;
62 }

◆ unwrap()

IMediaData * com::avpkit::core::MediaDataWrapper::unwrap ( )
virtual

Gets the non IMediaDataWrapper object ultimately wrapped in this wrapper, or null if there isn't one.

Returns
The non IMediaDataWrapper object ultimately wrapped

Implements com::avpkit::core::IMediaDataWrapper.

Definition at line 165 of file MediaDataWrapper.cpp.

166 {
167  RefPointer<IMediaData> unwrapped = get();
168 
169  // as long unwrapped points to an IMediaDataWrapper, then unwrap
170  while(unwrapped && dynamic_cast<IMediaDataWrapper*>(unwrapped.value()))
171  unwrapped = (dynamic_cast<IMediaDataWrapper*>(unwrapped.value()))->get();
172  return unwrapped.get();
173 }
virtual IMediaData * get()
Return the object being wrapped.
This class is only useful from C++.
Definition: RefPointer.h:47
T * get()
Call RefCounted::acquire() on the managed pointer and return it.
Definition: RefPointer.h:206
T * value()
Return the managed pointer without calling RefCounted::acquire() on it.
Definition: RefPointer.h:226

References com::avpkit::ferry::RefPointer< T >::get(), and com::avpkit::ferry::RefPointer< T >::value().

◆ wrap()

void com::avpkit::core::MediaDataWrapper::wrap ( IMediaData aObj)
virtual

Set an object to wrap, or null to release the old object.

Parameters
aObjThe object to wrap; null just releases the last object

Implements com::avpkit::core::IMediaDataWrapper.

Definition at line 113 of file MediaDataWrapper.cpp.

114 {
115  IMediaDataWrapper* wrapper=dynamic_cast<IMediaDataWrapper*>(aObj);
116  // loop detection to make sure we're not wrapping ourselves.
117  if (wrapper) {
119  IMediaDataWrapper *me = static_cast<IMediaDataWrapper*>(this);
120  do
121  {
122  if (wrapper == me)
123  break;
124  obj = wrapper->get();
125  } while (0 != (wrapper = dynamic_cast<IMediaDataWrapper*>(obj.value())));
126 
127  if (wrapper == me)
128  {
129  VS_LOG_ERROR("Attempted to wrap an object that ultimately wraps itself. Ignoring");
130  // we're wrapping ourselves
131  return;
132  }
133  }
134  mWrapped.reset(aObj, true);
135  if (aObj)
136  {
137  setTimeStamp(aObj->getTimeStamp());
138  IRational *base = aObj->getTimeBase();
139  setTimeBase(base);
140  VS_REF_RELEASE(base);
141  setKey(aObj->isKey());
142  }
143  else
144  {
146  setTimeBase(0);
147  setKey(true);
148  }
149 }
static const int64_t NO_PTS
A value that means no time stamp is set for a given object.
Definition: Global.h:50
virtual void setTimeStamp(int64_t aTimeStamp)
Set the time stamp for this object in getTimeBase() units.
virtual void setKey(bool aIsKey)
Allows you to reset whether the wrapper things this is key or not.
virtual void setTimeBase(IRational *aBase)
Set the time base that time stamps of this object are represented in.

References com::avpkit::core::IMediaDataWrapper::get(), com::avpkit::core::IMediaData::getTimeBase(), com::avpkit::core::IMediaData::getTimeStamp(), com::avpkit::core::IMediaData::isKey(), com::avpkit::core::Global::NO_PTS, and com::avpkit::ferry::RefPointer< T >::value().

Referenced by make().


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