/* * Copyright (C) 2025 Amlogic, Inc. All rights reserved. * * All information contained herein is Amlogic confidential. * * This software is provided to you pursuant to Software License Agreement * (SLA) with Amlogic Inc ("Amlogic"). This software may be used * only in accordance with the terms of this agreement. * * Redistribution and use in source and binary forms, with or without * modification is strictly prohibited without prior written permission from * Amlogic. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include #include #include "ccdatabase/dataserver_client.h" #include "ccdatabase/dataserver_cmd_resp.h" #include "ccdatabase/dataserver_data_userdata.h" #include "ccdatabase/dataserver_data_vbi.h" #include "ccdatabase/dataserver_message.h" #ifdef __cplusplus extern "C" { #endif #define CC_POLL_TIMEOUT (16) #define USERDATA_POLL_TIMEOUT (100) #define MAX_CC_DATA_LEN (1024 * 5 + 4) #define AMSTREAM_USDRDATA_DEV_FILE "/dev/amstream_userdata" #define CC_VBI_DEV_FILE "/dev/vbi" #define MEDIA_PROXY_DEV_FILE "/dev/mediaproxy" /* CC source manager handle */ typedef void *CcSourceMgrHnd; /* DTV cc userdata data callback */ typedef void (*CcSourceUserdataCallback)(CcSourceMgrHnd handle, void *data); /* ATV cc data callback */ typedef void (*CcSourceVbiDataCallback)(CcSourceMgrHnd handle, void *data); /* ATV cc event callback */ typedef void (*CcSourceVbiEventHandler)(CcSourceMgrHnd handle); /* CC data source type */ typedef enum { CC_SOURCE_TYPE_AMSTREAM_DEVICE = 0, // /dev/amstream_userdata CC_SOURCE_TYPE_VBI_DEVICE, // /dev/vbi CC_SOURCE_TYPE_MEDIA_PROXY, // /dev/mediaproxy CC_SOURCE_TYPE_CCDATASERVER_AMSTREAM_DEVICE, // dataserver /dev/amstream_userdata CC_SOURCE_TYPE_CCDATASERVER_VBI_DEVICE, // dataserver /dev/vbi CC_SOURCE_TYPE_CCDATASERVER_MEDIA_PROXY // dataserver /dev/mediaproxy } CcSourceType; /* CC data source ops status */ typedef enum { CC_SOURCE_INVALID = -1, CC_SOURCE_FAIL = 0, CC_SOURCE_OK, } CcSourceStatus; /* CC data source ops param */ typedef struct { int playerId; CcSourceType srcType; CcSourceUserdataCallback uDataCb; // Userdata data callback CcSourceVbiDataCallback vDataCb; // Vbi data callback CcSourceVbiEventHandler vEvtHandler; // Vbi event handler char owner[32]; } CcSourceStartParam; /* CC source vbi context */ typedef struct { int last; int now; int timeout; int last_data_mask; } CcSourceVbiCtx; /* CC data source userdata param */ struct CcSourceUserdataParam { uint32_t version; uint32_t instance_id; // input, 0~9 uint32_t buf_len; // input uint32_t data_size; // output void *pbuf_addr; // input struct userdata_meta_info_t meta_info; // output }; /* CC data source context */ typedef struct { bool running; char devFile[32]; CcSourceStartParam param; CcSourceVbiCtx vCtx; pthread_t thread; pthread_mutex_t lock; ds_conn_t *das; ds_conn_t *(*das_connect)(); void *privData; } CcSourceCtx; /** Create a new close caption source manager * [out] CcSourceMgrHnd Return the source handle */ CcSourceMgrHnd ccSourceManagerCreate(); /** Release a close caption source manager * [in] CcSourceMgrHnd source handle * [out] CcSourceStatus Close caption source status */ CcSourceStatus ccSourceManagerDestroy(CcSourceMgrHnd handle); /** start a close caption source manager * [in] CcSourceMgrHnd & cc source param * [out] CcSourceStatus Close caption source status */ CcSourceStatus ccSourceManagerStart(CcSourceMgrHnd handle, CcSourceStartParam *param); /** stop a close caption source manager * [in] CcSourceMgrHnd * [out] CcSourceStatus Close caption source status */ CcSourceStatus ccSourceManagerStop(CcSourceMgrHnd handle); #ifdef __cplusplus } #endif