Home | History | Annotate | Download | only in lvpp
      1 /*
      2  * Copyright (C) 2011 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 
     18 #include <stdint.h>
     19 #include <media/stagefright/MediaSource.h>
     20 #include "AudioBufferProvider.h"
     21 #include "AudioResampler.h"
     22 
     23 namespace android {
     24 
     25 struct MediaBuffer;
     26 
     27 class VideoEditorSRC : public MediaSource , public AudioBufferProvider {
     28 
     29 public:
     30     VideoEditorSRC(const sp<MediaSource> &source);
     31 
     32     virtual status_t start (MetaData *params = NULL);
     33     virtual status_t stop();
     34     virtual sp<MetaData> getFormat();
     35     virtual status_t read (
     36                 MediaBuffer **buffer, const ReadOptions *options = NULL);
     37 
     38     virtual status_t getNextBuffer(Buffer* buffer, int64_t pts);
     39     virtual void releaseBuffer(Buffer* buffer);
     40 
     41     // Sampling freqencies
     42     enum {
     43         kFreq8000Hz  = 8000,
     44         kFreq11025Hz = 11025,
     45         kFreq12000Hz = 12000,
     46         kFreq16000Hz = 16000,
     47         kFreq22050Hz = 22050,
     48         kFreq24000Hz = 24000,
     49         kFreq32000Hz = 32000,
     50         kFreq44100Hz = 44100,
     51         kFreq48000Hz = 48000,
     52     };
     53 
     54 protected :
     55     virtual ~VideoEditorSRC();
     56 
     57 private:
     58     AudioResampler *mResampler;
     59     sp<MediaSource> mSource;
     60     int mChannelCnt;
     61     int mSampleRate;
     62     int32_t mOutputSampleRate;
     63     bool mStarted;
     64     sp<MetaData> mOutputFormat;
     65 
     66     MediaBuffer* mBuffer;
     67     int32_t mLeftover;
     68     bool mFormatChanged;
     69     bool mStopPending;
     70 
     71     int64_t mInitialTimeStampUs;
     72     int64_t mAccuOutBufferSize;
     73 
     74     int64_t mSeekTimeUs;
     75     ReadOptions::SeekMode mSeekMode;
     76 
     77     VideoEditorSRC();
     78     void checkAndSetResampler();
     79 
     80     // Don't call me
     81     VideoEditorSRC(const VideoEditorSRC&);
     82     VideoEditorSRC &operator=(const VideoEditorSRC &);
     83 
     84 };
     85 
     86 } //namespce android
     87 
     88