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 #ifndef PVMI_MIO_AVIFILE_FACTORY_H_INCLUDED 19 #define PVMI_MIO_AVIFILE_FACTORY_H_INCLUDED 20 21 #ifndef OSCL_BASE_H_INCLUDED 22 #include "oscl_base.h" 23 #endif 24 #ifndef OSCL_MEM_H_INCLUDED 25 #include "oscl_mem.h" 26 #endif 27 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED 28 #include "oscl_string_containers.h" 29 #endif 30 #ifndef PVMF_FORMAT_TYPE_H_INCLUDED 31 #include "pvmf_format_type.h" 32 #endif 33 #ifndef PV_AVIFILE_H_INCLUDED 34 #include "pv_avifile.h" 35 #endif 36 37 // Forward declarations 38 class PvmiMIOControl; 39 class OsclMemAllocator; 40 41 /** 42 * Structure containing configuration info for this node 43 */ 44 class PvmiMIOAviWavFileSettings 45 { 46 public: PvmiMIOAviWavFileSettings()47 PvmiMIOAviWavFileSettings() 48 { 49 iMediaFormat = PVMF_MIME_FORMAT_UNKNOWN; 50 iNumLoops = 0; 51 iRecModeSyncWithClock = false; 52 iStreamNumber = 0; 53 iSamplingFrequency = 0; 54 iNumChannels = 0; 55 iTimescale = 0; 56 iFrameHeight = 0; 57 iFrameWidth = 0; 58 iFrameRate = 0; 59 iSampleSize = 0; 60 iByteRate = 0; 61 iFrameDuration = 0; 62 iDataBufferSize = 0; 63 iPicBottomUp = false; 64 } 65 PvmiMIOAviWavFileSettings(const PvmiMIOAviWavFileSettings & aSettings)66 PvmiMIOAviWavFileSettings(const PvmiMIOAviWavFileSettings& aSettings) 67 { 68 iMediaFormat = aSettings.iMediaFormat; 69 iMimeType = aSettings.iMimeType; 70 iNumLoops = 0; 71 iRecModeSyncWithClock = aSettings.iRecModeSyncWithClock; 72 iStreamNumber = aSettings.iStreamNumber; 73 iSamplingFrequency = aSettings.iSamplingFrequency; 74 iNumChannels = aSettings.iNumChannels; 75 iTimescale = aSettings.iTimescale; 76 iFrameHeight = aSettings.iFrameHeight; 77 iFrameWidth = aSettings.iFrameWidth; 78 iFrameRate = aSettings.iFrameRate; 79 iSampleSize = aSettings.iSampleSize; 80 iByteRate = aSettings.iByteRate; 81 iFrameDuration = aSettings.iFrameDuration; 82 iDataBufferSize = aSettings.iDataBufferSize; 83 iPicBottomUp = aSettings.iPicBottomUp; 84 85 } 86 ~PvmiMIOAviWavFileSettings()87 ~PvmiMIOAviWavFileSettings() {} 88 89 // General settings 90 PVMFFormatType iMediaFormat; 91 OSCL_HeapString<OsclMemAllocator> iMimeType; 92 uint32 iNumLoops; 93 bool iRecModeSyncWithClock; 94 uint32 iStreamNumber; 95 96 // Settings for audio stream 97 OsclFloat iSamplingFrequency; 98 uint32 iNumChannels; 99 100 // Settings for video stream 101 uint32 iTimescale; 102 uint32 iFrameHeight; 103 uint32 iFrameWidth; 104 OsclFloat iFrameRate; 105 uint32 iSampleSize; 106 uint32 iByteRate; 107 uint32 iFrameDuration; 108 uint32 iDataBufferSize; 109 bool iPicBottomUp; 110 }; 111 112 /** 113 * enum for file type information 114 */ 115 116 typedef enum 117 { 118 FILE_FORMAT_WAV, 119 FILE_FORMAT_AVI 120 } FileFormatType; 121 122 /** 123 * Factory class for PvmiMIOAviWavFile 124 */ 125 class PvmiMIOAviWavFileFactory 126 { 127 public: 128 /** 129 * Creates an instance of PvmiMIOAviWavFile. If the creation fails, 130 * this function will leave. 131 * 132 * @param aLoopIn set if required to record in loop 133 * @param aRecordingMode true if Authoring in sync with clock. false if Authoring as soon as data is available. 134 * @param aStreamNo stream number for avi file, if there are multiple streams in the file. There will be one MIO Component and MIO node per stream. 135 * @param aFileParser Pointer to file parser (AVI or WAV) 136 * @param aFileType file type (AVI or WAV) 137 * @returns A pointer to an PvmiMIOControl for the file input media input module 138 * @return arError error code. 1 if success 139 * @throw Leaves with OsclErrNoMemory if memory allocation failed. 140 */ 141 OSCL_IMPORT_REF static PvmiMIOControl* Create(uint32 aNumLoops, bool aRecordingMode, uint32 aStreamNo, 142 OsclAny* aFileParser, FileFormatType aFileType, int32& arError); 143 144 /** 145 * This function allows the application to delete an instance of file input MIO module 146 * and reclaim all allocated resources. An instance can be deleted only in 147 * the idle state. An attempt to delete in any other state will fail and return false. 148 * 149 * @param aNode The file input MIO module to be deleted. 150 * @returns A status code indicating success or failure. 151 */ 152 OSCL_IMPORT_REF static bool Delete(PvmiMIOControl* aMio); 153 }; 154 155 #endif // PVMI_MIO_AVIFILE_FACTORY_H_INCLUDED 156