mirror of
https://github.com/openharmony/drivers_peripheral.git
synced 2026-08-25 13:19:36 -04:00
5e56b4ea6f
Signed-off-by: zhangguorong <zhangguorong@kaihongdigi.com>
91 lines
3.1 KiB
C
91 lines
3.1 KiB
C
/*
|
|
* Copyright (c) 2022 Shenzhen Kaihong DID Co., Ltd.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef CODEC_INSTANCE_H
|
|
#define CODEC_INSTANCE_H
|
|
|
|
#include <pthread.h>
|
|
#include <stdio.h>
|
|
#include "buffer_manager_iface.h"
|
|
#include "buffer_manager_wrapper.h"
|
|
#include "codec_oem_if.h"
|
|
#include "share_mem.h"
|
|
|
|
#define MAX_BUFFER_NUM 64
|
|
#define QUEUE_TIME_OUT 10
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
typedef enum {
|
|
CODEC_STATUS_IDLE,
|
|
CODEC_STATUS_STARTED,
|
|
CODEC_STATUS_STOPED,
|
|
} CodecStatus;
|
|
|
|
struct CodecInstance {
|
|
pthread_t task;
|
|
ShareMemory inputBuffers[MAX_BUFFER_NUM];
|
|
ShareMemory outputBuffers[MAX_BUFFER_NUM];
|
|
int32_t inputBuffersCount;
|
|
int32_t outputBuffersCount;
|
|
CodecBuffer *inputInfos[MAX_BUFFER_NUM];
|
|
CodecBuffer *outputInfos[MAX_BUFFER_NUM];
|
|
int32_t inputInfoCount;
|
|
int32_t outputInfoCount;
|
|
|
|
void *oemLibHandle;
|
|
struct CodecOemIf *codecOemIface;
|
|
|
|
void *bufferManagerLibHandle;
|
|
struct BufferManagerIf *bufferManagerIface;
|
|
struct BufferManagerWrapper *bufferManagerWrapper;
|
|
|
|
CODEC_HANDLETYPE handle;
|
|
CodecType codecType;
|
|
volatile CodecStatus codecStatus;
|
|
CodecCallback defaultCb;
|
|
bool hasCallback;
|
|
};
|
|
|
|
struct CodecInstance* GetCodecInstance(void);
|
|
int32_t InitCodecInstance(struct CodecInstance *instance);
|
|
int32_t RunCodecInstance(struct CodecInstance *instance);
|
|
int32_t StopCodecInstance(struct CodecInstance *instance);
|
|
int32_t DestroyCodecInstance(struct CodecInstance *instance);
|
|
void AddInputShm(struct CodecInstance *instance, const CodecBufferInfo *bufferInfo, int32_t bufferId);
|
|
void AddOutputShm(struct CodecInstance *instance, const CodecBufferInfo *bufferInfo, int32_t bufferId);
|
|
ShareMemory* GetInputShm(struct CodecInstance *instance, int32_t id);
|
|
ShareMemory* GetOutputShm(struct CodecInstance *instance, int32_t id);
|
|
int32_t GetFdById(struct CodecInstance *instance, int32_t id);
|
|
void ReleaseInputShm(struct CodecInstance *instance);
|
|
void ReleaseOutputShm(struct CodecInstance *instance);
|
|
void AddInputInfo(struct CodecInstance *instance, CodecBuffer *info);
|
|
void AddOutputInfo(struct CodecInstance *instance, CodecBuffer *info);
|
|
CodecBuffer* GetInputInfo(struct CodecInstance *instance, uint32_t id);
|
|
CodecBuffer* GetOutputInfo(struct CodecInstance *instance, uint32_t id);
|
|
void ReleaseInputInfo(struct CodecInstance *instance);
|
|
void ReleaseOutputInfo(struct CodecInstance *instance);
|
|
void ResetBuffers(struct CodecInstance *instance);
|
|
bool CopyCodecBuffer(CodecBuffer *dst, const CodecBuffer *src);
|
|
CodecBuffer* DupCodecBuffer(const CodecBuffer *src);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif // CODEC_INSTANCE_H
|