1/* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 19#include "pvmf_duration_infomessage.h" 20#include "oscl_mem.h" 21 22OSCL_EXPORT_REF PVMFDurationInfoMessage::PVMFDurationInfoMessage() : 23 iEventCode(0), 24 iDuration(0), 25 iRefCount(1) 26{ 27} 28 29OSCL_EXPORT_REF PVMFDurationInfoMessage::PVMFDurationInfoMessage(uint32 aDuration, int32 aCode, PVUuid aUuid) : 30 iRefCount(1) 31{ 32 // Save the event info 33 iEventCode = aCode; 34 iEventUuid = aUuid; 35 iDuration = aDuration; 36} 37 38OSCL_EXPORT_REF PVMFDurationInfoMessage::~PVMFDurationInfoMessage() 39{ 40 // If the destructor is called directly (instead of via removeRef()) 41 // then the ref count for the next message in the list needs to decremented 42} 43OSCL_EXPORT_REF void PVMFDurationInfoMessage::destroy() 44{ 45 OSCL_DELETE(this); 46} 47 48OSCL_EXPORT_REF void PVMFDurationInfoMessage::SetEventCodeUUID(int32 aCode, PVUuid aUuid) 49{ 50 // Set event code and UUID 51 iEventCode = aCode; 52 iEventUuid = aUuid; 53} 54 55OSCL_EXPORT_REF void PVMFDurationInfoMessage::GetCodeUUID(int32& aCode, PVUuid& aUuid) 56{ 57 // Return event code and UUID 58 aCode = iEventCode; 59 aUuid = iEventUuid; 60} 61 62OSCL_EXPORT_REF uint32 PVMFDurationInfoMessage::GetDuration() 63{ 64 // Return the next message in the list 65 return iDuration; 66} 67 68OSCL_EXPORT_REF void PVMFDurationInfoMessage::addRef() 69{ 70 // Increment this object's ref count 71 ++iRefCount; 72} 73 74OSCL_EXPORT_REF void PVMFDurationInfoMessage::removeRef() 75{ 76 // Decrement this object's ref count 77 --iRefCount; 78 79 // If ref count reaches 0 then destroy this object automatically 80 if (iRefCount <= 0) 81 { 82 // The next message's refcount has already been decremented so 83 // set to NULL so the destructor won't decrement again. 84 // Destroy this instance. 85 destroy(); 86 } 87} 88 89OSCL_EXPORT_REF bool PVMFDurationInfoMessage::queryInterface(const PVUuid& uuid, PVInterface*& iface) 90{ 91 // Only returns the error/info message interface 92 if (uuid == PVMFDurationInfoMessageInterfaceUUID) 93 { 94 PVMFDurationInfoMessageInterface* myInterface = OSCL_STATIC_CAST(PVMFDurationInfoMessageInterface*, this); 95 iface = OSCL_STATIC_CAST(PVInterface*, myInterface); 96 } 97 else 98 { 99 return false; 100 } 101 return true; 102} 103 104