/* * Copyright (C) Texas Instruments - http://www.ti.com/ * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef VTC_LOOPBACK_H #define VTC_LOOPBACK_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef ANDROID_API_JB_OR_LATER #include #else #include #endif #include #include #include #ifdef ANDROID_API_JB_OR_LATER #include #include #include #include #include #else #include #include #include #include #include #endif #include "OMX_TI_Index.h" // for OMX_TI_VIDEO_PARAM_FRAMEDATACONTENTTYPE #include "OMX_TI_Video.h" // for OMX_VIDEO_PARAM_DATASYNCMODETYPE #include "OMX_TI_Common.h" // for OMX_TI_COMPONENT_HANDLE #include "OMX_TI_IVCommon.h"// for OMX_TI_COLOR_FormatYUV420PackedSemiPlanar #include "MessageQueue.h" #include "VtcCommon.h" #define SLEEP_AFTER_STARTING_PREVIEW 2 #define WIDTH 640 #define HEIGHT 480 #define BITRATE 5000000 // 5 mbps #define INPUT_PORT 0 #define OUTPUT_PORT 1 #define TWO_SECOND 1000000000ll // 1000,000,000 nsec = 1sec #define FPS_CAMERA 0x1 #define FPS_ENCODER 0X2 #define FPS_DECODER 0x4 #define DEBUG_DUMP_CAMERA_TIMESTAMP 0x8 #define DEBUG_DUMP_ENCODER_TIMESTAMP 0x10 #define ENCODER_EFFECTIVE_BITRATE 0x20 #define ENCODER_NO_FILE_WRTIE 0x40 #define INPUT_SLICE_MODE 0x80 #define INPUT_OUTPUT_SLICE_MODE 0x100 #define ENCODER_LATENCY 0x200 #define DECODER_LATENCY 0x400 #define ENCODER_MAX_BUFFER_COUNT 10 #define NUM_PORTS 2 #define INIT_OMX_STRUCT(_s_, _name_) \ memset((_s_), 0x0, sizeof(_name_)); \ (_s_)->nSize = sizeof(_name_); \ (_s_)->nVersion.s.nVersionMajor = 0x1; \ (_s_)->nVersion.s.nVersionMinor = 0x1; \ (_s_)->nVersion.s.nRevision = 0x0; \ (_s_)->nVersion.s.nStep = 0x0 using namespace android; class MyCameraClient : public BnCameraClient { public: virtual void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) {} virtual void dataCallback(int32_t msgType, const sp& data, camera_frame_metadata_t *metadata){} virtual void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp& data); MyCameraClient(); ~MyCameraClient() {} sp getCameraPayload(int64_t& frameTime); void encoderReady() { encoder_is_ready = 1; } void encoderNotReady() { encoder_is_ready = 0; } void releaseBuffer(sp data) { if (mReleaser != NULL) { mReleaser->releaseRecordingFrame(data); } } void setReleaser(ICamera *releaser) { mReleaser = releaser; } private: void putCameraPayload(sp payload, int64_t frameTime); int encoder_is_ready; ICamera *mReleaser; List > cameraPayloadQueue; List frameTimeQueue; Mutex cameraPayloadQueueMutex; Condition cameraPayloadWait; int cameraPayloadWaitFlag; }; void dump_video_port_values(OMX_PARAM_PORTDEFINITIONTYPE& def); const char *OMXStateName(OMX_STATETYPE state); #endif