|
AVPKit
|
A set of raw (decoded) samples, plus a timestamp for when to play those samples relative to other items in a given IContainer. More...
#include <IAudioSamples.h>


Public Types | |
| enum | Format { FMT_NONE = -1 , FMT_U8 , FMT_S16 , FMT_S32 , FMT_FLT , FMT_DBL , FMT_U8P , FMT_S16P , FMT_S32P , FMT_FLTP , FMT_DBLP } |
| The format we use to represent audio. More... | |
| enum class | ChannelLayout : uint64_t { CH_NONE = 0 , CH_FRONT_LEFT = 0x00000001 , CH_FRONT_RIGHT = 0x00000002 , CH_FRONT_CENTER = 0x00000004 , CH_LOW_FREQUENCY = 0x00000008 , CH_BACK_LEFT = 0x00000010 , CH_BACK_RIGHT = 0x00000020 , CH_FRONT_LEFT_OF_CENTER = 0x00000040 , CH_FRONT_RIGHT_OF_CENTER = 0x00000080 , CH_BACK_CENTER = 0x00000100 , CH_SIDE_LEFT = 0x00000200 , CH_SIDE_RIGHT = 0x00000400 , CH_TOP_CENTER = 0x00000800 , CH_TOP_FRONT_LEFT = 0x00001000 , CH_TOP_FRONT_CENTER = 0x00002000 , CH_TOP_FRONT_RIGHT = 0x00004000 , CH_TOP_BACK_LEFT = 0x00008000 , CH_TOP_BACK_CENTER = 0x00010000 , CH_TOP_BACK_RIGHT = 0x00020000 , CH_STEREO_LEFT = 0x20000000 , CH_STEREO_RIGHT = 0x40000000 , CH_WIDE_LEFT = 0x0000000080000000ULL , CH_WIDE_RIGHT = 0x0000000100000000ULL , CH_SURROUND_DIRECT_LEFT = 0x0000000200000000ULL , CH_SURROUND_DIRECT_RIGHT = 0x0000000400000000ULL , CH_LOW_FREQUENCY_2 = 0x0000000800000000ULL , CH_LAYOUT_NATIVE = 0x8000000000000000ULL , , channel_mask_c , CH_LAYOUT_MONO = (CH_FRONT_CENTER) , CH_LAYOUT_STEREO = (CH_FRONT_LEFT|CH_FRONT_RIGHT) , CH_LAYOUT_2POINT1 = (CH_LAYOUT_STEREO|CH_LOW_FREQUENCY) , CH_LAYOUT_2_1 = (CH_LAYOUT_STEREO|CH_BACK_CENTER) , CH_LAYOUT_SURROUND = (CH_LAYOUT_STEREO|CH_FRONT_CENTER) , CH_LAYOUT_3POINT1 = (CH_LAYOUT_SURROUND|CH_LOW_FREQUENCY) , CH_LAYOUT_4POINT0 = (CH_LAYOUT_SURROUND|CH_BACK_CENTER) , CH_LAYOUT_4POINT1 = (CH_LAYOUT_4POINT0|CH_LOW_FREQUENCY) , CH_LAYOUT_2_2 = (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT) , CH_LAYOUT_QUAD = (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT) , CH_LAYOUT_5POINT0 = (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT) , CH_LAYOUT_5POINT1 = (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY) , CH_LAYOUT_5POINT0_BACK = (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT) , CH_LAYOUT_5POINT1_BACK = (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY) , CH_LAYOUT_6POINT0 = (CH_LAYOUT_5POINT0|CH_BACK_CENTER) , CH_LAYOUT_6POINT0_FRONT = (CH_LAYOUT_2_2|CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER) , CH_LAYOUT_HEXAGONAL = (CH_LAYOUT_5POINT0_BACK|CH_BACK_CENTER) , CH_LAYOUT_6POINT1 = (CH_LAYOUT_5POINT1|CH_BACK_CENTER) , CH_LAYOUT_6POINT1_BACK = (CH_LAYOUT_5POINT1_BACK|CH_BACK_CENTER) , CH_LAYOUT_6POINT1_FRONT = (CH_LAYOUT_6POINT0_FRONT|CH_LOW_FREQUENCY) , CH_LAYOUT_7POINT0 = (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT) , CH_LAYOUT_7POINT0_FRONT = (CH_LAYOUT_5POINT0|CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER) , CH_LAYOUT_7POINT1 = (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT) , CH_LAYOUT_7POINT1_WIDE = (CH_LAYOUT_5POINT1|CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER) , CH_LAYOUT_7POINT1_WIDE_BACK = (CH_LAYOUT_5POINT1_BACK|CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER) , CH_LAYOUT_OCTAGONAL = (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_CENTER|CH_BACK_RIGHT) , CH_LAYOUT_HEXADECAGONAL = (CH_LAYOUT_OCTAGONAL|CH_WIDE_LEFT|CH_WIDE_RIGHT|CH_TOP_BACK_LEFT|CH_TOP_BACK_RIGHT|CH_TOP_BACK_CENTER|CH_TOP_FRONT_CENTER|CH_TOP_FRONT_LEFT|CH_TOP_FRONT_RIGHT) , CH_LAYOUT_STEREO_DOWNMIX = (CH_STEREO_LEFT|CH_STEREO_RIGHT) } |
| typedef enum com::avpkit::core::IAudioSamples::Format | Format |
| The format we use to represent audio. More... | |
Public Member Functions | |
| virtual bool | isComplete ()=0 |
| Returns whether or not we think this buffer has been filled with data. More... | |
| virtual int32_t | getSampleRate ()=0 |
| Find the sample rate of the samples in this audio buffer. More... | |
| virtual int32_t | getChannels ()=0 |
| Return the number of channels of the samples in this buffer. More... | |
| virtual int32_t | getSampleBitDepth ()=0 |
| Find out the bit-depth of the samples in this buffer. More... | |
| virtual Format | getFormat ()=0 |
| Find the Format of the samples in this buffer. More... | |
| virtual int32_t | getNumSamples ()=0 |
| Get the number of samples in this video. More... | |
| virtual int32_t | getMaxBufferSize ()=0 |
| virtual int32_t | getMaxSamples ()=0 |
| virtual int32_t | getSampleSize ()=0 |
| virtual int64_t | getPts ()=0 |
| What is the Presentation Time Stamp of this set of audio samples. More... | |
| virtual void | setPts (int64_t aValue)=0 |
| Set the Presentation Time Stamp for this set of samples. More... | |
| virtual int64_t | getNextPts ()=0 |
| What would be the next Presentation Time Stamp after all the samples in this buffer were played? More... | |
| virtual void | setComplete (bool complete, int32_t numSamples, int32_t sampleRate, int32_t channels, Format format, int64_t pts)=0 |
| Call this if you modify the samples and are now done. More... | |
| virtual short * | getRawSamples (uint32_t startingSample)=0 |
| virtual int32_t | setSample (int32_t sampleIndex, int32_t channel, Format format, int32_t sample)=0 |
| Sets the sample at the given index and channel to the sample. More... | |
| virtual int32_t | getSample (int32_t sampleIndex, int32_t channel, Format format)=0 |
| Get the sample at the given sampleIndex and channel, and return it in the asked for format. More... | |
| virtual ChannelLayout | getChannelLayout ()=0 |
| virtual void | setComplete (bool complete, int32_t numSamples, int32_t sampleRate, int32_t channels, ChannelLayout channelLayout, Format format, int64_t pts)=0 |
Public Member Functions inherited from com::avpkit::core::IMediaData | |
| virtual int64_t | getTimeStamp ()=0 |
| Get the time stamp of this object in getTimeBase() units. More... | |
| virtual void | setTimeStamp (int64_t aTimeStamp)=0 |
| Set the time stamp for this object in getTimeBase() units. More... | |
| virtual IRational * | getTimeBase ()=0 |
| Get the time base that time stamps of this object are represented in. More... | |
| virtual void | setTimeBase (IRational *aBase)=0 |
| Set the time base that time stamps of this object are represented in. More... | |
| virtual com::avpkit::ferry::IBuffer * | getData ()=0 |
| Get any underlying raw data available for this object. More... | |
| virtual int32_t | getSize ()=0 |
| Get the size in bytes of the raw data available for this object. More... | |
| virtual bool | isKey ()=0 |
| Is this object a key object? i.e. More... | |
| virtual void | setData (com::avpkit::ferry::IBuffer *buffer)=0 |
| 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 RefCounted * | copyReference () |
| 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 int32_t | findSampleBitDepth (Format format) |
| A convenience method that returns the # of bits in a given format. More... | |
| static IAudioSamples * | make (int32_t numSamples, int32_t numChannels) |
| Get a new audio samples buffer. More... | |
| static int64_t | samplesToDefaultPts (int64_t samples, int sampleRate) |
| Converts a number of samples at a given sampleRate into Microseconds. More... | |
| static int64_t | defaultPtsToSamples (int64_t duration, int sampleRate) |
| Converts a duration in microseconds into a number of samples, assuming a given sampleRate. More... | |
| static IAudioSamples * | make (com::avpkit::ferry::IBuffer *buffer, int channels, IAudioSamples::Format format) |
| Creates an IAudioSamples object by wrapping an object. More... | |
| static IAudioSamples * | make (int32_t numSamples, int32_t numChannels, IAudioSamples::Format format) |
| Get a new audio samples buffer. 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 | |
| AtomicInteger * | mRefCount |
| This is the internal reference count, represented as an AtomicInteger to make sure it is thread safe. | |
| void * | mAllocator |
| Not part of public API. | |
A set of raw (decoded) samples, plus a timestamp for when to play those samples relative to other items in a given IContainer.
The timestamp value in decoded data is always in Microseonds.
Definition at line 37 of file IAudioSamples.h.
The format we use to represent audio.
Today only FMT_S16 (signed integer 16-bit audio) is supported.
|
strong |
Definition at line 276 of file IAudioSamples.h.
The format we use to represent audio.
Today only FMT_S16 (signed integer 16-bit audio) is supported.
Definition at line 46 of file IAudioSamples.h.
|
static |
Converts a duration in microseconds into a number of samples, assuming a given sampleRate.
| duration | The duration in microseconds. |
| sampleRate | sample rate that you want to use. |
Definition at line 86 of file IAudioSamples.cpp.
References com::avpkit::core::Global::DEFAULT_PTS_PER_SECOND, com::avpkit::core::Global::init(), and com::avpkit::core::Global::NO_PTS.
|
static |
A convenience method that returns the # of bits in a given format.
Be aware that right now this library only supports 16-bit audio.
| format | The format you want to find the number of bits in. |
Definition at line 38 of file IAudioSamples.cpp.
Referenced by com::avpkit::core::AudioSamples::getSampleBitDepth(), and com::avpkit::core::AudioResampler::resample().
|
pure virtual |
Return the number of channels of the samples in this buffer.
For example, 1 is mono, 2 is stereo.
Implemented in com::avpkit::core::AudioSamples.
Referenced by com::avpkit::core::AudioResampler::getMinimumNumSamplesRequiredInOutputSamples().
|
pure virtual |
Find the Format of the samples in this buffer.
Right now only FMT_S16 is supported.
Implemented in com::avpkit::core::AudioSamples.
Referenced by com::avpkit::core::AudioResampler::getMinimumNumSamplesRequiredInOutputSamples().
|
pure virtual |
Implemented in com::avpkit::core::AudioSamples.
|
pure virtual |
Implemented in com::avpkit::core::AudioSamples.
|
pure virtual |
What would be the next Presentation Time Stamp after all the samples in this buffer were played?
Implemented in com::avpkit::core::AudioSamples.
|
pure virtual |
Get the number of samples in this video.
For example, if you have 100 bytes of stereo (2-channel) 16-bit audio in this buffer, there are 25 samples. If you have 100 bytes of mono (1-channel) 16-bit audio in this buffer, you have 50 samples.
Implemented in com::avpkit::core::AudioSamples.
Referenced by com::avpkit::core::AudioResampler::getMinimumNumSamplesRequiredInOutputSamples().
|
pure virtual |
What is the Presentation Time Stamp of this set of audio samples.
Implemented in com::avpkit::core::AudioSamples.
|
pure virtual |
Get the sample at the given sampleIndex and channel, and return it in the asked for format.
| sampleIndex | The zero-based index into this set of samples. |
| channel | The zero-based channel to get the sample from |
| format | The format to return in |
Implemented in com::avpkit::core::AudioSamples.
|
pure virtual |
Find out the bit-depth of the samples in this buffer.
Implemented in com::avpkit::core::AudioSamples.
|
pure virtual |
Find the sample rate of the samples in this audio buffer.
Implemented in com::avpkit::core::AudioSamples.
Referenced by com::avpkit::core::AudioResampler::getMinimumNumSamplesRequiredInOutputSamples().
|
pure virtual |
Implemented in com::avpkit::core::AudioSamples.
|
pure virtual |
Returns whether or not we think this buffer has been filled with data.
Implemented in com::avpkit::core::AudioSamples.
Referenced by com::avpkit::core::AudioResampler::getMinimumNumSamplesRequiredInOutputSamples().
|
static |
Creates an IAudioSamples object by wrapping an object.
If you are decoding into this buffer, the buffer must be at least 192k*channels large (an FFmpeg requirement) or the decodeAudio call on IStreamCoder will fail with an error. If you are encoding from, any size should do.
| buffer | the buffer to wrap |
| channels | the number of channels of audio you will put it the buffer |
| format | the audio sample format |
Definition at line 61 of file IAudioSamples.cpp.
References com::avpkit::core::Global::init().
|
static |
Get a new audio samples buffer.
Note that any buffers this objects needs will be lazily allocated (i.e. we won't actually grab all the memory until we need it).
| numSamples | The minimum number of samples you're going to want to put in this buffer. We may (and probably will) return a larger buffer, but you cannot assume that. |
| numChannels | The number of channels in the audio you'll want to put in this buffer. |
Definition at line 45 of file IAudioSamples.cpp.
References com::avpkit::core::Global::init().
|
static |
Get a new audio samples buffer.
Note that any buffers this objects needs will be lazily allocated (i.e. we won't actually grab all the memory until we need it).
| numSamples | The minimum number of samples you're going to want to put in this buffer. We may (and probably will) return a larger buffer, but you cannot assume that. |
| numChannels | The number of channels in the audio you'll want to put in this buffer. |
| format | The format of this buffer |
Definition at line 52 of file IAudioSamples.cpp.
References com::avpkit::core::Global::init().
|
static |
Converts a number of samples at a given sampleRate into Microseconds.
| samples | Number of samples. |
| sampleRate | sample rate that those samples are recorded at. |
Definition at line 69 of file IAudioSamples.cpp.
References com::avpkit::core::Global::DEFAULT_PTS_PER_SECOND, com::avpkit::core::Global::init(), and com::avpkit::core::Global::NO_PTS.
Referenced by com::avpkit::core::AudioSamples::getNextPts(), and com::avpkit::core::AudioResampler::resample().
|
pure virtual |
Call this if you modify the samples and are now done.
This updates the pertinent information in the structure.
| complete | Is this set of samples complete? |
| numSamples | Number of samples in this update (note that 4 shorts of 16-bit audio in stereo is actually 1 sample). |
| sampleRate | The sample rate (in Hz) of this set of samples. |
| channels | The number of channels in this set of samples. |
| format | The sample-format of this set of samples. |
| pts | The presentation time stamp of the starting sample in this buffer. Caller must ensure pts is in units of 1/1,000,000 of a second |
Implemented in com::avpkit::core::AudioSamples.
|
pure virtual |
Set the Presentation Time Stamp for this set of samples.
| aValue | the new value |
Implemented in com::avpkit::core::AudioSamples.
|
pure virtual |
Sets the sample at the given index and channel to the sample.
In theory we assume input is the given Format, and will convert if needed, but right now we only support FMT_S16 anyway.
| sampleIndex | The zero-based index into the set of samples |
| channel | The zero-based channel number. If this set of samples doesn't have that given channel, an error is returned. |
| format | The format of the given sample |
| sample | The actual sample |
Implemented in com::avpkit::core::AudioSamples.