📄 umc_dual_thread_codec.cpp
字号:
/*//// INTEL CORPORATION PROPRIETARY INFORMATION// This software is supplied under the terms of a license agreement or// nondisclosure agreement with Intel Corporation and may not be copied// or disclosed except in accordance with the terms of that agreement.// Copyright(c) 2003-2005 Intel Corporation. All Rights Reserved.//*/#include "umc_dual_thread_codec.h"#include "vm_debug.h"#include "vm_time.h"#include "umc_audio_codec.h"namespace UMC{DualThreadCodecParams::DualThreadCodecParams(){ m_pMediaBufferParams = NULL; m_pMediaBuffer = NULL; m_pCodecInitParams = NULL; m_pCodec = NULL;} // DualThreadCodecParams::DualThreadCodecParams()DualThreadedCodec::DualThreadedCodec(){ m_pMediaBuffer = NULL; m_pCodec = NULL;} // DualThreadedCodec::DualThreadedCodec()DualThreadedCodec::~DualThreadedCodec(){ Close();} // DualThreadedCodec::~DualThreadedCodec()Status DualThreadedCodec::InitCodec(DualThreadCodecParams* init){ BaseCodecParams CodecParams; Status umcRes; // release codec Close(); // check parameter(s) if ((NULL == init) || (NULL == init->m_pCodec) || (NULL == init->m_pMediaBuffer) || (NULL == init->m_pCodecInitParams) || (NULL == init->m_pMediaBufferParams)) return UMC_NULL_PTR; // init audio codec umcRes = init->m_pCodec->Init(init->m_pCodecInitParams); // get audio info if (UMC_OK == umcRes) umcRes = init->m_pCodec->GetInfo(&CodecParams); // initialize media buffer init->m_pMediaBufferParams->m_prefOutputBufferSize = CodecParams.m_SuggestedInputSize; if (UMC_OK == umcRes) umcRes = init->m_pMediaBuffer->Init(init->m_pMediaBufferParams); // save pointer(s) if (UMC_OK == umcRes) { m_pCodec = init->m_pCodec; m_pMediaBuffer = init->m_pMediaBuffer; } return umcRes;} // Status DualThreadedCodec::InitCodec(DualThreadCodecParams* init)Status DualThreadedCodec::Reset(){ BaseCodecParams CodecParams; Status umcRes = UMC_OK; m_pCodec->Reset(); m_pMediaBuffer->Reset(); return umcRes;} // Status DualThreadedCodec::InitCodec(DualThreadCodecParams* init)Status DualThreadedCodec::LockInputBuffer(MediaData* in){ if (NULL == m_pMediaBuffer) return UMC_NOT_INITIALIZED; return m_pMediaBuffer->LockInputBuffer(in);} // Status DualThreadedCodec::LockInputBuffer(MediaData* in)Status DualThreadedCodec::UnLockInputBuffer(MediaData* in, Status StreamStatus){ if (NULL == m_pMediaBuffer) return UMC_NOT_INITIALIZED; return m_pMediaBuffer->UnLockInputBuffer(in, StreamStatus);} // Status DualThreadedCodec::UnLockInputBuffer(MediaData* in, Status StreamStatus)Status DualThreadedCodec::GetFrame(MediaData* out){ MediaData in; Status umcRes; // check error(s) if ((NULL == out) || (NULL == m_pMediaBuffer)) return UMC_NULL_PTR; // get audio data umcRes = m_pMediaBuffer->LockOutputBuffer(&in); // process audio data if (UMC_OK == umcRes) umcRes = m_pCodec->GetFrame(&in, out); // skip potion of media data if ((unsigned char*)in.GetDataPointer() != (unsigned char*)in.GetBufferPointer()) m_pMediaBuffer->UnLockOutputBuffer(&in); else if(in.GetDataSize() || umcRes == UMC_NOT_ENOUGH_DATA) umcRes = UMC_NOT_ENOUGH_DATA; return umcRes;} // Status DualThreadedCodec::GetFrame(MediaData* out)Status DualThreadedCodec::Stop(){ if (m_pMediaBuffer) return m_pMediaBuffer->Stop(); return UMC_NULL_PTR;} // Status DualThreadedCodec::Stop()Status DualThreadedCodec::Close(){ m_pCodec = NULL; m_pMediaBuffer = NULL; return UMC_OK;} // Status DualThreadedCodec::Close()Status DualThreadedCodec::GetInfo(BaseCodecParams* info){ if (m_pCodec) return m_pCodec->GetInfo(info); return UMC_NULL_PTR;} // Status DualThreadedCodec::GetInfo(BaseCodecParams* info)} // namespace UMC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -