Home | History | Annotate | Download | only in api
      1 /* Copyright 2014 The Chromium Authors. All rights reserved.
      2  * Use of this source code is governed by a BSD-style license that can be
      3  * found in the LICENSE file.
      4  */
      5 
      6 /**
      7  * Defines the <code>PPB_AudioBuffer</code> interface.
      8  */
      9 
     10 [generate_thunk]
     11 
     12 label Chrome {
     13   [channel=dev] M34 = 0.1,
     14   M35 = 0.1
     15 };
     16 
     17 /**
     18  * PP_AudioBuffer_SampleRate is an enumeration of the different audio sample
     19  * rates.
     20  */
     21 enum PP_AudioBuffer_SampleRate {
     22   PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN = 0,
     23   PP_AUDIOBUFFER_SAMPLERATE_8000 = 8000,
     24   PP_AUDIOBUFFER_SAMPLERATE_16000 = 16000,
     25   PP_AUDIOBUFFER_SAMPLERATE_22050 = 22050,
     26   PP_AUDIOBUFFER_SAMPLERATE_32000 = 32000,
     27   PP_AUDIOBUFFER_SAMPLERATE_44100 = 44100,
     28   PP_AUDIOBUFFER_SAMPLERATE_48000 = 48000,
     29   PP_AUDIOBUFFER_SAMPLERATE_96000 = 96000,
     30   PP_AUDIOBUFFER_SAMPLERATE_192000 = 192000
     31 };
     32 
     33 /**
     34  * PP_AudioBuffer_SampleSize is an enumeration of the different audio sample
     35  * sizes.
     36  */
     37 enum PP_AudioBuffer_SampleSize {
     38   PP_AUDIOBUFFER_SAMPLESIZE_UNKNOWN = 0,
     39   PP_AUDIOBUFFER_SAMPLESIZE_16_BITS = 2
     40 };
     41 
     42 [version=0.1]
     43 interface PPB_AudioBuffer {
     44   /**
     45    * Determines if a resource is an AudioBuffer resource.
     46    *
     47    * @param[in] resource The <code>PP_Resource</code> to test.
     48    *
     49    * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> if the given
     50    * resource is an AudioBuffer resource or <code>PP_FALSE</code> otherwise.
     51    */
     52   PP_Bool IsAudioBuffer([in] PP_Resource resource);
     53 
     54   /**
     55    * Gets the timestamp of the audio buffer.
     56    *
     57    * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
     58    * buffer resource.
     59    *
     60    * @return A <code>PP_TimeDelta</code> containing the timestamp of the audio
     61    * buffer. Given in seconds since the start of the containing audio stream.
     62    */
     63   [on_failure=0.0]
     64   PP_TimeDelta GetTimestamp([in] PP_Resource buffer);
     65 
     66   /**
     67    * Sets the timestamp of the audio buffer.
     68    *
     69    * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
     70    * buffer resource.
     71    * @param[in] timestamp A <code>PP_TimeDelta</code> containing the timestamp
     72    * of the audio buffer. Given in seconds since the start of the containing
     73    * audio stream.
     74    */
     75   void SetTimestamp([in] PP_Resource buffer, [in] PP_TimeDelta timestamp);
     76 
     77   /**
     78    * Gets the sample rate of the audio buffer.
     79    *
     80    * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
     81    * buffer resource.
     82    *
     83    * @return The sample rate of the audio buffer.
     84    */
     85   [on_failure=PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN]
     86   PP_AudioBuffer_SampleRate GetSampleRate([in] PP_Resource buffer);
     87 
     88   /**
     89    * Gets the sample size of the audio buffer.
     90    *
     91    * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
     92    * buffer resource.
     93    *
     94    * @return The sample size of the audio buffer.
     95    */
     96   [on_failure=PP_AUDIOBUFFER_SAMPLESIZE_UNKNOWN]
     97   PP_AudioBuffer_SampleSize GetSampleSize([in] PP_Resource buffer);
     98 
     99   /**
    100    * Gets the number of channels in the audio buffer.
    101    *
    102    * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
    103    * buffer resource.
    104    *
    105    * @return The number of channels in the audio buffer.
    106    */
    107   uint32_t GetNumberOfChannels([in] PP_Resource buffer);
    108 
    109   /**
    110    * Gets the number of samples in the audio buffer.
    111    *
    112    * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
    113    * buffer resource.
    114    *
    115    * @return The number of samples in the audio buffer.
    116    * For example, at a sampling rate of 44,100 Hz in stereo audio, a buffer
    117    * containing 4410 * 2 samples would have a duration of 100 milliseconds.
    118    */
    119   uint32_t GetNumberOfSamples([in] PP_Resource buffer);
    120 
    121   /**
    122    * Gets the data buffer containing the audio samples.
    123    *
    124    * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
    125    * buffer resource.
    126    *
    127    * @return A pointer to the beginning of the data buffer.
    128    */
    129   mem_t GetDataBuffer([in] PP_Resource buffer);
    130 
    131   /**
    132    * Gets the size of the data buffer in bytes.
    133    *
    134    * @param[in] buffer A <code>PP_Resource</code> corresponding to an audio
    135    * buffer resource.
    136    *
    137    * @return The size of the data buffer in bytes.
    138    */
    139   uint32_t GetDataBufferSize([in] PP_Resource buffer);
    140 };
    141