2 * Copyright (c) 2000-2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.1 (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
8 * http://floralicense.org/license/
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.
17 #include "DrmFileMgr.h"
18 #include "TADC_ErrorCode.h"
19 #include "drm_intf_tapps.h"
22 int DrmTdcFileOpen(const char* filePath, int* handle)
24 int nRet = TADC_SUCCESS;
27 DrmFileMgr* pDrmFileMgr = NULL;
29 if (filePath == NULL || strlen(filePath) < 1)
31 DRM_TAPPS_EXCEPTION("Parameter error!");
32 return TADC_PARAMETER_ERROR;
35 pDrmFileMgr = DrmFileMgr::GetInstance();
36 if (pDrmFileMgr == NULL)
38 DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
39 return TADC_GET_FILE_HANDLER_ERROR;
42 nRet = pDrmFileMgr->OpenFileHandler(filePath, &key);
43 if (nRet != TADC_SUCCESS)
45 DRM_TAPPS_EXCEPTION("DrmFileMgr::OpenFileHandler() error!");
55 int DrmTdcFileClose(int* handle)
57 int nRet = TADC_SUCCESS;
60 DrmFileMgr *pDrmFileMgr = DrmFileMgr::GetInstance();
61 if (pDrmFileMgr == NULL)
63 DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
64 return TADC_GET_FILE_HANDLER_ERROR;
67 nRet = pDrmFileMgr->CloseFileHandler(key);
68 if (nRet != TADC_SUCCESS)
70 DRM_TAPPS_EXCEPTION("DrmFileMgr::OpenFileHandler() error!");
78 int DrmTdcFileRead(int* handle, void* pBuf, long long bufLen, long long* pReadLen)
80 int nRet = TADC_SUCCESS;
83 DrmFileMgr* pDrmFileMgr = NULL;
84 DrmFileHandler* pDrmFileHandler = NULL;
86 pDrmFileMgr = DrmFileMgr::GetInstance();
87 if (pDrmFileMgr == NULL)
89 DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
90 return TADC_GET_FILE_HANDLER_ERROR;
93 nRet = pDrmFileMgr->GetFileHandler(key, &pDrmFileHandler);
94 if (nRet != TADC_SUCCESS)
96 DRM_TAPPS_EXCEPTION("DrmFileMgr::GetFileHandler() error!");
100 nRet = pDrmFileHandler->DrmRead(pBuf, bufLen, pReadLen);
101 if (nRet != TADC_SUCCESS)
103 DRM_TAPPS_EXCEPTION("DrmFileMgr::DrmRead() error!");
110 int DrmTdcFileTell(int* handle, long long *position)
112 int nRet = TADC_SUCCESS;
114 long long offset = 0;
116 DrmFileMgr* pDrmFileMgr = NULL;
117 DrmFileHandler* pDrmFileHandler = NULL;
119 pDrmFileMgr = DrmFileMgr::GetInstance();
120 if (pDrmFileMgr == NULL)
122 DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
123 return TADC_GET_FILE_HANDLER_ERROR;
126 nRet = pDrmFileMgr->GetFileHandler(key, &pDrmFileHandler);
127 if (nRet != TADC_SUCCESS)
129 DRM_TAPPS_EXCEPTION("DrmFileMgr::GetFileHandler() error!");
133 offset = pDrmFileHandler->DrmTell();
141 int DrmTdcFileSeek(int* handle, long long offset, int origin)
143 int nRet = TADC_SUCCESS;
146 DrmFileMgr* pDrmFileMgr = NULL;
147 DrmFileHandler* pDrmFileHandler = NULL;
149 pDrmFileMgr = DrmFileMgr::GetInstance();
150 if (pDrmFileMgr == NULL)
152 DRM_TAPPS_EXCEPTION("DrmFileMgr::GetInstance() error!");
153 return TADC_GET_FILE_HANDLER_ERROR;
156 nRet = pDrmFileMgr->GetFileHandler(key, &pDrmFileHandler);
157 if (nRet != TADC_SUCCESS)
159 DRM_TAPPS_EXCEPTION("DrmFileMgr::GetFileHandler() error!");
163 nRet = pDrmFileHandler->DrmSeek(offset, origin);
164 if (nRet != TADC_SUCCESS)
166 DRM_TAPPS_EXCEPTION("DrmFileHandler::DrmSeek() error!");