Home | History | Annotate | Download | only in enc
      1 /*
      2  * Copyright (C) 2012 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 SOFT_MPEG4_ENCODER_H_
     18 #define SOFT_MPEG4_ENCODER_H_
     19 
     20 #include <media/stagefright/MediaBuffer.h>
     21 #include <media/stagefright/foundation/ABase.h>
     22 #include "SoftVideoEncoderOMXComponent.h"
     23 #include "mp4enc_api.h"
     24 
     25 
     26 namespace android {
     27 
     28 struct CodecProfileLevel;
     29 struct MediaBuffer;
     30 
     31 struct SoftMPEG4Encoder : public SoftVideoEncoderOMXComponent {
     32     SoftMPEG4Encoder(
     33             const char *name,
     34             const char *componentRole,
     35             OMX_VIDEO_CODINGTYPE codingType,
     36             const char *mime,
     37             const CodecProfileLevel *profileLevels,
     38             size_t numProfileLevels,
     39             const OMX_CALLBACKTYPE *callbacks,
     40             OMX_PTR appData,
     41             OMX_COMPONENTTYPE **component);
     42 
     43     // Override SimpleSoftOMXComponent methods
     44     virtual OMX_ERRORTYPE internalGetParameter(
     45             OMX_INDEXTYPE index, OMX_PTR params);
     46 
     47     virtual OMX_ERRORTYPE internalSetParameter(
     48             OMX_INDEXTYPE index, const OMX_PTR params);
     49 
     50     virtual void onQueueFilled(OMX_U32 portIndex);
     51 
     52 protected:
     53     virtual ~SoftMPEG4Encoder();
     54 
     55 private:
     56     enum {
     57         kNumBuffers = 2,
     58     };
     59 
     60     // OMX input buffer's timestamp and flags
     61     typedef struct {
     62         int64_t mTimeUs;
     63         int32_t mFlags;
     64     } InputBufferInfo;
     65 
     66     MP4EncodingMode mEncodeMode;
     67     int32_t  mIDRFrameRefreshIntervalInSec;
     68 
     69     int64_t  mNumInputFrames;
     70     bool     mStarted;
     71     bool     mSawInputEOS;
     72     bool     mSignalledError;
     73 
     74     tagvideoEncControls   *mHandle;
     75     tagvideoEncOptions    *mEncParams;
     76     uint8_t               *mInputFrameData;
     77     Vector<InputBufferInfo> mInputBufferInfoVec;
     78 
     79     OMX_ERRORTYPE initEncParams();
     80     OMX_ERRORTYPE initEncoder();
     81     OMX_ERRORTYPE releaseEncoder();
     82 
     83     DISALLOW_EVIL_CONSTRUCTORS(SoftMPEG4Encoder);
     84 };
     85 
     86 }  // namespace android
     87 
     88 #endif  // SOFT_MPEG4_ENCODER_H_
     89