Home | History | Annotate | Download | only in stagefright
      1 /*
      2  * Copyright (C) 2009 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef AUDIO_SOURCE_H_
     18 
     19 #define AUDIO_SOURCE_H_
     20 
     21 #include <media/AudioSystem.h>
     22 #include <media/stagefright/MediaSource.h>
     23 
     24 namespace android {
     25 
     26 class AudioRecord;
     27 struct MediaBufferGroup;
     28 
     29 struct AudioSource : public MediaSource {
     30     // Note that the "channels" parameter is _not_ the number of channels,
     31     // but a bitmask of AudioSystem::audio_channels constants.
     32     AudioSource(
     33             int inputSource, uint32_t sampleRate,
     34             uint32_t channels = AudioSystem::CHANNEL_IN_MONO);
     35 
     36     status_t initCheck() const;
     37 
     38     virtual status_t start(MetaData *params = NULL);
     39     virtual status_t stop();
     40     virtual sp<MetaData> getFormat();
     41 
     42     virtual status_t read(
     43             MediaBuffer **buffer, const ReadOptions *options = NULL);
     44 
     45 protected:
     46     virtual ~AudioSource();
     47 
     48 private:
     49     enum { kMaxBufferSize = 8192 };
     50 
     51     AudioRecord *mRecord;
     52     status_t mInitCheck;
     53     bool mStarted;
     54     MediaBufferGroup *mGroup;
     55 
     56     AudioSource(const AudioSource &);
     57     AudioSource &operator=(const AudioSource &);
     58 };
     59 
     60 }  // namespace android
     61 
     62 #endif  // AUDIO_SOURCE_H_
     63