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 * @file pvmf_media_data.h 20 * @brief This file defines the PV Multimedia Framework (PVMF) media data 21 * class which is used as the interface to the media data containers that 22 * are passed between nodes along the normal media data path. 23 * 24 */ 25 26 #ifndef PVMF_MEDIA_DATA_H_INCLUDED 27 #define PVMF_MEDIA_DATA_H_INCLUDED 28 29 #ifndef PVMF_MEDIA_MSG_H_INCLUDED 30 #include "pvmf_media_msg.h" 31 #endif 32 33 #ifndef OSCL_REFCOUNTER_MEMFRAG_H_INCLUDED 34 #include "oscl_refcounter_memfrag.h" 35 #endif 36 37 #ifndef OSCL_SHARED_PTR_H_INCLUDED 38 #include "oscl_shared_ptr.h" 39 #endif 40 41 42 struct PVMFMediaMsgHeader; 43 class PVMFMediaDataImpl; 44 45 // media data error masks 46 #define PVMF_MEDIA_DATA_BIT_ERRORS 0x1 47 #define PVMF_MEDIA_DATA_PACKET_LOSS 0x2 48 49 //marker info masks 50 //marker info is a 32 bit field, with each bit signalling different info 51 // LSB->MSB; Bit 0 - M bit (indicates whether the media data contains end of a media unit) 52 // Bit 1 - Signals whether the media data has a valid duration field, if this bit is not 53 // set then duration value returned in "getDuration" is undefined and should not be used. 54 // Bit 2 - Signals whether the media data should be rendered or not. If set to 1, this 55 // means the media data contained is not to be rendered. Applies only to media data and not 56 // to media commands 57 // Bit 3 - Signals whether the media data is or part of a key sample. If set to 1, this 58 // means the media data contained is is or part of a key sample. 59 // Applies only to media data and not to media commands 60 // Bit 4 - Signals whether the node needs to report the completion of this message to the 61 // Observer. If set to 1, this means the node needs to report info event after processing 62 // this message 63 // Bit 5 - Indicates for H.264/AVC if fragment marks the end of a NAL. This is false for 64 // the first and middle fragments and true for the last fragment and for complete NALs 65 // (single or aggregate). 66 // Bits 6 through 31 - Reserved 67 #define PVMF_MEDIA_DATA_MARKER_INFO_M_BIT 0x00000001 68 #define PVMF_MEDIA_DATA_MARKER_INFO_DURATION_AVAILABLE_BIT 0x00000002 69 #define PVMF_MEDIA_DATA_MARKER_INFO_NO_RENDER_BIT 0x00000004 70 #define PVMF_MEDIA_DATA_MARKER_INFO_RANDOM_ACCESS_POINT_BIT 0x00000008 71 #define PVMF_MEDIA_DATA_MARKER_INFO_REPORT_OBSERVER_BIT 0x00000010 72 #define PVMF_MEDIA_DATA_MARKER_INFO_END_OF_NAL_BIT 0x00000020 73 74 class PVMFMediaData : public PVMFMediaMsg 75 { 76 77 78 public: 79 OSCL_IMPORT_REF virtual ~PVMFMediaData(); 80 OSCL_IMPORT_REF virtual PVMFTimestamp getTimestamp(); 81 OSCL_IMPORT_REF virtual uint32 getDuration(); 82 OSCL_IMPORT_REF virtual uint32 getStreamID(); 83 OSCL_IMPORT_REF virtual uint32 getSeqNum(); 84 OSCL_IMPORT_REF virtual PVUid32 getFormatID(); 85 OSCL_IMPORT_REF virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface); 86 OSCL_IMPORT_REF virtual bool getFormatSpecificInfo(OsclRefCounterMemFrag& memfrag); 87 OSCL_IMPORT_REF virtual void setFormatSpecificInfo(OsclRefCounterMemFrag& memfrag); 88 OSCL_IMPORT_REF virtual bool setMediaFragFilledLen(uint32 index, uint32 len); 89 OSCL_IMPORT_REF virtual void setTimestamp(const PVMFTimestamp& timestamp); 90 OSCL_IMPORT_REF virtual void setDuration(const uint32& duration); 91 OSCL_IMPORT_REF virtual void setStreamID(uint32 id); 92 OSCL_IMPORT_REF virtual void setSeqNum(uint32 seqnum); 93 94 OSCL_IMPORT_REF uint32 getMarkerInfo(); 95 OSCL_IMPORT_REF bool setMarkerInfo(uint32 aMarker); 96 OSCL_IMPORT_REF uint32 getErrorsFlag(); 97 OSCL_IMPORT_REF uint32 getNumFragments(); 98 OSCL_IMPORT_REF bool getMediaFragment(uint32 index, OsclRefCounterMemFrag& memfrag); 99 OSCL_IMPORT_REF bool getMediaDataImpl(OsclSharedPtr<PVMFMediaDataImpl>& 100 media_data_impl); 101 OSCL_IMPORT_REF uint32 getFilledSize(); 102 OSCL_IMPORT_REF uint32 getCapacity(); 103 OSCL_IMPORT_REF const PVMFMediaMsgHeader* getMessageHeader(); 104 105 106 OSCL_IMPORT_REF static OsclSharedPtr<PVMFMediaData> 107 createMediaData(OsclSharedPtr<PVMFMediaDataImpl>& in_impl_ptr, 108 Oscl_DefAlloc* gen_alloc = NULL); 109 110 OSCL_IMPORT_REF static OsclSharedPtr<PVMFMediaData> 111 createMediaData(OsclSharedPtr<PVMFMediaDataImpl>& in_impl_ptr, 112 const PVMFMediaMsgHeader* msgHeader, 113 Oscl_DefAlloc* gen_alloc = NULL); 114 115 private: 116 PVMFMediaData(): hdr_ptr(0), impl_ptr() {}; 117 PVMFMediaMsgHeader* hdr_ptr; 118 OsclSharedPtr<PVMFMediaDataImpl> impl_ptr; 119 }; 120 121 typedef OsclSharedPtr<PVMFMediaData> PVMFSharedMediaDataPtr; 122 123 OSCL_IMPORT_REF void convertToPVMFMediaMsg(PVMFSharedMediaMsgPtr& dest, PVMFSharedMediaDataPtr& source); 124 OSCL_IMPORT_REF void convertToPVMFMediaData(PVMFSharedMediaDataPtr& dest, PVMFSharedMediaMsgPtr& source); 125 126 #endif 127